Makes the "Add new Dataset" button on Quick Wizard to not be seen when in edit mode.

This commit is contained in:
Diamantis Tziotzios 2019-03-26 17:52:21 +02:00
parent b76d7dd5b8
commit 0432aed3cb
2 changed files with 86 additions and 88 deletions

View File

@ -4,12 +4,12 @@
</div>
<div class="col-auto">
<mat-button-toggle-group [ngModel]="_inputValue">
<mat-button-toggle value="list" (change)="onValChange($event.value)" matTooltip="Dataset List">
<mat-icon>format_align_left</mat-icon>
</mat-button-toggle>
<mat-button-toggle value="add" (change)="onValChange($event.value)" matTooltip="Add Dataset">
<mat-button-toggle value="add" *ngIf="listingMode()" (change)="onValChange($event.value)" matTooltip="{{'QUICKWIZARD.CREATE-ADD.CREATE.QUICKWIZARD_CREATE.THIRD-STEP.ADD-BUTTON-TOOLTIP' | translate}}">
<mat-icon>add</mat-icon>
</mat-button-toggle>
<mat-button-toggle value="list" (change)="onValChange($event.value)" matTooltip="{{'QUICKWIZARD.CREATE-ADD.CREATE.QUICKWIZARD_CREATE.THIRD-STEP.LIST-BUTTON-TOOLTIP' | translate}}">
<mat-icon>format_align_left</mat-icon>
</mat-button-toggle>
</mat-button-toggle-group>
</div>
<div class="col-12">
@ -43,9 +43,12 @@
<div *ngIf="toggleButton === 2 && editedDataset" class="col-12">
<div class="row">
<mat-form-field class="col-md-12">
<input matInput placeholder="{{'QUICKWIZARD.CREATE-ADD.CREATE.QUICKWIZARD_CREATE.THIRD-STEP.DATASET-LABEL' | translate}}" type="string" name="datasetLabel" [formControl]="this.formGroup.get('datasets').get('datasetsList')['controls'][lastIndexOfDataset].get('datasetLabel')" required>
<input matInput placeholder="{{'QUICKWIZARD.CREATE-ADD.CREATE.QUICKWIZARD_CREATE.THIRD-STEP.DATASET-LABEL' | translate}}"
type="string" name="datasetLabel" [formControl]="this.formGroup.get('datasets').get('datasetsList')['controls'][lastIndexOfDataset].get('datasetLabel')"
required>
</mat-form-field>
<app-dataset-description-form class="col-12" [form]="this.formGroup.get('datasets').get('datasetsList')['controls'][lastIndexOfDataset]" [visibilityRules]="this.datasetProfileDefinition.rules" [datasetProfileId]="datasetProfile.value.id">
<app-dataset-description-form class="col-12" [form]="this.formGroup.get('datasets').get('datasetsList')['controls'][lastIndexOfDataset]"
[visibilityRules]="this.datasetProfileDefinition.rules" [datasetProfileId]="datasetProfile.value.id">
</app-dataset-description-form>
</div>
</div>

View File

