Skip to content

Commit db81d7f

Browse files
committed
Add the ability fot task to retrive dinamic fields
1 parent 8a82e0b commit db81d7f

2 files changed

Lines changed: 27 additions & 1 deletion

File tree

ProcessMaker/Http/Controllers/Api/TaskController.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,14 @@ public function index(Request $request, $getTotal = false, User $user = null)
134134

135135
$query = $this->indexBaseQuery($request);
136136

137+
// Get fields from request (sent by frontend)
138+
// If not provided, don't apply select() to maintain backward compatibility (returns all columns)
139+
$fields = $request->input('fields', '');
140+
if ($fields) {
141+
$selectedFields = explode(',', $fields);
142+
$query = $query->select($selectedFields);
143+
}
144+
137145
$this->applyFilters($query, $request);
138146

139147
$this->excludeNonVisibleTasks($query, $request);

resources/js/requests/components/RequestDetail.vue

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,13 +184,31 @@ export default {
184184
this.status
185185
}&per_page=${
186186
this.perPage
187-
}${this.getSortParam()}`,
187+
}${this.getSortParam()}${this.getColumnsParam()}`,
188188
)
189189
.then((response) => {
190190
this.data = this.transform(response.data);
191191
this.loading = false;
192192
});
193193
},
194+
/**
195+
* Get the fields parameter for the API request
196+
* @returns {string} The fields parameter for the API request
197+
*/
198+
getColumnsParam() {
199+
const fields = [
200+
'id',
201+
'element_name',
202+
'user_id',
203+
'process_id',
204+
'process_request_id',
205+
'status',
206+
'due_at',
207+
'is_self_service',
208+
'is_actionbyemail',
209+
];
210+
return `&fields=${fields.join(',')}`;
211+
},
194212
getSortParam() {
195213
if (this.sortOrder instanceof Array && this.sortOrder.length > 0) {
196214
return (

0 commit comments

Comments
 (0)