From 8f300761efd2ecb8279c25e5e1e6204aee65a467 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B8ren=20Kottal?= Date: Tue, 1 Oct 2019 21:11:56 +0200 Subject: [PATCH] Makes it possible to change the icon for list view content apps --- .../listview/icon.prevalues.controller.js | 31 +++++++++++++++++++ .../listview/icon.prevalues.html | 11 +++++++ .../ContentApps/ListViewContentAppFactory.cs | 9 ++++++ .../PropertyEditors/ListViewConfiguration.cs | 3 ++ 4 files changed, 54 insertions(+) create mode 100644 src/Umbraco.Web.UI.Client/src/views/propertyeditors/listview/icon.prevalues.controller.js create mode 100644 src/Umbraco.Web.UI.Client/src/views/propertyeditors/listview/icon.prevalues.html diff --git a/src/Umbraco.Web.UI.Client/src/views/propertyeditors/listview/icon.prevalues.controller.js b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/listview/icon.prevalues.controller.js new file mode 100644 index 0000000000..86dcfdc415 --- /dev/null +++ b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/listview/icon.prevalues.controller.js @@ -0,0 +1,31 @@ +function iconPreValsController($scope, editorService) { + + if (!$scope.model.value) { + $scope.model.value = "icon-list"; + } + + $scope.openIconPicker = function () { + var iconPicker = { + icon: $scope.model.value.split(' ')[0], + color: $scope.model.value.split(' ')[1], + submit: function (model) { + if (model.icon) { + if (model.color) { + $scope.model.value = model.icon + " " + model.color; + } else { + $scope.model.value = model.icon; + } + $scope.iconForm.$setDirty(); + } + editorService.close(); + }, + close: function () { + editorService.close(); + } + }; + editorService.iconPicker(iconPicker); + }; +} + + +angular.module("umbraco").controller("Umbraco.PrevalueEditors.IconPickerController", iconPreValsController); diff --git a/src/Umbraco.Web.UI.Client/src/views/propertyeditors/listview/icon.prevalues.html b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/listview/icon.prevalues.html new file mode 100644 index 0000000000..2d3d4eeae2 --- /dev/null +++ b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/listview/icon.prevalues.html @@ -0,0 +1,11 @@ +
+ +
+ +
+ +
+
+
+
diff --git a/src/Umbraco.Web/ContentApps/ListViewContentAppFactory.cs b/src/Umbraco.Web/ContentApps/ListViewContentAppFactory.cs index ab605c7014..ae6d324e84 100644 --- a/src/Umbraco.Web/ContentApps/ListViewContentAppFactory.cs +++ b/src/Umbraco.Web/ContentApps/ListViewContentAppFactory.cs @@ -100,6 +100,15 @@ namespace Umbraco.Web.ContentApps if (configTabName != null && String.IsNullOrWhiteSpace(configTabName.ToString()) == false) contentApp.Name = configTabName.ToString(); } + + //Override Icon if icon is provided + if (listViewConfig.ContainsKey("icon")) + { + var configIcon = listViewConfig["icon"]; + if (configIcon != null && String.IsNullOrWhiteSpace(configIcon.ToString()) == false) + contentApp.Icon = configIcon.ToString(); + } + // if the list view is configured to show umbContent first, update the list view content app weight accordingly if(listViewConfig.ContainsKey("showContentFirst") && listViewConfig["showContentFirst"]?.ToString().TryConvertTo().Result == true) diff --git a/src/Umbraco.Web/PropertyEditors/ListViewConfiguration.cs b/src/Umbraco.Web/PropertyEditors/ListViewConfiguration.cs index 4f854a7556..ae0b32fde1 100644 --- a/src/Umbraco.Web/PropertyEditors/ListViewConfiguration.cs +++ b/src/Umbraco.Web/PropertyEditors/ListViewConfiguration.cs @@ -60,6 +60,9 @@ namespace Umbraco.Web.PropertyEditors Description = "The bulk actions that are allowed from the list view")] public BulkActionPermissionSettings BulkActionPermissions { get; set; } = new BulkActionPermissionSettings(); // TODO: managing defaults? + [ConfigurationField("icon", "Content app icon", "views/propertyeditors/listview/icon.prevalues.html", Description = "The icon of the listview content app")] + public string Icon { get; set; } + [ConfigurationField("tabName", "Content app name", "textstring", Description = "The name of the listview content app (default if empty: 'Child Items')")] public string TabName { get; set; }