12
12
v-model:is-audit-modal-visible =" isAuditModalVisible"
13
13
v-model:is-column-selector-visible =" isColumnSelectorVisible"
14
14
:audit-button-disabled =" auditButtonDisabled"
15
+ :has-column-selector =" true"
15
16
/>
16
17
17
18
<table class =" w-full text-left mt-2" >
18
19
<thead >
19
20
<tr >
20
- <th class =" bg-teal-500/20 pl-2" >
21
- <!-- <Checkbox binary v-model="selection" /> -->
22
- </th >
21
+ <th class =" bg-teal-500/20 pl-2" ></th >
23
22
<th class =" bg-teal-500/20" ></th >
24
23
<th
25
24
v-for =" col of fields"
@@ -101,11 +100,12 @@ import ColumnSelector from '@/components/Findings/ColumnSelector.vue';
101
100
import FindingTableHeader from ' ./FindingTableHeader.vue' ;
102
101
import { useFiltering } from ' @/composables/useFiltering' ;
103
102
import { useColumnFiltering } from ' @/composables/useColumnFiltering' ;
104
- import { dispatchError , dispatchMessage } from ' @/configuration/config' ;
103
+ import { dispatchError } from ' @/configuration/config' ;
105
104
import Panel from ' primevue/panel' ;
106
105
import Checkbox from ' primevue/checkbox' ;
107
106
import Button from ' primevue/button' ;
108
107
import FindingStatusBadge from ' ../Common/FindingStatusBadge.vue' ;
108
+ import { useAuditFunctions } from ' @/composables/useAuditFunctions' ;
109
109
110
110
const props = defineProps <{
111
111
findings: DetailedFindingRead [] | undefined ;
@@ -128,22 +128,32 @@ const { filterString, filteredList } = useFiltering(findingList);
128
128
129
129
setTableFields ();
130
130
131
- function toggleExpand(idx : number ) {
132
- selectedIndex .value = idx ;
133
- expanded .value = expanded .value === idx ? - 1 : idx ;
134
- }
135
-
136
- function toggleAllCheckboxes() {
137
- if (filteredList .value === undefined ) {
138
- return ;
139
- }
140
-
141
- if (selection .value .length < filteredList .value .length ) {
142
- selection .value = filteredList .value .map ((f ) => f .id_ );
143
- } else {
144
- selection .value = [];
145
- }
146
- }
131
+ const {
132
+ toggleExpand,
133
+ toggleAllCheckboxes,
134
+ selectDown,
135
+ selectUp,
136
+ openDetails,
137
+ closeDetails,
138
+ openCommitUrl,
139
+ toggleSelect,
140
+ markAsFalsePositive,
141
+ markAsTruePositive,
142
+ markAsGone,
143
+ markAllAsFalsePositive,
144
+ markAllAsTruePositive,
145
+ markAllAsGone,
146
+ auditThis,
147
+ } = useAuditFunctions (
148
+ selection ,
149
+ selectedIndex ,
150
+ expanded ,
151
+ // @ts-expect-error
152
+ filteredList ,
153
+ isAuditModalVisible ,
154
+ (item ) => item .id_ ,
155
+ sendUpdate ,
156
+ );
147
157
148
158
function updateAudit(status : FindingStatus , comment : string ) {
149
159
updateVisualBadge (selection .value , status , comment );
@@ -170,101 +180,6 @@ function updateVisualBadge(selectedIds: number[], status: FindingStatus, comment
170
180
selection .value = selection .value .filter ((s ) => s !== selectedIds [0 ]);
171
181
}
172
182
173
- function getCurrentFindingSelected(): DetailedFindingRead {
174
- if (filteredList .value === undefined ) {
175
- dispatchMessage (' List is empty' );
176
- throw new Error (' oups!' );
177
- }
178
-
179
- return filteredList .value [selectedIndex .value ];
180
- }
181
-
182
- function selectDown(): boolean {
183
- if (filteredList .value === undefined ) {
184
- return false ;
185
- }
186
-
187
- selectedIndex .value = ((selectedIndex .value ?? - 1 ) + 1 ) % filteredList .value .length ;
188
- expanded .value = expanded .value === - 1 ? - 1 : selectedIndex .value ;
189
-
190
- return true ;
191
- }
192
-
193
- function selectUp(): boolean {
194
- if (filteredList .value === undefined ) {
195
- return false ;
196
- }
197
-
198
- selectedIndex .value =
199
- (selectedIndex .value + filteredList .value .length - 1 ) % filteredList .value .length ;
200
- expanded .value = expanded .value === - 1 ? - 1 : selectedIndex .value ;
201
-
202
- return true ;
203
- }
204
-
205
- function openDetails() {
206
- expanded .value = selectedIndex .value ;
207
- }
208
-
209
- function closeDetails() {
210
- expanded .value = - 1 ;
211
- }
212
-
213
- function openCommitUrl() {
214
- const url = getCurrentFindingSelected ()?.commit_url ;
215
- if (url !== undefined && url !== null ) {
216
- window .open (url , ' _blank' )?.focus ();
217
- }
218
- }
219
-
220
- function toggleSelect() {
221
- const item = getCurrentFindingSelected ();
222
- if (selection .value .filter ((idx ) => idx === item .id_ ).length > 0 ) {
223
- selection .value = selection .value .filter ((idx ) => idx !== item .id_ );
224
- } else {
225
- selection .value .push (item .id_ );
226
- }
227
- }
228
-
229
- function markAsFalsePositive() {
230
- const item = getCurrentFindingSelected ();
231
- sendUpdate ([item .id_ ], ' FALSE_POSITIVE' );
232
- selectDown ();
233
- }
234
-
235
- function markAsTruePositive() {
236
- const item = getCurrentFindingSelected ();
237
- sendUpdate ([item .id_ ], ' TRUE_POSITIVE' );
238
- selectDown ();
239
- }
240
-
241
- function markAsGone() {
242
- const item = getCurrentFindingSelected ();
243
- sendUpdate ([item .id_ ], ' NOT_ACCESSIBLE' );
244
- selectDown ();
245
- }
246
-
247
- function markAllAsFalsePositive() {
248
- sendUpdate (selection .value , ' FALSE_POSITIVE' );
249
- }
250
-
251
- function markAllAsTruePositive() {
252
- sendUpdate (selection .value , ' TRUE_POSITIVE' );
253
- }
254
-
255
- function markAllAsGone() {
256
- sendUpdate (selection .value , ' NOT_ACCESSIBLE' );
257
- }
258
-
259
- function auditThis() {
260
- if (selection .value .length > 0 ) {
261
- isAuditModalVisible .value = true ;
262
- return ;
263
- }
264
-
265
- openDetails ();
266
- }
267
-
268
183
function sendUpdate(selectedIds : number [], status : FindingStatus ) {
269
184
FindingsService .auditFindings (selectedIds , status , ' ' )
270
185
.then (() => {
0 commit comments