diff --git a/src/Umbraco.Web.UI.Client/src/views/macros/create.html b/src/Umbraco.Web.UI.Client/src/views/macros/create.html index a72cd373b2..9406c71064 100644 --- a/src/Umbraco.Web.UI.Client/src/views/macros/create.html +++ b/src/Umbraco.Web.UI.Client/src/views/macros/create.html @@ -1,19 +1,30 @@ 
+ + diff --git a/src/Umbraco.Web.UI.Client/src/views/macros/macros.create.controller.js b/src/Umbraco.Web.UI.Client/src/views/macros/macros.create.controller.js index 1745b7b7f6..e2559741a2 100644 --- a/src/Umbraco.Web.UI.Client/src/views/macros/macros.create.controller.js +++ b/src/Umbraco.Web.UI.Client/src/views/macros/macros.create.controller.js @@ -13,29 +13,32 @@ function MacrosCreateController($scope, $location, macroResource, navigationServ function createItem() { - var node = $scope.currentNode; + if (formHelper.submitForm({ scope: $scope, formCtrl: this.createMacroForm })) { - macroResource.createMacro(vm.itemKey).then(function (data) { - navigationService.hideMenu(); + var node = $scope.currentNode; - // set new item as active in tree - var currPath = node.path ? node.path : "-1"; - navigationService.syncTree({ tree: "macros", path: currPath + "," + data, forceReload: true, activate: true }); - - // reset form state - formHelper.resetForm({ scope: $scope }); - - // navigate to edit view - var currentSection = appState.getSectionState("currentSection"); - $location.path("/" + currentSection + "/macros/edit/" + data); - - - }, function (err) { - if (err.data && err.data.message) { - notificationsService.error(err.data.message); + macroResource.createMacro(vm.itemKey).then(function (data) { navigationService.hideMenu(); - } - }); + + // set new item as active in tree + var currPath = node.path ? node.path : "-1"; + navigationService.syncTree({ tree: "macros", path: currPath + "," + data, forceReload: true, activate: true }); + + // reset form state + formHelper.resetForm({ scope: $scope }); + + // navigate to edit view + var currentSection = appState.getSectionState("currentSection"); + $location.path("/" + currentSection + "/macros/edit/" + data); + + + }, function (err) { + if (err.data && err.data.message) { + notificationsService.error(err.data.message); + navigationService.hideMenu(); + } + }); + } } vm.createItem = createItem; diff --git a/src/Umbraco.Web.UI.Client/src/views/macros/macros.edit.controller.js b/src/Umbraco.Web.UI.Client/src/views/macros/macros.edit.controller.js index fd998ce4ba..e91d8ae366 100644 --- a/src/Umbraco.Web.UI.Client/src/views/macros/macros.edit.controller.js +++ b/src/Umbraco.Web.UI.Client/src/views/macros/macros.edit.controller.js @@ -95,6 +95,11 @@ function MacrosEditController($scope, $q, $routeParams, macroResource, editorSta function bindMacro(data) { vm.macro = data; + + if (vm.macro && vm.macro.view) { + vm.macro.node = { icon: 'icon-article', name: vm.macro.view }; + } + editorState.set(vm.macro); navigationService.syncTree({ tree: "macros", path: vm.macro.path, forceReload: true }).then(function (syncArgs) { @@ -109,21 +114,24 @@ function MacrosEditController($scope, $q, $routeParams, macroResource, editorSta vm.promises['parameterEditors'] = getParameterEditors(); vm.promises['macro'] = getMacro(); + vm.views = []; + vm.node = null; + $q.all(vm.promises).then(function (values) { var keys = Object.keys(values); for (var i = 0; i < keys.length; i++) { var key = keys[i]; - if (keys[i] === 'partialViews') { + if (key === 'partialViews') { vm.views = values[key]; } - if (keys[i] === 'parameterEditors') { + if (key === 'parameterEditors') { vm.parameterEditors = values[key]; } - if (keys[i] === 'macro') { + if (key === 'macro') { bindMacro(values[key]); } } diff --git a/src/Umbraco.Web.UI.Client/src/views/macros/views/macro.settings.controller.js b/src/Umbraco.Web.UI.Client/src/views/macros/views/macro.settings.controller.js new file mode 100644 index 0000000000..c250138adb --- /dev/null +++ b/src/Umbraco.Web.UI.Client/src/views/macros/views/macro.settings.controller.js @@ -0,0 +1,66 @@ +/** + * @ngdoc controller + * @name Umbraco.Editors.Macros.SettingsController + * @function + * + * @description + * The controller for editing macros settings + */ +function MacrosSettingsController($scope, editorService, localizationService) { + + const vm = this; + + //vm.openViewPicker = openViewPicker; + //vm.removeMacroView = removeMacroView; + $scope.model.openViewPicker = openViewPicker; + $scope.model.removeMacroView = removeMacroView; + + function openViewPicker() { + const controlPicker = { + title: "Select view", + section: "settings", + treeAlias: "partialViewMacros", + entityType: "partialView", + onlyInitialized: false, + filter: function (i) { + if (i.name.indexOf(".cshtml") === -1 && i.name.indexOf(".vbhtml") === -1) { + return true; + } + }, + filterCssClass: "not-allowed", + select: function (node) { + const id = unescape(node.id); + + //vm.macro.view = id; + $scope.model.macro.view = "~/Views/MacroPartials/" + id; + + $scope.model.macro.node = { + icon: node.icon, + name: $scope.model.macro.view + }; + + //$scope.model.submit($scope.model); + + editorService.close(); + }, + close: function () { + editorService.close(); + } + }; + editorService.treePicker(controlPicker); + } + + function removeMacroView() { + //vm.macro.view = null; + $scope.model.macro.node = null; + $scope.model.macro.view = null; + } + + function init() { + + } + + init(); +} + +angular.module("umbraco").controller("Umbraco.Editors.Macros.SettingsController", MacrosSettingsController); diff --git a/src/Umbraco.Web.UI.Client/src/views/macros/views/settings.html b/src/Umbraco.Web.UI.Client/src/views/macros/views/settings.html index 0b214b9dee..60aeae0d92 100644 --- a/src/Umbraco.Web.UI.Client/src/views/macros/views/settings.html +++ b/src/Umbraco.Web.UI.Client/src/views/macros/views/settings.html @@ -1,43 +1,61 @@ - - - - - {{model.macro.id}}
- {{model.macro.key}} -
-
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +
+ + + + + {{model.macro.id}}
+ {{model.macro.key}} +
+
+
+ + + + + + + + + + Add + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
diff --git a/src/Umbraco.Web.UI.Client/src/views/mediatypes/create.html b/src/Umbraco.Web.UI.Client/src/views/mediatypes/create.html index 45fbebbe71..094d1ff8e4 100644 --- a/src/Umbraco.Web.UI.Client/src/views/mediatypes/create.html +++ b/src/Umbraco.Web.UI.Client/src/views/mediatypes/create.html @@ -37,7 +37,7 @@
- + diff --git a/src/Umbraco.Web.UI.Client/src/views/relationtypes/create.html b/src/Umbraco.Web.UI.Client/src/views/relationtypes/create.html index 9f3a22d6f1..67a48e77cd 100644 --- a/src/Umbraco.Web.UI.Client/src/views/relationtypes/create.html +++ b/src/Umbraco.Web.UI.Client/src/views/relationtypes/create.html @@ -1,6 +1,9 @@