[Create] Remove unused code, dependencies

This commit is contained in:
Victor Woeltjen
2016-02-10 12:05:01 -08:00
parent 8c602025d4
commit 88750d92ef

View File

@ -37,11 +37,7 @@ define(
* @memberof platform/commonUI/edit * @memberof platform/commonUI/edit
*/ */
function SaveAction( function SaveAction(
$q,
$location,
$injector, $injector,
urlService,
navigationService,
policyService, policyService,
dialogService, dialogService,
creationService, creationService,
@ -49,17 +45,13 @@ define(
context context
) { ) {
this.domainObject = (context || {}).domainObject; this.domainObject = (context || {}).domainObject;
this.$location = $location;
this.injectObjectService = function(){ this.injectObjectService = function(){
this.objectService = $injector.get("objectService"); this.objectService = $injector.get("objectService");
}; };
this.urlService = urlService;
this.navigationService = navigationService;
this.policyService = policyService; this.policyService = policyService;
this.dialogService = dialogService; this.dialogService = dialogService;
this.creationService = creationService; this.creationService = creationService;
this.copyService = copyService; this.copyService = copyService;
this.$q = $q;
} }
SaveAction.prototype.getObjectService = function(){ SaveAction.prototype.getObjectService = function(){
@ -79,8 +71,6 @@ define(
*/ */
SaveAction.prototype.perform = function () { SaveAction.prototype.perform = function () {
var domainObject = this.domainObject, var domainObject = this.domainObject,
$location = this.$location,
urlService = this.urlService,
copyService = this.copyService, copyService = this.copyService,
self = this; self = this;
@ -92,22 +82,18 @@ define(
function doWizardSave(parent) { function doWizardSave(parent) {
var context = domainObject.getCapability("context"), var context = domainObject.getCapability("context"),
wizard = new CreateWizard(domainObject, parent, self.policyService); wizard = new CreateWizard(
domainObject,
parent,
self.policyService
);
return self.dialogService return self.dialogService
.getUserInput(wizard.getFormStructure(true), wizard.getInitialFormValue()) .getUserInput(
.then(function(formValue){ wizard.getFormStructure(true),
return wizard.populateObjectFromInput(formValue, domainObject); wizard.getInitialFormValue()
}); )
} .then(wizard.populateObjectFromInput.bind(wizard));
function persistObject(object){
//Persist first to mark dirty
return object.getCapability('persistence').persist().then(function(){
//then save permanently
return object.getCapability('editor').save();
});
} }
function fetchObject(objectId){ function fetchObject(objectId){
@ -120,18 +106,6 @@ define(
return fetchObject(object.getModel().location); return fetchObject(object.getModel().location);
} }
function locateObjectInParent(parent){
parent.getCapability('composition').add(domainObject.getId());
return parent.getCapability('persistence').persist().then(function() {
return parent;
});
}
function doNothing() {
// Create cancelled, do nothing
return false;
}
function cancelEditingAfterClone(clonedObject) { function cancelEditingAfterClone(clonedObject) {
return domainObject.getCapability("editor").cancel() return domainObject.getCapability("editor").cancel()
.then(resolveWith(clonedObject)); .then(resolveWith(clonedObject));
@ -150,7 +124,7 @@ define(
.then(getParent) .then(getParent)
.then(copyService.perform.bind(copyService, domainObject)) .then(copyService.perform.bind(copyService, domainObject))
.then(cancelEditingAfterClone) .then(cancelEditingAfterClone)
.catch(doNothing); .catch(resolveWith(false));
} else { } else {
return domainObject.getCapability("editor").save() return domainObject.getCapability("editor").save()
.then(resolveWith(domainObject.getOriginalObject())); .then(resolveWith(domainObject.getOriginalObject()));
@ -161,7 +135,7 @@ define(
// UI, which will have been pushed atop the Browse UI.) // UI, which will have been pushed atop the Browse UI.)
function returnToBrowse(object) { function returnToBrowse(object) {
if (object) { if (object) {
self.navigationService.setNavigation(object); object.getCapability("action").perform("navigate");
} }
return object; return object;
} }