Copy all items from one NC to another (WIP)
This commit is contained in:
+48
-4
@@ -93,8 +93,10 @@ angular.module("umbraco").controller("Umbraco.PropertyEditors.NestedContent.Prop
|
||||
"iconHelper",
|
||||
"clipboardService",
|
||||
"eventsService",
|
||||
|
||||
function ($scope, $interpolate, $filter, $timeout, contentResource, localizationService, iconHelper, clipboardService, eventsService) {
|
||||
"$routeParams",
|
||||
"editorState",
|
||||
|
||||
function ($scope, $interpolate, $filter, $timeout, contentResource, localizationService, iconHelper, clipboardService, eventsService, $routeParams, editorState) {
|
||||
|
||||
var contentTypeAliases = [];
|
||||
_.each($scope.model.config.contentTypes, function (contentType) {
|
||||
@@ -160,7 +162,15 @@ angular.module("umbraco").controller("Umbraco.PropertyEditors.NestedContent.Prop
|
||||
view: "itempicker",
|
||||
event: $event,
|
||||
clickPasteItem: function(item) {
|
||||
$scope.pasteFromClipboard(item.data);
|
||||
if (item.alias === "nc_pasteAllItems") {
|
||||
_.each(item.data, function (node) {
|
||||
delete node.$$hashKey;
|
||||
$scope.pasteFromClipboard(node);
|
||||
});
|
||||
} else {
|
||||
$scope.pasteFromClipboard(item.data);
|
||||
}
|
||||
|
||||
$scope.overlayMenu.show = false;
|
||||
$scope.overlayMenu = null;
|
||||
},
|
||||
@@ -194,6 +204,20 @@ angular.module("umbraco").controller("Umbraco.PropertyEditors.NestedContent.Prop
|
||||
$scope.overlayMenu.size = $scope.overlayMenu.availableItems.length > 6 ? "medium" : "small";
|
||||
|
||||
$scope.overlayMenu.pasteItems = [];
|
||||
var nestedContentForPaste = clipboardService.retriveDataOfType("nestedContent", ["nc_copyOfAllItems"]);
|
||||
_.each(nestedContentForPaste, function (nestedContent) {
|
||||
if (_.every(nestedContent.nodes,
|
||||
function(node) {
|
||||
return contentTypeAliases.indexOf(node.contentTypeAlias) >= 0;
|
||||
})) {
|
||||
$scope.overlayMenu.pasteItems.push({
|
||||
alias: "nc_pasteAllItems",
|
||||
name: nestedContent.name, // source property name
|
||||
data: nestedContent.nodes, // all items from source property
|
||||
icon: "icon-bulleted-list"
|
||||
});
|
||||
}
|
||||
});
|
||||
var availableNodesForPaste = clipboardService.retriveDataOfType("elementType", contentTypeAliases);
|
||||
_.each(availableNodesForPaste, function (node) {
|
||||
$scope.overlayMenu.pasteItems.push({
|
||||
@@ -210,6 +234,7 @@ angular.module("umbraco").controller("Umbraco.PropertyEditors.NestedContent.Prop
|
||||
$event.stopPropagation();
|
||||
$event.preventDefault();
|
||||
clipboardService.clearEntriesOfType("elementType", contentTypeAliases);
|
||||
clipboardService.clearEntriesOfType("nestedContent", ["nc_copyOfAllItems"]);
|
||||
$scope.overlayMenu.pasteItems = [];// This dialog is not connected via the clipboardService events, so we need to update manually.
|
||||
};
|
||||
|
||||
@@ -359,7 +384,26 @@ angular.module("umbraco").controller("Umbraco.PropertyEditors.NestedContent.Prop
|
||||
clipboardService.copy("elementType", node.contentTypeAlias, node);
|
||||
$event.stopPropagation();
|
||||
}
|
||||
|
||||
|
||||
$scope.clickCopyAll = function () {
|
||||
|
||||
syncCurrentNode();
|
||||
|
||||
var culture = $routeParams.cculture ? $routeParams.cculture : $routeParams.mculture;
|
||||
var activeVariant = _.find(editorState.current.variants, function (v) {
|
||||
return !v.language || v.language.culture === culture;
|
||||
});
|
||||
|
||||
localizationService.localize("content_nestedContentCopyAllItemsName", [$scope.model.label, activeVariant.name]).then(function(data) {
|
||||
var model = {
|
||||
nodes: $scope.nodes,
|
||||
key: "nc_" + $scope.model.alias,
|
||||
name: data
|
||||
};
|
||||
clipboardService.copy("nestedContent", "nc_copyOfAllItems", model);
|
||||
});
|
||||
}
|
||||
|
||||
$scope.pasteFromClipboard = function(newNode) {
|
||||
|
||||
if (newNode === undefined) {
|
||||
|
||||
@@ -42,6 +42,9 @@
|
||||
<a href class="umb-nested-content__add-content" ng-class="{ '--disabled': !scaffolds.length }" ng-click="openNodeTypePicker($event)" prevent-default>
|
||||
<localize key="grid_addElement"></localize>
|
||||
</a>
|
||||
<a class="umb-nested-content__icon umb-nested-content__icon--copy" title="{{copyIconTitle}}" ng-click="clickCopyAll();" ng-if="showCopy && nodes.length" prevent-default>
|
||||
<i class="icon icon-documents"></i>
|
||||
</a>
|
||||
</div>
|
||||
|
||||
</ng-form>
|
||||
|
||||
@@ -273,6 +273,7 @@
|
||||
<key alias="nestedContentDeleteItem">Are you sure you want to delete this item?</key>
|
||||
<key alias="nestedContentEditorNotSupported">Property %0% uses editor %1% which is not supported by Nested Content.</key>
|
||||
<key alias="nestedContentNoContentTypes">No content types are configured for this property.</key>
|
||||
<key alias="nestedContentCopyAllItemsName">%0% from %1%</key>
|
||||
<key alias="addTextBox">Add another text box</key>
|
||||
<key alias="removeTextBox">Remove this text box</key>
|
||||
<key alias="contentRoot">Content root</key>
|
||||
|
||||
@@ -277,6 +277,7 @@
|
||||
<key alias="nestedContentDeleteItem">Are you sure you want to delete this item?</key>
|
||||
<key alias="nestedContentEditorNotSupported">Property %0% uses editor %1% which is not supported by Nested Content.</key>
|
||||
<key alias="nestedContentNoContentTypes">No content types are configured for this property.</key>
|
||||
<key alias="nestedContentCopyAllItemsName">%0% from %1%</key>
|
||||
<key alias="addTextBox">Add another text box</key>
|
||||
<key alias="removeTextBox">Remove this text box</key>
|
||||
<key alias="contentRoot">Content root</key>
|
||||
|
||||
Reference in New Issue
Block a user