@ -13,97 +13,92 @@ import { QuickWizardDatasetDescriptionModel } from "./quick-wizard-dataset-descr
import { IfStmt } from "@angular/compiler";
import { TranslateService } from "@ngx-translate/core";
@Component({
selector: 'app-dataset-editor-wizard-component',
templateUrl: 'dataset-editor-wizard.component.html',
styleUrls: ['./dataset-editor-wizard.component.scss']
selector: 'app-dataset-editor-wizard-component',
templateUrl: 'dataset-editor-wizard.component.html',
styleUrls: ['./dataset-editor-wizard.component.scss']
})
export class DatasetEditorWizardComponent extends BaseComponent implements OnInit, IBreadCrumbComponent {
breadCrumbs: Observable<BreadcrumbItem[]>;
breadCrumbs: Observable<BreadcrumbItem[]>;
@Input() formGroup: FormGroup;
@Input() datasetProfile: FormGroup;// DatasetProfileModel;
@Input() datasetLabel: string;
editedDataset: boolean = false;
dataset: DatasetDescriptionFormEditorModel;
public datasetProfileDefinition: DatasetDescriptionFormEditorModel;
public lastIndexOfDataset = 0;
public toggleButton = 0;
public _inputValue: string;
@Input() formGroup: FormGroup;
@Input() datasetProfile: FormGroup;// DatasetProfileModel;
@Input() datasetLabel: string;
editedDataset: boolean = false;
dataset: DatasetDescriptionFormEditorModel;
public datasetProfileDefinition: DatasetDescriptionFormEditorModel;
public lastIndexOfDataset = 0;
public toggleButton = 0;
public _inputValue: string;
constructor(
private datasetWizardService: DatasetWizardService,
public language: TranslateService,
) {
super();
}
constructor(
private datasetWizardService: DatasetWizardService,
public language: TranslateService,
) {
super();
}
ngOnInit(): void {
this.datasetWizardService.getDefinition(this.datasetProfile.value["id"])
.pipe(takeUntil(this._destroyed))
.subscribe(item => {
this.datasetProfileDefinition = new DatasetDescriptionFormEditorModel().fromModel(item);
this.onValChange("list");
const length = (this.formGroup.get('datasets').get('datasetsList') as FormArray).length;
if (length == 0) {
this.lastIndexOfDataset = length;
this.addDataset();
this.onValChange("dataset");
}
});
}
ngOnInit(): void {
this.datasetWizardService.getDefinition(this.datasetProfile.value["id"])
.pipe(takeUntil(this._destroyed))
.subscribe(item => {
this.datasetProfileDefinition = new DatasetDescriptionFormEditorModel().fromModel(item);
this.onValChange("list");
const length = (this.formGroup.get('datasets').get('datasetsList') as FormArray).length;
if (length == 0) {
this.lastIndexOfDataset = length;
this.addDataset();
this.onValChange("dataset");
}
});
}
onValChange(event: any) {
if (event == "list") {
this.toggleButton = 0;
this.editedDataset = false;
this._inputValue = "list";
} else if (event == "add") {
this.addDataset();
this.toggleButton = 2;
this._inputValue = "dataset";
} else if (event == "dataset") {
this.toggleButton = 2;
this._inputValue = "dataset";
}
}
onValChange(event: any) {
if (event == "list") {
this.toggleButton = 0;
this.editedDataset = false;
this._inputValue = "list";
} else if (event == "add") {
this.addDataset();
this.toggleButton = 2;
this._inputValue = "dataset";
} else if (event == "dataset") {
this.toggleButton = 2;
this._inputValue = "dataset";
}
editDataset(index: number) {
this.lastIndexOfDataset = index;
this.toggleButton = 2;
this.editedDataset = true;
this._inputValue = "dataset"
}
}
editDataset(index: number) {
this.lastIndexOfDataset = index;
this.toggleButton = 2;
this.editedDataset = true;
this._inputValue = "dataset"
}
deleteDataset(index: number) {//TODO: delete Dataset From List
this.lastIndexOfDataset = index;
this.toggleButton = 0;
this.editedDataset = false;
this._inputValue = "list";
(this.formGroup.get('datasets').get('datasetsList') as FormArray).removeAt(index);
}
deleteDataset(index: number) {//TODO: delete Dataset From List
this.lastIndexOfDataset = index;
this.toggleButton = 0;
this.editedDataset = false;
this._inputValue = "list";
(this.formGroup.get('datasets').get('datasetsList') as FormArray).removeAt(index);
}
addDataset() {
const formArray: FormArray = (this.formGroup.get('datasets').get('datasetsList') as FormArray);
let dataset = new QuickWizardDatasetDescriptionModel().fromModel(this.datasetProfileDefinition);
let formGroup = dataset.buildForm();
addDataset() {
const formArray: FormArray = (this.formGroup.get('datasets').get('datasetsList') as FormArray);
let dataset = new QuickWizardDatasetDescriptionModel().fromModel(this.datasetProfileDefinition);
let formGroup = dataset.buildForm();
formGroup.get('datasetLabel').setValue(
this.language.instant('QUICKWIZARD.CREATE-ADD.CREATE.QUICKWIZARD_CREATE.THIRD-STEP.DATASET-NAME') +
this.datasetProfile.value["label"] +
this.language.instant('QUICKWIZARD.CREATE-ADD.CREATE.QUICKWIZARD_CREATE.THIRD-STEP.DATASET-NAME-FOR') +
this.datasetLabel);
formArray.push(formGroup);
this.lastIndexOfDataset = formArray.length - 1;
this.editedDataset = true;
}
formGroup.get('datasetLabel').setValue(
this.language.instant('QUICKWIZARD.CREATE-ADD.CREATE.QUICKWIZARD_CREATE.THIRD-STEP.DATASET-NAME') +
this.datasetProfile.value["label"] +
this.language.instant('QUICKWIZARD.CREATE-ADD.CREATE.QUICKWIZARD_CREATE.THIRD-STEP.DATASET-NAME-FOR') +
this.datasetLabel);
formArray.push(formGroup);
this.lastIndexOfDataset = formArray.length - 1;
this.editedDataset = true;
}
}
listingMode() {
if (this.toggleButton === 0) return true;
}
}