no message
This commit is contained in:
parent
57f7b672aa
commit
173345ed17
|
@ -1,3 +1,5 @@
|
||||||
|
import { TranslateService } from '@ngx-translate/core';
|
||||||
|
import { BaseErrorModel } from '../models/error/BaseErrorModel';
|
||||||
import { ActivatedRoute, Router, Params} from '@angular/router';
|
import { ActivatedRoute, Router, Params} from '@angular/router';
|
||||||
import { DatasetService } from '../services/dataset/dataset.service';
|
import { DatasetService } from '../services/dataset/dataset.service';
|
||||||
import { DatasetWizardModel } from '../models/datasets/DatasetWizardModel';
|
import { DatasetWizardModel } from '../models/datasets/DatasetWizardModel';
|
||||||
|
@ -13,6 +15,8 @@ import { DataManagementPlanModel } from "../models/data-managemnt-plans/DataMana
|
||||||
import { JsonSerializer } from "../utilities/JsonSerializer";
|
import { JsonSerializer } from "../utilities/JsonSerializer";
|
||||||
import { Observable } from "rxjs/Observable";
|
import { Observable } from "rxjs/Observable";
|
||||||
import { RequestItem } from "../models/criteria/RequestItem";
|
import { RequestItem } from "../models/criteria/RequestItem";
|
||||||
|
import { MatPaginator, MatSort, MatSnackBar } from "@angular/material";
|
||||||
|
import { SnackBarNotificationComponent } from "../shared/components/notificaiton/snack-bar-notification.component";
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-dataset-wizard-component',
|
selector: 'app-dataset-wizard-component',
|
||||||
|
@ -33,8 +37,9 @@ export class DatasetWizardComponent implements AfterViewInit {
|
||||||
private formBuilder: FormBuilder,
|
private formBuilder: FormBuilder,
|
||||||
private datasetService: DatasetService,
|
private datasetService: DatasetService,
|
||||||
private route: ActivatedRoute,
|
private route: ActivatedRoute,
|
||||||
|
public snackBar: MatSnackBar,
|
||||||
public router: Router,
|
public router: Router,
|
||||||
|
public language: TranslateService,
|
||||||
) {
|
) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -103,4 +108,43 @@ export class DatasetWizardComponent implements AfterViewInit {
|
||||||
public cancel(): void {
|
public cancel(): void {
|
||||||
//this.router.navigate(['/dataManagementPlans']);
|
//this.router.navigate(['/dataManagementPlans']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
formSubmit(): void {
|
||||||
|
//this.touchAllFormFields(this.formGroup);
|
||||||
|
if (!this.isFormValid()) { return; }
|
||||||
|
this.onSubmit();
|
||||||
|
}
|
||||||
|
|
||||||
|
public isFormValid() {
|
||||||
|
return this.formGroup.valid;
|
||||||
|
}
|
||||||
|
|
||||||
|
onSubmit(): void {
|
||||||
|
this.datasetService.createDataset(this.formGroup.value).subscribe(
|
||||||
|
complete => this.onCallbackSuccess(),
|
||||||
|
error => this.onCallbackError(error)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
onCallbackSuccess(): void {
|
||||||
|
this.snackBar.openFromComponent(SnackBarNotificationComponent, {
|
||||||
|
data: { message: this.isNew ? 'GENERAL.SNACK-BAR.SUCCESSFUL-CREATION' : 'GENERAL.SNACK-BAR.SUCCESSFUL-UPDATE', language: this.language },
|
||||||
|
duration: 3000,
|
||||||
|
extraClasses: ['snackbar-success']
|
||||||
|
})
|
||||||
|
this.router.navigate(['/datasets']);
|
||||||
|
}
|
||||||
|
|
||||||
|
onCallbackError(error: any) {
|
||||||
|
this.setErrorModel(error.error);
|
||||||
|
//this.validateAllFormFields(this.formGroup);
|
||||||
|
}
|
||||||
|
|
||||||
|
public setErrorModel(errorModel: BaseErrorModel) {
|
||||||
|
Object.keys(errorModel).forEach(item => {
|
||||||
|
(<any>this.datasetModel.errorModel)[item] = (<any>errorModel)[item];
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -79,7 +79,7 @@
|
||||||
</td-chips>
|
</td-chips>
|
||||||
|
|
||||||
<td-chips color="accent" [items]="filteredServices" formControlName="services" placeholder="{{'DATASET-EDITOR.FIELDS.SERVICES' | translate}}"
|
<td-chips color="accent" [items]="filteredServices" formControlName="services" placeholder="{{'DATASET-EDITOR.FIELDS.SERVICES' | translate}}"
|
||||||
(inputChange)="filteredServices($event)" requireMatch>
|
(inputChange)="filterServices($event)" requireMatch>
|
||||||
<ng-template td-chip let-chip="chip">
|
<ng-template td-chip let-chip="chip">
|
||||||
<div class="tc-grey-100 bgc-teal-700" td-chip-avatar>{{chip.label.substring(0, 1).toUpperCase()}}</div>
|
<div class="tc-grey-100 bgc-teal-700" td-chip-avatar>{{chip.label.substring(0, 1).toUpperCase()}}</div>
|
||||||
{{chip.name}}
|
{{chip.name}}
|
||||||
|
@ -92,12 +92,6 @@
|
||||||
<mat-progress-bar [style.height.px]="2" *ngIf="filteringResearchersAsync" mode="indeterminate"></mat-progress-bar>
|
<mat-progress-bar [style.height.px]="2" *ngIf="filteringResearchersAsync" mode="indeterminate"></mat-progress-bar>
|
||||||
</td-chips>
|
</td-chips>
|
||||||
|
|
||||||
<div layout="row" class="full-width text-right" align="end">
|
|
||||||
<button mat-raised-button color="primary" (click)="cancel()" type="button">{{'DATASET-EDITOR.ACTIONS.CANCEL' | translate}}</button>
|
|
||||||
<button mat-raised-button color="primary" type="submit">{{'DATASET-EDITOR.ACTIONS.SAVE' | translate}}</button>
|
|
||||||
<button *ngIf="!isNew" mat-raised-button color="primary" type="submit" (click)="delete()">{{'DATASET-EDITOR.ACTIONS.DELETE' | translate}}</button>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</mat-card-content>
|
</mat-card-content>
|
||||||
</mat-card>
|
</mat-card>
|
||||||
</form>
|
</form>
|
||||||
|
|
|
@ -67,42 +67,6 @@ export class DatasetEditorComponent implements AfterViewInit {
|
||||||
}); */
|
}); */
|
||||||
}
|
}
|
||||||
|
|
||||||
formSubmit(): void {
|
|
||||||
//this.touchAllFormFields(this.formGroup);
|
|
||||||
if (!this.isFormValid()) { return; }
|
|
||||||
//this.onSubmit();
|
|
||||||
}
|
|
||||||
|
|
||||||
public isFormValid() {
|
|
||||||
return this.formGroup.valid;
|
|
||||||
}
|
|
||||||
|
|
||||||
onSubmit(): void {
|
|
||||||
this.datasetService.createDataset(this.formGroup.value).subscribe(
|
|
||||||
complete => this.onCallbackSuccess(),
|
|
||||||
error => this.onCallbackError(error)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
onCallbackSuccess(): void {
|
|
||||||
this.snackBar.openFromComponent(SnackBarNotificationComponent, {
|
|
||||||
data: { message: this.isNew ? 'GENERAL.SNACK-BAR.SUCCESSFUL-CREATION' : 'GENERAL.SNACK-BAR.SUCCESSFUL-UPDATE', language: this.language },
|
|
||||||
duration: 3000,
|
|
||||||
extraClasses: ['snackbar-success']
|
|
||||||
})
|
|
||||||
this.router.navigate(['/datasets']);
|
|
||||||
}
|
|
||||||
|
|
||||||
onCallbackError(error: any) {
|
|
||||||
this.setErrorModel(error.error);
|
|
||||||
//this.validateAllFormFields(this.formGroup);
|
|
||||||
}
|
|
||||||
|
|
||||||
public setErrorModel(errorModel: BaseErrorModel) {
|
|
||||||
Object.keys(errorModel).forEach(item => {
|
|
||||||
(<any>this.dataset.errorModel)[item] = (<any>errorModel)[item];
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
public cancel(): void {
|
public cancel(): void {
|
||||||
this.router.navigate(['/datasets']);
|
this.router.navigate(['/datasets']);
|
||||||
|
@ -150,7 +114,7 @@ export class DatasetEditorComponent implements AfterViewInit {
|
||||||
if (value) {
|
if (value) {
|
||||||
this.filteredServicesAsync = true;
|
this.filteredServicesAsync = true;
|
||||||
|
|
||||||
this.externalSourcesService.searchDMPResearchers(value).subscribe(items => {
|
this.externalSourcesService.searchDatasetService(value).subscribe(items => {
|
||||||
this.filteredServices = items;
|
this.filteredServices = items;
|
||||||
this.filteredServicesAsync = false;
|
this.filteredServicesAsync = false;
|
||||||
|
|
||||||
|
|
|
@ -63,11 +63,11 @@ export class DatasetWizardModel implements Serializable<DatasetWizardModel> {
|
||||||
baseContext.validation.push({ key: 'label', validators: [Validators.required, BackendErrorValidator(this.errorModel, 'label')] });
|
baseContext.validation.push({ key: 'label', validators: [Validators.required, BackendErrorValidator(this.errorModel, 'label')] });
|
||||||
baseContext.validation.push({ key: 'profile', validators: [Validators.required, BackendErrorValidator(this.errorModel, 'profile')] });
|
baseContext.validation.push({ key: 'profile', validators: [Validators.required, BackendErrorValidator(this.errorModel, 'profile')] });
|
||||||
baseContext.validation.push({ key: 'uri', validators: [Validators.required, BackendErrorValidator(this.errorModel, 'uri')] });
|
baseContext.validation.push({ key: 'uri', validators: [Validators.required, BackendErrorValidator(this.errorModel, 'uri')] });
|
||||||
baseContext.validation.push({ key: 'status', validators: [Validators.required, BackendErrorValidator(this.errorModel, 'status')] });
|
baseContext.validation.push({ key: 'status', validators: [ BackendErrorValidator(this.errorModel, 'status')] });
|
||||||
baseContext.validation.push({ key: 'description', validators: [Validators.required, BackendErrorValidator(this.errorModel, 'description')] });
|
baseContext.validation.push({ key: 'description', validators: [Validators.required, BackendErrorValidator(this.errorModel, 'description')] });
|
||||||
baseContext.validation.push({ key: 'services', validators: [Validators.required, BackendErrorValidator(this.errorModel, 'services')] });
|
baseContext.validation.push({ key: 'services', validators: [ BackendErrorValidator(this.errorModel, 'services')] });
|
||||||
baseContext.validation.push({ key: 'registries', validators: [Validators.required, BackendErrorValidator(this.errorModel, 'registries')] });
|
baseContext.validation.push({ key: 'registries', validators: [ BackendErrorValidator(this.errorModel, 'registries')] });
|
||||||
baseContext.validation.push({ key: 'dataRepositories', validators: [Validators.required, BackendErrorValidator(this.errorModel, 'dataRepositories')] });
|
baseContext.validation.push({ key: 'dataRepositories', validators: [BackendErrorValidator(this.errorModel, 'dataRepositories')] });
|
||||||
baseContext.validation.push({ key: 'dmp', validators: [BackendErrorValidator(this.errorModel, 'dmp')] }); //TODO
|
baseContext.validation.push({ key: 'dmp', validators: [BackendErrorValidator(this.errorModel, 'dmp')] }); //TODO
|
||||||
return baseContext;
|
return baseContext;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue