Skip to content

Commit 557bd4b

Browse files
gino-mgemini-code-assist[bot]rfontanarosa
authored
Refactor JobDialogComponent to use shared TaskEditorComponent (#2409)
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> Co-authored-by: Roberto Fontanarosa <robertofontanarosa@gmail.com>
1 parent 283a059 commit 557bd4b

File tree

50 files changed

+323
-1389
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+323
-1389
lines changed

web/src/app/components/create-survey/task-details/task-details.component.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@
1414
limitations under the License.
1515
-->
1616

17-
<tasks-editor
17+
<task-editor
1818
#tasksEditor
1919
[tasks]="tasks"
2020
(onValidationChanges)="onTasksChange($event)"
21-
></tasks-editor>
21+
></task-editor>
2222

web/src/app/components/create-survey/task-details/task-details.component.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import {
2323
} from '@angular/core';
2424
import { List } from 'immutable';
2525

26-
import { TasksEditorComponent } from 'app/components/shared/tasks-editor/tasks-editor.component';
26+
import { TaskEditorComponent } from 'app/components/shared/task-editor/task-editor.component';
2727
import { Job } from 'app/models/job.model';
2828
import { Task } from 'app/models/task/task.model';
2929

@@ -41,7 +41,7 @@ export class TaskDetailsComponent {
4141
tasks: List<Task> = List([]);
4242

4343
@ViewChild('tasksEditor')
44-
tasksEditor?: TasksEditorComponent;
44+
tasksEditor?: TaskEditorComponent;
4545

4646
constructor() {}
4747

web/src/app/components/create-survey/task-details/task-details.module.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,13 @@
1717
import { CommonModule } from '@angular/common';
1818
import { NgModule } from '@angular/core';
1919

20-
import { TasksEditorModule } from 'app/components/shared/tasks-editor/tasks-editor.module';
20+
import { TaskEditorModule } from 'app/components/shared/task-editor/task-editor.module';
2121

2222
import { TaskDetailsComponent } from './task-details.component';
2323

2424
@NgModule({
2525
declarations: [TaskDetailsComponent],
26-
imports: [CommonModule, TasksEditorModule],
26+
imports: [CommonModule, TaskEditorModule],
2727
exports: [TaskDetailsComponent],
2828
})
2929
export class TaskDetailsModule {}

web/src/app/components/edit-survey/edit-job/edit-job.component.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,12 @@
5151
</div>
5252

5353
<div *ngSwitchCase="EditJobSection.TASKS">
54-
<tasks-editor
54+
<task-editor
5555
[tasks]="tasks"
5656
(onValueChanges)="onTasksChange($event)"
5757
#tasksEditor
5858
>
59-
</tasks-editor>
59+
</task-editor>
6060
</div>
6161
</div>
6262
</div>

web/src/app/components/edit-survey/edit-job/edit-job.component.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ import { Subject, from, of } from 'rxjs';
3030

3131
import { EditJobComponent } from 'app/components/edit-survey/edit-job/edit-job.component';
3232
import { LoiEditorComponent } from 'app/components/shared/loi-editor/loi-editor.component';
33-
import { TasksEditorModule } from 'app/components/shared/tasks-editor/tasks-editor.module';
33+
import { TaskEditorModule } from 'app/components/shared/task-editor/task-editor.module';
3434
import { Job } from 'app/models/job.model';
3535
import { LocationOfInterest } from 'app/models/loi.model';
3636
import { Role } from 'app/models/role.model';
@@ -83,7 +83,7 @@ describe('EditJobComponent', () => {
8383
MatButtonToggle,
8484
MatDialogModule,
8585
MatIconModule,
86-
TasksEditorModule,
86+
TaskEditorModule,
8787
],
8888
providers: [
8989
{ provide: AuthService, useValue: { getUser$: () => user$ } },

web/src/app/components/edit-survey/edit-job/edit-job.component.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import { List } from 'immutable';
2020
import { Subscription } from 'rxjs';
2121

2222
import { LoiEditorComponent } from 'app/components/shared/loi-editor/loi-editor.component';
23-
import { TasksEditorComponent } from 'app/components/shared/tasks-editor/tasks-editor.component';
23+
import { TaskEditorComponent } from 'app/components/shared/task-editor/task-editor.component';
2424
import { DataCollectionStrategy, Job } from 'app/models/job.model';
2525
import { LocationOfInterest } from 'app/models/loi.model';
2626
import { Task } from 'app/models/task/task.model';
@@ -58,7 +58,7 @@ export class EditJobComponent {
5858
EditJobSection = EditJobSection;
5959

6060
@ViewChild('tasksEditor')
61-
tasksEditor?: TasksEditorComponent;
61+
tasksEditor?: TaskEditorComponent;
6262

6363
@ViewChild('loiEditor')
6464
loiEditor?: LoiEditorComponent;

web/src/app/components/edit-survey/edit-job/edit-job.module.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import { MatIconModule } from '@angular/material/icon';
2424

2525
import { EditJobComponent } from 'app/components/edit-survey/edit-job/edit-job.component';
2626
import { LoiEditorModule } from 'app/components/shared/loi-editor/loi-editor.module';
27-
import { TasksEditorModule } from 'app/components/shared/tasks-editor/tasks-editor.module';
27+
import { TaskEditorModule } from 'app/components/shared/task-editor/task-editor.module';
2828

2929
@NgModule({
3030
declarations: [EditJobComponent],
@@ -34,7 +34,7 @@ import { TasksEditorModule } from 'app/components/shared/tasks-editor/tasks-edit
3434
MatButtonToggle,
3535
MatIconModule,
3636
LoiEditorModule,
37-
TasksEditorModule,
37+
TaskEditorModule,
3838
],
3939
exports: [EditJobComponent],
4040
})

web/src/app/components/main-page-container/main-page/job-dialog/job-dialog.component.html

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -57,28 +57,7 @@ <h3>Task Layout</h3>
5757
polygon in this job.
5858
</div>
5959
</div>
60-
<div cdkDropList (cdkDropListDropped)="drop($event)">
61-
<div
62-
*ngFor="let task of tasks; let i = index; trackBy: trackByFn"
63-
cdkDrag
64-
>
65-
<ground-task-editor
66-
[label]="task.label"
67-
[required]="task.required"
68-
[taskType]="task.type"
69-
[cardinality]="task.multipleChoice?.cardinality"
70-
[multipleChoice]="task.multipleChoice"
71-
[taskCount]="tasks.size"
72-
(update)="onTaskUpdate($event, i)"
73-
(delete)="onTaskDelete(i)"
74-
>
75-
</ground-task-editor>
76-
</div>
77-
</div>
78-
<button mat-button class="add-question" type="button" (click)="addQuestion()">
79-
<mat-icon color="primary">add</mat-icon>
80-
<span class="link-add-question">Add question</span>
81-
</button>
60+
<task-editor #tasksEditor [tasks]="tasks"></task-editor>
8261
</mat-dialog-content>
8362
<mat-dialog-actions>
8463
<div>

web/src/app/components/main-page-container/main-page/job-dialog/job-dialog.component.spec.ts

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ import { DataStoreService } from 'app/services/data-store/data-store.service';
4040
import { EditStyleButtonModule } from './edit-style-button/edit-style-button.module';
4141
import { JobService } from 'app/services/job/job.service';
4242
import { JobDialogComponent } from './job-dialog.component';
43-
import { TaskEditorModule } from './task-editor/task-editor.module';
43+
import { TaskEditorModule } from 'app/components/shared/task-editor/task-editor.module';
4444

4545
@Component({
4646
selector: 'mat-dialog-content',
@@ -113,12 +113,6 @@ describe('JobDialogComponent', () => {
113113
it('should create', () => {
114114
expect(component).toBeTruthy();
115115
});
116-
117-
it('should add question', () => {
118-
component.addQuestion();
119-
expect(component.tasks.size).toBe(2);
120-
expect(component.tasks.first()?.type).toBe(TaskType.TEXT);
121-
});
122116
});
123117

124118
function createRouterSpy() {

0 commit comments

Comments
 (0)