From 9a0451e1ad80bed64f4852a13e2f8f2fc2187b7b Mon Sep 17 00:00:00 2001 From: AndyButland Date: Wed, 30 Jul 2014 09:43:37 +0200 Subject: [PATCH] Improvements to UI for selecting additional columns for container list view --- .../listview/listview.controller.js | 2 +- .../controls/ContentTypeControlNew.ascx | 175 ++++++++++++++++-- .../ContentTypeControlNew.ascx.designer.cs | 1 + .../ContentAndMediaTypeBaseController.cs | 10 +- .../controls/ContentTypeControlNew.ascx.cs | 70 +++++-- 5 files changed, 229 insertions(+), 29 deletions(-) diff --git a/src/Umbraco.Web.UI.Client/src/views/propertyeditors/listview/listview.controller.js b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/listview/listview.controller.js index 7cc4643aa4..aac3e436af 100644 --- a/src/Umbraco.Web.UI.Client/src/views/propertyeditors/listview/listview.controller.js +++ b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/listview/listview.controller.js @@ -41,7 +41,7 @@ function listViewController($rootScope, $scope, $routeParams, $injector, notific allowBulkDelete: true, additionalColumns: [ { alias: 'UpdateDate', header: 'Last edited', localizationKey: 'defaultdialogs_lastEdited' }, - { alias: 'Owner', header: 'Last edited', localizationKey: 'content_updatedBy' } + { alias: 'Updator', header: 'Last edited', localizationKey: 'content_updatedBy' } ] }; diff --git a/src/Umbraco.Web.UI/umbraco/controls/ContentTypeControlNew.ascx b/src/Umbraco.Web.UI/umbraco/controls/ContentTypeControlNew.ascx index 1c1e4cc625..4e3e26bd6c 100644 --- a/src/Umbraco.Web.UI/umbraco/controls/ContentTypeControlNew.ascx +++ b/src/Umbraco.Web.UI/umbraco/controls/ContentTypeControlNew.ascx @@ -76,51 +76,200 @@
+ + + + +
-
- +
+ - + + + + + + + + + + + + +
Selected columns
- - + + - + - Ascending Descending - + - Yes No - + - Yes No - + - Yes No diff --git a/src/Umbraco.Web.UI/umbraco/controls/ContentTypeControlNew.ascx.designer.cs b/src/Umbraco.Web.UI/umbraco/controls/ContentTypeControlNew.ascx.designer.cs index 582c67837d..deda04c7b6 100644 --- a/src/Umbraco.Web.UI/umbraco/controls/ContentTypeControlNew.ascx.designer.cs +++ b/src/Umbraco.Web.UI/umbraco/controls/ContentTypeControlNew.ascx.designer.cs @@ -11,5 +11,6 @@ namespace Umbraco.Web.UI.Umbraco.Controls { public partial class ContentTypeControlNew { + } } diff --git a/src/Umbraco.Web/Editors/ContentAndMediaTypeBaseController.cs b/src/Umbraco.Web/Editors/ContentAndMediaTypeBaseController.cs index c289b80888..8a57ce921d 100644 --- a/src/Umbraco.Web/Editors/ContentAndMediaTypeBaseController.cs +++ b/src/Umbraco.Web/Editors/ContentAndMediaTypeBaseController.cs @@ -87,15 +87,21 @@ namespace Umbraco.Web.Editors column.Header = "Last edited"; column.LocalizationKey = "defaultdialogs_lastEdited"; } - else if (alias == "Owner") + else if (alias == "Updator") { // Special case to restore hard-coded column titles (2) column.Header = "Updated by"; column.LocalizationKey = "content_updatedBy"; } + else if (alias == "Owner") + { + // Special case to restore hard-coded column titles (3) + column.Header = "Created by"; + column.LocalizationKey = "content_createBy"; + } else { - // Otherwise just sentence case the alias + // For others just sentence case the alias and camel case for the key column.Header = alias.ToFirstUpper().SplitPascalCasing(); column.LocalizationKey = "content_" + alias.ToFirstLower(); } diff --git a/src/Umbraco.Web/umbraco.presentation/umbraco/controls/ContentTypeControlNew.ascx.cs b/src/Umbraco.Web/umbraco.presentation/umbraco/controls/ContentTypeControlNew.ascx.cs index 3156cf5cdb..60223b37ef 100644 --- a/src/Umbraco.Web/umbraco.presentation/umbraco/controls/ContentTypeControlNew.ascx.cs +++ b/src/Umbraco.Web/umbraco.presentation/umbraco/controls/ContentTypeControlNew.ascx.cs @@ -293,7 +293,14 @@ namespace umbraco.controls //_contentType.ContentTypeItem.Thumbnail = ddlThumbnails.SelectedValue; _contentType.ContentTypeItem.AllowedAsRoot = allowAtRoot.Checked; _contentType.ContentTypeItem.IsContainer = cb_isContainer.Checked; - _contentType.ContentTypeItem.ContainerConfig = GetProvidedContainerConfigAsJsonString(); + if (cb_isContainer.Checked) + { + _contentType.ContentTypeItem.ContainerConfig = GetProvidedContainerConfigAsJsonString(); + } + else + { + _contentType.ContentTypeItem.ContainerConfig = string.Empty; + } int i = 0; var ids = SaveAllowedChildTypes(); @@ -367,9 +374,9 @@ namespace umbraco.controls // Set defaults for saving if not all fields are provided var pageSize = 10; - var additionalColumns = "UpdateDate,Owner"; - var orderBy = "UpdateDate"; - var orderDirection = "desc"; + var additionalColumns = string.Empty; + var orderBy = "Name"; + var orderDirection = "asc"; var allowBulkPublish = true; var allowBulkUnpublish = true; var allowBulkDelete = true; @@ -384,9 +391,9 @@ namespace umbraco.controls configProvided = true; } - if (!string.IsNullOrEmpty(txtContainerConfigOrderBy.Text)) + if (ddlContainerConfigOrderBy.SelectedIndex > 0) { - orderBy = txtContainerConfigOrderBy.Text; + orderBy = ddlContainerConfigOrderBy.SelectedItem.Value; configProvided = true; } @@ -645,27 +652,63 @@ jQuery(document).ready(function() {{ refreshDropDowns(); }}); DualAllowedContentTypes.Value = chosenContentTypeIDs; } + // Set up options for columns and order by + ddlContainerConfigOrderBy.Items.Add(new ListItem(string.Empty, string.Empty)); + ddlContainerConfigOrderBy.Items.Add(new ListItem("Node name", "Name")); + ddlContainerConfigOrderBy.Items.Add(new ListItem("Last edited on", "UpdateDate")); + ddlContainerConfigOrderBy.Items.Add(new ListItem("Last updated by", "Updator")); + ddlContainerConfigOrderBy.Items.Add(new ListItem("Created on", "CreateDate")); + 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")); + ddlContainerConfigAdditionalColumnsChooser.Items.Add(new ListItem("Created by", "Owner")); + ddlContainerConfigAdditionalColumnsChooser.Items.Add(new ListItem("---", string.Empty)); + + // - get properties from allowed document types (i.e. those that might appear in the list view) + var allPropertiesOfAllowedContentTypes = Services.ContentTypeService + .GetAllContentTypes(_contentType.AllowedChildContentTypeIDs) + .SelectMany(x => x.PropertyTypes) + .ToList(); + foreach (var property in allPropertiesOfAllowedContentTypes) + { + ddlContainerConfigAdditionalColumnsChooser.Items.Add(new ListItem(property.Name, property.Alias)); + } + + // Populate controls with values allowAtRoot.Checked = _contentType.AllowAtRoot; cb_isContainer.Checked = _contentType.IsContainerContentType; + ddlContainerConfigOrderBy.SelectedIndex = -1; ddlContainerConfigOrderDirection.SelectedIndex = -1; ddlContainerConfigAllowBulkPublish.SelectedIndex = -1; ddlContainerConfigAllowBulkUnpublish.SelectedIndex = -1; ddlContainerConfigAllowBulkDelete.SelectedIndex = -1; - if (!string.IsNullOrEmpty(_contentType.ContainerConfig)) + + if (_contentType.IsContainerContentType && !string.IsNullOrEmpty(_contentType.ContainerConfig)) { var containerConfig = GetContentTypeContainerConfigurationFromJsonString(_contentType.ContainerConfig); txtContainerConfigPageSize.Text = containerConfig.PageSize.ToString(); txtContainerConfigAdditionalColumns.Text = containerConfig.AdditionalColumnAliases; - txtContainerConfigOrderBy.Text = containerConfig.OrderBy; + ddlContainerConfigOrderBy.Items.FindByValue(containerConfig.OrderBy).Selected = true; ddlContainerConfigOrderDirection.Items.FindByValue(containerConfig.OrderDirection).Selected = true; - ddlContainerConfigAllowBulkPublish.SelectedIndex = containerConfig.AllowBulkPublish ? 1 : 2; - ddlContainerConfigAllowBulkUnpublish.SelectedIndex = containerConfig.AllowBulkUnpublish ? 1 : 2; - ddlContainerConfigAllowBulkDelete.SelectedIndex = containerConfig.AllowBulkDelete ? 1 : 2; + ddlContainerConfigAllowBulkPublish.SelectedIndex = containerConfig.AllowBulkPublish ? 0 : 1; + ddlContainerConfigAllowBulkUnpublish.SelectedIndex = containerConfig.AllowBulkUnpublish ? 0 : 1; + ddlContainerConfigAllowBulkDelete.SelectedIndex = containerConfig.AllowBulkDelete ? 0 : 1; } else { - txtContainerConfigPageSize.Text = string.Empty; + // Set defaults matching original hard-coded values unless config has been provided + txtContainerConfigPageSize.Text = "10"; + txtContainerConfigAdditionalColumns.Text = "UpdateDate,Updator"; + ddlContainerConfigOrderBy.Items.FindByValue("UpdateDate").Selected = true; + ddlContainerConfigOrderDirection.Items.FindByValue("desc").Selected = true; + ddlContainerConfigAllowBulkPublish.SelectedIndex = 0; + ddlContainerConfigAllowBulkUnpublish.SelectedIndex = 0; + ddlContainerConfigAllowBulkDelete.SelectedIndex = 0; } } @@ -1445,10 +1488,11 @@ jQuery(document).ready(function() {{ refreshDropDowns(); }}); protected global::System.Web.UI.WebControls.TextBox txtContainerConfigPageSize; protected global::umbraco.uicontrols.PropertyPanel pp_containerConfigAdditionalColumns; + protected global::System.Web.UI.WebControls.DropDownList ddlContainerConfigAdditionalColumnsChooser; protected global::System.Web.UI.WebControls.TextBox txtContainerConfigAdditionalColumns; protected global::umbraco.uicontrols.PropertyPanel pp_containerConfigOrderBy; - protected global::System.Web.UI.WebControls.TextBox txtContainerConfigOrderBy; + protected global::System.Web.UI.WebControls.DropDownList ddlContainerConfigOrderBy; protected global::umbraco.uicontrols.PropertyPanel pp_containerConfigOrderDirection; protected global::System.Web.UI.WebControls.DropDownList ddlContainerConfigOrderDirection;