Adds Save and Finalize functionality on QuickWizard. Fixes Save on QuickWizard so one can save even if form is invalid.
This commit is contained in:
parent
e90d23ae54
commit
3d3eff8a65
|
@ -59,8 +59,10 @@
|
|||
<div class="navigation-buttons-container">
|
||||
<button matStepperPrevious mat-raised-button
|
||||
color="primary">{{'QUICKWIZARD.CREATE-ADD.CREATE.QUICKWIZARD_CREATE.ACTIONS.BACK' | translate}}</button>
|
||||
<button style="float:right;" matStepperNext mat-raised-button (click)='formSubmit()'
|
||||
color="primary">{{'QUICKWIZARD.CREATE-ADD.CREATE.QUICKWIZARD_CREATE.ACTIONS.SAVE' | translate}}</button>
|
||||
<button class="saveAndFinalizeButton" matStepperNext mat-raised-button (click)='saveFinalize()' [disabled]="!formGroup.valid"
|
||||
color="primary">{{'QUICKWIZARD.CREATE-ADD.CREATE.QUICKWIZARD_CREATE.ACTIONS.SAVE-AND-FINALIZE' | translate}}</button>
|
||||
<button class="saveButton" matStepperNext mat-raised-button (click)='formSubmit()'
|
||||
color="primary">{{'QUICKWIZARD.CREATE-ADD.CREATE.QUICKWIZARD_CREATE.ACTIONS.SAVE' | translate}}</button>
|
||||
</div>
|
||||
</ng-container>
|
||||
</mat-step>
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
.saveAndFinalizeButton{
|
||||
float:right;
|
||||
}
|
||||
.saveButton{
|
||||
float:right;
|
||||
margin-right: 15px;
|
||||
}
|
|
@ -15,7 +15,6 @@ import { ProjectEditorWizardModel } from '../project-editor/project-editor-wizar
|
|||
import { QuickWizardEditorWizardModel } from './quick-wizard-editor.model';
|
||||
|
||||
|
||||
|
||||
@Component({
|
||||
selector: 'app-quick-wizard-editor-component',
|
||||
templateUrl: 'quick-wizard-editor.component.html',
|
||||
|
@ -24,15 +23,10 @@ import { QuickWizardEditorWizardModel } from './quick-wizard-editor.model';
|
|||
export class QuickWizardEditorComponent extends BaseComponent implements OnInit, IBreadCrumbComponent {
|
||||
|
||||
breadCrumbs: Observable<BreadcrumbItem[]> = Observable.of([]);
|
||||
|
||||
@ViewChild('stepper') stepper: MatStepper;
|
||||
isNew = true;
|
||||
|
||||
quickWizard: QuickWizardEditorWizardModel
|
||||
formGroup: FormGroup = null;
|
||||
firstStepFormGroup: FormGroup;
|
||||
secondFormGroup: FormGroup;
|
||||
|
||||
|
||||
constructor(
|
||||
public snackBar: MatSnackBar,
|
||||
|
@ -72,13 +66,18 @@ export class QuickWizardEditorComponent extends BaseComponent implements OnInit,
|
|||
|
||||
formSubmit(): void {
|
||||
this.touchAllFormFields(this.formGroup);
|
||||
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) {
|
||||
this.onSubmit();
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
saveFinalize() {
|
||||
if (!this.isFormValid()) { return; }
|
||||
this.formGroup.get('status').setValue('1');
|
||||
this.onSubmit();
|
||||
}
|
||||
|
||||
public isFormValid() {
|
||||
return this.formGroup.valid;
|
||||
|
@ -100,7 +99,6 @@ export class QuickWizardEditorComponent extends BaseComponent implements OnInit,
|
|||
}
|
||||
|
||||
onSubmit(): void {
|
||||
if (!this.isFormValid()) { return; }
|
||||
this.quickWizardService.createQuickWizard(this.formGroup.getRawValue())
|
||||
.pipe(takeUntil(this._destroyed))
|
||||
.subscribe(
|
||||
|
@ -109,7 +107,6 @@ export class QuickWizardEditorComponent extends BaseComponent implements OnInit,
|
|||
);
|
||||
}
|
||||
|
||||
|
||||
onCallbackSuccess(): void {
|
||||
this.uiNotificationService.snackBarNotification(this.isNew ? this.language.instant('GENERAL.SNACK-BAR.SUCCESSFUL-CREATION') : this.language.instant('GENERAL.SNACK-BAR.SUCCESSFUL-UPDATE'), SnackBarNotificationLevel.Success);
|
||||
this.router.navigate(['/home']);
|
||||
|
@ -148,9 +145,4 @@ export class QuickWizardEditorComponent extends BaseComponent implements OnInit,
|
|||
return this.formGroup.get('project').get('label').value;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -680,6 +680,7 @@
|
|||
"ACTIONS": {
|
||||
"DELETE": "Delete",
|
||||
"SAVE": "Save",
|
||||
"SAVE-AND-FINALIZE":"Save and Finalize",
|
||||
"NEXT": "Next",
|
||||
"BACK": "Back",
|
||||
"CREATE-NEW":"Create new",
|
||||
|
|
Loading…
Reference in New Issue