From 9a246a1970c218ae72ed300dd7fbc5313baa7302 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B8ren=20Gregersen?= Date: Tue, 21 Sep 2021 06:56:27 +0200 Subject: [PATCH] Implement icon parameter for doctype editor (#11008) * fix: implement icon parameter for doctype editor issue #10108 * fix: move color from icon to class attribute * fix: removed defined colors, defaulting to the standard dark grey (ie "no color picked" in icon picker) * cleaned up unused dependencies, double quotes to single, removed unused 'color' param from the create methods, and use shorthand object creation in createDocType (if the key has the same name as the variable passed as a prop, we only need to pass the key name) * fix comment Co-authored-by: Nathan Woulfe --- .../views/documenttypes/create.controller.js | 77 +++++++++++-------- .../src/views/documenttypes/create.html | 8 +- .../views/documenttypes/edit.controller.js | 8 ++ 3 files changed, 58 insertions(+), 35 deletions(-) diff --git a/src/Umbraco.Web.UI.Client/src/views/documenttypes/create.controller.js b/src/Umbraco.Web.UI.Client/src/views/documenttypes/create.controller.js index 23173a404dc3..b82146e75be5 100644 --- a/src/Umbraco.Web.UI.Client/src/views/documenttypes/create.controller.js +++ b/src/Umbraco.Web.UI.Client/src/views/documenttypes/create.controller.js @@ -6,11 +6,11 @@ * @description * The controller for the doc type creation dialog */ -function DocumentTypesCreateController($scope, $location, navigationService, contentTypeResource, formHelper, appState, notificationsService, localizationService, iconHelper) { +function DocumentTypesCreateController($scope, $location, navigationService, contentTypeResource, formHelper, appState) { $scope.model = { - allowCreateFolder: $scope.currentNode.parentId === null || $scope.currentNode.nodeType === "container", - folderName: "", + allowCreateFolder: $scope.currentNode.parentId === null || $scope.currentNode.nodeType === 'container', + folderName: '', creatingFolder: false }; @@ -31,18 +31,18 @@ function DocumentTypesCreateController($scope, $location, navigationService, con navigationService.hideMenu(); - var currPath = node.path ? node.path : "-1"; + var currPath = node.path ? node.path : '-1'; navigationService.syncTree({ - tree: "documenttypes", - path: currPath + "," + folderId, + tree: 'documenttypes', + path: currPath + ',' + folderId, forceReload: true, activate: true }); formHelper.resetForm({ scope: $scope, formCtrl: $scope.createFolderForm }); - var section = appState.getSectionState("currentSection"); + var section = appState.getSectionState('currentSection'); }, function (err) { @@ -51,39 +51,54 @@ function DocumentTypesCreateController($scope, $location, navigationService, con }); } - }; + }; + + function createDocType(config) { + + $location.search('create', null); + $location.search('notemplate', null); + $location.search('iscomposition', null); + $location.search('iselement', null); + $location.search('icon', null); + + var icon = null; + + if (config.icon != undefined && config.icon != null) { + icon = config.icon; + if (config.color) { + icon += ' ' + config.color; + } + } + + $location + .path('/settings/documenttypes/edit/' + node.id) + .search('create', 'true') + .search('notemplate', config.notemplate ? 'true' : null) + .search('iscomposition', config.iscomposition ? 'true' : null) + .search('iselement', config.iselement ? 'true' : null) + .search('icon', icon); + + navigationService.hideMenu(); + } + // Disabling logic for creating document type with template if disableTemplates is set to true if (!disableTemplates) { - $scope.createDocType = function () { - $location.search('create', null); - $location.search('notemplate', null); - $location.path("/settings/documenttypes/edit/" + node.id).search("create", "true"); - navigationService.hideMenu(); + $scope.createDocType = function (icon) { + createDocType({ icon }); }; } - $scope.createComponent = function () { - $location.search('create', null); - $location.search('notemplate', null); - $location.path("/settings/documenttypes/edit/" + node.id).search("create", "true").search("notemplate", "true"); - navigationService.hideMenu(); + $scope.createComponent = function (icon) { + createDocType({ notemplate: true, icon }); }; - $scope.createComposition = function () { - $location.search('create', null); - $location.search('notemplate', null); - $location.search('iscomposition', null); - $location.path("/settings/documenttypes/edit/" + node.id).search("create", "true").search("notemplate", "true").search("iscomposition", "true"); - navigationService.hideMenu(); + $scope.createComposition = function (icon) { + createDocType({ iscomposition: true, iselement: true, icon }); }; - $scope.createElement = function () { - $location.search('create', null); - $location.search('notemplate', null); - $location.search('iselement', null); - $location.path("/settings/documenttypes/edit/" + node.id).search("create", "true").search("notemplate", "true").search("iselement", "true"); - navigationService.hideMenu(); + $scope.createElement = function (icon) { + createDocType({ iselement: true, icon }); }; $scope.close = function() { @@ -92,4 +107,4 @@ function DocumentTypesCreateController($scope, $location, navigationService, con }; } -angular.module('umbraco').controller("Umbraco.Editors.DocumentTypes.CreateController", DocumentTypesCreateController); +angular.module('umbraco').controller('Umbraco.Editors.DocumentTypes.CreateController', DocumentTypesCreateController); diff --git a/src/Umbraco.Web.UI.Client/src/views/documenttypes/create.html b/src/Umbraco.Web.UI.Client/src/views/documenttypes/create.html index 8992c73525dd..143d9b9df1e8 100644 --- a/src/Umbraco.Web.UI.Client/src/views/documenttypes/create.html +++ b/src/Umbraco.Web.UI.Client/src/views/documenttypes/create.html @@ -5,7 +5,7 @@
Create an item under {{current
  • -
  • -
  • -
  • -