Skip to content

Commit 270e159

Browse files
Ticket #109 : Add button in the HumanTask editor
1 parent 24fe9d5 commit 270e159

20 files changed

Lines changed: 275 additions & 38 deletions

src/CaseManagement.Website/angularApp/app/humantasks/humantasks.module.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import { HeaderComponent, HeaderComponentDialog } from './viewdef/rendering/comp
2525
import { PwdComponent, PwdComponentDialog } from './viewdef/rendering/components/pwd/pwd.component';
2626
import { RowComponent, RowComponentDialog } from './viewdef/rendering/components/row/row.component';
2727
import { SelectComponent, SelectComponentDialog } from './viewdef/rendering/components/select/select.component';
28+
import { SubmitBtnComponent, SubmitBtnComponentDialog } from './viewdef/rendering/components/submitbtn/submitbtn.component';
2829
import { TxtComponent, TxtComponentDialog } from './viewdef/rendering/components/txt/txt.component';
2930
import { ViewHumanTaskDefRenderingComponent } from './viewdef/rendering/rendering.component';
3031
import { ViewHumanTaskDef } from './viewdef/view.component';
@@ -59,7 +60,9 @@ import { ViewHumanTaskDef } from './viewdef/view.component';
5960
HeaderComponent,
6061
ContainerComponent,
6162
ConfirmPwdComponent,
62-
ConfirmPwdComponentDialog
63+
ConfirmPwdComponentDialog,
64+
SubmitBtnComponentDialog,
65+
SubmitBtnComponent
6366
],
6467
declarations: [
6568
AddHumanTaskDefDialog,
@@ -97,7 +100,9 @@ import { ViewHumanTaskDef } from './viewdef/view.component';
97100
ContainerComponent,
98101
ConfirmPwdComponent,
99102
ConfirmPwdComponentDialog,
100-
TranslateEnumPipe
103+
TranslateEnumPipe,
104+
SubmitBtnComponentDialog,
105+
SubmitBtnComponent
101106
]
102107
})
103108

