Adds button to change Dataset Status, if DMP is Draft
This commit is contained in:
parent
349dffb137
commit
758c72ed2e
|
@ -101,6 +101,8 @@
|
|||
(click)="saveFinalize();"
|
||||
type="button">{{ 'DATASET-WIZARD.ACTIONS.FINALIZE' | translate }}</button>
|
||||
<div class="fill-space"></div>
|
||||
<button *ngIf="hasReversableStatus" mat-raised-button class="reverseButton" color="primary" (click)="reverse();"
|
||||
type="button">{{ 'DATASET-WIZARD.ACTIONS.REVERSE' | translate }}</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
.description-action-row {
|
||||
margin-top: 1em;
|
||||
}
|
||||
.deleteButton {
|
||||
.deleteButton, .reverseButton {
|
||||
margin-top: 15px;
|
||||
margin-bottom: 15px;
|
||||
margin-right: 15px;
|
||||
|
|
|
@ -29,6 +29,7 @@ import { IBreadCrumbComponent } from '../../misc/breadcrumb/definition/IBreadCru
|
|||
import { DatasetDescriptionFormEditorModel } from '../../misc/dataset-description-form/dataset-description-form.model';
|
||||
import { DatasetCopyDialogueComponent } from './dataset-copy-dialogue/dataset-copy-dialogue.component';
|
||||
import { DatasetWizardEditorModel } from './dataset-wizard-editor.model';
|
||||
import { DmpStatus } from '../../../core/common/enum/dmp-status';
|
||||
|
||||
@Component({
|
||||
selector: 'app-dataset-wizard-component',
|
||||
|
@ -58,6 +59,7 @@ export class DatasetWizardComponent extends BaseComponent implements OnInit, IBr
|
|||
profileUpdateId: string;
|
||||
downloadDocumentId: string;
|
||||
isLinear = false;
|
||||
hasReversableStatus: boolean = false;
|
||||
|
||||
constructor(
|
||||
private datasetWizardService: DatasetWizardService,
|
||||
|
@ -83,31 +85,6 @@ export class DatasetWizardComponent extends BaseComponent implements OnInit, IBr
|
|||
const dmpRequestItem: RequestItem<DmpCriteria> = new RequestItem();
|
||||
dmpRequestItem.criteria = new DmpCriteria();
|
||||
|
||||
// const externalDatasetRequestItem: RequestItem<ExternalDatasetCriteria> = new RequestItem();
|
||||
// externalDatasetRequestItem.criteria = new ExternalDatasetCriteria();
|
||||
// this.externalDatasetAutoCompleteConfiguration = new AutoCompleteConfiguration(this.externalSourcesService.searchDatasetSExternalDatasetservice.bind(this.externalSourcesService),
|
||||
// externalDatasetRequestItem, new BehaviorSubject(false));
|
||||
|
||||
// const registriesRequestItem: RequestItem<RegistryCriteria> = new RequestItem();
|
||||
// registriesRequestItem.criteria = new RegistryCriteria();
|
||||
// this.registriesAutoCompleteConfiguration = new AutoCompleteConfiguration(this.externalSourcesService.searchDatasetRegistry.bind(this.externalSourcesService),
|
||||
// registriesRequestItem, new BehaviorSubject(false));
|
||||
|
||||
// const dataRepositoriesRequestItem: RequestItem<DataRepositoryCriteria> = new RequestItem();
|
||||
// dataRepositoriesRequestItem.criteria = new DataRepositoryCriteria();
|
||||
// this.dataRepositoriesAutoCompleteConfiguration = new AutoCompleteConfiguration(this.externalSourcesService.searchDatasetRepository.bind(this.externalSourcesService),
|
||||
// dataRepositoriesRequestItem, new BehaviorSubject(false));
|
||||
|
||||
// const servicesRequestItem: RequestItem<ServiceCriteria> = new RequestItem();
|
||||
// servicesRequestItem.criteria = new ServiceCriteria();
|
||||
// this.servicesAutoCompleteConfiguration = new AutoCompleteConfiguration(this.externalSourcesService.searchDatasetService.bind(this.externalSourcesService),
|
||||
// servicesRequestItem, new BehaviorSubject(false));
|
||||
|
||||
// const tagsRequestItem: RequestItem<TagCriteria> = new RequestItem();
|
||||
// tagsRequestItem.criteria = new TagCriteria();
|
||||
// this.tagsAutoCompleteConfiguration = new AutoCompleteConfiguration(this.externalSourcesService.searchDatasetTags.bind(this.externalSourcesService),
|
||||
// tagsRequestItem, new BehaviorSubject(false));
|
||||
|
||||
this.dmpAutoCompleteConfiguration = {
|
||||
filterFn: this.searchDmp.bind(this),
|
||||
initialItems: (extraData) => this.searchDmp(''),
|
||||
|
@ -138,11 +115,6 @@ export class DatasetWizardComponent extends BaseComponent implements OnInit, IBr
|
|||
label: this.datasetWizardModel.label,
|
||||
url: '/datasets/edit/' + this.datasetWizardModel.id,
|
||||
notFoundResolver: [
|
||||
// {
|
||||
// parentComponentName: null,
|
||||
// label: this.datasetWizardModel.dmp.label,
|
||||
// url: '/plans/overview/' + this.datasetWizardModel.dmp.id
|
||||
// },
|
||||
{
|
||||
parentComponentName: null,
|
||||
label: this.language.instant('NAV-BAR.MY-DATASET-DESCRIPTIONS').toUpperCase(),
|
||||
|
@ -158,16 +130,11 @@ export class DatasetWizardComponent extends BaseComponent implements OnInit, IBr
|
|||
}
|
||||
// if (this.viewOnly) { this.formGroup.disable(); } // For future use, to make Dataset edit like DMP.
|
||||
this.loadDatasetProfiles();
|
||||
this.formGroup.get('dmp').valueChanges
|
||||
.pipe(takeUntil(this._destroyed))
|
||||
.subscribe(() => {
|
||||
this.dmpValueChanged(this.formGroup.get('dmp').value);
|
||||
});
|
||||
this.formGroup.get('profile').valueChanges
|
||||
.pipe(takeUntil(this._destroyed))
|
||||
.subscribe(x => {
|
||||
this.datasetProfileValueChanged(x);
|
||||
});
|
||||
this.registerFormListeners();
|
||||
|
||||
if (this.formGroup.get('dmp').value.status == DmpStatus.Draft && this.formGroup.get('status').value == DatasetStatus.Finalized) {
|
||||
this.hasReversableStatus = true;
|
||||
}
|
||||
});
|
||||
} else if (dmpId != null) {
|
||||
this.isNew = true;
|
||||
|
@ -179,21 +146,10 @@ export class DatasetWizardComponent extends BaseComponent implements OnInit, IBr
|
|||
this.datasetWizardModel.dmp = data;
|
||||
this.formGroup = this.datasetWizardModel.buildForm();
|
||||
this.editMode = this.datasetWizardModel.status === DatasetStatus.Draft;
|
||||
if (this.datasetWizardModel.status === DatasetStatus.Finalized) {
|
||||
this.formGroup.disable();
|
||||
this.viewOnly = true;
|
||||
}
|
||||
|
||||
this.loadDatasetProfiles();
|
||||
this.formGroup.get('dmp').valueChanges
|
||||
.pipe(takeUntil(this._destroyed))
|
||||
.subscribe(() => {
|
||||
this.dmpValueChanged(this.formGroup.get('dmp').value);
|
||||
});
|
||||
this.formGroup.get('profile').valueChanges
|
||||
.pipe(takeUntil(this._destroyed))
|
||||
.subscribe(x => {
|
||||
this.datasetProfileValueChanged(x);
|
||||
});
|
||||
this.registerFormListeners();
|
||||
|
||||
this.breadCrumbs = Observable.of([
|
||||
{
|
||||
parentComponentName: null,
|
||||
|
@ -327,16 +283,7 @@ export class DatasetWizardComponent extends BaseComponent implements OnInit, IBr
|
|||
this.viewOnly = true;
|
||||
}
|
||||
//if (this.viewOnly) { this.formGroup.disable(); } // For future use, to make Dataset edit like DMP.
|
||||
this.formGroup.get('dmp').valueChanges
|
||||
.pipe(takeUntil(this._destroyed))
|
||||
.subscribe(x => {
|
||||
this.dmpValueChanged(x);
|
||||
});
|
||||
this.formGroup.get('profile').valueChanges
|
||||
.pipe(takeUntil(this._destroyed))
|
||||
.subscribe(x => {
|
||||
this.datasetProfileValueChanged(x);
|
||||
});
|
||||
this.registerFormListeners();
|
||||
this.dmpValueChanged(null);
|
||||
this.breadCrumbs = Observable.of([
|
||||
{
|
||||
|
@ -354,6 +301,19 @@ export class DatasetWizardComponent extends BaseComponent implements OnInit, IBr
|
|||
// });
|
||||
}
|
||||
|
||||
registerFormListeners() {
|
||||
this.formGroup.get('dmp').valueChanges
|
||||
.pipe(takeUntil(this._destroyed))
|
||||
.subscribe(x => {
|
||||
this.dmpValueChanged(x);
|
||||
});
|
||||
this.formGroup.get('profile').valueChanges
|
||||
.pipe(takeUntil(this._destroyed))
|
||||
.subscribe(x => {
|
||||
this.datasetProfileValueChanged(x);
|
||||
});
|
||||
}
|
||||
|
||||
dmpValueChanged(dmp: DmpListingModel) {
|
||||
if (dmp) {
|
||||
this.formGroup.get('profile').enable();
|
||||
|
@ -446,13 +406,21 @@ export class DatasetWizardComponent extends BaseComponent implements OnInit, IBr
|
|||
});
|
||||
}
|
||||
|
||||
|
||||
save() {
|
||||
//if (!this.isFormValid()) { return; }
|
||||
this.formGroup.get('status').setValue(DatasetStatus.Draft);
|
||||
this.submit();
|
||||
}
|
||||
|
||||
reverse() {
|
||||
this.hasReversableStatus = false;
|
||||
this.datasetWizardModel.status = DatasetStatus.Draft;
|
||||
setTimeout(x => { this.formGroup = null; });
|
||||
setTimeout(x => {
|
||||
this.formGroup = this.datasetWizardModel.buildForm();
|
||||
this.registerFormListeners();
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
saveFinalize() {
|
||||
const dialogRef = this.dialog.open(ConfirmationDialogComponent, {
|
||||
data: {
|
||||
|
@ -599,9 +567,9 @@ export class DatasetWizardComponent extends BaseComponent implements OnInit, IBr
|
|||
maxWidth: '300px',
|
||||
data: {
|
||||
message: this.language.instant('GENERAL.CONFIRMATION-DIALOG.DELETE-ITEM'),
|
||||
confirmButton: this.language.instant('GENERAL.CONFIRMATION-DIALOG.ACTIONS.CONFIRM'),
|
||||
confirmButton: this.language.instant('GENERAL.CONFIRMATION-DIALOG.ACTIONS.DELETE'),
|
||||
cancelButton: this.language.instant('GENERAL.CONFIRMATION-DIALOG.ACTIONS.CANCEL'),
|
||||
isDeleteConfirmation: false
|
||||
isDeleteConfirmation: true
|
||||
}
|
||||
});
|
||||
dialogRef.afterClosed().pipe(takeUntil(this._destroyed)).subscribe(result => {
|
||||
|
|
|
@ -324,6 +324,7 @@
|
|||
"SAVE": "Save",
|
||||
"SAVE-AND-FINALISE": "Save and Finalize",
|
||||
"FINALIZE": "Finalize",
|
||||
"REVERSE": "Undo Finalization",
|
||||
"DOWNLOAD-PDF": "Download PDF",
|
||||
"DOWNLOAD-XML": "Download XML",
|
||||
"DOWNLOAD-DOCX": "Download DOCX",
|
||||
|
|
Loading…
Reference in New Issue