diff --git a/src/Umbraco.Web.UI.Client/src/common/directives/components/content/edit.controller.js b/src/Umbraco.Web.UI.Client/src/common/directives/components/content/edit.controller.js index 2633b0854b..aa1a8b08b0 100644 --- a/src/Umbraco.Web.UI.Client/src/common/directives/components/content/edit.controller.js +++ b/src/Umbraco.Web.UI.Client/src/common/directives/components/content/edit.controller.js @@ -14,13 +14,13 @@ scope.page.menu.currentNode = null; scope.page.menu.currentSection = appState.getSectionState("currentSection"); scope.page.listViewPath = null; - scope.page.isNew = $routeParams.create; + scope.page.isNew = scope.createOptions ? true : false; scope.page.buttonGroupState = "init"; function init(content) { var buttons = contentEditingHelper.configureContentEditorButtons({ - create: $routeParams.create, + create: scope.page.isNew, content: content, methods: { saveAndPublish: scope.saveAndPublish, @@ -35,7 +35,7 @@ editorState.set(scope.content); //We fetch all ancestors of the node to generate the footer breadcrumb navigation - if (!$routeParams.create) { + if (!scope.page.isNew) { if (content.parentId && content.parentId !== -1) { entityResource.getAncestors(content.id, "document") .then(function (anc) { @@ -111,12 +111,12 @@ } } - if ($routeParams.create) { + if (scope.page.isNew) { scope.page.loading = true; //we are creating so get an empty content item - contentResource.getScaffold($routeParams.id, $routeParams.doctype) + contentResource.getScaffold(scope.contentId, scope.createOptions.docType) .then(function (data) { scope.content = data; @@ -134,7 +134,7 @@ scope.page.loading = true; //we are editing so get the content item from the server - contentResource.getById($routeParams.id) + contentResource.getById(scope.contentId) .then(function (data) { scope.content = data; @@ -229,7 +229,8 @@ replace: true, templateUrl: 'views/components/content/edit.html', scope: { - + contentId: "=", + createOptions: "=" }, link: link }; diff --git a/src/Umbraco.Web.UI.Client/src/views/content/content.edit.controller.js b/src/Umbraco.Web.UI.Client/src/views/content/content.edit.controller.js new file mode 100644 index 0000000000..aa87044530 --- /dev/null +++ b/src/Umbraco.Web.UI.Client/src/views/content/content.edit.controller.js @@ -0,0 +1,20 @@ +/** + * @ngdoc controller + * @name Umbraco.Editors.Content.EditController + * @function + * + * @description + * The controller for the content editor + */ +function ContentEditController($scope, $routeParams) { + + $scope.contentId = $routeParams.id; + $scope.createOptions = null; + if ($routeParams.create && $routeParams.doctype) { + $scope.createOptions = { + docType: $routeParams.doctype + } + } +} + +angular.module("umbraco").controller("Umbraco.Editors.Content.EditController", ContentEditController); diff --git a/src/Umbraco.Web.UI.Client/src/views/content/edit.html b/src/Umbraco.Web.UI.Client/src/views/content/edit.html index 04d4259e09..432d0ba19e 100644 --- a/src/Umbraco.Web.UI.Client/src/views/content/edit.html +++ b/src/Umbraco.Web.UI.Client/src/views/content/edit.html @@ -1,3 +1,5 @@ -