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,12 +59,14 @@
|
||||||
<div class="navigation-buttons-container">
|
<div class="navigation-buttons-container">
|
||||||
<button matStepperPrevious mat-raised-button
|
<button matStepperPrevious mat-raised-button
|
||||||
color="primary">{{'QUICKWIZARD.CREATE-ADD.CREATE.QUICKWIZARD_CREATE.ACTIONS.BACK' | translate}}</button>
|
color="primary">{{'QUICKWIZARD.CREATE-ADD.CREATE.QUICKWIZARD_CREATE.ACTIONS.BACK' | translate}}</button>
|
||||||
<button style="float:right;" matStepperNext mat-raised-button (click)='formSubmit()'
|
<button class="saveAndFinalizeButton" matStepperNext mat-raised-button (click)='saveFinalize()' [disabled]="!formGroup.valid"
|
||||||
color="primary">{{'QUICKWIZARD.CREATE-ADD.CREATE.QUICKWIZARD_CREATE.ACTIONS.SAVE' | translate}}</button>
|
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>
|
</div>
|
||||||
</ng-container>
|
</ng-container>
|
||||||
</mat-step>
|
</mat-step>
|
||||||
</mat-horizontal-stepper>
|
</mat-horizontal-stepper>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -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';
|
import { QuickWizardEditorWizardModel } from './quick-wizard-editor.model';
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-quick-wizard-editor-component',
|
selector: 'app-quick-wizard-editor-component',
|
||||||
templateUrl: 'quick-wizard-editor.component.html',
|
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 {
|
export class QuickWizardEditorComponent extends BaseComponent implements OnInit, IBreadCrumbComponent {
|
||||||
|
|
||||||
breadCrumbs: Observable<BreadcrumbItem[]> = Observable.of([]);
|
breadCrumbs: Observable<BreadcrumbItem[]> = Observable.of([]);
|
||||||
|
|
||||||
@ViewChild('stepper') stepper: MatStepper;
|
@ViewChild('stepper') stepper: MatStepper;
|
||||||
isNew = true;
|
isNew = true;
|
||||||
|
|
||||||
quickWizard: QuickWizardEditorWizardModel
|
quickWizard: QuickWizardEditorWizardModel
|
||||||
formGroup: FormGroup = null;
|
formGroup: FormGroup = null;
|
||||||
firstStepFormGroup: FormGroup;
|
|
||||||
secondFormGroup: FormGroup;
|
|
||||||
|
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
public snackBar: MatSnackBar,
|
public snackBar: MatSnackBar,
|
||||||
|
@ -72,13 +66,18 @@ export class QuickWizardEditorComponent extends BaseComponent implements OnInit,
|
||||||
|
|
||||||
formSubmit(): void {
|
formSubmit(): void {
|
||||||
this.touchAllFormFields(this.formGroup);
|
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) {
|
if (this.formGroup.get('datasets') && this.formGroup.get('datasets').get('datasetsList') && (this.formGroup.get('datasets').get('datasetsList') as FormArray).length > 0) {
|
||||||
this.onSubmit();
|
this.onSubmit();
|
||||||
} else {
|
} else {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
saveFinalize() {
|
||||||
|
if (!this.isFormValid()) { return; }
|
||||||
|
this.formGroup.get('status').setValue('1');
|
||||||
|
this.onSubmit();
|
||||||
|
}
|
||||||
|
|
||||||
public isFormValid() {
|
public isFormValid() {
|
||||||
return this.formGroup.valid;
|
return this.formGroup.valid;
|
||||||
|
@ -100,7 +99,6 @@ export class QuickWizardEditorComponent extends BaseComponent implements OnInit,
|
||||||
}
|
}
|
||||||
|
|
||||||
onSubmit(): void {
|
onSubmit(): void {
|
||||||
if (!this.isFormValid()) { return; }
|
|
||||||
this.quickWizardService.createQuickWizard(this.formGroup.getRawValue())
|
this.quickWizardService.createQuickWizard(this.formGroup.getRawValue())
|
||||||
.pipe(takeUntil(this._destroyed))
|
.pipe(takeUntil(this._destroyed))
|
||||||
.subscribe(
|
.subscribe(
|
||||||
|
@ -109,7 +107,6 @@ export class QuickWizardEditorComponent extends BaseComponent implements OnInit,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
onCallbackSuccess(): void {
|
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.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']);
|
this.router.navigate(['/home']);
|
||||||
|
@ -148,9 +145,4 @@ export class QuickWizardEditorComponent extends BaseComponent implements OnInit,
|
||||||
return this.formGroup.get('project').get('label').value;
|
return this.formGroup.get('project').get('label').value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -680,6 +680,7 @@
|
||||||
"ACTIONS": {
|
"ACTIONS": {
|
||||||
"DELETE": "Delete",
|
"DELETE": "Delete",
|
||||||
"SAVE": "Save",
|
"SAVE": "Save",
|
||||||
|
"SAVE-AND-FINALIZE":"Save and Finalize",
|
||||||
"NEXT": "Next",
|
"NEXT": "Next",
|
||||||
"BACK": "Back",
|
"BACK": "Back",
|
||||||
"CREATE-NEW":"Create new",
|
"CREATE-NEW":"Create new",
|
||||||
|
|
Loading…
Reference in New Issue