From 230bf1052cde249587d4ce06a2fb23859094f414 Mon Sep 17 00:00:00 2001 From: Marc Goodson Date: Wed, 10 Feb 2021 23:25:38 +0000 Subject: [PATCH] V8/feature/super doctype create menu (#9174) * WIP - added options from superdoctypecreate package resolve merge conflict in create html file * fiddling with the wording but it will never be perfect * looks like ng-if should be ng-show * Update data-elements for uniqueness (I'm not sure what these are used for!) * pass 'iscomposition' on the querystring when choosing the 'composition' option from the menu Why? - in the future we could hide the 'Compositions...' button when choosing to create a composition * Remove PostCreateCollection implementation now the Create Collection is removed in this PR from the DocType Create menu resolve merge conflict in Remove PostCreateCollection implementation now the Create Collection is removed in this PR from the DocType Create menu * Add translations * Put back PostSave method. It's useful. Co-authored-by: Kenn Jacobsen Co-authored-by: Nathan Woulfe --- .../common/resources/contenttype.resource.js | 35 +------ .../views/documenttypes/create.controller.js | 75 ++++---------- .../src/views/documenttypes/create.html | 99 ++++++------------- src/Umbraco.Web.UI/Umbraco/config/lang/da.xml | 10 ++ src/Umbraco.Web.UI/Umbraco/config/lang/en.xml | 10 ++ .../Umbraco/config/lang/en_us.xml | 10 ++ .../Editors/ContentTypeController.cs | 86 +++------------- 7 files changed, 96 insertions(+), 229 deletions(-) diff --git a/src/Umbraco.Web.UI.Client/src/common/resources/contenttype.resource.js b/src/Umbraco.Web.UI.Client/src/common/resources/contenttype.resource.js index 01b6360d07..6acf702546 100644 --- a/src/Umbraco.Web.UI.Client/src/common/resources/contenttype.resource.js +++ b/src/Umbraco.Web.UI.Client/src/common/resources/contenttype.resource.js @@ -511,41 +511,8 @@ function contentTypeResource($q, $http, umbRequestHelper, umbDataFormatter, loca $http.post(umbRequestHelper.getApiUrl("contentTypeApiBaseUrl", "PostCreateContainer", { parentId: parentId, name: encodeURIComponent(name) })), 'Failed to create a folder under parent id ' + parentId); - }, - /** - * @ngdoc method - * @name umbraco.resources.contentTypeResource#createCollection - * @methodOf umbraco.resources.contentTypeResource - * - * @description - * Create a collection of a content types - * - * ##usage - *
-        * contentTypeResource.createCollection(1244,"testcollectionname",true,"collectionItemName",true,"icon-name","icon-name")
-        *    .then(function() {
-        *       Do stuff..
-        *    });
-        * 
- * - * @param {Int} parentId the ID of the parent content type underneath which to create the collection - * @param {String} collectionName the name of the collection - * @param {Boolean} collectionCreateTemplate true/false to specify whether to create a default template for the collection - * @param {String} collectionItemName the name of the collection item - * @param {Boolean} collectionItemCreateTemplate true/false to specify whether to create a default template for the collection item - * @param {String} collectionIcon the icon for the collection - * @param {String} collectionItemIcon the icon for the collection item - * @returns {Promise} resourcePromise object. - * - */ - createCollection: function (parentId, collectionName, collectionCreateTemplate, collectionItemName, collectionItemCreateTemplate, collectionIcon, collectionItemIcon) { - - return umbRequestHelper.resourcePromise( - $http.post(umbRequestHelper.getApiUrl("contentTypeApiBaseUrl", "PostCreateCollection", { parentId: parentId, collectionName: collectionName, collectionCreateTemplate: collectionCreateTemplate, collectionItemName: collectionItemName, collectionItemCreateTemplate: collectionItemCreateTemplate, collectionIcon: collectionIcon, collectionItemIcon: collectionItemIcon})), - 'Failed to create collection under ' + parentId); - - }, + }, /** * @ngdoc method 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 71eee085ee..23173a404d 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 @@ -11,8 +11,7 @@ function DocumentTypesCreateController($scope, $location, navigationService, con $scope.model = { allowCreateFolder: $scope.currentNode.parentId === null || $scope.currentNode.nodeType === "container", folderName: "", - creatingFolder: false, - creatingDoctypeCollection: false + creatingFolder: false }; var disableTemplates = Umbraco.Sys.ServerVariables.features.disabledFeatures.disableTemplates; @@ -24,12 +23,6 @@ function DocumentTypesCreateController($scope, $location, navigationService, con $scope.model.creatingFolder = true; }; - $scope.showCreateDocTypeCollection = function () { - $scope.model.creatingDoctypeCollection = true; - $scope.model.collectionCreateTemplate = !$scope.model.disableTemplates; - $scope.model.collectionItemCreateTemplate = !$scope.model.disableTemplates; - }; - $scope.createContainer = function () { if (formHelper.submitForm({ scope: $scope, formCtrl: $scope.createFolderForm })) { @@ -58,55 +51,7 @@ function DocumentTypesCreateController($scope, $location, navigationService, con }); } - }; - - $scope.createCollection = function () { - - if (formHelper.submitForm({ scope: $scope, formCtrl: this.createDoctypeCollectionForm, statusMessage: "Creating Doctype Collection..." })) { - - // see if we can find matching icons - var collectionIcon = "icon-folders", collectionItemIcon = "icon-document"; - iconHelper.getIcons().then(function (icons) { - - for (var i = 0; i < icons.length; i++) { - // for matching we'll require a full match for collection, partial match for item - if (icons[i].substring(5) == $scope.model.collectionName.toLowerCase()) { - collectionIcon = icons[i]; - } else if (icons[i].substring(5).indexOf($scope.model.collectionItemName.toLowerCase()) > -1) { - collectionItemIcon = icons[i]; - } - } - - contentTypeResource.createCollection(node.id, $scope.model.collectionName, $scope.model.collectionCreateTemplate, $scope.model.collectionItemName, $scope.model.collectionItemCreateTemplate, collectionIcon, collectionItemIcon) - .then(function (collectionData) { - - navigationService.hideMenu(); - $location.search('create', null); - $location.search('notemplate', null); - - formHelper.resetForm({ scope: $scope, formCtrl: this.createDoctypeCollectionForm }); - - var section = appState.getSectionState("currentSection"); - - // redirect to the item id - $location.path("/" + section + "/documenttypes/edit/" + collectionData.containerId); - - }, function (err) { - - formHelper.resetForm({ scope: $scope, formCtrl: this.createDoctypeCollectionForm, hasErrors: true }); - $scope.error = err; - - //show any notifications - if (Utilities.isArray(err.data.notifications)) { - for (var i = 0; i < err.data.notifications.length; i++) { - notificationsService.showNotification(err.data.notifications[i]); - } - } - }); - }); - } - - }; + }; // Disabling logic for creating document type with template if disableTemplates is set to true if (!disableTemplates) { @@ -125,6 +70,22 @@ function DocumentTypesCreateController($scope, $location, navigationService, con navigationService.hideMenu(); }; + $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.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.close = function() { const showMenu = true; navigationService.hideDialog(showMenu); 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 4ebb96c09b..208b4eaeda 100644 --- a/src/Umbraco.Web.UI.Client/src/views/documenttypes/create.html +++ b/src/Umbraco.Web.UI.Client/src/views/documenttypes/create.html @@ -1,16 +1,15 @@
-