diff --git a/src/Umbraco.Web.UI.Client/src/common/directives/components/content/umbcontentnodeinfo.directive.js b/src/Umbraco.Web.UI.Client/src/common/directives/components/content/umbcontentnodeinfo.directive.js index c9d78a3551..5f9f1f4a36 100644 --- a/src/Umbraco.Web.UI.Client/src/common/directives/components/content/umbcontentnodeinfo.directive.js +++ b/src/Umbraco.Web.UI.Client/src/common/directives/components/content/umbcontentnodeinfo.directive.js @@ -12,6 +12,7 @@ scope.disableTemplates = Umbraco.Sys.ServerVariables.features.disabledFeatures.disableTemplates; scope.allowChangeDocumentType = false; + scope.allowChangeTemplate = false; function onInit() { @@ -20,6 +21,7 @@ angular.forEach(user.sections, function(section){ if(section.alias === "settings") { scope.allowChangeDocumentType = true; + scope.allowChangeTemplate = true; } }); }); @@ -92,15 +94,21 @@ }; scope.openTemplate = function () { - var url = "/settings/templates/edit/" + scope.node.templateId; - $location.url(url); + var templateEditor = { + id: scope.node.templateId, + submit: function(model) { + editorService.close(); + }, + close: function() { + editorService.close(); + } + }; + editorService.templateEditor(templateEditor); } scope.updateTemplate = function (templateAlias) { - // update template value scope.node.template = templateAlias; - }; scope.datePickerChange = function (event, type) { diff --git a/src/Umbraco.Web.UI.Client/src/common/services/editor.service.js b/src/Umbraco.Web.UI.Client/src/common/services/editor.service.js index 0bbfe34fe1..800f150ee8 100644 --- a/src/Umbraco.Web.UI.Client/src/common/services/editor.service.js +++ b/src/Umbraco.Web.UI.Client/src/common/services/editor.service.js @@ -232,6 +232,23 @@ open(editor); } + /** + * @ngdoc method + * @name umbraco.services.editorService#templateEditor + * @methodOf umbraco.services.editorService + * + * @description + * Opens the user group picker in infinite editing, the submit callback returns the saved template + * @param {String} editor.id The template id + * @param {Callback} editor.submit Submits the editor + * @param {Callback} editor.close Closes the editor + * @returns {Object} editor object + */ + function templateEditor(editor) { + editor.view = "views/templates/edit.html"; + open(editor); + } + /** * @ngdoc method * @name umbraco.services.editorService#sectionPicker @@ -249,6 +266,40 @@ open(editor); } + /** + * @ngdoc method + * @name umbraco.services.editorService#insertField + * @methodOf umbraco.services.editorService + * + * @description + * Opens the insert field editor in infinite editing, the submit callback returns the code snippet + * @param {Callback} editor.submit Submits the editor + * @param {Callback} editor.close Closes the editor + * @returns {Object} editor object + */ + function insertField(editor) { + editor.view = "views/common/infiniteeditors/insertfield/insertfield.html"; + editor.size = "small"; + open(editor); + } + + /** + * @ngdoc method + * @name umbraco.services.editorService#templateSections + * @methodOf umbraco.services.editorService + * + * @description + * Opens the template sections editor in infinite editing, the submit callback returns the type to insert + * @param {Callback} editor.submit Submits the editor + * @param {Callback} editor.close Closes the editor + * @returns {Object} editor object + */ + function templateSections(editor) { + editor.view = "views/common/infiniteeditors/templatesections/templatesections.html"; + editor.size = "small"; + open(editor); + } + /** * @ngdoc method * @name umbraco.services.editorService#sectionPicker @@ -266,6 +317,45 @@ open(editor); } + /** + * @ngdoc method + * @name umbraco.services.editorService#itemPicker + * @methodOf umbraco.services.editorService + * + * @description + * Opens the section picker in infinite editing, the submit callback returns an array of the selected items + * + * @param {Array} editor.availableItems Array of available items. + * @param {Array} editor.selectedItems Array of selected items. When passed in the selected items will be filtered from the available items. + * @param {Boolean} editor.filter Set to false to hide the filter. + * @param {Callback} editor.submit Submits the editor. + * @param {Callback} editor.close Closes the editor. + * @returns {Object} editor object + */ + function itemPicker(editor) { + editor.view = "views/common/infiniteeditors/itempicker/itempicker.html"; + editor.size = "small"; + open(editor); + } + + /** + * @ngdoc method + * @name umbraco.services.editorService#macroPicker + * @methodOf umbraco.services.editorService + * + * @description + * Opens a macro picker in infinite editing, the submit callback returns an array of the selected items + * + * @param {Callback} editor.submit Submits the editor. + * @param {Callback} editor.close Closes the editor. + * @returns {Object} editor object + */ + function macroPicker(editor) { + editor.view = "views/common/infiniteeditors/macropicker/macropicker.html"; + editor.size = "small"; + open(editor); + } + var service = { getEditors: getEditors, open: open, @@ -282,8 +372,13 @@ nodePermissions: nodePermissions, insertCodeSnippet: insertCodeSnippet, userGroupPicker: userGroupPicker, + templateEditor: templateEditor, sectionPicker: sectionPicker, - userPicker: userPicker + insertField: insertField, + templateSections: templateSections, + userPicker: userPicker, + itemPicker: itemPicker, + macroPicker: macroPicker }; return service; diff --git a/src/Umbraco.Web.UI.Client/src/views/common/infiniteeditors/insertcodesnippet/insertcodesnippet.controller.js b/src/Umbraco.Web.UI.Client/src/views/common/infiniteeditors/insertcodesnippet/insertcodesnippet.controller.js index 90d3e945a4..526d076048 100644 --- a/src/Umbraco.Web.UI.Client/src/views/common/infiniteeditors/insertcodesnippet/insertcodesnippet.controller.js +++ b/src/Umbraco.Web.UI.Client/src/views/common/infiniteeditors/insertcodesnippet/insertcodesnippet.controller.js @@ -28,52 +28,39 @@ } function openMacroPicker() { - - vm.macroPickerOverlay = { - view: "macropicker", + var macroPicker = { dialogData: {}, - show: true, submit: function(model) { - $scope.model.insert = { "type": "macro", "macroParams": model.macroParams, "selectedMacro": model.selectedMacro }; - $scope.model.submit($scope.model); - - vm.macroPickerOverlay.show = false; - vm.macroPickerOverlay = null; - + editorService.close(); + }, + close: function() { + editorService.close(); } }; - + editorService.macroPicker(macroPicker); } function openPageFieldOverlay() { - vm.pageFieldOverlay = { - submitButtonLabel: "Insert", - closeButtonlabel: "Cancel", - view: "insertfield", - show: true, + var insertFieldEditor = { submit: function(model) { - $scope.model.insert = { "type": "umbracoField", "umbracoField": model.umbracoField }; - $scope.model.submit($scope.model); - - vm.pageFieldOverlay.show = false; - vm.pageFieldOverlay = null; + editorService.close(); }, close: function (model) { - vm.pageFieldOverlay.show = false; - vm.pageFieldOverlay = null; + editorService.close(); } }; + editorService.insertField(insertFieldEditor); } function openDictionaryItemOverlay() { diff --git a/src/Umbraco.Web.UI.Client/src/views/common/infiniteeditors/insertcodesnippet/insertcodesnippet.html b/src/Umbraco.Web.UI.Client/src/views/common/infiniteeditors/insertcodesnippet/insertcodesnippet.html index 2cc5cb2e5c..405a56e79b 100644 --- a/src/Umbraco.Web.UI.Client/src/views/common/infiniteeditors/insertcodesnippet/insertcodesnippet.html +++ b/src/Umbraco.Web.UI.Client/src/views/common/infiniteeditors/insertcodesnippet/insertcodesnippet.html @@ -60,9 +60,5 @@ view="vm.macroPickerOverlay.view" position="right"> - - + diff --git a/src/Umbraco.Web.UI.Client/src/views/common/overlays/insertfield/insertfield.controller.js b/src/Umbraco.Web.UI.Client/src/views/common/infiniteeditors/insertfield/insertfield.controller.js similarity index 90% rename from src/Umbraco.Web.UI.Client/src/views/common/overlays/insertfield/insertfield.controller.js rename to src/Umbraco.Web.UI.Client/src/views/common/infiniteeditors/insertfield/insertfield.controller.js index ebe2feabb9..db3e16f8b6 100644 --- a/src/Umbraco.Web.UI.Client/src/views/common/overlays/insertfield/insertfield.controller.js +++ b/src/Umbraco.Web.UI.Client/src/views/common/infiniteeditors/insertfield/insertfield.controller.js @@ -1,7 +1,7 @@ (function () { "use strict"; - function InsertFieldController($scope, $http, contentTypeResource, localizationService) { + function InsertFieldController($scope, contentTypeResource, localizationService) { var vm = this; @@ -29,6 +29,8 @@ vm.setCasingOption = setCasingOption; vm.setEncodingOption = setEncodingOption; vm.generateOutputSample = generateOutputSample; + vm.submit = submit; + vm.close = close; function onInit() { @@ -139,10 +141,21 @@ } - onInit(); + function submit(model) { + if($scope.model.submit) { + $scope.model.submit(model); + } + } + function close() { + if($scope.model.close) { + $scope.model.close(); + } + } + + onInit(); } - angular.module("umbraco").controller("Umbraco.Overlays.InsertFieldController", InsertFieldController); + angular.module("umbraco").controller("Umbraco.Editors.InsertFieldController", InsertFieldController); })(); diff --git a/src/Umbraco.Web.UI.Client/src/views/common/infiniteeditors/insertfield/insertfield.html b/src/Umbraco.Web.UI.Client/src/views/common/infiniteeditors/insertfield/insertfield.html new file mode 100644 index 0000000000..56bd498fd1 --- /dev/null +++ b/src/Umbraco.Web.UI.Client/src/views/common/infiniteeditors/insertfield/insertfield.html @@ -0,0 +1,223 @@ +
+ + + + + + + + + + + +
+
+ +
+ +
+
+
+ +
+ + +
+ + +
+ + Add fallback field + +
+
+ +
+ +
+
+
+
+
+ + +
+ + +
+
+ +
+ +
+
+
+
+ + +
+
+
+ + +
+
+
+ +
Format and encoding
+ + +
+
+
+
+ +
+ Date only + Date and time + +
+
+
+ + +
+
+
+
+ +
+ Uppercase + Lowercase +
+
+
+ + +
+
+
+
+ +
+ HTML + URL +
+
+
+ +
Modify output
+ + +
+
+ +
+ +
+
+
+ + +
+
+ +
+ +
+
+
+ + +
+
+
+
+ +
+ +
+
+
+ + +
+
+
+ +
{{ vm.generateOutputSample() }}
+
+
+
+ +
+
+
+ + + + + + + + + + +
+ +
diff --git a/src/Umbraco.Web.UI.Client/src/views/common/infiniteeditors/itempicker/itempicker.controller.js b/src/Umbraco.Web.UI.Client/src/views/common/infiniteeditors/itempicker/itempicker.controller.js new file mode 100644 index 0000000000..094e108d8f --- /dev/null +++ b/src/Umbraco.Web.UI.Client/src/views/common/infiniteeditors/itempicker/itempicker.controller.js @@ -0,0 +1,47 @@ +/** + * @ngdoc controller + * @name Umbraco.Editors.ItemPickerController + * @function + * + * @description + * The controller for a reusable editor to pick items + */ + +function ItemPickerController($scope, localizationService) { + + var vm = this; + + vm.selectItem = selectItem; + vm.submit = submit; + vm.close = close; + + function onInit() { + if (!$scope.model.title) { + localizationService.localize("defaultdialogs_selectItem").then(function(value){ + $scope.model.title = value; + }); + } + } + + function selectItem(item) { + $scope.model.selectedItem = item; + submit($scope.model); + }; + + function submit(model) { + if($scope.model.submit) { + $scope.model.submit(model); + } + } + + function close() { + if($scope.model.close) { + $scope.model.close(); + } + } + + onInit(); + +} + +angular.module("umbraco").controller("Umbraco.Editors.ItemPicker", ItemPickerController); diff --git a/src/Umbraco.Web.UI.Client/src/views/common/infiniteeditors/itempicker/itempicker.html b/src/Umbraco.Web.UI.Client/src/views/common/infiniteeditors/itempicker/itempicker.html new file mode 100644 index 0000000000..9963807772 --- /dev/null +++ b/src/Umbraco.Web.UI.Client/src/views/common/infiniteeditors/itempicker/itempicker.html @@ -0,0 +1,54 @@ +
+ + + + + + + + + + + + + + + + + + + + + + + + + +
diff --git a/src/Umbraco.Web.UI.Client/src/views/common/overlays/macropicker/macropicker.controller.js b/src/Umbraco.Web.UI.Client/src/views/common/infiniteeditors/macropicker/macropicker.controller.js similarity index 98% rename from src/Umbraco.Web.UI.Client/src/views/common/overlays/macropicker/macropicker.controller.js rename to src/Umbraco.Web.UI.Client/src/views/common/infiniteeditors/macropicker/macropicker.controller.js index 058f71bfcf..aa63f2d6d6 100644 --- a/src/Umbraco.Web.UI.Client/src/views/common/overlays/macropicker/macropicker.controller.js +++ b/src/Umbraco.Web.UI.Client/src/views/common/infiniteeditors/macropicker/macropicker.controller.js @@ -26,6 +26,12 @@ function MacroPickerController($scope, entityResource, macroResource, umbPropEdi } }; + $scope.close = function() { + if($scope.model.close) { + $scope.model.close(); + } + } + /** changes the view to edit the params of the selected macro */ /** if there is pnly one macro, and it has parameters - editor can skip selecting the Macro **/ function editParams(insertIfNoParameters) { diff --git a/src/Umbraco.Web.UI.Client/src/views/common/infiniteeditors/macropicker/macropicker.html b/src/Umbraco.Web.UI.Client/src/views/common/infiniteeditors/macropicker/macropicker.html new file mode 100644 index 0000000000..a9551138e1 --- /dev/null +++ b/src/Umbraco.Web.UI.Client/src/views/common/infiniteeditors/macropicker/macropicker.html @@ -0,0 +1,91 @@ +
+ + + + + + + + + +
+ +
+ + + + + + + + There are no macros available to insert + + +
+ +
+ +
{{model.selectedMacro.name}}
+ +
    +
  • + + + + + + + +
  • +
+ + + There are no parameters for this macro + + +
+
+
+
+
+ + + + + + + + +
+ +
diff --git a/src/Umbraco.Web.UI.Client/src/views/common/overlays/templatesections/templatesections.controller.js b/src/Umbraco.Web.UI.Client/src/views/common/infiniteeditors/templatesections/templatesections.controller.js similarity index 52% rename from src/Umbraco.Web.UI.Client/src/views/common/overlays/templatesections/templatesections.controller.js rename to src/Umbraco.Web.UI.Client/src/views/common/infiniteeditors/templatesections/templatesections.controller.js index d8cc93c1b8..36d7c0f4ed 100644 --- a/src/Umbraco.Web.UI.Client/src/views/common/overlays/templatesections/templatesections.controller.js +++ b/src/Umbraco.Web.UI.Client/src/views/common/infiniteeditors/templatesections/templatesections.controller.js @@ -1,35 +1,47 @@ (function () { "use strict"; - function TemplateSectionsOverlayController($scope) { + function TemplateSectionsController($scope, formHelper) { var vm = this; + vm.select = select; + vm.submit = submit; + vm.close = close; + $scope.model.mandatoryRenderSection = false; if(!$scope.model.title) { $scope.model.title = "Sections"; } - vm.select = select; - function onInit() { - if($scope.model.hasMaster) { $scope.model.insertType = 'addSection'; } else { $scope.model.insertType = 'renderBody'; } - } function select(type) { $scope.model.insertType = type; } + function submit(model) { + if (formHelper.submitForm({scope: $scope})) { + $scope.model.submit($scope.model); + } + } + + function close() { + if($scope.model.close) { + $scope.model.close(); + } + } + onInit(); } - angular.module("umbraco").controller("Umbraco.Overlays.TemplateSectionsOverlay", TemplateSectionsOverlayController); + angular.module("umbraco").controller("Umbraco.Editors.TemplateSectionsController", TemplateSectionsController); })(); diff --git a/src/Umbraco.Web.UI.Client/src/views/common/infiniteeditors/templatesections/templatesections.html b/src/Umbraco.Web.UI.Client/src/views/common/infiniteeditors/templatesections/templatesections.html new file mode 100644 index 0000000000..d6e3996287 --- /dev/null +++ b/src/Umbraco.Web.UI.Client/src/views/common/infiniteeditors/templatesections/templatesections.html @@ -0,0 +1,105 @@ +
+ +
+ + + + + + + + + + +
+
+ +
+ +
+ +
+
+ +
+ +
+
+
+ +
+ +
+
+ + + + + +
+ +
+ + +
+ +
+
+
+ +
+ +
+ +
+
+
+ +
+ +
+
+ + + + + +
+
+ +
+ +
+
+ +
+ + + + + + + + + + +
+ +
+ +
diff --git a/src/Umbraco.Web.UI.Client/src/views/common/overlays/insertfield/insertfield.html b/src/Umbraco.Web.UI.Client/src/views/common/overlays/insertfield/insertfield.html deleted file mode 100644 index 3218b44dd8..0000000000 --- a/src/Umbraco.Web.UI.Client/src/views/common/overlays/insertfield/insertfield.html +++ /dev/null @@ -1,188 +0,0 @@ -
- - -
-
- -
- -
-
-
- -
- - -
- - -
- - Add fallback field - -
-
- -
- -
-
-
-
-
- - -
-
- - Add default value -
- -
-
- -
- -
-
-
-
- - -
-
-
- - -
-
-
- -
Format and encoding
- - -
-
-
-
- -
- Date only - Date and time - -
-
-
- - -
-
-
-
- -
- Uppercase - Lowercase -
-
-
- - -
-
-
-
- -
- HTML - URL -
-
-
- -
Modify output
- - -
-
- -
- -
-
-
- - -
-
- -
- -
-
-
- - -
-
-
-
- -
- -
-
-
- - -
-
-
- -
{{ vm.generateOutputSample() }}
-
-
-
- -
- - diff --git a/src/Umbraco.Web.UI.Client/src/views/common/overlays/macropicker/macropicker.html b/src/Umbraco.Web.UI.Client/src/views/common/overlays/macropicker/macropicker.html deleted file mode 100644 index 8f16bc40d4..0000000000 --- a/src/Umbraco.Web.UI.Client/src/views/common/overlays/macropicker/macropicker.html +++ /dev/null @@ -1,63 +0,0 @@ -
- -
- - -
- - - - - - - - There are no macros available to insert - - -
- -
- -
{{model.selectedMacro.name}}
- -
    -
  • - - - - - - - -
  • -
- - - There are no parameters for this macro - - -
-
- -
diff --git a/src/Umbraco.Web.UI.Client/src/views/common/overlays/templatesections/templatesections.html b/src/Umbraco.Web.UI.Client/src/views/common/overlays/templatesections/templatesections.html deleted file mode 100644 index b97057302e..0000000000 --- a/src/Umbraco.Web.UI.Client/src/views/common/overlays/templatesections/templatesections.html +++ /dev/null @@ -1,64 +0,0 @@ -
- - -
-
- -
- -
- -
-
- -
- -
-
-
- -
- -
-
- - - - - -
- -
- - -
- -
-
-
- -
- -
- -
-
-
- -
- -
-
- - - - - -
-
- -
-
-
diff --git a/src/Umbraco.Web.UI.Client/src/views/components/content/umb-content-node-info.html b/src/Umbraco.Web.UI.Client/src/views/components/content/umb-content-node-info.html index 32e79c1131..5d980f1262 100644 --- a/src/Umbraco.Web.UI.Client/src/views/components/content/umb-content-node-info.html +++ b/src/Umbraco.Web.UI.Client/src/views/components/content/umb-content-node-info.html @@ -197,7 +197,7 @@ ng-change="updateTemplate(node.template)"> - + Open diff --git a/src/Umbraco.Web.UI.Client/src/views/dictionary/dictionary.edit.controller.js b/src/Umbraco.Web.UI.Client/src/views/dictionary/dictionary.edit.controller.js index 1b9d5c3f4c..8c1e7edb73 100644 --- a/src/Umbraco.Web.UI.Client/src/views/dictionary/dictionary.edit.controller.js +++ b/src/Umbraco.Web.UI.Client/src/views/dictionary/dictionary.edit.controller.js @@ -6,7 +6,8 @@ * @description * The controller for editing dictionary items */ -function DictionaryEditController($scope, $routeParams, dictionaryResource, treeService, navigationService, appState, editorState, contentEditingHelper, formHelper, notificationsService, localizationService) { +function DictionaryEditController($scope, $routeParams, $location, dictionaryResource, navigationService, appState, editorState, contentEditingHelper, formHelper, notificationsService, localizationService) { + var vm = this; //setup scope vars @@ -18,6 +19,10 @@ function DictionaryEditController($scope, $routeParams, dictionaryResource, tree vm.page.menu.currentSection = appState.getSectionState("currentSection"); vm.page.menu.currentNode = null; vm.description = ""; + vm.showBackButton = true; + + vm.save = saveDictionary; + vm.back = back; function loadDictionary() { @@ -26,9 +31,7 @@ function DictionaryEditController($scope, $routeParams, dictionaryResource, tree //we are editing so get the content item from the server dictionaryResource.getById($routeParams.id) .then(function (data) { - bindDictionary(data); - vm.page.loading = false; }); } @@ -100,7 +103,9 @@ function DictionaryEditController($scope, $routeParams, dictionaryResource, tree } } - vm.save = saveDictionary; + function back() { + $location.path("settings/dictionary/list"); + } $scope.$watch("vm.content.name", function (newVal, oldVal) { //when the value changes, we need to set the name dirty diff --git a/src/Umbraco.Web.UI.Client/src/views/dictionary/dictionary.list.controller.js b/src/Umbraco.Web.UI.Client/src/views/dictionary/dictionary.list.controller.js index 35739b3db7..83daa6b243 100644 --- a/src/Umbraco.Web.UI.Client/src/views/dictionary/dictionary.list.controller.js +++ b/src/Umbraco.Web.UI.Client/src/views/dictionary/dictionary.list.controller.js @@ -18,9 +18,10 @@ function DictionaryListController($scope, $location, dictionaryResource, localiz dictionaryResource.getList() .then(function (data) { - vm.items = data; - + angular.forEach(vm.items, function(item){ + item.style = { "paddingLeft": item.level * 10 }; + }); vm.loading = false; }); } diff --git a/src/Umbraco.Web.UI.Client/src/views/dictionary/edit.html b/src/Umbraco.Web.UI.Client/src/views/dictionary/edit.html index c016d37eca..b14517a005 100644 --- a/src/Umbraco.Web.UI.Client/src/views/dictionary/edit.html +++ b/src/Umbraco.Web.UI.Client/src/views/dictionary/edit.html @@ -12,14 +12,20 @@ name-locked="vm.page.nameLocked" hide-icon="true" hide-description="true" - hide-alias="true"> + hide-alias="true" + on-back="vm.back()" + show-back-button="vm.showBackButton"> -

- - - + + +

+ + + +
+
diff --git a/src/Umbraco.Web.UI.Client/src/views/dictionary/list.html b/src/Umbraco.Web.UI.Client/src/views/dictionary/list.html index 82b088df49..db0314639c 100644 --- a/src/Umbraco.Web.UI.Client/src/views/dictionary/list.html +++ b/src/Umbraco.Web.UI.Client/src/views/dictionary/list.html @@ -11,36 +11,27 @@ name-locked="true"> -
-
-
-
-
- Name -
-
- - - -
-
-
-
-
-
-
- - -
-
- -
-
-
-
+ + + + + + + + + + + + + + +
Name{{column.displayName}}
+ {{item.name}} + + + +
+
diff --git a/src/Umbraco.Web.UI.Client/src/views/partialviewmacros/edit.controller.js b/src/Umbraco.Web.UI.Client/src/views/partialviewmacros/edit.controller.js index c58a5573a9..84b58cac94 100644 --- a/src/Umbraco.Web.UI.Client/src/views/partialviewmacros/edit.controller.js +++ b/src/Umbraco.Web.UI.Client/src/views/partialviewmacros/edit.controller.js @@ -154,50 +154,34 @@ } function openMacroOverlay() { - - vm.macroPickerOverlay = { - view: "macropicker", + var macroPicker = { dialogData: {}, - show: true, submit: function (model) { - var macroObject = macroService.collectValueData(model.selectedMacro, model.macroParams, "Mvc"); insert(macroObject.syntax); - - vm.macroPickerOverlay.show = false; - vm.macroPickerOverlay = null; - + editorService.close(); }, - close: function(oldModel) { - // close the dialog - vm.macroPickerOverlay.show = false; - vm.macroPickerOverlay = null; - // focus editor + close: function() { + editorService.close(); vm.editor.focus(); } }; + editorService.macroPicker(macroPicker); } function openPageFieldOverlay() { - vm.pageFieldOverlay = { - submitButtonLabel: "Insert", - closeButtonlabel: "Cancel", - view: "insertfield", - show: true, + var insertFieldEditor = { submit: function (model) { insert(model.umbracoField); - vm.pageFieldOverlay.show = false; - vm.pageFieldOverlay = null; + editorService.close(); }, - close: function (model) { - // close the dialog - vm.pageFieldOverlay.show = false; - vm.pageFieldOverlay = null; - // focus editor - vm.editor.focus(); + close: function () { + editorService.close(); + vm.editor.focus(); } }; + editorService.insertField(insertFieldEditor); } diff --git a/src/Umbraco.Web.UI.Client/src/views/partialviewmacros/edit.html b/src/Umbraco.Web.UI.Client/src/views/partialviewmacros/edit.html index 810b1cb8ae..e28b76d785 100644 --- a/src/Umbraco.Web.UI.Client/src/views/partialviewmacros/edit.html +++ b/src/Umbraco.Web.UI.Client/src/views/partialviewmacros/edit.html @@ -76,18 +76,4 @@ - - - - - - diff --git a/src/Umbraco.Web.UI.Client/src/views/partialviews/edit.controller.js b/src/Umbraco.Web.UI.Client/src/views/partialviews/edit.controller.js index d5a17c83c7..a337a00acc 100644 --- a/src/Umbraco.Web.UI.Client/src/views/partialviews/edit.controller.js +++ b/src/Umbraco.Web.UI.Client/src/views/partialviews/edit.controller.js @@ -161,50 +161,33 @@ function openMacroOverlay() { - - vm.macroPickerOverlay = { - view: "macropicker", + var macroPicker = { dialogData: {}, - show: true, submit: function (model) { - var macroObject = macroService.collectValueData(model.selectedMacro, model.macroParams, "Mvc"); insert(macroObject.syntax); - - vm.macroPickerOverlay.show = false; - vm.macroPickerOverlay = null; - + editorService.close(); }, - close: function(oldModel) { - // close the dialog - vm.macroPickerOverlay.show = false; - vm.macroPickerOverlay = null; - // focus editor + close: function() { + editorService.close(); vm.editor.focus(); } }; + editorService.macroPicker(macroPicker); } - function openPageFieldOverlay() { - vm.pageFieldOverlay = { - submitButtonLabel: "Insert", - closeButtonlabel: "Cancel", - view: "insertfield", - show: true, + var insertFieldEditor = { submit: function (model) { insert(model.umbracoField); - vm.pageFieldOverlay.show = false; - vm.pageFieldOverlay = null; + editorService.close(); }, - close: function (model) { - // close the dialog - vm.pageFieldOverlay.show = false; - vm.pageFieldOverlay = null; - // focus editor + close: function () { + editorService.close(); vm.editor.focus(); } }; + editorService.insertField(insertFieldEditor); } diff --git a/src/Umbraco.Web.UI.Client/src/views/partialviews/edit.html b/src/Umbraco.Web.UI.Client/src/views/partialviews/edit.html index 4a16ad4ebf..a222234e80 100644 --- a/src/Umbraco.Web.UI.Client/src/views/partialviews/edit.html +++ b/src/Umbraco.Web.UI.Client/src/views/partialviews/edit.html @@ -84,18 +84,4 @@ - - - - - - diff --git a/src/Umbraco.Web.UI.Client/src/views/templates/edit.controller.js b/src/Umbraco.Web.UI.Client/src/views/templates/edit.controller.js index 39ae1dd583..615aeb94ee 100644 --- a/src/Umbraco.Web.UI.Client/src/views/templates/edit.controller.js +++ b/src/Umbraco.Web.UI.Client/src/views/templates/edit.controller.js @@ -5,6 +5,9 @@ var vm = this; var oldMasterTemplateAlias = null; + var infiniteMode = $scope.model && $scope.model.infiniteMode; + var id = infiniteMode ? $scope.model.id : $routeParams.id; + var create = infiniteMode ? $scope.model.create : $routeParams.create; vm.page = {}; vm.page.loading = true; @@ -83,24 +86,25 @@ rebindCallback: function (orignal, saved) {} }).then(function (saved) { - if (!suppressNotification) { - localizationService.localizeMany(["speechBubbles_templateSavedHeader", "speechBubbles_templateSavedText"]).then(function(data){ - var header = data[0]; - var message = data[1]; - notificationsService.success(header, message); - }); - } - + if (!suppressNotification) { + localizationService.localizeMany(["speechBubbles_templateSavedHeader", "speechBubbles_templateSavedText"]).then(function(data){ + var header = data[0]; + var message = data[1]; + notificationsService.success(header, message); + }); + } vm.page.saveButtonState = "success"; vm.template = saved; //sync state - editorState.set(vm.template); + if(!infiniteMode) { + editorState.set(vm.template); + } // sync tree // if master template alias has changed move the node to it's new location - if(oldMasterTemplateAlias !== vm.template.masterTemplateAlias) { + if(!infiniteMode && oldMasterTemplateAlias !== vm.template.masterTemplateAlias) { // When creating a new template the id is -1. Make sure We don't remove the root node. if (vm.page.menu.currentNode.id !== "-1") { @@ -119,15 +123,21 @@ } else { // normal tree sync - navigationService.syncTree({ tree: "templates", path: vm.template.path, forceReload: true }).then(function (syncArgs) { - vm.page.menu.currentNode = syncArgs.node; - }); + if(!infiniteMode) { + navigationService.syncTree({ tree: "templates", path: vm.template.path, forceReload: true }).then(function (syncArgs) { + vm.page.menu.currentNode = syncArgs.node; + }); + } } // clear $dirty state on form setFormState("pristine"); + if(infiniteMode) { + submit(); + } + }, function (err) { @@ -154,18 +164,14 @@ vm.templates = templates; }); - if($routeParams.create){ - - templateResource.getScaffold(($routeParams.id)).then(function (template) { + if(create) { + templateResource.getScaffold((id)).then(function (template) { vm.ready(template); }); - - }else{ - - templateResource.getById($routeParams.id).then(function(template){ + } else { + templateResource.getById(id).then(function(template){ vm.ready(template); }); - } }; @@ -176,7 +182,7 @@ vm.template = template; // if this is a new template, bind to the blur event on the name - if ($routeParams.create) { + if (create) { $timeout(function() { var nameField = angular.element(document.querySelector('[data-element="editor-name-field"]')); if (nameField) { @@ -191,10 +197,12 @@ //sync state - editorState.set(vm.template); - navigationService.syncTree({ tree: "templates", path: vm.template.path, forceReload: true }).then(function (syncArgs) { - vm.page.menu.currentNode = syncArgs.node; - }); + if(!infiniteMode) { + editorState.set(vm.template); + navigationService.syncTree({ tree: "templates", path: vm.template.path, forceReload: true }).then(function (syncArgs) { + vm.page.menu.currentNode = syncArgs.node; + }); + } // save state of master template to use for comparison when syncing the tree on save oldMasterTemplateAlias = angular.copy(template.masterTemplateAlias); @@ -312,7 +320,7 @@ // initial cursor placement // Keep cursor in name field if we are create a new template // else set the cursor at the bottom of the code editor - if(!$routeParams.create) { + if(!create) { $timeout(function(){ vm.editor.navigateFileEnd(); vm.editor.focus(); @@ -341,6 +349,8 @@ vm.getMasterTemplateName = getMasterTemplateName; vm.removeMasterTemplate = removeMasterTemplate; vm.closeShortcuts = closeShortcuts; + vm.submit = submit; + vm.close = close; function openInsertOverlay() { var insertOverlay = { @@ -381,50 +391,33 @@ } function openMacroOverlay() { - - vm.macroPickerOverlay = { - view: "macropicker", + var macroPicker = { dialogData: {}, - show: true, submit: function (model) { - var macroObject = macroService.collectValueData(model.selectedMacro, model.macroParams, "Mvc"); insert(macroObject.syntax); - - vm.macroPickerOverlay.show = false; - vm.macroPickerOverlay = null; - + editorService.close(); }, - close: function(oldModel) { - // close the dialog - vm.macroPickerOverlay.show = false; - vm.macroPickerOverlay = null; - // focus editor + close: function() { + editorService.close(); vm.editor.focus(); } }; + editorService.macroPicker(macroPicker); } - function openPageFieldOverlay() { - vm.pageFieldOverlay = { - submitButtonLabel: "Insert", - closeButtonlabel: "Cancel", - view: "insertfield", - show: true, + var insertFieldEditor = { submit: function (model) { insert(model.umbracoField); - vm.pageFieldOverlay.show = false; - vm.pageFieldOverlay = null; + editorService.close(); }, - close: function (model) { - // close the dialog - vm.pageFieldOverlay.show = false; - vm.pageFieldOverlay = null; - // focus editor - vm.editor.focus(); + close: function () { + editorService.close(); + vm.editor.focus(); } }; + editorService.insertField(insertFieldEditor); } @@ -517,12 +510,8 @@ function openSectionsOverlay() { - - vm.sectionsOverlay = { - view: "templatesections", + var templateSections = { isMaster: vm.template.isMasterTemplate, - submitButtonLabel: "Insert", - show: true, submit: function(model) { if (model.insertType === 'renderBody') { @@ -540,18 +529,15 @@ wrap(code); } - vm.sectionsOverlay.show = false; - vm.sectionsOverlay = null; + editorService.close(); }, close: function(model) { - // close dialog - vm.sectionsOverlay.show = false; - vm.sectionsOverlay = null; - // focus editor + editorService.close(); vm.editor.focus(); } } + editorService.templateSections(templateSections); } function openMasterTemplateOverlay() { @@ -572,16 +558,11 @@ localizationService.localize("template_mastertemplate").then(function(value){ var title = value; - - vm.masterTemplateOverlay = { - view: "itempicker", + var masterTemplate = { title: title, availableItems: availableMasterTemplates, - show: true, submit: function(model) { - var template = model.selectedItem; - if (template && template.alias) { vm.template.masterTemplateAlias = template.alias; setLayout(template.alias + ".cshtml"); @@ -589,18 +570,16 @@ vm.template.masterTemplateAlias = null; setLayout(null); } - - vm.masterTemplateOverlay.show = false; - vm.masterTemplateOverlay = null; + editorService.close(); }, close: function(oldModel) { // close dialog - vm.masterTemplateOverlay.show = false; - vm.masterTemplateOverlay = null; + editorService.close(); // focus editor vm.editor.focus(); } }; + editorService.itemPicker(masterTemplate); }); } @@ -715,6 +694,19 @@ function closeShortcuts() { vm.showKeyboardShortcut = false; } + + function submit() { + if($scope.model.submit) { + $scope.model.template = vm.template; + $scope.model.submit($scope.model); + } + } + + function close() { + if($scope.model.close) { + $scope.model.close(); + } + } vm.init(); diff --git a/src/Umbraco.Web.UI.Client/src/views/templates/edit.html b/src/Umbraco.Web.UI.Client/src/views/templates/edit.html index 0b1b574e70..5576d2713f 100644 --- a/src/Umbraco.Web.UI.Client/src/views/templates/edit.html +++ b/src/Umbraco.Web.UI.Client/src/views/templates/edit.html @@ -106,16 +106,24 @@ + + + - - + + @@ -124,33 +132,4 @@ - - - - - - - - - - - - -