Resolved merge conflicts
This commit is contained in:
@@ -201,7 +201,8 @@ define([
|
||||
"description": "Discard changes made to these objects.",
|
||||
"depends": [
|
||||
"$injector",
|
||||
"navigationService"
|
||||
"navigationService",
|
||||
"$window"
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
@@ -44,30 +44,16 @@ define(
|
||||
* cancellation has completed
|
||||
*/
|
||||
CancelAction.prototype.perform = function () {
|
||||
var domainObject = this.domainObject,
|
||||
self = this;
|
||||
var domainObject = this.domainObject;
|
||||
|
||||
// Look up the object's "editor.completion" capability;
|
||||
// this is introduced by EditableDomainObject which is
|
||||
// used to insulate underlying objects from changes made
|
||||
// during editing.
|
||||
function getEditorCapability() {
|
||||
return domainObject.getCapability("editor");
|
||||
function returnToBrowse () {
|
||||
var parent;
|
||||
domainObject.getCapability("location").getOriginal().then(function (original) {
|
||||
parent = original.getCapability("context").getParent();
|
||||
parent.getCapability("action").perform("navigate");
|
||||
});
|
||||
}
|
||||
|
||||
// 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())
|
||||
return this.domainObject.getCapability("editor").cancel()
|
||||
.then(returnToBrowse);
|
||||
};
|
||||
|
||||
|
||||
@@ -71,25 +71,12 @@ define(
|
||||
*/
|
||||
EditAction.prototype.perform = function () {
|
||||
var self = this;
|
||||
if (!this.domainObject.hasCapability("editor")) {
|
||||
//TODO: This is only necessary because the drop gesture is
|
||||
// wrapping the object itself, need to refactor this later.
|
||||
// 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);
|
||||
}
|
||||
function cancelEditing(){
|
||||
self.domainObject.getCapability('editor').cancel();
|
||||
self.navigationService.removeListener(cancelEditing);
|
||||
}
|
||||
this.navigationService.addListener(cancelEditing);
|
||||
this.domainObject.useCapability("editor");
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -50,17 +50,23 @@ define(
|
||||
|
||||
EditorCapability.prototype.edit = function () {
|
||||
this.transactionService.startTransaction();
|
||||
this.getCapability('status').set('editing', true);
|
||||
this.domainObject.getCapability('status').set('editing', true);
|
||||
};
|
||||
|
||||
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 () {
|
||||
var domainObject = this.domainObject;
|
||||
return this.transactionService.cancel().then(function(){
|
||||
domainObject.getCapability("status").set("editing", false);
|
||||
return domainObject;
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
@@ -58,7 +58,8 @@ define(
|
||||
* transaction is in progress.
|
||||
*/
|
||||
TransactionDecorator.prototype.getCapabilities = function (model) {
|
||||
var capabilities = this.capabilityService.getCapabilities(model),
|
||||
var self = this,
|
||||
capabilities = this.capabilityService.getCapabilities(model),
|
||||
persistenceCapability = capabilities.persistence;
|
||||
|
||||
capabilities.persistence = function (domainObject) {
|
||||
|
||||
@@ -57,7 +57,9 @@ define(
|
||||
};
|
||||
|
||||
TransactionalPersistenceCapability.prototype.refresh = function () {
|
||||
var dirtyModelCache = this.dirtyModelCache;
|
||||
var domainObject = this.domainObject,
|
||||
dirtyModelCache = this.dirtyModelCache;
|
||||
|
||||
return this.persistenceCapability.refresh().then(function (result) {
|
||||
dirtyModelCache.markClean(domainObject);
|
||||
return result;
|
||||
|
||||
@@ -32,7 +32,7 @@ define(
|
||||
};
|
||||
|
||||
DirtyModelCache.prototype.isDirty = function (domainObject) {
|
||||
return !!this.get(domainObject.getId());
|
||||
return !!this.cache[domainObject.getId()];
|
||||
};
|
||||
|
||||
DirtyModelCache.prototype.markDirty = function (domainObject) {
|
||||
|
||||
@@ -39,9 +39,8 @@ define(
|
||||
}
|
||||
|
||||
TransactionService.prototype.startTransaction = function () {
|
||||
if (this.transaction) {
|
||||
throw "Transaction in progress";
|
||||
}
|
||||
if (this.transaction)
|
||||
console.error("Transaction already in progress")
|
||||
this.transaction = true;
|
||||
};
|
||||
|
||||
@@ -68,7 +67,7 @@ define(
|
||||
}
|
||||
|
||||
return this.$q.all(
|
||||
Object.keys(this.cache)
|
||||
Object.keys(cache)
|
||||
.map(keyToObject)
|
||||
.map(objectToPromise))
|
||||
.then(function () {
|
||||
@@ -93,7 +92,7 @@ define(
|
||||
}
|
||||
|
||||
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)
|
||||
|
||||
Reference in New Issue
Block a user