Skip to content

Commit 0ca3a76

Browse files
committed
chore: add completed_field_column_name param to task progress bar
1 parent 67e4bb9 commit 0ca3a76

File tree

2 files changed

+28
-6
lines changed

2 files changed

+28
-6
lines changed

src/app/shared/components/template/components/task-progress-bar/task-progress-bar.component.ts

+18-3
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,19 @@ interface ITaskProgressBarParams {
4545
/**
4646
* TEMPLATE PARAMETER: completed_column_name.
4747
* The name of the column in the source data list that tracks the completed value of each subtask.
48-
* If there is no column with this name, the component will look for a column called "completed_field",
49-
* and use corresponding app fields to track the completion status of subtasks. In this case, the
50-
* task progress bar will not update without a page reload.
48+
* If there is no column with this name, the component will look for a column matching completed_field_column_name,
49+
* and use the corresponding app fields to track the completion status of subtasks.
5150
* Deafult "completed"
5251
* */
5352
completedColumnName: string;
53+
/**
54+
* TEMPLATE PARAMETER: completed_field_column_name.
55+
* The name of the column in the source data list which stores the name of the completed field of each subtask.
56+
* The app fields corresponding to the values in this column are used to evaluate the completion of subtasks iff the
57+
* completed_column_name column is not present. In this case, the task progress bar will not update without a page reload.
58+
* Deafult "completed_field"
59+
* */
60+
completedFieldColumnName: string;
5461
}
5562

5663
@Component({
@@ -119,13 +126,20 @@ export class TmplTaskProgressBarComponent
119126
"completed_column_name",
120127
"completed"
121128
);
129+
this.params.completedFieldColumnName = getStringParamFromTemplateRow(
130+
this._row,
131+
"completed_field_column_name",
132+
"completed_field"
133+
);
122134
}
123135
// If component is being instantiated by a parent component (e.g. task-card), use Input() values for params.
124136
else {
125137
this.params.dataListName = this.dataListName;
126138
this.params.completedField = this.completedField;
127139
this.params.progressUnitsName = this.progressUnitsName;
128140
this.params.showText = this.showText;
141+
this.params.completedColumnName = "completed";
142+
this.params.completedFieldColumnName = "completed_field";
129143
}
130144
}
131145

@@ -148,6 +162,7 @@ export class TmplTaskProgressBarComponent
148162
await this.taskService.evaluateTaskGroupData(this.dataRows, {
149163
completedColumnName: this.params.completedColumnName,
150164
completedField: this.params.completedField,
165+
completedFieldColumnName: this.params.completedFieldColumnName,
151166
dataListName: this.params.dataListName,
152167
useDynamicData: this.useDynamicData,
153168
});

src/app/shared/services/task/task.service.ts

+10-3
Original file line numberDiff line numberDiff line change
@@ -138,22 +138,29 @@ export class TaskService extends AsyncServiceBase {
138138
options: {
139139
completedColumnName: string;
140140
completedField: string;
141+
completedFieldColumnName: string;
141142
dataListName: string;
142143
useDynamicData: boolean;
143144
}
144145
) {
145-
const { useDynamicData, completedColumnName, completedField, dataListName } = options;
146+
const {
147+
useDynamicData,
148+
completedColumnName,
149+
completedFieldColumnName,
150+
completedField,
151+
dataListName,
152+
} = options;
146153
const subtasks = dataRows || [];
147154
const subtasksTotal = subtasks.length;
148155
const subtasksCompleted = subtasks.filter((task) => {
149156
if (useDynamicData) {
150157
return task[completedColumnName];
151158
} else {
152159
try {
153-
return this.templateFieldService.getField(task["completed_field"]);
160+
return this.templateFieldService.getField(task[completedFieldColumnName]);
154161
} catch {
155162
console.error(
156-
`[TASK] - Source data list ${dataListName} has no column "completed_field" nor "${completedColumnName}". It is mandatory for at least one of these columns to be present to task subtask progress.`
163+
`[TASK] - Source data list ${dataListName} has no column "${completedFieldColumnName}" nor "${completedColumnName}". It is mandatory for at least one of these columns to be present to task subtask progress.`
157164
);
158165
}
159166
}

0 commit comments

Comments
 (0)