Gets the 'return to list' button working for all content types

This commit is contained in:
Shannon
2014-09-19 11:52:13 +10:00
parent 0264a72762
commit 51061e10a9
13 changed files with 79 additions and 38 deletions

View File

@@ -14,7 +14,6 @@ function ContentEditController($scope, $rootScope, $routeParams, $q, $timeout, $
$scope.currentSection = appState.getSectionState("currentSection");
$scope.currentNode = null; //the editors affiliated node
//This sets up the action buttons based on what permissions the user has.
//The allowedActions parameter contains a list of chars, each represents a button by permission so
//here we'll build the buttons according to the chars of the user.
@@ -217,6 +216,12 @@ function ContentEditController($scope, $rootScope, $routeParams, $q, $timeout, $
$scope.loaded = true;
$scope.content = data;
if (data.isChildOfListView) {
$scope.listViewPath = ($routeParams.page)
? "/content/content/edit/" + data.parentId + "?page=" + $routeParams.page
: "/content/content/edit/" + data.parentId;
}
editorState.set($scope.content);
configureButtons($scope.content);

View File

@@ -39,6 +39,12 @@
<div class="umb-tab-buttons" detect-fold ng-class="{'umb-dimmed': busy}">
<div class="btn-group" ng-show="listViewPath">
<a class="btn" href="#{{listViewPath}}">
<localize key="buttons_returnToList">Return to list</localize>
</a>
</div>
<div class="btn-group" ng-show="content.template">
<a class="btn" ng-click="preview(content)">
@@ -46,12 +52,6 @@
</a>
</div>
<div class="btn-group" ng-show="content.isChildOfListView">
<a class="btn" href="#/content/content/edit/{{content.parentId}}">
<localize key="buttons_returnToList">Return to list</localize>
</a>
</div>
<div class="btn-group dropup" ng-if="defaultButton" >
<!-- primary button -->
<a class="btn btn-success" href="#" ng-click="performAction(defaultButton)" prevent-default>

View File

@@ -38,6 +38,13 @@
</umb-property>
<div class="umb-tab-buttons" detect-fold ng-class="{'umb-dimmed': busy}">
<div class="btn-group" ng-show="listViewPath">
<a class="btn" href="#{{listViewPath}}">
<localize key="buttons_returnToList">Return to list</localize>
</a>
</div>
<div class="btn-group">
<button type="submit" data-hotkey="ctrl+s" class="btn btn-success">
<localize key="buttons_save">Save</localize>

View File

@@ -48,6 +48,12 @@ function mediaEditController($scope, $routeParams, appState, mediaResource, enti
$scope.loaded = true;
$scope.content = data;
if (data.isChildOfListView) {
$scope.listViewPath = ($routeParams.page)
? "/media/media/edit/" + data.parentId + "?page=" + $routeParams.page
: "/media/media/edit/" + data.parentId;
}
editorState.set($scope.content);
//in one particular special case, after we've created a new item we redirect back to the edit

View File

@@ -38,6 +38,13 @@
</umb-property>
<div class="umb-tab-buttons" detect-fold ng-class="{'umb-dimmed': busy}">
<div class="btn-group" ng-if="listViewPath">
<a class="btn" href="#{{listViewPath}}">
<localize key="buttons_returnToList">Return to list</localize>
</a>
</div>
<div class="btn-group">
<button type="submit" data-hotkey="ctrl+s" class="btn btn-success">
<localize key="buttons_save">Save</localize>

View File

@@ -3,11 +3,11 @@
ng-show="loaded">
<umb-panel>
<umb-header tabs="content.tabs">
<div class="span7" ng-if="content.membershipScenario == 0">
<h4>{{content.name}}</h4>
</div>
<div class="umb-headline-editor-wrapper span12">
<h1>{{content.name}}</h1>
</div>
</umb-header>
<umb-tab-view>

View File

@@ -12,9 +12,13 @@ function MemberEditController($scope, $routeParams, $location, $q, $window, appS
$scope.currentSection = appState.getSectionState("currentSection");
$scope.currentNode = null; //the editors affiliated node
$scope.listViewPath = ($routeParams.page && $routeParams.listName)
? "/member/member/list/" + $routeParams.listName + "?page=" + $routeParams.page
: null;
//build a path to sync the tree with
function buildTreePath(data) {
//TODO: Will this work for the 'other' list ?
//TODO: Sync it to the member's member type, if the prev path was not passed in
function buildTreePath(data) {
var path = data.name[0].toLowerCase() + "," + data.key;
return path;
}

View File

@@ -1,4 +1,4 @@
function listViewController($rootScope, $scope, $routeParams, $injector, notificationsService, iconHelper, dialogService, editorState, localizationService) {
function listViewController($rootScope, $scope, $routeParams, $injector, notificationsService, iconHelper, dialogService, editorState, localizationService, $location) {
//this is a quick check to see if we're in create mode, if so just exit - we cannot show children for content
// that isn't created yet, if we continue this will use the parent id in the route params which isn't what
@@ -10,34 +10,40 @@ function listViewController($rootScope, $scope, $routeParams, $injector, notific
}
//Now we need to check if this is for media, members or content because that will depend on the resources we use
var contentResource, getContentTypesCallback, getListResultsCallback, deleteItemCallback, getIdCallback;
var contentResource, getContentTypesCallback, getListResultsCallback, deleteItemCallback, getIdCallback, createEditUrlCallback;
if ($scope.model.config.entityType && $scope.model.config.entityType === "member") {
$scope.entityType = "member";
contentResource = $injector.get('memberResource');
getContentTypesCallback = $injector.get('memberTypeResource').getTypes;
getListResultsCallback = contentResource.getPagedResults;
deleteItemCallback = contentResource.deleteByKey;
getIdCallback = function(selected) {
return selected.key;
}
$scope.entityType = "member";
};
createEditUrlCallback = function(item) {
return "/" + $scope.entityType + "/" + $scope.entityType + "/edit/" + item.key + "?page=" + $scope.options.pageNumber + "&listName=" + $scope.contentId;
};
}
else {
if ($scope.model.config.entityType && $scope.model.config.entityType === "media") {
contentResource = $injector.get('mediaResource');
getContentTypesCallback = $injector.get('mediaTypeResource').getAllowedTypes;
$scope.entityType = "media";
contentResource = $injector.get('mediaResource');
getContentTypesCallback = $injector.get('mediaTypeResource').getAllowedTypes;
}
else {
contentResource = $injector.get('contentResource');
getContentTypesCallback = $injector.get('contentTypeResource').getAllowedTypes;
$scope.entityType = "content";
contentResource = $injector.get('contentResource');
getContentTypesCallback = $injector.get('contentTypeResource').getAllowedTypes;
}
getListResultsCallback = contentResource.getChildren;
deleteItemCallback = contentResource.deleteById;
getIdCallback = function (selected) {
getIdCallback = function(selected) {
return selected.id;
}
};
createEditUrlCallback = function(item) {
return "/" + $scope.entityType + "/" + $scope.entityType + "/edit/" + item.id + "?page=" + $scope.options.pageNumber;
};
}
$scope.isNew = false;
@@ -49,7 +55,7 @@ function listViewController($rootScope, $scope, $routeParams, $injector, notific
$scope.options = {
pageSize: $scope.model.config.pageSize ? $scope.model.config.pageSize : 10,
pageNumber: 1,
pageNumber: ($routeParams.page && Number($routeParams.page) != NaN && Number($routeParams.page) > 0) ? $routeParams.page : 1,
filter: '',
orderBy: ($scope.model.config.orderBy ? $scope.model.config.orderBy : 'VersionDate').trim(),
orderDirection: $scope.model.config.orderDirection ? $scope.model.config.orderDirection.trim() : "desc",
@@ -69,7 +75,7 @@ function listViewController($rootScope, $scope, $routeParams, $injector, notific
//NOTE: special case for contentTypeAlias, it's a system property that cannot be sorted
// to do that, we'd need to update the base query for content to include the content type alias column
// which requires another join and would be slower.
// which requires another join and would be slower. BUT We are doing this for members so not sure it makes a diff?
if (e.alias != "contentTypeAlias") {
e.allowSorting = true;
}
@@ -90,16 +96,16 @@ function listViewController($rootScope, $scope, $routeParams, $injector, notific
if ($scope.options.pageNumber < $scope.listViewResultSet.totalPages) {
$scope.options.pageNumber++;
$scope.reloadView($scope.contentId);
//saveLastPageNumber();
//TODO: this would be nice but causes the whole view to reload
//$location.search("page", $scope.options.pageNumber);
}
};
$scope.goToPage = function(pageNumber) {
$scope.options.pageNumber = pageNumber + 1;
$scope.reloadView($scope.contentId);
//saveLastPageNumber();
//TODO: this would be nice but causes the whole view to reload
//$location.search("page", $scope.options.pageNumber);
};
$scope.sort = function(field, allow) {
@@ -121,8 +127,8 @@ function listViewController($rootScope, $scope, $routeParams, $injector, notific
if ($scope.options.pageNumber > 1) {
$scope.options.pageNumber--;
$scope.reloadView($scope.contentId);
//saveLastPageNumber();
//TODO: this would be nice but causes the whole view to reload
//$location.search("page", $scope.options.pageNumber);
}
};
@@ -322,6 +328,9 @@ function listViewController($rootScope, $scope, $routeParams, $injector, notific
/** This ensures that the correct value is set for each item in a row, we don't want to call a function during interpolation or ng-bind as performance is really bad that way */
function setPropertyValues(result) {
//set the edit url
result.editPath = createEditUrlCallback(result);
_.each($scope.options.includeProperties, function (e, i) {
var alias = e.alias;

View File

@@ -87,8 +87,8 @@
<input type="checkbox" ng-model="result.selected" no-dirty-check>
</td>
<td>
<a ng-class="{inactive: (entityType === 'content' && !result.published) || isTrashed}"
href="#/{{entityType}}/{{entityType}}/edit/{{result.id}}"
<a ng-class="{inactive: (entityType === 'content' && !result.published) || isTrashed}"
href="#{{result.editPath}}"
ng-bind="result.name"></a>
</td>