blueprint scaffolding working

This commit is contained in:
Shannon
2017-06-04 21:21:16 +02:00
parent addd8946e8
commit f5ad4a35cd
5 changed files with 48 additions and 11 deletions

View File

@@ -14,7 +14,7 @@
scope.page.menu.currentNode = null;
scope.page.menu.currentSection = appState.getSectionState("currentSection");
scope.page.listViewPath = null;
scope.page.isNew = scope.createOptions ? true : false;
scope.page.isNew = scope.isNew ? true : false;
scope.page.buttonGroupState = "init";
function init(content) {
@@ -116,7 +116,7 @@
scope.page.loading = true;
//we are creating so get an empty content item
contentResource.getScaffold(scope.contentId, scope.createOptions.docType)
scope.getScaffoldMethod()()
.then(function (data) {
scope.content = data;
@@ -230,11 +230,12 @@
templateUrl: 'views/components/content/edit.html',
scope: {
contentId: "=",
isNew: "=?",
treeAlias: "@",
createOptions: "=?",
page: "=?",
saveMethod: "&",
getMethod: "&"
getMethod: "&",
getScaffoldMethod: "&?"
},
link: link
};

View File

@@ -399,6 +399,17 @@ function contentResource($q, $http, umbDataFormatter, umbRequestHelper) {
'Failed to retrieve data for empty content item type ' + alias);
},
getBlueprintScaffold: function (blueprintId) {
return umbRequestHelper.resourcePromise(
$http.get(
umbRequestHelper.getApiUrl(
"contentApiBaseUrl",
"GetEmpty",
[{ blueprintId: blueprintId }])),
'Failed to retrieve blueprint for id ' + blueprintId);
},
/**
* @ngdoc method
* @name umbraco.resources.contentResource#getNiceUrl

View File

@@ -8,16 +8,19 @@
*/
function ContentEditController($scope, $routeParams, contentResource) {
function scaffoldEmpty() {
return contentResource.getScaffold($routeParams.id, $routeParams.doctype);
}
function scaffoldBlueprint() {
return contentResource.getBlueprintScaffold($routeParams.blueprintId);
}
$scope.contentId = $routeParams.id;
$scope.saveMethod = contentResource.save;
$scope.getMethod = contentResource.getById;
$scope.getScaffoldMethod = $routeParams.blueprintId ? scaffoldBlueprint : scaffoldEmpty;
$scope.page = $routeParams.page;
$scope.createOptions = null;
if ($routeParams.create && $routeParams.doctype) {
$scope.createOptions = {
docType: $routeParams.doctype
}
}
$scope.isNew = $routeParams.create;
}
angular.module("umbraco").controller("Umbraco.Editors.Content.EditController", ContentEditController);

View File

@@ -4,6 +4,8 @@
page="page"
save-method="saveMethod"
get-method="getMethod"
tree-alias="content">
get-scaffold-method="getScaffoldMethod"
tree-alias="content"
is-new="isNew">
</content-editor>
</div>

View File

@@ -179,6 +179,26 @@ namespace Umbraco.Web.Editors
return mapped;
}
[OutgoingEditorModelEvent]
public ContentItemDisplay GetEmpty(int blueprintId)
{
var blueprint = Services.ContentService.GetBlueprintById(blueprintId);
if (blueprint == null)
{
throw new HttpResponseException(HttpStatusCode.NotFound);
}
blueprint.Id = 0;
blueprint.Name = string.Empty;
var mapped = Mapper.Map<ContentItemDisplay>(blueprint);
//remove this tab if it exists: umbContainerView
var containerTab = mapped.Tabs.FirstOrDefault(x => x.Alias == Constants.Conventions.PropertyGroups.ListViewGroupName);
mapped.Tabs = mapped.Tabs.Except(new[] { containerTab });
return mapped;
}
/// <summary>
/// Gets the Url for a given node ID
/// </summary>