Skip to content

Commit 38471a7

Browse files
committed
Fixing broken activation/deactivation of tasks.
1 parent 2fc5db7 commit 38471a7

File tree

4 files changed

+32
-53
lines changed

4 files changed

+32
-53
lines changed

eform-client/src/app/plugins/modules/backend-configuration-pn/modules/task-wizard/components/task-wizard-actions/task-wizard-create-modal/task-wizard-create-modal.component.html

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@ <h3 mat-dialog-title>{{ 'Create new task' | translate }}</h3>
55
class="p-2"
66
color="primary"
77
id="createTaskStatusToggle"
8-
formControlName="status"
9-
[checked]="taskForm.value.status === TaskWizardStatusesEnum.Active"
8+
formControlName="taskStatus"
109
(change)="changeStatus($event.checked)"
1110
>
1211
{{ 'Status' | translate }}

eform-client/src/app/plugins/modules/backend-configuration-pn/modules/task-wizard/components/task-wizard-actions/task-wizard-create-modal/task-wizard-create-modal.component.ts

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -183,22 +183,22 @@ export class TaskWizardCreateModalComponent implements OnInit, OnDestroy {
183183
}
184184

185185
this.taskForm = this.fb.group({
186-
status: new FormControl(this.model?.status ?? TaskWizardStatusesEnum.Active),
187-
propertyId: new FormControl(this.model?.propertyId, Validators.required),
188-
itemPlanningTagId: new FormControl(this.model?.itemPlanningTagId),
189-
startDate: new FormControl(this.model?.startDate),
190-
repeatType: new FormControl(this.model?.repeatType ?? 0),
191-
repeatEvery: new FormControl(this.model?.repeatEvery),
192-
eformId: new FormControl(this.model?.eformId, Validators.required),
193-
tagIds: new FormControl(this.model?.tagIds || []),
194-
sites: new FormControl(this.model?.sites || []),
195-
folderId: new FormControl(this.model?.folderId),
186+
taskStatus: [this.model?.status === TaskWizardStatusesEnum.Active],
187+
propertyId: [this.model?.propertyId, Validators.required],
188+
itemPlanningTagId: [this.model?.itemPlanningTagId],
189+
startDate: [this.model?.startDate],
190+
repeatType: [this.model?.repeatType ?? 0],
191+
repeatEvery: [this.model?.repeatEvery],
192+
eformId: [this.model?.eformId, Validators.required],
193+
tagIds: [this.model?.tagIds || []],
194+
sites: [this.model?.sites || []],
195+
folderId: [this.model?.folderId],
196196
translates: this.fb.array(
197197
this.model.translates.map(t => this.fb.group({
198198
languageId: [t.languageId],
199199
id: [t.id],
200-
name: [t.name, Validators.required],
201-
description: [t.description]
200+
name: [t.name || '', Validators.required],
201+
description: [t.description || '']
202202
}))
203203
)
204204
});
@@ -292,10 +292,9 @@ export class TaskWizardCreateModalComponent implements OnInit, OnDestroy {
292292

293293
changeStatus(event: boolean) {
294294
this.taskForm.patchValue({
295-
status: event
296-
? TaskWizardStatusesEnum.Active
297-
: TaskWizardStatusesEnum.NotActive,
295+
taskStatus: event,
298296
});
297+
this.model.status = event ? TaskWizardStatusesEnum.Active : TaskWizardStatusesEnum.NotActive;
299298
}
300299

301300
getLanguageName(languageId) {
@@ -355,7 +354,7 @@ export class TaskWizardCreateModalComponent implements OnInit, OnDestroy {
355354
...this.taskForm.value,
356355
translates: this.taskForm.get('translates')?.value,
357356
};
358-
357+
task.status = this.taskForm.value.taskStatus ? TaskWizardStatusesEnum.Active : TaskWizardStatusesEnum.NotActive;
359358

360359
this.createTask.emit(task);
361360
}

eform-client/src/app/plugins/modules/backend-configuration-pn/modules/task-wizard/components/task-wizard-actions/task-wizard-update-modal/task-wizard-update-modal.component.html

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@ <h3 mat-dialog-title>{{ 'Edit task' | translate }}</h3>
44
<mat-slide-toggle class="p-2"
55
color="accent"
66
id="updateTaskStatusToggle"
7-
[checked]="taskForm?.value?.status === TaskWizardStatusesEnum.Active"
8-
formControlName="status"
7+
formControlName="taskStatus"
98
(change)="changeStatus($event.checked)">
109
{{ 'Status' | translate }}
1110
</mat-slide-toggle>

eform-client/src/app/plugins/modules/backend-configuration-pn/modules/task-wizard/components/task-wizard-actions/task-wizard-update-modal/task-wizard-update-modal.component.ts

Lines changed: 15 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ export class TaskWizardUpdateModalComponent implements OnInit, OnDestroy {
114114
}
115115

116116
ngOnInit(): void {
117-
this.initForm();
117+
// this.initForm();
118118

119119
this.statuses = Object.keys(TaskWizardStatusesEnum)
120120
.filter(key => isNaN(Number(key)))
@@ -177,16 +177,16 @@ export class TaskWizardUpdateModalComponent implements OnInit, OnDestroy {
177177

178178
initForm() {
179179
this.taskForm = this.fb.group({
180-
status: new FormControl(this.model?.status ?? TaskWizardStatusesEnum.Active),
181-
propertyId: new FormControl(this.model?.propertyId, Validators.required),
182-
itemPlanningTagId: new FormControl(this.model?.itemPlanningTagId),
183-
startDate: new FormControl(this.model?.startDate),
184-
repeatType: new FormControl(this.model?.repeatType ?? 0),
185-
repeatEvery: new FormControl(this.model?.repeatEvery),
186-
eformId: new FormControl(this.model?.eformId, Validators.required),
187-
tagIds: new FormControl(this.model?.tagIds || []),
188-
sites: new FormControl(this.model?.sites || []),
189-
folderId: new FormControl(this.model?.folderId),
180+
taskStatus: [this.model?.status === TaskWizardStatusesEnum.Active],
181+
propertyId: [this.model?.propertyId, Validators.required],
182+
itemPlanningTagId: [this.model?.itemPlanningTagId],
183+
startDate: [this.model?.startDate],
184+
repeatType: [this.model?.repeatType ?? 0],
185+
repeatEvery: [this.model?.repeatEvery],
186+
eformId: [this.model?.eformId, Validators.required],
187+
tagIds: [this.model?.tagIds || []],
188+
sites: [this.model?.sites || []],
189+
folderId: [this.model?.folderId],
190190
translates: this.fb.array(
191191
this.model.translates.map(t => this.fb.group({
192192
languageId: [t.languageId],
@@ -253,10 +253,9 @@ export class TaskWizardUpdateModalComponent implements OnInit, OnDestroy {
253253

254254
changeStatus(event: boolean) {
255255
this.taskForm.patchValue({
256-
status: event
257-
? TaskWizardStatusesEnum.Active
258-
: TaskWizardStatusesEnum.NotActive,
256+
taskStatus: event,
259257
});
258+
this.model.status = event ? TaskWizardStatusesEnum.Active : TaskWizardStatusesEnum.NotActive;
260259
}
261260

262261
getLanguageName(languageId: number): string {
@@ -316,7 +315,7 @@ export class TaskWizardUpdateModalComponent implements OnInit, OnDestroy {
316315
...this.taskForm.value,
317316
translates: this.taskForm.get('translates')?.value,
318317
};
319-
318+
task.status = this.taskForm.value.taskStatus ? TaskWizardStatusesEnum.Active : TaskWizardStatusesEnum.NotActive;
320319

321320
this.updateTask.emit(task);
322321
}
@@ -331,25 +330,8 @@ export class TaskWizardUpdateModalComponent implements OnInit, OnDestroy {
331330

332331
fillModelAndCopyModel(model: TaskWizardCreateModel) {
333332

334-
if (!this.taskForm) {
335-
this.initForm();
336-
}
337-
338333
this.model = R.clone(model);
339-
this.taskForm.patchValue({
340-
propertyId: model.propertyId,
341-
itemPlanningTagId: model.itemPlanningTagId,
342-
folderId: model.folderId,
343-
startDate: model.startDate,
344-
tagIds: model.tagIds || [],
345-
repeatType: model.repeatType,
346-
repeatEvery: model.repeatEvery,
347-
eformId: model.eformId,
348-
status: model.status,
349-
sites: model.sites || [],
350-
translates: model.translates || [],
351-
});
352-
334+
this.initForm();
353335

354336
const translatesFormArray = this.fb.array(
355337
(model.translates || []).map(t =>

0 commit comments

Comments
 (0)