componentManager duplicate-item message
This commit is contained in:
@@ -678,7 +678,8 @@ angular.module('app')
|
||||
this.reloadComponentContext = function() {
|
||||
// componentStack is used by the template to ng-repeat
|
||||
this.componentStack = componentManager.componentsForArea("editor-stack").sort((a, b) => {
|
||||
// Careful here. For some reason, sorting by updated_at (or any other property that may always be changing)
|
||||
// Careful here. For some reason (probably because re-assigning array everytime quickly destroys componentView elements, causing deallocs),
|
||||
// sorting by updated_at (or any other property that may always be changing)
|
||||
// causes weird problems with ext communication when changing notes or activating/deactivating in quick succession
|
||||
return a.name.toLowerCase() < b.name.toLowerCase() ? -1 : 1;
|
||||
});
|
||||
|
||||
@@ -372,6 +372,8 @@ class ComponentManager {
|
||||
this.handleInstallLocalComponentMessage(component, message);
|
||||
} else if(message.action === "present-conflict-resolution") {
|
||||
this.handlePresentConflictResolutionMessage(component, message);
|
||||
} else if(message.action === "duplicate-item") {
|
||||
this.handleDuplicateItemMessage(component, message);
|
||||
}
|
||||
|
||||
// Notify observers
|
||||
@@ -568,6 +570,24 @@ class ComponentManager {
|
||||
});
|
||||
}
|
||||
|
||||
handleDuplicateItemMessage(component, message) {
|
||||
var itemParams = message.data.item;
|
||||
var item = this.modelManager.findItem(itemParams.uuid);
|
||||
var requiredPermissions = [
|
||||
{
|
||||
name: "stream-items",
|
||||
content_types: [item.content_type]
|
||||
}
|
||||
];
|
||||
|
||||
this.runWithPermissions(component, requiredPermissions, () => {
|
||||
var duplicate = this.modelManager.duplicateItem(item);
|
||||
this.syncManager.sync();
|
||||
|
||||
this.replyToMessage(component, message, {item: this.jsonForItem(duplicate, component)});
|
||||
});
|
||||
}
|
||||
|
||||
handleCreateItemsMessage(component, message) {
|
||||
var responseItems = message.data.item ? [message.data.item] : message.data.items;
|
||||
let uniqueContentTypes = _.uniq(responseItems.map((item) => {return item.content_type}));
|
||||
|
||||
Reference in New Issue
Block a user