Implements doc type collections

This commit is contained in:
Niels Hartvig
2018-04-30 09:13:34 +02:00
parent 1a99d0e4d0
commit 9ffca1bcab
6 changed files with 160 additions and 4 deletions

View File

@@ -260,14 +260,22 @@ function contentTypeResource($q, $http, umbRequestHelper, umbDataFormatter) {
'Failed to copy content');
},
createContainer: function(parentId, name) {
createContainer: function (parentId, name) {
return umbRequestHelper.resourcePromise(
$http.post(umbRequestHelper.getApiUrl("contentTypeApiBaseUrl", "PostCreateContainer", { parentId: parentId, name: name })),
$http.post(umbRequestHelper.getApiUrl("contentTypeApiBaseUrl", "PostCreateContainer", { parentId: parentId, name: name })),
'Failed to create a folder under parent id ' + parentId);
},
createCollection: function (parentId, collectionName, itemName) {
return umbRequestHelper.resourcePromise(
$http.post(umbRequestHelper.getApiUrl("contentTypeApiBaseUrl", "PostCreateCollection", { parentId: parentId, collectionName: collectionName, itemName: itemName})),
'Failed to create collection under ' + parentId);
},
renameContainer: function(id, name) {
return umbRequestHelper.resourcePromise(

View File

@@ -12,6 +12,7 @@ function DocumentTypesCreateController($scope, $location, navigationService, con
allowCreateFolder: $scope.dialogOptions.currentNode.parentId === null || $scope.dialogOptions.currentNode.nodeType === "container",
folderName: "",
creatingFolder: false,
creatingDoctypeCollection: false
};
var disableTemplates = Umbraco.Sys.ServerVariables.features.disabledFeatures.disableTemplates;
@@ -24,6 +25,10 @@ function DocumentTypesCreateController($scope, $location, navigationService, con
$scope.model.creatingFolder = true;
};
$scope.showCreateDocTypeCollection = function () {
$scope.model.creatingDoctypeCollection = true;
};
$scope.createContainer = function () {
if (formHelper.submitForm({ scope: $scope, formCtrl: this.createFolderForm, statusMessage: localizeCreateFolder })) {
@@ -61,6 +66,39 @@ function DocumentTypesCreateController($scope, $location, navigationService, con
}
};
$scope.createCollection = function () {
if (formHelper.submitForm({ scope: $scope, formCtrl: this.createDoctypeCollectionForm, statusMessage: "Creating Doctype Collection..." })) {
contentTypeResource.createCollection(node.id, $scope.model.collectionName, $scope.model.collectionItemName).then(function (collectionData) {
navigationService.hideMenu();
$location.search('create', null);
$location.search('notemplate', null);
formHelper.resetForm({
scope: $scope
});
var section = appState.getSectionState("currentSection");
// redirect to the item id
$location.path("/settings/documenttypes/edit/" + collectionData.ItemId);
}, function (err) {
$scope.error = err;
//show any notifications
if (angular.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) {
$scope.createDocType = function () {

View File

@@ -1,6 +1,6 @@
<div class="umbracoDialog umb-dialog-body with-footer" ng-controller="Umbraco.Editors.DocumentTypes.CreateController" ng-cloak>
<div class="umb-pane" ng-if="!model.creatingFolder">
<div class="umb-pane" ng-if="!model.creatingFolder && !model.creatingDoctypeCollection">
<h5><localize key="create_createUnder">Create an item under</localize> {{currentNode.name}}</h5>
<ul class="umb-actions umb-actions-child">
@@ -24,6 +24,17 @@
</span>
</a>
</li>
<li data-element="action-documentTypeCollection">
<a href="" ng-click="showCreateDocTypeCollection()">
<i class="large icon-thumbnail-list"></i>
<span class="menu-label">
Document Type Collection
<!-- <localize key="content_documentType_collection">Document Type Collection</localize>-->
</span>
</a>
</li>
<li data-element="action-folder" ng-if="model.allowCreateFolder">
<a href="" ng-click="showCreateFolder()">
<i class="large icon-folder"></i>
@@ -51,6 +62,33 @@
</form>
</div>
<div class="umb-pane" ng-if="model.creatingDoctypeCollection">
<small>
A Document Type collection is a fast way to create two Document Types in one task.
The Item Document Type will automatically be
allowed under the Parent Document Type.
</small>
<p>&nbsp;</p>
<form novalidate name="createDoctypeCollectionForm"
ng-submit="createCollection()"
val-form-manager>
<div ng-show="error">
<h5 class="text-error">{{error.errorMsg}}</h5>
<p class="text-error">{{error.data.message}}</p>
</div>
<umb-control-group label="Name of the Parent Document Type" hide-label="false">
<input type="text" name="collectionName" ng-model="model.collectionName" class="umb-textstring textstring input-block-level" umb-auto-focus required />
</umb-control-group>
<umb-control-group label="Name of the Item Document Type" hide-label="false">
<input type="text" name="collectionItemName" ng-model="model.collectionItemName" class="umb-textstring textstring input-block-level" required />
</umb-control-group>
<button type="submit" class="btn btn-primary"><localize key="general_create">Create</localize></button>
</form>
</div>
</div>
<div class="umb-dialog-footer btn-toolbar umb-btn-toolbar" ng-if="!model.creatingFolder">