From a2a17faca1ee3adee6d92c5a31c25fe8ecfecde2 Mon Sep 17 00:00:00 2001 From: Mads Rasmussen Date: Mon, 6 Feb 2017 16:11:51 +0100 Subject: [PATCH] Fixes: U4-9474 Update macro picker to follow the new picker UI --- .../macrocontainer.controller.js | 20 ++++++++- .../macrocontainer/macrocontainer.html | 45 +++++++++---------- 2 files changed, 40 insertions(+), 25 deletions(-) diff --git a/src/Umbraco.Web.UI.Client/src/views/propertyeditors/macrocontainer/macrocontainer.controller.js b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/macrocontainer/macrocontainer.controller.js index b74e30004e..f0fe89b14f 100644 --- a/src/Umbraco.Web.UI.Client/src/views/propertyeditors/macrocontainer/macrocontainer.controller.js +++ b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/macrocontainer/macrocontainer.controller.js @@ -3,7 +3,11 @@ angular.module('umbraco') .controller("Umbraco.PropertyEditors.MacroContainerController", function($scope, dialogService, entityResource, macroService){ + $scope.renderModel = []; + $scope.allowOpenButton = true; + $scope.allowRemoveButton = true; + $scope.sortableOptions = {}; if($scope.model.value){ var macros = $scope.model.value.split('>'); @@ -20,6 +24,7 @@ angular.module('umbraco') parsed.syntax = syntax; collectDetails(parsed); $scope.renderModel.push(parsed); + setSortingState($scope.renderModel); } }); } @@ -27,11 +32,12 @@ angular.module('umbraco') function collectDetails(macro){ macro.details = ""; + macro.icon = "icon-settings-alt"; if(macro.macroParamsDictionary){ angular.forEach((macro.macroParamsDictionary), function(value, key){ macro.details += key + ": " + value + " "; }); - } + } } function openDialog(index){ @@ -61,6 +67,8 @@ angular.module('umbraco') $scope.renderModel.push(macroObject); } + setSortingState($scope.renderModel); + $scope.macroPickerOverlay.show = false; $scope.macroPickerOverlay = null; }; @@ -90,6 +98,7 @@ angular.module('umbraco') $scope.remove =function(index){ $scope.renderModel.splice(index, 1); + setSortingState($scope.renderModel); }; $scope.clear = function() { @@ -117,4 +126,13 @@ angular.module('umbraco') return str.replace(rgxtrim, ''); } + function setSortingState(items) { + // disable sorting if the list only consist of one item + if(items.length > 1) { + $scope.sortableOptions.disabled = false; + } else { + $scope.sortableOptions.disabled = true; + } + } + }); diff --git a/src/Umbraco.Web.UI.Client/src/views/propertyeditors/macrocontainer/macrocontainer.html b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/macrocontainer/macrocontainer.html index 96c74c9c55..1dec2788e2 100644 --- a/src/Umbraco.Web.UI.Client/src/views/propertyeditors/macrocontainer/macrocontainer.html +++ b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/macrocontainer/macrocontainer.html @@ -1,30 +1,27 @@
- - - + + Add +