11<template >
22 <div class =" Column" data-cy =" DocumentList-Column" >
33 <div class =" d-flex flex-row align-items-center" >
4- <div class =" flex-grow-1" >
5- <b-dropdown
6- class =" mr-2"
7- data-cy =" SelectField"
8- variant =" outline-secondary"
9- menu-class =" dropdownScroll"
10- text =" Fields"
11- no-flip
4+ <div class =" flex-grow-1 d-flex align-items-stretch" >
5+ <div class =" d-inline-block mr-2 w-full max-w-24rem" >
6+ <multiselect
7+ v-model =" selectedFieldsComputed"
8+ :options =" dropdownFields.map((field) => field.text)"
9+ :taggable =" true"
10+ tag-placeholder =" Add custom field"
11+ placeholder =" Select fields"
12+ :multiple =" true"
13+ :close-on-select =" false"
14+ :allow-empty =" true"
15+ @tag =" addCustomField"
16+ />
17+ </div >
18+ <b-button
19+ variant =" outline-dark"
20+ class =" mr-2 align-self-center"
21+ @click =" $emit('toggle-all')"
1222 >
13- <b-dropdown-item-button
14- v-if =" selectedFields.length !== 0"
15- class =" pl-4"
16- @click =" resetColumns"
17- >
18- Unselect all
19- </b-dropdown-item-button >
20- <b-dropdown-text
21- v-for =" field of dropdownFields"
22- :key =" `dropdown-${field.text}`"
23- class =" dropdown-text inlineDisplay pointer p-0"
24- >
25- <span class =" inlineDisplay-item" >
26- <b-form-checkbox
27- :id =" field.text"
28- class =" mx-2"
29- :checked =" field.displayed"
30- :data-cy =" `SelectField--${field.text}`"
31- @change =" toggleColumn(field.text, $event)"
32- />
33- </span >
34- <label class =" inlineDisplay-item code pointer" :for =" field.text" :title =" field.text" >{{
35- field.text
36- }}</label >
37- </b-dropdown-text >
38- <b-dropdown-item v-if =" dropdownFields.length === 0" >
39- <span class =" inlineDisplay-item" > No searchable field </span >
40- </b-dropdown-item >
41- </b-dropdown >
42- <b-button variant =" outline-dark" class =" mr-2" @click =" $emit('toggle-all')" >
4323 <i :class =" `far ${allChecked ? 'fa-check-square' : 'fa-square'} left`" />
4424 Toggle all
4525 </b-button >
26+ <b-button variant =" outline-secondary" class =" mr-2 align-self-center" @click =" resetColumns" >
27+ Reset
28+ </b-button >
4629
4730 <b-button
4831 variant =" outline-danger"
49- class =" mr-2"
32+ class =" mr-2 align-self-center "
5033 :disabled =" !bulkDeleteEnabled"
5134 @click =" $emit('bulk-delete')"
5235 >
5639
5740 <b-button
5841 variant =" outline-secondary"
59- class =" mr-2"
42+ class =" mr-2 align-self-center "
6043 data-cy =" Column-btnExportCSV"
6144 title =" Export columns to CSV"
6245 @click.prevent =" displayModalExportCSV"
@@ -236,6 +219,8 @@ import NewDocumentsBadge from '@/components/Data/Documents/Common/NewDocumentsBa
236219import HeaderTableView from ' ./HeaderTableView.vue' ;
237220import HighlightableRow from ' ./HighlightableRow.vue' ;
238221import TableCell from ' ./TableCell.vue' ;
222+ import Multiselect from ' vue-multiselect' ;
223+ import {} from ' vue-multiselect/dist/vue-multiselect.min.css' ;
239224
240225export default {
241226 name: ' Column' ,
@@ -249,6 +234,7 @@ export default {
249234 TableCell,
250235 HighlightableRow,
251236 NewDocumentsBadge,
237+ Multiselect,
252238 },
253239 props: {
254240 searchQuery: Object ,
@@ -355,6 +341,14 @@ export default {
355341 fieldList () {
356342 return Object .keys (this .flatMapping );
357343 },
344+ selectedFieldsComputed: {
345+ get () {
346+ return this .selectedFields ;
347+ },
348+ set (value ) {
349+ this .selectedFields .splice (0 , this .selectedFields .length , ... value);
350+ },
351+ },
358352 },
359353 watch: {
360354 $route: {
@@ -404,7 +398,7 @@ export default {
404398 };
405399 },
406400 resetColumns () {
407- this .selectedFields = [] ;
401+ this .selectedFields . splice ( 0 , this . selectedFields . length ) ;
408402 },
409403 truncateName,
410404 isChecked (id ) {
@@ -420,12 +414,10 @@ export default {
420414 initSelectedFields () {
421415 this .selectedFields = get (this .collectionSettings , ' columnView.fields' , []);
422416 },
423- toggleColumn (field , value ) {
424- if (value && ! this .selectedFields .includes (field)) {
425- this .selectedFields .push (field);
426- }
427- if (! value) {
428- this .$delete (this .selectedFields , this .selectedFields .indexOf (field));
417+ addCustomField (newField ) {
418+ const trimmedField = newField .trim ();
419+ if (trimmedField && ! this .selectedFields .includes (trimmedField)) {
420+ this .selectedFields .push (trimmedField);
429421 }
430422 },
431423 toggleJsonFormatter (id ) {
@@ -502,4 +494,12 @@ export default {
502494 ' Noto Sans' , ' Liberation Sans' , sans-serif , ' Apple Color Emoji' , ' Segoe UI Emoji' ,
503495 ' Segoe UI Symbol' , ' Noto Color Emoji' ;
504496}
497+
498+ .multiselect__option--selected.multiselect__option--highlight {
499+ background : #e64472 !important ;
500+ }
501+
502+ .max-w-24rem {
503+ max-width : 24rem ;
504+ }
505505 </style >
0 commit comments