adds parameters to the content editor directive

This commit is contained in:
Shannon
2017-06-04 16:27:59 +02:00
parent 028903c306
commit 584c3e4c19
3 changed files with 32 additions and 9 deletions

View File

@@ -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
};

View File

@@ -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);

View File

@@ -1,3 +1,5 @@
<div>
<content-editor></content-editor>
<div ng-controller="Umbraco.Editors.Content.EditController">
<content-editor create-options="createOptions"
content-id="contentId">
</content-editor>
</div>