mirror of
https://github.com/nasa/openmct.git
synced 2025-06-18 15:18:12 +00:00
Elements pool and drag drop (#2196)
* Implemented drag-and-drop composition * Added composition policy for tables * Reimplemented elements pool in Vue * No need to resolve all objects on the navigated path * Only show elements pool in edit mode * Remove old elements pool * Updated legacy code to use composition policy API * Keep object in sync when mutated
This commit is contained in:
committed by
Pete Richards
parent
a296bc2b81
commit
cbcfd44016
@ -36,6 +36,9 @@ export default class Editor extends EventEmitter {
|
||||
* or finish() are called.
|
||||
*/
|
||||
edit() {
|
||||
if (this.editing === true) {
|
||||
throw "Already editing";
|
||||
}
|
||||
this.editing = true;
|
||||
this.getTransactionService().startTransaction();
|
||||
this.emit('isEditing', true);
|
||||
|
@ -44,7 +44,7 @@ define([
|
||||
function CompositionAPI(publicAPI) {
|
||||
this.registry = [];
|
||||
this.policies = [];
|
||||
this.addProvider(new DefaultCompositionProvider(publicAPI));
|
||||
this.addProvider(new DefaultCompositionProvider(publicAPI, this));
|
||||
this.publicAPI = publicAPI;
|
||||
}
|
||||
|
||||
|
@ -43,9 +43,34 @@ define([
|
||||
* @memberof module:openmct
|
||||
*/
|
||||
|
||||
function DefaultCompositionProvider(publicAPI) {
|
||||
function DefaultCompositionProvider(publicAPI, compositionAPI) {
|
||||
this.publicAPI = publicAPI;
|
||||
this.listeningTo = {};
|
||||
|
||||
this.cannotContainDuplicates = this.cannotContainDuplicates.bind(this);
|
||||
this.cannotContainItself = this.cannotContainItself.bind(this);
|
||||
|
||||
compositionAPI.addPolicy(this.cannotContainDuplicates);
|
||||
compositionAPI.addPolicy(this.cannotContainItself);
|
||||
}
|
||||
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
DefaultCompositionProvider.prototype.cannotContainDuplicates = function (parent, child) {
|
||||
return this.appliesTo(parent) &&
|
||||
parent.composition.findIndex((composeeId) => {
|
||||
return composeeId.namespace === child.identifier.namespace &&
|
||||
composeeId.key === child.identifier.key;
|
||||
}) === -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
DefaultCompositionProvider.prototype.cannotContainItself = function (parent, child) {
|
||||
return !(parent.identifier.namespace === child.identifier.namespace &&
|
||||
parent.identifier.key === child.identifier.key);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -203,7 +228,7 @@ define([
|
||||
}
|
||||
|
||||
var oldComposition = listeners.composition.map(objectUtils.makeKeyString);
|
||||
var newComposition = oldDomainObject.getModel().composition;
|
||||
var newComposition = oldDomainObject.getModel().composition.map(objectUtils.makeKeyString);
|
||||
|
||||
var added = _.difference(newComposition, oldComposition).map(objectUtils.parseKeyString);
|
||||
var removed = _.difference(oldComposition, newComposition).map(objectUtils.parseKeyString);
|
||||
|
Reference in New Issue
Block a user