src/CaseManagement.Website/angularApp/app/humantasks/viewdef/rendering/components/basetxt-dialog.component.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,18 @@ export abstract class BaseTxtComponentDialog {
1111
@Inject(MAT_DIALOG_DATA) public data: any,
1212
public dialogRef: MatDialogRef<BaseTxtComponentDialog>
1313
) {
14-
this.configureForm = new FormGroup({
14+
const self = this;
15+
self.configureForm = new FormGroup({
1516
name: new FormControl(''),
1617
validationRule: new FormControl('')
1718
});
18-
this.languages.forEach((lng: string) => {
19-
this.configureForm.addControl('label#' + lng, new FormControl(''));
19+
self.languages.forEach((lng: string) => {
20+
self.configureForm.addControl('label#' + lng, new FormControl(''));
2021
});
21-
this.configureForm.get('name').setValue(data.opt.name);
22+
self.configureForm.get('name').setValue(data.opt.name);
2223
if (data.opt.translations) {
2324
data.opt.translations.forEach(function (tr: any) {
24-
this.configureForm.get('label#' + tr.language).setValue(tr.value);
25+
self.configureForm.get('label#' + tr.language).setValue(tr.value);
2526
});
2627
}
2728

src/CaseManagement.Website/angularApp/app/humantasks/viewdef/rendering/components/basetxt.component.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,10 @@ export abstract class BaseTxtComponent extends BaseUIComponent {
5555
return;
5656
}
5757

58-
this.option = r;
58+
this.option.name = r.name;
59+
this.option.type = r.type;
60+
this.option.validationRules = r.validationRules;
61+
this.option.translations = r.translations;
5962
this.control = new FormControl('', this.buildValidationRules());
6063
this.form.removeControl(this.option.name);
6164
this.form.addControl(this.option.name, this.control);

src/CaseManagement.Website/angularApp/app/humantasks/viewdef/rendering/components/dynamic.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<div #parent (drop)="dropElt($event)" [class]="'component '+ title" [class.selected]="isSelected" [class.editMode]="uiOption.editMode" (click)="clickComponent($event)">
1+
<div #parent (drop)="dropElt($event)" (dragleave)="dragLeave($event)" (dragover)="dragOver($event)" [class]="'component '+ title" [class.focused]="isFocused" [class.selected]="isSelected" [class.editMode]="uiOption.editMode" (click)="clickComponent($event)">
22
<div class="title" *ngIf="uiOption.editMode">
33
{{ title }}
44
</div>

src/CaseManagement.Website/angularApp/app/humantasks/viewdef/rendering/components/dynamic.component.ts

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { HeaderComponent } from "./header/header.component";
99
import { FormGroup } from "@angular/forms";
1010
import { PwdComponent } from "./pwd/pwd.component";
1111
import { ConfirmPwdComponent } from "./confirmpwd/confirmpwd.component";
12+
import { SubmitBtnComponent } from "./submitbtn/submitbtn.component";
1213

1314
@Component({
1415
selector: 'dynamic-component',
@@ -31,7 +32,8 @@ export class DynamicComponent implements OnInit, OnDestroy {
3132
'container': ContainerComponent,
3233
'header': HeaderComponent,
3334
'pwd': PwdComponent,
34-
'confirmpwd': ConfirmPwdComponent
35+
'confirmpwd': ConfirmPwdComponent,
36+
'submitbtn': SubmitBtnComponent
3537
};
3638
@ViewChild('container', { read: ViewContainerRef }) container: ViewContainerRef;
3739
@ViewChild('parent', { read: ViewContainerRef }) parent: ViewContainerRef;
@@ -74,6 +76,7 @@ export class DynamicComponent implements OnInit, OnDestroy {
7476
}
7577
@Input() parentOption: any = null;
7678
isSelected: boolean = false;
79+
isFocused: boolean = false;
7780
title: string = null;
7881

7982
constructor(private compFactoryResolver: ComponentFactoryResolver) { }
@@ -118,6 +121,35 @@ export class DynamicComponent implements OnInit, OnDestroy {
118121

119122
const json = JSON.parse(evt.dataTransfer.getData('json'));
120123
this.option.children.push(json);
124+
this.isFocused = false;
125+
}
126+
127+
dragLeave(evt: any) {
128+
if (!this._uiOption.editMode) {
129+
return;
130+
}
131+
132+
evt.preventDefault();
133+
evt.stopPropagation();
134+
if (!this.option.children) {
135+
return;
136+
}
137+
138+
this.isFocused = false;
139+
}
140+
141+
dragOver(evt: any) {
142+
if (!this._uiOption.editMode) {
143+
return;
144+
}
145+
146+
evt.preventDefault();
147+
evt.stopPropagation();
148+
if (!this.option.children) {
149+
return;
150+
}
151+
152+
this.isFocused = true;
121153
}
122154

123155
openSettings(evt: any) {
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
<div [class]="option.class">{{ option.txt }}</div>
1+
<div [class]="option.class">{{ option.translations | translateenum }}</div>

src/CaseManagement.Website/angularApp/app/humantasks/viewdef/rendering/components/header/header.component.ts

Lines changed: 33 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,23 +30,50 @@ export class HeaderComponent extends BaseUIComponent {
3030
templateUrl: 'headerdialog.component.html',
3131
})
3232
export class HeaderComponentDialog {
33-
configureHeaderForm: FormGroup;
33+
configureForm: FormGroup;
34+
languages: string[] = ['fr', 'en'];
35+
3436
constructor(
3537
@Inject(MAT_DIALOG_DATA) public data: any,
3638
public dialogRef: MatDialogRef<HeaderComponentDialog>
3739
) {
38-
this.configureHeaderForm = new FormGroup({
40+
const self = this;
41+
this.configureForm = new FormGroup({
3942
txt: new FormControl({ value: '' }),
4043
class: new FormControl({ value: '' })
4144
});
42-
this.configureHeaderForm.get('txt').setValue(data.opt.txt);
43-
this.configureHeaderForm.get('class').setValue(data.opt.class);
45+
self.languages.forEach((lng: string) => {
46+
this.configureForm.addControl('label#' + lng, new FormControl(''));
47+
});
48+
this.configureForm.get('class').setValue(data.opt.class);
49+
if (data.opt.translations) {
50+
data.opt.translations.forEach(function (tr: any) {
51+
self.configureForm.get('label#' + tr.language).setValue(tr.value);
52+
});
53+
}
4454
}
4555

46-
onSave(val: { txt: string, class: string }) {
56+
onSave(val: { class: string }) {
57+
const translations: any[] = [];
58+
for (const key in this.configureForm.controls) {
59+
if (key.startsWith('label')) {
60+
const language = key.split('#')[1];
61+
translations.push({
62+
language: language,
63+
value: this.configureForm.get(key).value
64+
});
65+
}
66+
}
67+
4768
const opt = this.data.opt;
48-
opt.txt = val.txt;
69+
opt.translations = translations;
4970
opt.class = val.class;
5071
this.dialogRef.close(opt);
5172
}
73+
74+
close(evt: any) {
75+
evt.preventDefault();
76+
evt.stopPropagation();
77+
this.dialogRef.close(null);
78+
}
5279
}
Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
<h1 mat-dialog-title>{{ 'HUMANTASK.EDITOR.CONFIGUREHEADER' | translate }}</h1>
2-
<div mat-dialog-content>
3-
<form [formGroup]="configureHeaderForm" (ngSubmit)="onSave(configureHeaderForm.value)">
4-
<!-- Text -->
5-
<mat-form-field class="full-width" appearance="outline" floatLabel="always">
6-
<mat-label>{{ 'SHARED.TEXT' | translate }}</mat-label>
7-
<input matInput name="txt" formControlName="txt" />
2+
<form [formGroup]="configureForm" (ngSubmit)="onSave(configureForm.value)">
3+
<div mat-dialog-content>
4+
<!-- Label -->
5+
<mat-form-field class="full-width" appearance="outline" floatLabel="always" *ngFor="let language of languages">
6+
<mat-label>{{ 'HUMANTASK.EDITOR.TRANSLATIONS.' + language | translate }}</mat-label>
7+
<input matInput name="label" [formControlName]="'label#' + language" />
88
</mat-form-field>
99
<!-- Types -->
1010
<mat-form-field class="full-width" appearance="outline" floatLabel="always">
@@ -15,9 +15,9 @@
1515
<mat-option value="mat-display-4">Display 4</mat-option>
1616
</mat-select>
1717
</mat-form-field>
18+
</div>
19+
<mat-dialog-actions>
1820
<button mat-raised-button color="primary">{{ 'SHARED.SAVE' | translate }}</button>
19-
</form>
20-
</div>
21-
<mat-dialog-actions>
22-
<button mat-button mat-dialog-close>{{ 'SHARED.CANCEL' | translate }}</button>
23-
</mat-dialog-actions>
21+
<button mat-button (click)="close($event)">{{ 'SHARED.CANCEL' | translate }}</button>
22+
</mat-dialog-actions>
23+
</form>

src/CaseManagement.Website/angularApp/app/humantasks/viewdef/rendering/components/row/row.component.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,4 +52,10 @@ export class RowComponentDialog {
5252

5353
this.dialogRef.close(opt);
5454
}
55+
56+
close(evt: any) {
57+
evt.preventDefault();
58+
evt.stopPropagation();
59+
this.dialogRef.close(null);
60+
}
5561
}
Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
<h1 mat-dialog-title>{{ 'HUMANTASK.EDITOR.CONFIGUREROW' | translate }}</h1>
2-
<div mat-dialog-content>
3-
<form [formGroup]="configureRowForm" (ngSubmit)="onSave(configureRowForm.value)">
1+
<h1 mat-dialog-title>{{ 'HUMANTASK.EDITOR.CONFIGUREROW' | translate }}</h1>
2+
<form [formGroup]="configureRowForm" (ngSubmit)="onSave(configureRowForm.value)">
3+
<div mat-dialog-content>
44
<!-- Nb columns -->
55
<mat-form-field class="full-width" appearance="outline" floatLabel="always">
66
<mat-label>{{ 'SHARED.NBCOLUMNS' | translate }}</mat-label>
77
<input matInput name="nbColumns" formControlName="nbColumns" />
88
</mat-form-field>
9+
</div>
10+
<mat-dialog-actions>
911
<button mat-raised-button color="primary">{{ 'SHARED.SAVE' | translate }}</button>
10-
</form>
11-
</div>
12-
<mat-dialog-actions>
13-
<button mat-button mat-dialog-close>{{ 'SHARED.CANCEL' | translate }}</button>
14-
</mat-dialog-actions>
12+
<button mat-button (click)="close($event)">{{ 'SHARED.CANCEL' | translate }}</button>
13+
</mat-dialog-actions>
14+
</form>

0 commit comments

Comments
 (0)