mirror of
https://github.com/nasa/openmct.git
synced 2025-06-01 15:10:50 +00:00
Resolved merge conflicts
This commit is contained in:
parent
e5ef7c0c22
commit
bd686790dc
@ -24,11 +24,8 @@
|
|||||||
* Module defining CreateAction. Created by vwoeltje on 11/10/14.
|
* Module defining CreateAction. Created by vwoeltje on 11/10/14.
|
||||||
*/
|
*/
|
||||||
define(
|
define(
|
||||||
[
|
[],
|
||||||
'./CreateWizard',
|
function () {
|
||||||
'../../../edit/src/objects/EditableDomainObject'
|
|
||||||
],
|
|
||||||
function (CreateWizard, EditableDomainObject) {
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Create Action is performed to create new instances of
|
* The Create Action is performed to create new instances of
|
||||||
@ -86,22 +83,19 @@ define(
|
|||||||
CreateAction.prototype.perform = function () {
|
CreateAction.prototype.perform = function () {
|
||||||
var newModel = this.type.getInitialModel(),
|
var newModel = this.type.getInitialModel(),
|
||||||
parentObject = this.navigationService.getNavigation(),
|
parentObject = this.navigationService.getNavigation(),
|
||||||
newObject,
|
newObject;
|
||||||
editableObject;
|
|
||||||
|
|
||||||
newModel.type = this.type.getKey();
|
newModel.type = this.type.getKey();
|
||||||
newObject = parentObject.useCapability('instantiation', newModel);
|
newObject = parentObject.useCapability('instantiation', newModel);
|
||||||
editableObject = new EditableDomainObject(newObject, this.$q);
|
newObject.useCapability('mutation', function(model){
|
||||||
editableObject.setOriginalObject(parentObject);
|
|
||||||
editableObject.getCapability('status').set('editing', true);
|
|
||||||
editableObject.useCapability('mutation', function(model){
|
|
||||||
model.location = parentObject.getId();
|
model.location = parentObject.getId();
|
||||||
});
|
});
|
||||||
|
|
||||||
if (countEditableViews(editableObject) > 0 && editableObject.hasCapability('composition')) {
|
if (countEditableViews(newObject) > 0 && newObject.hasCapability('composition')) {
|
||||||
this.navigationService.setNavigation(editableObject);
|
this.navigationService.setNavigation(newObject);
|
||||||
|
newObject.getCapability("action").perform("edit");
|
||||||
} else {
|
} else {
|
||||||
return editableObject.getCapability('action').perform('save');
|
return newObject.getCapability('action').perform('save');
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -201,7 +201,8 @@ define([
|
|||||||
"description": "Discard changes made to these objects.",
|
"description": "Discard changes made to these objects.",
|
||||||
"depends": [
|
"depends": [
|
||||||
"$injector",
|
"$injector",
|
||||||
"navigationService"
|
"navigationService",
|
||||||
|
"$window"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
@ -44,30 +44,16 @@ define(
|
|||||||
* cancellation has completed
|
* cancellation has completed
|
||||||
*/
|
*/
|
||||||
CancelAction.prototype.perform = function () {
|
CancelAction.prototype.perform = function () {
|
||||||
var domainObject = this.domainObject,
|
var domainObject = this.domainObject;
|
||||||
self = this;
|
|
||||||
|
|
||||||
// Look up the object's "editor.completion" capability;
|
function returnToBrowse () {
|
||||||
// this is introduced by EditableDomainObject which is
|
var parent;
|
||||||
// used to insulate underlying objects from changes made
|
domainObject.getCapability("location").getOriginal().then(function (original) {
|
||||||
// during editing.
|
parent = original.getCapability("context").getParent();
|
||||||
function getEditorCapability() {
|
parent.getCapability("action").perform("navigate");
|
||||||
return domainObject.getCapability("editor");
|
});
|
||||||
}
|
}
|
||||||
|
return this.domainObject.getCapability("editor").cancel()
|
||||||
// Invoke any save behavior introduced by the editor.completion
|
|
||||||
// capability.
|
|
||||||
function doCancel(editor) {
|
|
||||||
return editor.cancel();
|
|
||||||
}
|
|
||||||
|
|
||||||
//Discard current 'editable' object, and retrieve original
|
|
||||||
// un-edited object.
|
|
||||||
function returnToBrowse() {
|
|
||||||
return self.navigationService.setNavigation(self.domainObject.getOriginalObject());
|
|
||||||
}
|
|
||||||
|
|
||||||
return doCancel(getEditorCapability())
|
|
||||||
.then(returnToBrowse);
|
.then(returnToBrowse);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -71,25 +71,12 @@ define(
|
|||||||
*/
|
*/
|
||||||
EditAction.prototype.perform = function () {
|
EditAction.prototype.perform = function () {
|
||||||
var self = this;
|
var self = this;
|
||||||
if (!this.domainObject.hasCapability("editor")) {
|
function cancelEditing(){
|
||||||
//TODO: This is only necessary because the drop gesture is
|
self.domainObject.getCapability('editor').cancel();
|
||||||
// wrapping the object itself, need to refactor this later.
|
self.navigationService.removeListener(cancelEditing);
|
||||||
// All responsibility for switching into edit mode should be
|
|
||||||
// in the edit action, and not duplicated in the gesture
|
|
||||||
this.domainObject = new EditableDomainObject(this.domainObject, this.$q);
|
|
||||||
}
|
|
||||||
this.navigationService.setNavigation(this.domainObject);
|
|
||||||
this.domainObject.getCapability('status').set('editing', true);
|
|
||||||
|
|
||||||
//Register a listener to automatically cancel this edit action
|
|
||||||
//if the user navigates away from this object.
|
|
||||||
function cancelEditing(navigatedTo){
|
|
||||||
if (!navigatedTo || navigatedTo.getId() !== self.domainObject.getId()) {
|
|
||||||
self.domainObject.getCapability('editor').cancel();
|
|
||||||
self.navigationService.removeListener(cancelEditing);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
this.navigationService.addListener(cancelEditing);
|
this.navigationService.addListener(cancelEditing);
|
||||||
|
this.domainObject.useCapability("editor");
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -50,17 +50,23 @@ define(
|
|||||||
|
|
||||||
EditorCapability.prototype.edit = function () {
|
EditorCapability.prototype.edit = function () {
|
||||||
this.transactionService.startTransaction();
|
this.transactionService.startTransaction();
|
||||||
this.getCapability('status').set('editing', true);
|
this.domainObject.getCapability('status').set('editing', true);
|
||||||
};
|
};
|
||||||
|
|
||||||
EditorCapability.prototype.save = function () {
|
EditorCapability.prototype.save = function () {
|
||||||
return this.transactionService.commit();
|
var domainObject = this.domainObject;
|
||||||
|
return this.transactionService.commit().then(function() {
|
||||||
|
domainObject.getCapability('status').set('editing', false);
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
EditorCapability.prototype.invoke = EditorCapability.prototype.edit;
|
||||||
|
|
||||||
EditorCapability.prototype.cancel = function () {
|
EditorCapability.prototype.cancel = function () {
|
||||||
var domainObject = this.domainObject;
|
var domainObject = this.domainObject;
|
||||||
return this.transactionService.cancel().then(function(){
|
return this.transactionService.cancel().then(function(){
|
||||||
domainObject.getCapability("status").set("editing", false);
|
domainObject.getCapability("status").set("editing", false);
|
||||||
|
return domainObject;
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -58,7 +58,8 @@ define(
|
|||||||
* transaction is in progress.
|
* transaction is in progress.
|
||||||
*/
|
*/
|
||||||
TransactionDecorator.prototype.getCapabilities = function (model) {
|
TransactionDecorator.prototype.getCapabilities = function (model) {
|
||||||
var capabilities = this.capabilityService.getCapabilities(model),
|
var self = this,
|
||||||
|
capabilities = this.capabilityService.getCapabilities(model),
|
||||||
persistenceCapability = capabilities.persistence;
|
persistenceCapability = capabilities.persistence;
|
||||||
|
|
||||||
capabilities.persistence = function (domainObject) {
|
capabilities.persistence = function (domainObject) {
|
||||||
|
@ -57,7 +57,9 @@ define(
|
|||||||
};
|
};
|
||||||
|
|
||||||
TransactionalPersistenceCapability.prototype.refresh = function () {
|
TransactionalPersistenceCapability.prototype.refresh = function () {
|
||||||
var dirtyModelCache = this.dirtyModelCache;
|
var domainObject = this.domainObject,
|
||||||
|
dirtyModelCache = this.dirtyModelCache;
|
||||||
|
|
||||||
return this.persistenceCapability.refresh().then(function (result) {
|
return this.persistenceCapability.refresh().then(function (result) {
|
||||||
dirtyModelCache.markClean(domainObject);
|
dirtyModelCache.markClean(domainObject);
|
||||||
return result;
|
return result;
|
||||||
|
@ -32,7 +32,7 @@ define(
|
|||||||
};
|
};
|
||||||
|
|
||||||
DirtyModelCache.prototype.isDirty = function (domainObject) {
|
DirtyModelCache.prototype.isDirty = function (domainObject) {
|
||||||
return !!this.get(domainObject.getId());
|
return !!this.cache[domainObject.getId()];
|
||||||
};
|
};
|
||||||
|
|
||||||
DirtyModelCache.prototype.markDirty = function (domainObject) {
|
DirtyModelCache.prototype.markDirty = function (domainObject) {
|
||||||
|
@ -39,9 +39,8 @@ define(
|
|||||||
}
|
}
|
||||||
|
|
||||||
TransactionService.prototype.startTransaction = function () {
|
TransactionService.prototype.startTransaction = function () {
|
||||||
if (this.transaction) {
|
if (this.transaction)
|
||||||
throw "Transaction in progress";
|
console.error("Transaction already in progress")
|
||||||
}
|
|
||||||
this.transaction = true;
|
this.transaction = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -68,7 +67,7 @@ define(
|
|||||||
}
|
}
|
||||||
|
|
||||||
return this.$q.all(
|
return this.$q.all(
|
||||||
Object.keys(this.cache)
|
Object.keys(cache)
|
||||||
.map(keyToObject)
|
.map(keyToObject)
|
||||||
.map(objectToPromise))
|
.map(objectToPromise))
|
||||||
.then(function () {
|
.then(function () {
|
||||||
@ -93,7 +92,7 @@ define(
|
|||||||
}
|
}
|
||||||
|
|
||||||
function objectToPromise(object) {
|
function objectToPromise(object) {
|
||||||
return object.getCapability('persistence').refresh();
|
return self.$q.when(object.getModel().persisted && object.getCapability('persistence').refresh());
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.$q.all(Object.keys(cache)
|
return this.$q.all(Object.keys(cache)
|
||||||
|
@ -168,13 +168,10 @@ define(
|
|||||||
}, modified);
|
}, modified);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Only update if we don't have unsaved changes
|
return this.persistenceService.readObject(
|
||||||
return (model.modified === model.persisted) ?
|
|
||||||
this.persistenceService.readObject(
|
|
||||||
this.getSpace(),
|
this.getSpace(),
|
||||||
this.domainObject.getId()
|
this.domainObject.getId()
|
||||||
).then(updateModel) :
|
).then(updateModel);
|
||||||
fastPromise(false);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -24,9 +24,8 @@
|
|||||||
* Module defining DropGesture. Created by vwoeltje on 11/17/14.
|
* Module defining DropGesture. Created by vwoeltje on 11/17/14.
|
||||||
*/
|
*/
|
||||||
define(
|
define(
|
||||||
['./GestureConstants',
|
['./GestureConstants'],
|
||||||
'../../../commonUI/edit/src/objects/EditableDomainObject'],
|
function (GestureConstants) {
|
||||||
function (GestureConstants, EditableDomainObject) {
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A DropGesture adds and maintains event handlers upon an element
|
* A DropGesture adds and maintains event handlers upon an element
|
||||||
@ -41,7 +40,6 @@ define(
|
|||||||
*/
|
*/
|
||||||
function DropGesture(dndService, $q, navigationService, instantiate, typeService, element, domainObject) {
|
function DropGesture(dndService, $q, navigationService, instantiate, typeService, element, domainObject) {
|
||||||
var actionCapability = domainObject.getCapability('action'),
|
var actionCapability = domainObject.getCapability('action'),
|
||||||
editableDomainObject,
|
|
||||||
scope = element.scope && element.scope(),
|
scope = element.scope && element.scope(),
|
||||||
action; // Action for the drop, when it occurs
|
action; // Action for the drop, when it occurs
|
||||||
|
|
||||||
@ -66,23 +64,13 @@ define(
|
|||||||
x: event.pageX - rect.left,
|
x: event.pageX - rect.left,
|
||||||
y: event.pageY - rect.top
|
y: event.pageY - rect.top
|
||||||
},
|
},
|
||||||
editableDomainObject
|
domainObject
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function dragOver(e) {
|
function dragOver(e) {
|
||||||
//Refresh domain object on each dragOver to catch external
|
actionCapability = domainObject.getCapability('action');
|
||||||
// updates to the model
|
|
||||||
//Don't use EditableDomainObject for folders, allow immediate persistence
|
|
||||||
if (domainObject.hasCapability('editor') ||
|
|
||||||
domainObject.getModel().type==='folder') {
|
|
||||||
editableDomainObject = domainObject;
|
|
||||||
} else {
|
|
||||||
editableDomainObject = new EditableDomainObject(domainObject, $q);
|
|
||||||
}
|
|
||||||
|
|
||||||
actionCapability = editableDomainObject.getCapability('action');
|
|
||||||
|
|
||||||
var event = (e || {}).originalEvent || e,
|
var event = (e || {}).originalEvent || e,
|
||||||
selectedObject = dndService.getData(
|
selectedObject = dndService.getData(
|
||||||
@ -108,18 +96,19 @@ define(
|
|||||||
function drop(e) {
|
function drop(e) {
|
||||||
var event = (e || {}).originalEvent || e,
|
var event = (e || {}).originalEvent || e,
|
||||||
id = event.dataTransfer.getData(GestureConstants.MCT_DRAG_TYPE),
|
id = event.dataTransfer.getData(GestureConstants.MCT_DRAG_TYPE),
|
||||||
domainObjectType = editableDomainObject.getModel().type;
|
domainObjectType = domainObject.getModel().type;
|
||||||
|
|
||||||
// Handle the drop; add the dropped identifier to the
|
// Handle the drop; add the dropped identifier to the
|
||||||
// destination domain object's composition, and persist
|
// destination domain object's composition, and persist
|
||||||
// the change.
|
// the change.
|
||||||
if (id) {
|
if (id) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
$q.when(action && action.perform()).then(function (result) {
|
|
||||||
//Don't go into edit mode for folders
|
if (domainObjectType!=='folder') {
|
||||||
if (domainObjectType!=='folder') {
|
domainObject.getCapability('action').perform('edit');
|
||||||
editableDomainObject.getCapability('action').perform('edit');
|
}
|
||||||
}
|
|
||||||
|
$q.when(action && action.perform()).then(function () {
|
||||||
broadcastDrop(id, event);
|
broadcastDrop(id, event);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user