From a388657dbbc1a494b5be9ce9a81f54755abfbd30 Mon Sep 17 00:00:00 2001 From: Bjarne Fyrstenborg Date: Wed, 15 Nov 2017 19:11:35 +0100 Subject: [PATCH 1/3] Change types of listview properties --- .../PropertyEditors/ListViewPropertyEditor.cs | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/Umbraco.Web/PropertyEditors/ListViewPropertyEditor.cs b/src/Umbraco.Web/PropertyEditors/ListViewPropertyEditor.cs index 2ee208ed48..3a0066f9fc 100644 --- a/src/Umbraco.Web/PropertyEditors/ListViewPropertyEditor.cs +++ b/src/Umbraco.Web/PropertyEditors/ListViewPropertyEditor.cs @@ -37,14 +37,16 @@ namespace Umbraco.Web.PropertyEditors new {name = "Grid", path = "views/propertyeditors/listview/layouts/grid/grid.html", icon = "icon-thumbnails-small", isSystem = 1, selected = true} } }, - {"bulkActionPermissions", new + { + "bulkActionPermissions", new { allowBulkPublish = true, allowBulkUnpublish = true, allowBulkCopy = true, allowBulkMove = false, allowBulkDelete = true - }} + } + } }; } } @@ -52,7 +54,7 @@ namespace Umbraco.Web.PropertyEditors internal class ListViewPreValueEditor : PreValueEditor { [PreValueField("tabName", "Tab Name", "textstring", Description = "The name of the listview tab (default if empty: 'Child Items')")] - public int TabName { get; set; } + public string TabName { get; set; } [PreValueField("displayAtTabNumber", "Display At Tab Number", "number", Description = "Which tab position that the list of child items will be displayed")] public int DisplayAtTabNumber { get; set; } @@ -61,7 +63,7 @@ namespace Umbraco.Web.PropertyEditors public int PageSize { get; set; } [PreValueField("layouts", "Layouts", "views/propertyeditors/listview/layouts.prevalues.html")] - public int Layouts { get; set; } + public object Layouts { get; set; } [PreValueField("includeProperties", "Columns Displayed", "views/propertyeditors/listview/includeproperties.prevalues.html", Description = "The properties that will be displayed for each column")] @@ -69,10 +71,10 @@ namespace Umbraco.Web.PropertyEditors [PreValueField("orderBy", "Order By", "views/propertyeditors/listview/sortby.prevalues.html", Description = "The default sort order for the list")] - public int OrderBy { get; set; } + public string OrderBy { get; set; } [PreValueField("orderDirection", "Order Direction", "views/propertyeditors/listview/orderdirection.prevalues.html")] - public int OrderDirection { get; set; } + public string OrderDirection { get; set; } [PreValueField("bulkActionPermissions", "Bulk Action Permissions", "views/propertyeditors/listview/bulkactionpermissions.prevalues.html", Description = "The bulk actions that are allowed from the list view")] From 3d326158ca0a465950bde0a1cacff3021a774024 Mon Sep 17 00:00:00 2001 From: Matt Darby Date: Wed, 6 Dec 2017 19:58:58 +0700 Subject: [PATCH 2/3] Check node permissions only on content list view --- .../listview/listview.controller.js | 37 ++++++++++--------- .../propertyeditors/listview/listview.html | 2 +- 2 files changed, 21 insertions(+), 18 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 8f9279fb02..03b95b6883 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 @@ -57,24 +57,27 @@ function listViewController($rootScope, $scope, $routeParams, $injector, $cookie totalPages: 0, items: [] }; + + //when this is null, we don't check permissions + $scope.currentNodePermissions = null; + + if ($scope.entityType === "content") { + //Just ensure we do have an editorState + if (editorState.current) { + //Fetch current node allowed actions for the current user + //This is the current node & not each individual child node in the list + var currentUserPermissions = editorState.current.allowedActions; - $scope.currentNodePermissions = {} - - //Just ensure we do have an editorState - if (editorState.current) { - //Fetch current node allowed actions for the current user - //This is the current node & not each individual child node in the list - var currentUserPermissions = editorState.current.allowedActions; - - //Create a nicer model rather than the funky & hard to remember permissions strings - $scope.currentNodePermissions = { - "canCopy": _.contains(currentUserPermissions, 'O'), //Magic Char = O - "canCreate": _.contains(currentUserPermissions, 'C'), //Magic Char = C - "canDelete": _.contains(currentUserPermissions, 'D'), //Magic Char = D - "canMove": _.contains(currentUserPermissions, 'M'), //Magic Char = M - "canPublish": _.contains(currentUserPermissions, 'U'), //Magic Char = U - "canUnpublish": _.contains(currentUserPermissions, 'U'), //Magic Char = Z (however UI says it can't be set, so if we can publish 'U' we can unpublish) - }; + //Create a nicer model rather than the funky & hard to remember permissions strings + $scope.currentNodePermissions = { + "canCopy": _.contains(currentUserPermissions, 'O'), //Magic Char = O + "canCreate": _.contains(currentUserPermissions, 'C'), //Magic Char = C + "canDelete": _.contains(currentUserPermissions, 'D'), //Magic Char = D + "canMove": _.contains(currentUserPermissions, 'M'), //Magic Char = M + "canPublish": _.contains(currentUserPermissions, 'U'), //Magic Char = U + "canUnpublish": _.contains(currentUserPermissions, 'U'), //Magic Char = Z (however UI says it can't be set, so if we can publish 'U' we can unpublish) + }; + } } //when this is null, we don't check permissions diff --git a/src/Umbraco.Web.UI.Client/src/views/propertyeditors/listview/listview.html b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/listview/listview.html index 97500fd7c1..2683317dc1 100644 --- a/src/Umbraco.Web.UI.Client/src/views/propertyeditors/listview/listview.html +++ b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/listview/listview.html @@ -10,7 +10,7 @@ - +
Create From 02ac44e214c7d6cd1f9e630b1fe8e731f0449a16 Mon Sep 17 00:00:00 2001 From: Bjarne Fyrstenborg Date: Wed, 25 Jul 2018 16:29:20 +0200 Subject: [PATCH 3/3] U4-10792 - highlight error when trying to add duplicate in listview columns (#2362) --- .../includeproperties.prevalues.controller.js | 45 ++++++++++++++----- .../listview/includeproperties.prevalues.html | 3 +- 2 files changed, 36 insertions(+), 12 deletions(-) diff --git a/src/Umbraco.Web.UI.Client/src/views/propertyeditors/listview/includeproperties.prevalues.controller.js b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/listview/includeproperties.prevalues.controller.js index 0cd199ae4d..216f1555e2 100644 --- a/src/Umbraco.Web.UI.Client/src/views/propertyeditors/listview/includeproperties.prevalues.controller.js +++ b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/listview/includeproperties.prevalues.controller.js @@ -4,6 +4,9 @@ function includePropsPreValsController($rootScope, $scope, localizationService, $scope.model.value = []; } + $scope.hasError = false; + $scope.errorMsg = ""; + $scope.propertyAliases = []; $scope.selectedField = null; $scope.systemFields = [ @@ -45,6 +48,11 @@ function includePropsPreValsController($rootScope, $scope, localizationService, return alias; } + $scope.changeField = function () { + $scope.hasError = false; + $scope.errorMsg = ""; + } + $scope.removeField = function(e) { $scope.model.value = _.reject($scope.model.value, function (x) { return x.alias === e.alias; @@ -123,19 +131,34 @@ function includePropsPreValsController($rootScope, $scope, localizationService, $scope.addField = function () { var val = $scope.selectedField; - var isSystem = val.startsWith("_system_"); - if (isSystem) { - val = val.trimStart("_system_"); - } + if (val) { + var isSystem = val.startsWith("_system_"); + if (isSystem) { + val = val.trimStart("_system_"); + } - var exists = _.find($scope.model.value, function (i) { - return i.alias === val; - }); - if (!exists) { - $scope.model.value.push({ - alias: val, - isSystem: isSystem ? 1 : 0 + var exists = _.find($scope.model.value, function (i) { + return i.alias === val; }); + + if (!exists) { + $scope.hasError = false; + $scope.errorMsg = ""; + + $scope.model.value.push({ + alias: val, + isSystem: isSystem ? 1 : 0 + }); + } + else { + //there was an error, do the highlight (will be set back by the directive) + $scope.hasError = true; + $scope.errorMsg = "Property is already added"; + } + } + else { + $scope.hasError = true; + $scope.errorMsg = "No property selected"; } } diff --git a/src/Umbraco.Web.UI.Client/src/views/propertyeditors/listview/includeproperties.prevalues.html b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/listview/includeproperties.prevalues.html index 2e210e635f..749d5b5cb0 100644 --- a/src/Umbraco.Web.UI.Client/src/views/propertyeditors/listview/includeproperties.prevalues.html +++ b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/listview/includeproperties.prevalues.html @@ -1,7 +1,7 @@ 
- @@ -9,6 +9,7 @@ + {{errorMsg}}