Use of Status Enum on all .ts files

This commit is contained in:
apapachristou 2019-06-25 12:16:37 +03:00
parent e29fbd4dca
commit ff270185bd
12 changed files with 33 additions and 24 deletions

View File

@ -19,6 +19,7 @@ import { DatasetProfileEnum } from '../../../../core/common/enum/dataset-profile
import * as FileSaver from 'file-saver'; import * as FileSaver from 'file-saver';
import { BreadcrumbItem } from '../../../misc/breadcrumb/definition/breadcrumb-item'; import { BreadcrumbItem } from '../../../misc/breadcrumb/definition/breadcrumb-item';
import { Observable } from 'rxjs'; import { Observable } from 'rxjs';
import { DatasetStatus } from '../../../../core/common/enum/dataset-status';
//import * as data from 'src/assets/resources/skipDisable.json'; //import * as data from 'src/assets/resources/skipDisable.json';
const skipDisable: any[] = require('../../../../../assets/resources/skipDisable.json'); const skipDisable: any[] = require('../../../../../assets/resources/skipDisable.json');
@ -197,7 +198,7 @@ export class DatasetProfileEditorComponent extends BaseComponent implements OnIn
error => this.onCallbackErrorNewVersion(error) error => this.onCallbackErrorNewVersion(error)
); );
} else { } else {
this.form.get('status').setValue(0); this.form.get('status').setValue(DatasetStatus.Draft);
data = this.form.value; data = this.form.value;
this.datasetProfileService.createForm(data) this.datasetProfileService.createForm(data)
.pipe(takeUntil(this._destroyed)) .pipe(takeUntil(this._destroyed))

View File

@ -6,6 +6,7 @@ import { DatasetListingModel } from '../../../core/model/dataset/dataset-listing
import { AuthService } from '../../../core/services/auth/auth.service'; import { AuthService } from '../../../core/services/auth/auth.service';
import { RecentActivityType } from '../../../core/common/enum/recent-activity-type'; import { RecentActivityType } from '../../../core/common/enum/recent-activity-type';
import { Router} from '@angular/router'; import { Router} from '@angular/router';
import { DmpStatus } from '../../../core/common/enum/dmp-status';
@Component({ @Component({
selector: 'app-drafts', selector: 'app-drafts',
@ -28,7 +29,7 @@ export class DraftsComponent implements OnInit {
const fields: Array<string> = []; const fields: Array<string> = [];
const dmpDataTableRequest: DataTableRequest<DatasetCriteria> = new DataTableRequest(0, 2, { fields: fields }); const dmpDataTableRequest: DataTableRequest<DatasetCriteria> = new DataTableRequest(0, 2, { fields: fields });
dmpDataTableRequest.criteria = new DatasetCriteria(); dmpDataTableRequest.criteria = new DatasetCriteria();
dmpDataTableRequest.criteria.status = 0; dmpDataTableRequest.criteria.status = DmpStatus.Draft;
this.datasetService.getPaged(dmpDataTableRequest).subscribe(response => { this.datasetService.getPaged(dmpDataTableRequest).subscribe(response => {
this.datasetDrafts = response.data; this.datasetDrafts = response.data;
}); });

View File

@ -11,8 +11,8 @@ import { takeUntil } from 'rxjs/operators';
import { BreadcrumbItem } from '../misc/breadcrumb/definition/breadcrumb-item'; import { BreadcrumbItem } from '../misc/breadcrumb/definition/breadcrumb-item';
import { SnackBarNotificationLevel, UiNotificationService } from '../../core/services/notification/ui-notification-service'; import { SnackBarNotificationLevel, UiNotificationService } from '../../core/services/notification/ui-notification-service';
import { TranslateService } from '@ngx-translate/core'; import { TranslateService } from '@ngx-translate/core';
import { ConfirmationDialogComponent } from '../../library/confirmation-dialog/confirmation-dialog.component';
import { DatasetEditorWizardComponent } from '../quick-wizard/dataset-editor/dataset-editor-wizard.component'; import { DatasetEditorWizardComponent } from '../quick-wizard/dataset-editor/dataset-editor-wizard.component';
import { DatasetStatus } from '../../core/common/enum/dataset-status';
@Component({ @Component({
selector: 'dataset-create-wizard.component', selector: 'dataset-create-wizard.component',
@ -59,7 +59,7 @@ export class DatasetCreateWizard extends BaseComponent implements OnInit, IBread
save() { save() {
if (this.formGroup.get('datasets') && this.formGroup.get('datasets').get('datasetsList') && (this.formGroup.get('datasets').get('datasetsList') as FormArray).length > 0) { if (this.formGroup.get('datasets') && this.formGroup.get('datasets').get('datasetsList') && (this.formGroup.get('datasets').get('datasetsList') as FormArray).length > 0) {
for (let control of (this.formGroup.get('datasets').get('datasetsList') as FormArray).controls) { for (let control of (this.formGroup.get('datasets').get('datasetsList') as FormArray).controls) {
control.get('status').setValue('0'); control.get('status').setValue(DatasetStatus.Draft);
} }
// this.onSubmitSave(); // this.onSubmitSave();
const dmpId = this.formGroup.get('dmpMeta').get('dmp').value.id; const dmpId = this.formGroup.get('dmpMeta').get('dmp').value.id;
@ -77,7 +77,7 @@ export class DatasetCreateWizard extends BaseComponent implements OnInit, IBread
if (!this.isFormValid()) { return; } if (!this.isFormValid()) { return; }
if (this.formGroup.get('datasets') && this.formGroup.get('datasets').get('datasetsList') && (this.formGroup.get('datasets').get('datasetsList') as FormArray).length > 0) { if (this.formGroup.get('datasets') && this.formGroup.get('datasets').get('datasetsList') && (this.formGroup.get('datasets').get('datasetsList') as FormArray).length > 0) {
for (let control of (this.formGroup.get('datasets').get('datasetsList') as FormArray).controls) { for (let control of (this.formGroup.get('datasets').get('datasetsList') as FormArray).controls) {
control.get('status').setValue('1'); control.get('status').setValue(DatasetStatus.Finalized);
} }
this.onSubmitSaveAndFinalize(); this.onSubmitSaveAndFinalize();
} else { } else {

View File

@ -152,7 +152,7 @@ export class DatasetWizardComponent extends BaseComponent implements OnInit, IBr
}]); }]);
this.formGroup = this.datasetWizardModel.buildForm(); this.formGroup = this.datasetWizardModel.buildForm();
this.editMode = this.datasetWizardModel.status === DatasetStatus.Draft; this.editMode = this.datasetWizardModel.status === DatasetStatus.Draft;
if (this.datasetWizardModel.status === 1) { if (this.datasetWizardModel.status === DatasetStatus.Finalized) {
this.formGroup.disable(); this.formGroup.disable();
this.viewOnly = true; this.viewOnly = true;
} }
@ -179,7 +179,7 @@ export class DatasetWizardComponent extends BaseComponent implements OnInit, IBr
this.datasetWizardModel.dmp = data; this.datasetWizardModel.dmp = data;
this.formGroup = this.datasetWizardModel.buildForm(); this.formGroup = this.datasetWizardModel.buildForm();
this.editMode = this.datasetWizardModel.status === DatasetStatus.Draft; this.editMode = this.datasetWizardModel.status === DatasetStatus.Draft;
if (this.datasetWizardModel.status === 1) { if (this.datasetWizardModel.status === DatasetStatus.Finalized) {
this.formGroup.disable(); this.formGroup.disable();
this.viewOnly = true; this.viewOnly = true;
} }
@ -251,7 +251,7 @@ export class DatasetWizardComponent extends BaseComponent implements OnInit, IBr
}); });
}); });
this.editMode = this.datasetWizardModel.status === DatasetStatus.Draft; this.editMode = this.datasetWizardModel.status === DatasetStatus.Draft;
if (this.datasetWizardModel.status === 1) { if (this.datasetWizardModel.status === DatasetStatus.Finalized) {
this.formGroup.disable(); this.formGroup.disable();
this.viewOnly = true; this.viewOnly = true;
} }
@ -272,7 +272,7 @@ export class DatasetWizardComponent extends BaseComponent implements OnInit, IBr
this.datasetWizardModel = new DatasetWizardEditorModel().fromModel(data); this.datasetWizardModel = new DatasetWizardEditorModel().fromModel(data);
this.formGroup = this.datasetWizardModel.buildForm(); this.formGroup = this.datasetWizardModel.buildForm();
this.editMode = this.datasetWizardModel.status === DatasetStatus.Draft; this.editMode = this.datasetWizardModel.status === DatasetStatus.Draft;
if (this.datasetWizardModel.status === 1) { if (this.datasetWizardModel.status === DatasetStatus.Finalized) {
this.formGroup.disable(); this.formGroup.disable();
this.viewOnly = true; this.viewOnly = true;
} }
@ -311,7 +311,7 @@ export class DatasetWizardComponent extends BaseComponent implements OnInit, IBr
}]); }]);
this.formGroup = this.datasetWizardModel.buildForm(); this.formGroup = this.datasetWizardModel.buildForm();
this.editMode = this.datasetWizardModel.status === DatasetStatus.Draft; this.editMode = this.datasetWizardModel.status === DatasetStatus.Draft;
if (this.datasetWizardModel.status === 1) { if (this.datasetWizardModel.status === DatasetStatus.Finalized) {
this.formGroup.disable(); this.formGroup.disable();
this.viewOnly = true; this.viewOnly = true;
} }
@ -322,7 +322,7 @@ export class DatasetWizardComponent extends BaseComponent implements OnInit, IBr
this.datasetWizardModel = new DatasetWizardEditorModel(); this.datasetWizardModel = new DatasetWizardEditorModel();
this.formGroup = this.datasetWizardModel.buildForm(); this.formGroup = this.datasetWizardModel.buildForm();
this.editMode = this.datasetWizardModel.status === DatasetStatus.Draft; this.editMode = this.datasetWizardModel.status === DatasetStatus.Draft;
if (this.datasetWizardModel.status === 1) { if (this.datasetWizardModel.status === DatasetStatus.Finalized) {
this.formGroup.disable(); this.formGroup.disable();
this.viewOnly = true; this.viewOnly = true;
} }
@ -449,13 +449,13 @@ export class DatasetWizardComponent extends BaseComponent implements OnInit, IBr
save() { save() {
//if (!this.isFormValid()) { return; } //if (!this.isFormValid()) { return; }
this.formGroup.get('status').setValue('0'); this.formGroup.get('status').setValue(DatasetStatus.Draft);
this.submit(); this.submit();
} }
saveFinalize() { saveFinalize() {
if (!this.isFormValid()) { return; } if (!this.isFormValid()) { return; }
this.formGroup.get('status').setValue('1'); this.formGroup.get('status').setValue(DatasetStatus.Finalized);
this.submit(); this.submit();
} }
@ -626,7 +626,7 @@ export class DatasetWizardComponent extends BaseComponent implements OnInit, IBr
} }
needsUpdate() { needsUpdate() {
if (this.datasetWizardModel.isProfileLatestVersion || (this.datasetWizardModel.status === 1) if (this.datasetWizardModel.isProfileLatestVersion || (this.datasetWizardModel.status === DatasetStatus.Finalized)
|| (this.datasetWizardModel.isProfileLatestVersion == undefined && this.datasetWizardModel.status == undefined)) { || (this.datasetWizardModel.isProfileLatestVersion == undefined && this.datasetWizardModel.status == undefined)) {
return false; return false;
} }

View File

@ -13,6 +13,7 @@ import { BreadcrumbItem } from '../../misc/breadcrumb/definition/breadcrumb-item
import { IBreadCrumbComponent } from '../../misc/breadcrumb/definition/IBreadCrumbComponent'; import { IBreadCrumbComponent } from '../../misc/breadcrumb/definition/IBreadCrumbComponent';
import { DatasetCriteriaComponent } from './criteria/dataset-criteria.component'; import { DatasetCriteriaComponent } from './criteria/dataset-criteria.component';
import { TranslateService } from '@ngx-translate/core'; import { TranslateService } from '@ngx-translate/core';
import { DatasetStatus } from '../../../core/common/enum/dataset-status';
@Component({ @Component({
selector: 'app-dataset-listing-component', selector: 'app-dataset-listing-component',
@ -78,7 +79,7 @@ export class DatasetListingComponent extends BaseComponent implements OnInit, IB
}]); }]);
} }
if (this.status != null && this.status == 0) { if (this.status != null && this.status == DatasetStatus.Draft) {
this.criteria.setCriteria(this.getDraftCriteria()); this.criteria.setCriteria(this.getDraftCriteria());
this.refresh(); this.refresh();
this.criteria.setRefreshCallback((resetPages) => this.refresh(resetPages)); this.criteria.setRefreshCallback((resetPages) => this.refresh(resetPages));
@ -147,7 +148,7 @@ export class DatasetListingComponent extends BaseComponent implements OnInit, IB
getDraftCriteria(): DatasetCriteria { getDraftCriteria(): DatasetCriteria {
const draftCriteria = new DatasetCriteria(); const draftCriteria = new DatasetCriteria();
draftCriteria.status = 0; draftCriteria.status = DatasetStatus.Draft;
return draftCriteria; return draftCriteria;
} }

View File

@ -1,6 +1,7 @@
import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core'; import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core';
import { DatasetListingModel } from '../../../../core/model/dataset/dataset-listing'; import { DatasetListingModel } from '../../../../core/model/dataset/dataset-listing';
import { Router } from '@angular/router'; import { Router } from '@angular/router';
import { DatasetStatus } from '../../../../core/common/enum/dataset-status';
@Component({ @Component({
selector: 'app-dataset-listing-item-component', selector: 'app-dataset-listing-item-component',
@ -18,7 +19,7 @@ export class DatasetListingItemComponent implements OnInit {
constructor(private router: Router) { } constructor(private router: Router) { }
ngOnInit() { ngOnInit() {
if (this.dataset.status == 0) { this.isDraft = true } if (this.dataset.status == DatasetStatus.Draft) { this.isDraft = true }
else { this.isDraft = false } else { this.isDraft = false }
} }

View File

@ -2,6 +2,7 @@ import { Component, OnInit, Input } from '@angular/core';
import { DmpEditorModel } from '../dmp-editor.model'; import { DmpEditorModel } from '../dmp-editor.model';
import { Router } from '@angular/router'; import { Router } from '@angular/router';
import { DatasetOverviewModel } from '../../../../core/model/dataset/dataset-overview'; import { DatasetOverviewModel } from '../../../../core/model/dataset/dataset-overview';
import { DatasetStatus } from '../../../../core/common/enum/dataset-status';
@Component({ @Component({
selector: 'app-datasets-tab', selector: 'app-datasets-tab',
@ -29,7 +30,7 @@ export class DatasetsTabComponent implements OnInit {
} }
isDraft(dataset: DatasetOverviewModel) { isDraft(dataset: DatasetOverviewModel) {
if (dataset.status == 0) { return true } if (dataset.status == DatasetStatus.Draft) { return true }
else { return false } else { return false }
} }

View File

@ -122,7 +122,7 @@ export class DmpFinalizeDialogComponent extends BaseComponent implements OnInit
} }
isDraft(dataset: DatasetOverviewModel) { isDraft(dataset: DatasetOverviewModel) {
if (dataset.status == 0) { return true } if (dataset.status == DatasetStatus.Draft) { return true }
else { return false } else { return false }
} }

View File

@ -14,6 +14,7 @@ import { DataTableRequest } from '../../../../core/model/data-table/data-table-r
import { AuthService } from '../../../../core/services/auth/auth.service'; import { AuthService } from '../../../../core/services/auth/auth.service';
import { Principal } from '../../../../core/model/auth/Principal'; import { Principal } from '../../../../core/model/auth/Principal';
import { TranslateService } from '@ngx-translate/core'; import { TranslateService } from '@ngx-translate/core';
import { DmpStatus } from '../../../../core/common/enum/dmp-status';
@Component({ @Component({
selector: 'app-dmp-listing-item-component', selector: 'app-dmp-listing-item-component',
@ -37,7 +38,7 @@ export class DmpListingItemComponent implements OnInit {
private translate: TranslateService) { } private translate: TranslateService) { }
ngOnInit() { ngOnInit() {
if (this.dmp.status == 0) { this.isDraft = true } if (this.dmp.status == DmpStatus.Draft) { this.isDraft = true }
else { this.isDraft = false } else { this.isDraft = false }
} }

View File

@ -16,6 +16,7 @@ import * as FileSaver from 'file-saver';
import { ExportMethodDialogComponent } from '../../../library/export-method-dialog/export-method-dialog.component'; import { ExportMethodDialogComponent } from '../../../library/export-method-dialog/export-method-dialog.component';
import { Observable } from 'rxjs'; import { Observable } from 'rxjs';
import { BreadcrumbItem } from '../../misc/breadcrumb/definition/breadcrumb-item'; import { BreadcrumbItem } from '../../misc/breadcrumb/definition/breadcrumb-item';
import { DatasetStatus } from '../../../core/common/enum/dataset-status';
@Component({ @Component({
selector: 'app-dmp-overview', selector: 'app-dmp-overview',
@ -241,7 +242,7 @@ export class DmpOverviewComponent extends BaseComponent implements OnInit {
} }
isDraft(dataset: DatasetOverviewModel) { isDraft(dataset: DatasetOverviewModel) {
if (dataset.status == 0) { return true } if (dataset.status == DatasetStatus.Draft) { return true }
else { return false } else { return false }
} }
} }

View File

@ -1,5 +1,6 @@
import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core'; import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core';
import { DatasetListingModel } from '../../../core/model/dataset/dataset-listing'; import { DatasetListingModel } from '../../../core/model/dataset/dataset-listing';
import { DatasetStatus } from '../../../core/common/enum/dataset-status';
@Component({ @Component({
selector: 'app-explore-dataset-listing-item-component', selector: 'app-explore-dataset-listing-item-component',
@ -17,7 +18,7 @@ export class ExploreDatasetListingItemComponent implements OnInit {
constructor() { } constructor() { }
ngOnInit() { ngOnInit() {
if (this.dataset.status == 0) { this.isDraft = true } if (this.dataset.status == DatasetStatus.Draft) { this.isDraft = true }
else { this.isDraft = false } else { this.isDraft = false }
} }

View File

@ -17,6 +17,7 @@ import { DatasetEditorWizardComponent } from '../dataset-editor/dataset-editor-w
import { ConfirmationDialogComponent } from '../../../library/confirmation-dialog/confirmation-dialog.component'; import { ConfirmationDialogComponent } from '../../../library/confirmation-dialog/confirmation-dialog.component';
import { DmpFinalizeDialogComponent } from '../../dmp/editor/dmp-finalize-dialog/dmp-finalize-dialog.component'; import { DmpFinalizeDialogComponent } from '../../dmp/editor/dmp-finalize-dialog/dmp-finalize-dialog.component';
import { DmpStatus } from '../../../core/common/enum/dmp-status'; import { DmpStatus } from '../../../core/common/enum/dmp-status';
import { DatasetStatus } from '../../../core/common/enum/dataset-status';
@Component({ @Component({
@ -71,7 +72,7 @@ export class QuickWizardEditorComponent extends BaseComponent implements OnInit,
this.touchAllFormFields(this.formGroup); this.touchAllFormFields(this.formGroup);
if (this.formGroup.get('datasets') && this.formGroup.get('datasets').get('datasetsList') && (this.formGroup.get('datasets').get('datasetsList') as FormArray).length > 0) { if (this.formGroup.get('datasets') && this.formGroup.get('datasets').get('datasetsList') && (this.formGroup.get('datasets').get('datasetsList') as FormArray).length > 0) {
for (let control of (this.formGroup.get('datasets').get('datasetsList') as FormArray).controls) { for (let control of (this.formGroup.get('datasets').get('datasetsList') as FormArray).controls) {
control.get('status').setValue('0'); control.get('status').setValue(DatasetStatus.Draft);
} }
this.onSubmitSave(); this.onSubmitSave();
} else { } else {
@ -92,7 +93,7 @@ export class QuickWizardEditorComponent extends BaseComponent implements OnInit,
if (!this.isFormValid()) { return; } if (!this.isFormValid()) { return; }
if (this.formGroup.get('datasets') && this.formGroup.get('datasets').get('datasetsList') && (this.formGroup.get('datasets').get('datasetsList') as FormArray).length > 0) { if (this.formGroup.get('datasets') && this.formGroup.get('datasets').get('datasetsList') && (this.formGroup.get('datasets').get('datasetsList') as FormArray).length > 0) {
for (let control of (this.formGroup.get('datasets').get('datasetsList') as FormArray).controls) { for (let control of (this.formGroup.get('datasets').get('datasetsList') as FormArray).controls) {
control.get('status').setValue(DmpStatus.Finalized); control.get('status').setValue(DatasetStatus.Finalized);
} }
this.formGroup.get('dmp').get('status').setValue(DmpStatus.Finalized); this.formGroup.get('dmp').get('status').setValue(DmpStatus.Finalized);
this.onSubminSaveAndFinalize(); this.onSubminSaveAndFinalize();