Set up return to list button for list view children that on click returns to the list with the last viewed page restored
This commit is contained in:
@@ -6,7 +6,7 @@
|
||||
* @description
|
||||
* The controller for the content editor
|
||||
*/
|
||||
function ContentEditController($scope, $routeParams, $q, $timeout, $window, appState, contentResource, entityResource, navigationService, notificationsService, angularHelper, serverValidationManager, contentEditingHelper, treeService, fileManager, formHelper, umbRequestHelper, keyboardService, umbModelMapper, editorState, $http) {
|
||||
function ContentEditController($scope, $rootScope, $routeParams, $q, $timeout, $window, appState, contentResource, entityResource, navigationService, notificationsService, angularHelper, serverValidationManager, contentEditingHelper, treeService, fileManager, formHelper, umbRequestHelper, keyboardService, umbModelMapper, editorState, $http) {
|
||||
|
||||
//setup scope vars
|
||||
$scope.defaultButton = null;
|
||||
@@ -188,6 +188,15 @@ function ContentEditController($scope, $routeParams, $q, $timeout, $window, appS
|
||||
return deferred.promise;
|
||||
}
|
||||
|
||||
function resetLastListPageNumber(content) {
|
||||
// We're using rootScope to store the page number for list views, so if returning to the list
|
||||
// we can restore the page. If we've moved on to edit a piece of content that's not the list or it's children
|
||||
// we should remove this so as not to confuse if navigating to a different list
|
||||
if (!content.isChildOfListView && !content.isContainer) {
|
||||
$rootScope.lastPageNumber = null;
|
||||
}
|
||||
}
|
||||
|
||||
if ($routeParams.create) {
|
||||
//we are creating so get an empty content item
|
||||
contentResource.getScaffold($routeParams.id, $routeParams.doctype)
|
||||
@@ -198,6 +207,8 @@ function ContentEditController($scope, $routeParams, $q, $timeout, $window, appS
|
||||
editorState.set($scope.content);
|
||||
|
||||
configureButtons($scope.content);
|
||||
|
||||
resetLastListPageNumber($scope.content);
|
||||
});
|
||||
}
|
||||
else {
|
||||
@@ -219,6 +230,7 @@ function ContentEditController($scope, $routeParams, $q, $timeout, $window, appS
|
||||
|
||||
syncTreeNode($scope.content, data.path, true);
|
||||
|
||||
resetLastListPageNumber($scope.content);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -45,6 +45,12 @@
|
||||
</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>
|
||||
@@ -54,8 +60,9 @@
|
||||
<a class="btn btn-success dropdown-toggle" data-toggle="dropdown" ng-if="subButtons.length > 0">
|
||||
<span class="caret"></span>
|
||||
</a>
|
||||
|
||||
|
||||
<a href="#">Return to list</a>
|
||||
|
||||
<!-- sub buttons -->
|
||||
<ul class="dropdown-menu bottom-up" role="menu" aria-labelledby="dLabel" ng-if="subButtons.length > 0">
|
||||
<li ng-repeat="btn in subButtons">
|
||||
|
||||
@@ -77,12 +77,16 @@ function listViewController($rootScope, $scope, $routeParams, $injector, notific
|
||||
if ($scope.options.pageNumber < $scope.listViewResultSet.totalPages) {
|
||||
$scope.options.pageNumber++;
|
||||
$scope.reloadView($scope.contentId);
|
||||
|
||||
saveLastPageNumber();
|
||||
}
|
||||
};
|
||||
|
||||
$scope.goToPage = function (pageNumber) {
|
||||
$scope.options.pageNumber = pageNumber + 1;
|
||||
$scope.reloadView($scope.contentId);
|
||||
|
||||
saveLastPageNumber();
|
||||
};
|
||||
|
||||
$scope.sort = function (field, allow) {
|
||||
@@ -103,17 +107,31 @@ function listViewController($rootScope, $scope, $routeParams, $injector, notific
|
||||
if ($scope.options.pageNumber > 1) {
|
||||
$scope.options.pageNumber--;
|
||||
$scope.reloadView($scope.contentId);
|
||||
|
||||
saveLastPageNumber();
|
||||
}
|
||||
};
|
||||
|
||||
saveLastPageNumber = function () {
|
||||
// Saves the last page number into rootScope, so we can retrieve it when returning to the list and
|
||||
// re-present the correct page
|
||||
$rootScope.lastPageNumber = $scope.options.pageNumber;
|
||||
};
|
||||
|
||||
$scope.initView = function () {
|
||||
if ($routeParams.id) {
|
||||
$scope.pagination = new Array(10);
|
||||
$scope.listViewAllowedTypes = contentTypeResource.getAllowedTypes($routeParams.id);
|
||||
$scope.reloadView($routeParams.id);
|
||||
|
||||
$scope.contentId = $routeParams.id;
|
||||
$scope.isTrashed = $routeParams.id === "-20" || $routeParams.id === "-21";
|
||||
|
||||
// If we have a last page number saved, go straight to that one
|
||||
if ($rootScope.lastPageNumber) {
|
||||
$scope.goToPage($rootScope.lastPageNumber - 1);
|
||||
} else {
|
||||
$scope.reloadView($scope.contentId);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -84,6 +84,7 @@
|
||||
<key alias="macroInsert">Insert macro</key>
|
||||
<key alias="pictureInsert">Insert picture</key>
|
||||
<key alias="relations">Edit relations</key>
|
||||
<key alias="returnToList">Return to list</key>
|
||||
<key alias="save">Save</key>
|
||||
<key alias="saveAndPublish">Save and publish</key>
|
||||
<key alias="saveToPublish">Save and send for approval</key>
|
||||
|
||||
@@ -87,6 +87,7 @@
|
||||
<key alias="macroInsert">Insert macro</key>
|
||||
<key alias="pictureInsert">Insert picture</key>
|
||||
<key alias="relations">Edit relations</key>
|
||||
<key alias="returnToList">Return to list</key>
|
||||
<key alias="save">Save</key>
|
||||
<key alias="saveAndPublish">Save and publish</key>
|
||||
<key alias="saveToPublish">Save and send for approval</key>
|
||||
|
||||
@@ -86,7 +86,7 @@
|
||||
#container-config-panel { margin-left: 20px; }
|
||||
#container-config-column-list { margin: 8px 0 16px 0; }
|
||||
#container-config-column-list th, #container-config-column-list td { text-align: left; padding: 2px 0px 4px 10px; }
|
||||
#<%= txtContainerConfigAdditionalColumns.ClientID %> { display: block; }
|
||||
#<%= txtContainerConfigAdditionalColumns.ClientID %> { display: none; }
|
||||
</style>
|
||||
|
||||
<!-- Scripting for list view configuration -->
|
||||
|
||||
@@ -19,6 +19,12 @@ namespace Umbraco.Web.Models.ContentEditing
|
||||
[DataMember(Name = "contentTypeName")]
|
||||
public string ContentTypeName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Indicates if the content is configured as a list view container
|
||||
/// </summary>
|
||||
[DataMember(Name = "isContainer")]
|
||||
public bool IsContainer { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// This is used to add custom localized messages/strings to the response for the app to use for localized UI purposes.
|
||||
/// </summary>
|
||||
|
||||
@@ -47,6 +47,9 @@ namespace Umbraco.Web.Models.Mapping
|
||||
.ForMember(
|
||||
dto => dto.ContentTypeName,
|
||||
expression => expression.MapFrom(content => content.ContentType.Name))
|
||||
.ForMember(
|
||||
dto => dto.IsContainer,
|
||||
expression => expression.MapFrom(content => content.ContentType.IsContainer))
|
||||
.ForMember(
|
||||
dto => dto.IsChildOfListView,
|
||||
expression => expression.MapFrom(content => content.Parent().ContentType.IsContainer))
|
||||
|
||||
@@ -378,80 +378,32 @@ namespace umbraco.controls
|
||||
/// <returns>Container configuration as JSON string</returns>
|
||||
private string GetProvidedContainerConfigAsJsonString()
|
||||
{
|
||||
var configProvided = false;
|
||||
|
||||
// Set defaults for saving if not all fields are provided
|
||||
var pageSize = 10;
|
||||
var additionalColumns = string.Empty;
|
||||
var orderBy = "Name";
|
||||
var orderDirection = "asc";
|
||||
var allowBulkPublish = true;
|
||||
var allowBulkUnpublish = true;
|
||||
var allowBulkDelete = true;
|
||||
if (int.TryParse(txtContainerConfigPageSize.Text, out pageSize))
|
||||
// Create configuation from form fields
|
||||
var containerConfig = new ContentTypeContainerConfiguration
|
||||
{
|
||||
configProvided = true;
|
||||
AdditionalColumnAliases = txtContainerConfigAdditionalColumns.Text,
|
||||
OrderBy = ddlContainerConfigOrderBy.SelectedItem.Value,
|
||||
OrderDirection = ddlContainerConfigOrderDirection.SelectedItem.Value,
|
||||
AllowBulkPublish = ddlContainerConfigAllowBulkPublish.SelectedIndex == 0,
|
||||
AllowBulkUnpublish = ddlContainerConfigAllowBulkUnpublish.SelectedIndex == 0,
|
||||
AllowBulkDelete = ddlContainerConfigAllowBulkDelete.SelectedIndex == 0,
|
||||
};
|
||||
|
||||
int pageSize;
|
||||
if (!int.TryParse(txtContainerConfigPageSize.Text, out pageSize))
|
||||
{
|
||||
pageSize = 10;
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(txtContainerConfigAdditionalColumns.Text))
|
||||
{
|
||||
additionalColumns = txtContainerConfigAdditionalColumns.Text;
|
||||
configProvided = true;
|
||||
}
|
||||
|
||||
if (ddlContainerConfigOrderBy.SelectedIndex > 0)
|
||||
{
|
||||
orderBy = ddlContainerConfigOrderBy.SelectedItem.Value;
|
||||
configProvided = true;
|
||||
}
|
||||
|
||||
if (ddlContainerConfigOrderDirection.SelectedIndex > 0)
|
||||
{
|
||||
orderDirection = ddlContainerConfigOrderDirection.SelectedItem.Value;
|
||||
configProvided = true;
|
||||
}
|
||||
|
||||
if (ddlContainerConfigAllowBulkPublish.SelectedIndex > 0)
|
||||
{
|
||||
allowBulkPublish = ddlContainerConfigAllowBulkPublish.SelectedIndex == 1;
|
||||
configProvided = true;
|
||||
}
|
||||
|
||||
if (ddlContainerConfigAllowBulkUnpublish.SelectedIndex > 0)
|
||||
{
|
||||
allowBulkUnpublish = ddlContainerConfigAllowBulkUnpublish.SelectedIndex == 1;
|
||||
configProvided = true;
|
||||
}
|
||||
|
||||
if (ddlContainerConfigAllowBulkDelete.SelectedIndex > 0)
|
||||
{
|
||||
allowBulkDelete = ddlContainerConfigAllowBulkDelete.SelectedIndex == 1;
|
||||
configProvided = true;
|
||||
}
|
||||
|
||||
if (configProvided)
|
||||
{
|
||||
var containerConfig = new ContentTypeContainerConfiguration
|
||||
{
|
||||
PageSize = pageSize,
|
||||
AdditionalColumnAliases = additionalColumns,
|
||||
OrderBy = orderBy,
|
||||
OrderDirection = orderDirection,
|
||||
AllowBulkPublish = allowBulkPublish,
|
||||
AllowBulkUnpublish = allowBulkUnpublish,
|
||||
AllowBulkDelete = allowBulkDelete,
|
||||
};
|
||||
|
||||
// Serialize the object ignoring nulls so the calculated property AdditionalColumnHeadings is not persisted
|
||||
return JsonConvert.SerializeObject(containerConfig,
|
||||
Formatting.None,
|
||||
new JsonSerializerSettings
|
||||
{
|
||||
NullValueHandling = NullValueHandling.Ignore
|
||||
});
|
||||
}
|
||||
|
||||
return string.Empty;
|
||||
containerConfig.PageSize = pageSize;
|
||||
|
||||
// Serialize the object ignoring nulls so the calculated properties are not persisted
|
||||
return JsonConvert.SerializeObject(containerConfig,
|
||||
Formatting.None,
|
||||
new JsonSerializerSettings
|
||||
{
|
||||
NullValueHandling = NullValueHandling.Ignore
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -669,7 +621,6 @@ jQuery(document).ready(function() {{ refreshDropDowns(); }});
|
||||
ddlContainerConfigOrderBy.Items.Add(new ListItem("Created by", "Owner"));
|
||||
|
||||
ddlContainerConfigAdditionalColumnsChooser.Items.Add(new ListItem("Select a column...", string.Empty));
|
||||
ddlContainerConfigAdditionalColumnsChooser.Items.Add(new ListItem("Node name", "Name"));
|
||||
ddlContainerConfigAdditionalColumnsChooser.Items.Add(new ListItem("Last edited on", "UpdateDate"));
|
||||
ddlContainerConfigAdditionalColumnsChooser.Items.Add(new ListItem("Last updated by", "Updator"));
|
||||
ddlContainerConfigAdditionalColumnsChooser.Items.Add(new ListItem("Created on", "CreateDate"));
|
||||
|
||||
Reference in New Issue
Block a user