Migrate editors to components, disable previous editor when selecting new one

This commit is contained in:
Mo Bitar
2017-11-09 17:20:13 -06:00
parent 8767f1c5ec
commit 4e39a5e1b9
7 changed files with 90 additions and 154 deletions

View File

@@ -148,6 +148,12 @@ class ComponentManager {
})
}
componentForUrl(url) {
return this.components.filter(function(component){
return component.url === url;
})[0];
}
componentForSessionKey(key) {
return _.find(this.components, {sessionKey: key});
}
@@ -493,18 +499,27 @@ class ComponentManager {
}
disassociateComponentWithItem(component, item) {
_.pull(component.associatedItemIds, item.uuid);
if(component.disassociatedItemIds.indexOf(item.uuid) !== -1) {
return;
}
_.pull(component.associatedItemIds, item.uuid);
component.disassociatedItemIds.push(item.uuid);
component.setDirty(true);
this.syncManager.sync();
}
associateComponentWithItem(component, item) {
_.pull(component.disassociatedItemIds, item.uuid);
if(component.associatedItemIds.includes(item.uuid)) {
return;
}
component.associatedItemIds.push(item.uuid);
component.setDirty(true);
this.syncManager.sync();
}