mirror of
https://github.com/nasa/openmct.git
synced 2025-06-18 15:18:12 +00:00
[Create] Use duplicate at end of Save
...for unpersisted objects. Ensures that they share the persistence space of their parent. #656.
This commit is contained in:
@ -36,7 +36,18 @@ define(
|
|||||||
* @implements {Action}
|
* @implements {Action}
|
||||||
* @memberof platform/commonUI/edit
|
* @memberof platform/commonUI/edit
|
||||||
*/
|
*/
|
||||||
function SaveAction($q, $location, $injector, urlService, navigationService, policyService, dialogService, creationService, context) {
|
function SaveAction(
|
||||||
|
$q,
|
||||||
|
$location,
|
||||||
|
$injector,
|
||||||
|
urlService,
|
||||||
|
navigationService,
|
||||||
|
policyService,
|
||||||
|
dialogService,
|
||||||
|
creationService,
|
||||||
|
copyService,
|
||||||
|
context
|
||||||
|
) {
|
||||||
this.domainObject = (context || {}).domainObject;
|
this.domainObject = (context || {}).domainObject;
|
||||||
this.$location = $location;
|
this.$location = $location;
|
||||||
this.injectObjectService = function(){
|
this.injectObjectService = function(){
|
||||||
@ -47,6 +58,7 @@ define(
|
|||||||
this.policyService = policyService;
|
this.policyService = policyService;
|
||||||
this.dialogService = dialogService;
|
this.dialogService = dialogService;
|
||||||
this.creationService = creationService;
|
this.creationService = creationService;
|
||||||
|
this.copyService = copyService;
|
||||||
this.$q = $q;
|
this.$q = $q;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -69,6 +81,7 @@ define(
|
|||||||
var domainObject = this.domainObject,
|
var domainObject = this.domainObject,
|
||||||
$location = this.$location,
|
$location = this.$location,
|
||||||
urlService = this.urlService,
|
urlService = this.urlService,
|
||||||
|
copyService = this.copyService,
|
||||||
self = this;
|
self = this;
|
||||||
|
|
||||||
function resolveWith(object){
|
function resolveWith(object){
|
||||||
@ -88,7 +101,6 @@ define(
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function persistObject(object){
|
function persistObject(object){
|
||||||
|
|
||||||
//Persist first to mark dirty
|
//Persist first to mark dirty
|
||||||
@ -130,13 +142,10 @@ define(
|
|||||||
if (!domainObject.getModel().persisted){
|
if (!domainObject.getModel().persisted){
|
||||||
return getParent(domainObject)
|
return getParent(domainObject)
|
||||||
.then(doWizardSave)
|
.then(doWizardSave)
|
||||||
.then(persistObject)
|
.then(copyService.perform.bind(
|
||||||
.then(getParent)//Parent may have changed based
|
copyService,
|
||||||
// on user selection
|
[ domainObject ]
|
||||||
.then(locateObjectInParent)
|
))
|
||||||
.then(function(){
|
|
||||||
return fetchObject(domainObject.getId());
|
|
||||||
})
|
|
||||||
.catch(doNothing);
|
.catch(doNothing);
|
||||||
} else {
|
} else {
|
||||||
return domainObject.getCapability("editor").save()
|
return domainObject.getCapability("editor").save()
|
||||||
|
Reference in New Issue
Block a user