AdvancedTable.vue 57 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359
  1. <template>
  2. <div>
  3. <div
  4. class="table-outer-container"
  5. @mousemove="columnResizing($event)"
  6. @touchmove="columnResizing($event)"
  7. >
  8. <div class="table-header">
  9. <div>
  10. <tippy
  11. v-if="filters.length > 0"
  12. :touch="true"
  13. :interactive="true"
  14. placement="bottom-start"
  15. theme="search"
  16. ref="search"
  17. trigger="click"
  18. @show="
  19. () => {
  20. showFiltersDropdown = true;
  21. }
  22. "
  23. @hide="
  24. () => {
  25. showFiltersDropdown = false;
  26. }
  27. "
  28. >
  29. <div class="control has-addons" ref="trigger">
  30. <button class="button is-primary">
  31. <i class="material-icons icon-with-button"
  32. >filter_list</i
  33. >
  34. Filters
  35. </button>
  36. <button class="button">
  37. <i class="material-icons">
  38. {{
  39. showFiltersDropdown
  40. ? "expand_more"
  41. : "expand_less"
  42. }}
  43. </i>
  44. </button>
  45. </div>
  46. <template #content>
  47. <div class="control is-grouped input-with-button">
  48. <p class="control select is-expanded">
  49. <select v-model="addFilterValue">
  50. <option
  51. v-for="type in filters"
  52. :key="type.name"
  53. :value="type"
  54. >
  55. {{ type.displayName }}
  56. </option>
  57. </select>
  58. </p>
  59. <p class="control">
  60. <button
  61. :disabled="!addFilterValue"
  62. class="button material-icons is-success"
  63. @click="addFilterItem()"
  64. >
  65. control_point
  66. </button>
  67. </p>
  68. </div>
  69. <div
  70. v-for="(filter, index) in editingFilters"
  71. :key="`filter-${index}`"
  72. class="
  73. advanced-filter
  74. control
  75. is-grouped is-expanded
  76. "
  77. >
  78. <div class="control select">
  79. <select
  80. v-model="filter.filter"
  81. @change="changeFilterType(index)"
  82. >
  83. <option
  84. v-for="type in filters"
  85. :key="type.name"
  86. :value="type"
  87. >
  88. {{ type.displayName }}
  89. </option>
  90. </select>
  91. </div>
  92. <div class="control select">
  93. <select
  94. v-model="filter.filterType"
  95. :disabled="!filter.filterType"
  96. >
  97. <option
  98. v-for="filterType in filterTypes(
  99. filter.filter
  100. )"
  101. :key="filterType.name"
  102. :value="filterType"
  103. :selected="
  104. filter.filter
  105. .defaultFilterType ===
  106. filterType.name
  107. "
  108. >
  109. {{ filterType.displayName }}
  110. </option>
  111. </select>
  112. </div>
  113. <div
  114. v-if="
  115. filter.filterType.name &&
  116. filter.filterType.name === 'exact' &&
  117. filter.filter.filterValues
  118. "
  119. class="control is-expanded select"
  120. >
  121. <select
  122. v-model="filter.data"
  123. :disabled="!filter.filterType"
  124. >
  125. <option
  126. v-for="filterValue in filter.filter
  127. .filterValues"
  128. :key="filterValue"
  129. :value="filterValue"
  130. >
  131. {{ filterValue }}
  132. </option>
  133. </select>
  134. </div>
  135. <div
  136. v-else-if="
  137. filter.filterType.name &&
  138. filter.filterType.name === 'boolean'
  139. "
  140. class="control is-expanded select"
  141. >
  142. <select
  143. v-model="filter.data"
  144. :disabled="!filter.filterType"
  145. >
  146. <option :value="true">true</option>
  147. <option :value="false">false</option>
  148. </select>
  149. </div>
  150. <div v-else class="control is-expanded">
  151. <input
  152. v-if="
  153. filter.filterType.name &&
  154. filter.filterType.name.startsWith(
  155. 'datetime'
  156. )
  157. "
  158. v-model="filter.data"
  159. class="input"
  160. type="datetime-local"
  161. />
  162. <input
  163. v-else-if="
  164. filter.filterType.name &&
  165. filter.filterType.name.startsWith(
  166. 'number'
  167. )
  168. "
  169. v-model="filter.data"
  170. class="input"
  171. type="number"
  172. :disabled="!filter.filterType"
  173. @keydown.enter="applyFilterAndGetData()"
  174. />
  175. <input
  176. v-else
  177. v-model="filter.data"
  178. class="input"
  179. type="text"
  180. placeholder="Search value"
  181. :disabled="!filter.filterType"
  182. @keydown.enter="applyFilterAndGetData()"
  183. @blur="blurFilterInput(filter)"
  184. @focus="focusFilterInput(filter)"
  185. @keydown="keydownFilterInput(filter)"
  186. />
  187. <div
  188. class="autosuggest-container"
  189. v-if="
  190. filter.filter.autosuggest &&
  191. (autosuggest.inputFocussed[
  192. filter.filter.name
  193. ] ||
  194. autosuggest.containerFocussed[
  195. filter.filter.name
  196. ]) &&
  197. autosuggest.items[
  198. filter.filter.name
  199. ]?.length > 0
  200. "
  201. @mouseover="
  202. focusFilterAutosuggestContainer(
  203. filter
  204. )
  205. "
  206. @mouseleave="
  207. blurFilterAutosuggestContainer(
  208. filter
  209. )
  210. "
  211. >
  212. <span
  213. class="autosuggest-item"
  214. tabindex="0"
  215. @click="
  216. selectAutosuggestItem(
  217. index,
  218. filter,
  219. item
  220. )
  221. "
  222. v-for="item in autosuggest.items[
  223. filter.filter.name
  224. ]"
  225. :key="item"
  226. >{{ item }}
  227. </span>
  228. </div>
  229. </div>
  230. <div class="control">
  231. <button
  232. class="button material-icons is-danger"
  233. @click="removeFilterItem(index)"
  234. >
  235. remove_circle_outline
  236. </button>
  237. </div>
  238. </div>
  239. <div
  240. v-if="editingFilters.length > 0"
  241. class="control is-expanded is-grouped"
  242. >
  243. <label class="control label"
  244. >Filter operator</label
  245. >
  246. <div class="control select is-expanded">
  247. <select v-model="filterOperator">
  248. <option
  249. v-for="operator in filterOperators"
  250. :key="operator.name"
  251. :value="operator.name"
  252. >
  253. {{ operator.displayName }}
  254. </option>
  255. </select>
  256. </div>
  257. </div>
  258. <div
  259. class="advanced-filter-bottom"
  260. v-if="editingFilters.length > 0"
  261. >
  262. <div class="control is-expanded">
  263. <button
  264. class="button is-info"
  265. @click="applyFilterAndGetData()"
  266. >
  267. <i
  268. class="
  269. material-icons
  270. icon-with-button
  271. "
  272. >filter_list</i
  273. >
  274. Apply filters
  275. </button>
  276. </div>
  277. </div>
  278. <div
  279. class="advanced-filter-bottom"
  280. v-else-if="editingFilters.length === 0"
  281. >
  282. <div class="control is-expanded">
  283. <button
  284. class="button is-info"
  285. @click="applyFilterAndGetData()"
  286. >
  287. <i
  288. class="
  289. material-icons
  290. icon-with-button
  291. "
  292. >filter_list</i
  293. >
  294. Apply filters
  295. </button>
  296. </div>
  297. </div>
  298. </template>
  299. </tippy>
  300. <tippy
  301. v-if="appliedFilters.length > 0"
  302. :touch="true"
  303. :interactive="true"
  304. theme="info"
  305. ref="activeFilters"
  306. >
  307. <div class="filters-indicator">
  308. {{ appliedFilters.length }}
  309. <i class="material-icons" @click.prevent="true"
  310. >filter_list</i
  311. >
  312. </div>
  313. <template #content>
  314. <p
  315. v-for="(filter, index) in appliedFilters"
  316. :key="`filter-${index}`"
  317. >
  318. {{ filter.filter.displayName }}
  319. {{
  320. appliedFilters.length === 1 &&
  321. appliedFilterOperator === "nor"
  322. ? "not"
  323. : ""
  324. }}
  325. {{
  326. filter.filterType.displayName.toLowerCase()
  327. }}
  328. "{{ filter.data }}"
  329. {{
  330. appliedFilters.length === index + 1
  331. ? ""
  332. : appliedFilterOperator
  333. }}
  334. </p>
  335. </template>
  336. </tippy>
  337. <i
  338. v-else
  339. class="filters-indicator material-icons"
  340. content="No active filters"
  341. v-tippy="{ theme: 'info' }"
  342. >
  343. filter_list_off
  344. </i>
  345. </div>
  346. <div>
  347. <tippy
  348. v-if="hidableSortedColumns.length > 0"
  349. :touch="true"
  350. :interactive="true"
  351. placement="bottom-end"
  352. theme="dropdown"
  353. ref="editColumns"
  354. trigger="click"
  355. @show="
  356. () => {
  357. showColumnsDropdown = true;
  358. }
  359. "
  360. @hide="
  361. () => {
  362. showColumnsDropdown = false;
  363. }
  364. "
  365. >
  366. <div class="control has-addons" ref="trigger">
  367. <button class="button is-primary">
  368. <i class="material-icons icon-with-button"
  369. >tune</i
  370. >
  371. Columns
  372. </button>
  373. <button class="button">
  374. <i class="material-icons">
  375. {{
  376. showColumnsDropdown
  377. ? "expand_more"
  378. : "expand_less"
  379. }}
  380. </i>
  381. </button>
  382. </div>
  383. <template #content>
  384. <draggable
  385. item-key="name"
  386. v-model="orderedColumns"
  387. v-bind="columnDragOptions"
  388. tag="div"
  389. draggable=".item-draggable"
  390. class="nav-dropdown-items"
  391. @change="columnOrderChanged"
  392. >
  393. <template #item="{ element: column }">
  394. <button
  395. v-if="
  396. column.name !== 'select' &&
  397. column.name !== 'placeholder' &&
  398. column.name !== 'updatedPlaceholder'
  399. "
  400. :class="{
  401. sortable: column.sortable,
  402. 'item-draggable': column.draggable,
  403. 'nav-item': true
  404. }"
  405. @click.prevent="
  406. toggleColumnVisibility(column)
  407. "
  408. >
  409. <p
  410. class="
  411. control
  412. is-expanded
  413. checkbox-control
  414. "
  415. >
  416. <label class="switch">
  417. <input
  418. type="checkbox"
  419. :id="index"
  420. :checked="
  421. shownColumns.indexOf(
  422. column.name
  423. ) !== -1
  424. "
  425. @click="
  426. toggleColumnVisibility(
  427. column
  428. )
  429. "
  430. />
  431. <span
  432. :class="{
  433. slider: true,
  434. round: true,
  435. disabled:
  436. !column.hidable
  437. }"
  438. ></span>
  439. </label>
  440. <label :for="index">
  441. <span></span>
  442. <p>{{ column.displayName }}</p>
  443. </label>
  444. </p>
  445. </button>
  446. </template>
  447. </draggable>
  448. </template>
  449. </tippy>
  450. </div>
  451. </div>
  452. <div class="table-container">
  453. <table
  454. :class="{
  455. table: true,
  456. 'has-checkboxes': hasCheckboxes
  457. }"
  458. >
  459. <thead>
  460. <draggable
  461. item-key="name"
  462. v-model="orderedColumns"
  463. v-bind="columnDragOptions"
  464. tag="tr"
  465. handle=".handle"
  466. draggable=".item-draggable"
  467. @change="columnOrderChanged"
  468. >
  469. <template #item="{ element: column }">
  470. <th
  471. v-if="
  472. !(
  473. column.name === 'select' &&
  474. rows.length === 0
  475. ) &&
  476. shownColumns.indexOf(column.name) !== -1
  477. "
  478. :class="{
  479. sortable: column.sortable,
  480. 'item-draggable': column.draggable
  481. }"
  482. :style="{
  483. minWidth: Number.isNaN(column.minWidth)
  484. ? column.minWidth
  485. : `${column.minWidth}px`,
  486. width: Number.isNaN(column.width)
  487. ? column.width
  488. : `${column.width}px`,
  489. maxWidth: Number.isNaN(column.maxWidth)
  490. ? column.maxWidth
  491. : `${column.maxWidth}px`
  492. }"
  493. >
  494. <div v-if="column.name === 'select'">
  495. <p class="checkbox">
  496. <input
  497. type="checkbox"
  498. :checked="
  499. rows.filter(
  500. row => !row.removed
  501. ).length ===
  502. selectedRows.length
  503. "
  504. @click="toggleAllRows()"
  505. />
  506. </p>
  507. </div>
  508. <div v-else class="handle">
  509. <span>
  510. {{ column.displayName }}
  511. </span>
  512. <span
  513. v-if="column.sortable"
  514. :content="`Sort by ${column.displayName}`"
  515. v-tippy
  516. >
  517. <span
  518. v-if="
  519. !sort[column.sortProperty]
  520. "
  521. class="material-icons"
  522. @click="changeSort(column)"
  523. >
  524. unfold_more
  525. </span>
  526. <span
  527. v-if="
  528. sort[
  529. column.sortProperty
  530. ] === 'ascending'
  531. "
  532. class="material-icons active"
  533. @click="changeSort(column)"
  534. >
  535. expand_more
  536. </span>
  537. <span
  538. v-if="
  539. sort[
  540. column.sortProperty
  541. ] === 'descending'
  542. "
  543. class="material-icons active"
  544. @click="changeSort(column)"
  545. >
  546. expand_less
  547. </span>
  548. </span>
  549. </div>
  550. <div
  551. class="resizer"
  552. v-if="column.resizable"
  553. @mousedown.prevent.stop="
  554. columnResizingStart(column, $event)
  555. "
  556. @touchstart.prevent.stop="
  557. columnResizingStart(column, $event)
  558. "
  559. @mouseup="columnResizingStop()"
  560. @touchend="columnResizingStop()"
  561. @dblclick="columnResetWidth(column)"
  562. ></div>
  563. </th>
  564. </template>
  565. </draggable>
  566. </thead>
  567. <tbody>
  568. <tr
  569. v-for="(item, itemIndex) in rows"
  570. :key="item._id"
  571. :class="{
  572. selected: item.selected,
  573. highlighted: item.highlighted,
  574. updated: item.updated,
  575. removed: item.removed
  576. }"
  577. >
  578. <td
  579. v-for="column in sortedFilteredColumns"
  580. :key="`${item._id}-${column.name}`"
  581. >
  582. <slot
  583. :name="`column-${column.name}`"
  584. :item="item"
  585. v-if="
  586. column.properties.length === 0 ||
  587. column.properties.every(property =>
  588. property
  589. .split('.')
  590. .reduce(
  591. (previous, current) =>
  592. (previous !== null &&
  593. previous[
  594. current
  595. ]) !== null || null,
  596. item
  597. )
  598. )
  599. "
  600. ></slot>
  601. <div
  602. v-if="
  603. column.name === 'updatedPlaceholder' &&
  604. item.updated
  605. "
  606. class="updated-tooltip"
  607. content="Row updated"
  608. v-tippy="{
  609. theme: 'info',
  610. placement: 'right'
  611. }"
  612. ></div>
  613. <p
  614. class="checkbox"
  615. v-if="column.name === 'select'"
  616. >
  617. <input
  618. type="checkbox"
  619. :checked="item.selected"
  620. @click="
  621. toggleSelectedRow(itemIndex, $event)
  622. "
  623. :disabled="item.removed"
  624. />
  625. </p>
  626. <span
  627. v-if="item.removed"
  628. class="removed-overlay"
  629. content="Item removed"
  630. v-tippy="{ theme: 'info' }"
  631. ></span>
  632. <div
  633. class="resizer"
  634. v-if="column.resizable"
  635. @mousedown.prevent.stop="
  636. columnResizingStart(column, $event)
  637. "
  638. @touchstart.prevent.stop="
  639. columnResizingStart(column, $event)
  640. "
  641. @mouseup="columnResizingStop()"
  642. @touchend="columnResizingStop()"
  643. @dblclick="columnResetWidth(column)"
  644. ></div>
  645. </td>
  646. </tr>
  647. </tbody>
  648. </table>
  649. </div>
  650. <div class="table-footer">
  651. <div class="page-controls">
  652. <button
  653. :class="{ disabled: page === 1 }"
  654. class="button is-primary material-icons"
  655. :disabled="page === 1"
  656. @click="changePage(1)"
  657. content="First Page"
  658. v-tippy
  659. >
  660. skip_previous
  661. </button>
  662. <button
  663. :class="{ disabled: page === 1 }"
  664. class="button is-primary material-icons"
  665. :disabled="page === 1"
  666. @click="changePage(page - 1)"
  667. content="Previous Page"
  668. v-tippy
  669. >
  670. fast_rewind
  671. </button>
  672. <p>Page {{ page }} / {{ lastPage }}</p>
  673. <button
  674. :class="{ disabled: page === lastPage }"
  675. class="button is-primary material-icons"
  676. :disabled="page === lastPage"
  677. @click="changePage(page + 1)"
  678. content="Next Page"
  679. v-tippy
  680. >
  681. fast_forward
  682. </button>
  683. <button
  684. :class="{ disabled: page === lastPage }"
  685. class="button is-primary material-icons"
  686. :disabled="page === lastPage"
  687. @click="changePage(lastPage)"
  688. content="Last Page"
  689. v-tippy
  690. >
  691. skip_next
  692. </button>
  693. </div>
  694. <div class="page-size">
  695. <div class="control">
  696. <label class="label">Items per page</label>
  697. <p class="control select">
  698. <select
  699. v-model.number="pageSize"
  700. @change="changePageSize()"
  701. >
  702. <option value="10">10</option>
  703. <option value="25">25</option>
  704. <option value="50">50</option>
  705. <option value="100">100</option>
  706. <option value="250">250</option>
  707. <option value="500">500</option>
  708. <option value="1000">1000</option>
  709. </select>
  710. </p>
  711. </div>
  712. </div>
  713. </div>
  714. </div>
  715. <div
  716. v-if="hasCheckboxes && selectedRows.length > 0"
  717. class="bulk-popup"
  718. :style="{
  719. top: bulkPopup.top + 'px',
  720. left: bulkPopup.left + 'px'
  721. }"
  722. >
  723. <button
  724. class="button is-primary"
  725. :content="
  726. selectedRows.length === 1
  727. ? `${selectedRows.length} row selected`
  728. : `${selectedRows.length} rows selected`
  729. "
  730. v-tippy="{ theme: 'info' }"
  731. >
  732. {{ selectedRows.length }}
  733. </button>
  734. <slot name="bulk-actions" :item="selectedRows" />
  735. <div class="right">
  736. <slot name="bulk-actions-right" :item="selectedRows" />
  737. <span
  738. class="material-icons drag-icon"
  739. @mousedown.left="onDragBox"
  740. @touchstart="onDragBox"
  741. @dblclick="resetBulkActionsPosition()"
  742. >
  743. drag_indicator
  744. </span>
  745. </div>
  746. </div>
  747. </div>
  748. </template>
  749. <script>
  750. import { mapGetters } from "vuex";
  751. import draggable from "vuedraggable";
  752. import Toast from "toasters";
  753. import keyboardShortcuts from "@/keyboardShortcuts";
  754. import ws from "@/ws";
  755. export default {
  756. components: {
  757. draggable
  758. },
  759. props: {
  760. /*
  761. Column properties:
  762. name: Unique lowercase name
  763. displayName: Nice name for the column header
  764. properties: The properties this column needs to show data
  765. sortable: Boolean for whether the order of a particular column can be changed
  766. sortProperty: The property the backend will sort on if this column gets sorted, e.g. title
  767. hidable: Boolean for whether a column can be hidden
  768. defaultVisibility: Default visibility for a column, either "shown" or "hidden"
  769. draggable: Boolean for whether a column can be dragged/reordered,
  770. resizable: Boolean for whether a column can be resized
  771. minWidth: Minimum width of column, e.g. 50px
  772. width: Width of column, e.g. 100px
  773. maxWidth: Maximum width of column, e.g. 150px
  774. */
  775. columnDefault: { type: Object, default: () => {} },
  776. columns: { type: Array, default: null },
  777. filters: { type: Array, default: null },
  778. dataAction: { type: String, default: null },
  779. name: { type: String, default: null },
  780. maxWidth: { type: Number, default: 1880 },
  781. query: { type: Boolean, default: true },
  782. keyboardShortcuts: { type: Boolean, default: true },
  783. events: { type: Object, default: () => {} }
  784. },
  785. data() {
  786. return {
  787. page: 1,
  788. pageSize: 10,
  789. rows: [],
  790. count: 0, // TODO Rename
  791. sort: {},
  792. orderedColumns: [],
  793. shownColumns: [],
  794. columnDragOptions() {
  795. return {
  796. animation: 200,
  797. group: "columns",
  798. disabled: false,
  799. ghostClass: "draggable-list-ghost",
  800. filter: ".ignore-elements",
  801. fallbackTolerance: 50
  802. };
  803. },
  804. editingFilters: [],
  805. appliedFilters: [],
  806. filterOperator: "or",
  807. appliedFilterOperator: "or",
  808. filterOperators: [
  809. {
  810. name: "or",
  811. displayName: "OR"
  812. },
  813. {
  814. name: "and",
  815. displayName: "AND"
  816. },
  817. {
  818. name: "nor",
  819. displayName: "NOR"
  820. }
  821. ],
  822. resizing: {},
  823. allFilterTypes: {
  824. contains: {
  825. name: "contains",
  826. displayName: "Contains"
  827. },
  828. exact: {
  829. name: "exact",
  830. displayName: "Exact"
  831. },
  832. regex: {
  833. name: "regex",
  834. displayName: "Regex"
  835. },
  836. datetimeBefore: {
  837. name: "datetimeBefore",
  838. displayName: "Before"
  839. },
  840. datetimeAfter: {
  841. name: "datetimeAfter",
  842. displayName: "After"
  843. },
  844. numberLesserEqual: {
  845. name: "numberLesserEqual",
  846. displayName: "Less than or equal to"
  847. },
  848. numberLesser: {
  849. name: "numberLesser",
  850. displayName: "Less than"
  851. },
  852. numberGreater: {
  853. name: "numberGreater",
  854. displayName: "Greater than"
  855. },
  856. numberGreaterEqual: {
  857. name: "numberGreaterEqual",
  858. displayName: "Greater than or equal to"
  859. },
  860. numberEquals: {
  861. name: "numberEquals",
  862. displayName: "Equals"
  863. },
  864. boolean: {
  865. name: "boolean",
  866. displayName: "Boolean"
  867. }
  868. },
  869. bulkPopup: {
  870. top: 0,
  871. left: 0,
  872. pos1: 0,
  873. pos2: 0,
  874. pos3: 0,
  875. pos4: 0
  876. },
  877. addFilterValue: null,
  878. showFiltersDropdown: false,
  879. showColumnsDropdown: false,
  880. lastColumnResizerTapped: null,
  881. lastColumnResizerTappedDate: 0,
  882. lastBulkActionsTappedDate: 0,
  883. autosuggest: {
  884. inputFocussed: {},
  885. containerFocussed: {},
  886. keydownInputTimeout: {},
  887. items: {},
  888. allItems: {
  889. genres: ["edm", "pop", "test"]
  890. }
  891. }
  892. };
  893. },
  894. computed: {
  895. properties() {
  896. return Array.from(
  897. new Set(
  898. this.sortedFilteredColumns.flatMap(
  899. column => column.properties
  900. )
  901. )
  902. );
  903. },
  904. lastPage() {
  905. return Math.ceil(this.count / this.pageSize);
  906. },
  907. sortedFilteredColumns() {
  908. return this.orderedColumns.filter(
  909. column => this.shownColumns.indexOf(column.name) !== -1
  910. );
  911. },
  912. hidableSortedColumns() {
  913. return this.orderedColumns.filter(column => column.hidable);
  914. },
  915. lastSelectedItemIndex() {
  916. return this.rows.findIndex(item => item.highlighted);
  917. },
  918. selectedRows() {
  919. return this.rows.filter(row => row.selected);
  920. },
  921. hasCheckboxes() {
  922. return (
  923. this.$slots["bulk-actions"] != null ||
  924. this.$slots["bulk-actions-right"] != null
  925. );
  926. },
  927. ...mapGetters({
  928. socket: "websockets/getSocket"
  929. })
  930. },
  931. watch: {
  932. selectedRows(newSelectedRows, oldSelectedRows) {
  933. // If selected rows goes from zero to one or more selected, trigger onWindowResize, as otherwise the popup could be out of bounds
  934. if (oldSelectedRows.length === 0 && newSelectedRows.length > 0)
  935. this.onWindowResize();
  936. }
  937. },
  938. mounted() {
  939. const tableSettings = this.getTableSettings();
  940. this.orderedColumns = [
  941. {
  942. name: "updatedPlaceholder",
  943. displayName: "",
  944. properties: [],
  945. sortable: false,
  946. hidable: false,
  947. draggable: false,
  948. resizable: false,
  949. minWidth: 5,
  950. width: 5,
  951. maxWidth: 5
  952. },
  953. {
  954. name: "select",
  955. displayName: "",
  956. properties: [],
  957. sortable: false,
  958. hidable: false,
  959. draggable: false,
  960. resizable: false,
  961. minWidth: 47,
  962. defaultWidth: 47,
  963. maxWidth: 47
  964. },
  965. ...this.columns.map(column => ({
  966. ...this.columnDefault,
  967. ...column
  968. })),
  969. {
  970. name: "placeholder",
  971. displayName: "",
  972. properties: [],
  973. sortable: false,
  974. hidable: false,
  975. draggable: false,
  976. resizable: false,
  977. minWidth: "auto",
  978. width: "auto",
  979. maxWidth: "auto"
  980. }
  981. ].sort((columnA, columnB) => {
  982. // Always places updatedPlaceholder column in the first position
  983. if (columnA.name === "updatedPlaceholder") return -1;
  984. // Always places select column in the first position
  985. // if (columnA.name === "select") return -1;
  986. // Always places placeholder column in the last position
  987. if (columnB.name === "placeholder") return -1;
  988. // If there are no table settings stored, use default ordering
  989. if (!tableSettings || !tableSettings.columnOrder) return 0;
  990. const indexA = tableSettings.columnOrder.indexOf(columnA.name);
  991. const indexB = tableSettings.columnOrder.indexOf(columnB.name);
  992. // If either of the columns is not stored in the table settings, use default ordering
  993. if (indexA === -1 || indexB === -1) return 0;
  994. return indexA - indexB;
  995. });
  996. this.shownColumns = this.orderedColumns
  997. .filter(column => {
  998. // If table settings exist, use shownColumns from settings to determine which columns to show
  999. if (tableSettings && tableSettings.shownColumns)
  1000. return (
  1001. tableSettings.shownColumns.indexOf(column.name) !== -1
  1002. );
  1003. // Table settings don't exist, only show if the default visibility isn't hidden
  1004. return column.defaultVisibility !== "hidden";
  1005. })
  1006. .map(column => column.name);
  1007. this.recalculateWidths();
  1008. if (tableSettings) {
  1009. // If table settings' page is an integer, use it for the page
  1010. if (Number.isInteger(tableSettings?.page))
  1011. this.page = tableSettings.page;
  1012. // If table settings' pageSize is an integer, use it for the pageSize
  1013. if (Number.isInteger(tableSettings?.pageSize))
  1014. this.pageSize = tableSettings.pageSize;
  1015. // If table settings' columnSort exists, sort all still existing columns based on table settings' columnSort object
  1016. if (tableSettings.columnSort) {
  1017. Object.entries(tableSettings.columnSort).forEach(
  1018. ([columnName, sortDirection]) => {
  1019. if (
  1020. this.columns.find(
  1021. column => column.name === columnName
  1022. )
  1023. )
  1024. this.sort[columnName] = sortDirection;
  1025. }
  1026. );
  1027. }
  1028. // If table settings' columnWidths exists, load the stored widths into the columns
  1029. if (tableSettings.columnWidths) {
  1030. this.orderedColumns = this.orderedColumns.map(orderedColumn => {
  1031. const columnWidth = tableSettings.columnWidths.find(
  1032. column => column.name === orderedColumn.name
  1033. )?.width;
  1034. if (columnWidth)
  1035. return { ...orderedColumn, width: columnWidth };
  1036. return orderedColumn;
  1037. });
  1038. }
  1039. if (
  1040. tableSettings.filter &&
  1041. tableSettings.filter.appliedFilters &&
  1042. tableSettings.filter.appliedFilterOperator
  1043. ) {
  1044. const { appliedFilters, appliedFilterOperator } =
  1045. tableSettings.filter;
  1046. // Set the applied filter operator and filter operator to the value stored in table settings
  1047. this.appliedFilterOperator = this.filterOperator =
  1048. appliedFilterOperator;
  1049. // Set the applied filters and editing filters to the value stored in table settings, for all filters that are allowed
  1050. this.appliedFilters = appliedFilters.filter(appliedFilter =>
  1051. this.filters.find(
  1052. filter => appliedFilter.filter.name === filter.name
  1053. )
  1054. );
  1055. this.editingFilters = appliedFilters.filter(appliedFilter =>
  1056. this.filters.find(
  1057. filter => appliedFilter.filter.name === filter.name
  1058. )
  1059. );
  1060. }
  1061. }
  1062. this.resetBulkActionsPosition();
  1063. this.$nextTick(() => {
  1064. this.onWindowResize();
  1065. window.addEventListener("resize", this.onWindowResize);
  1066. });
  1067. ws.onConnect(this.init);
  1068. if (this.events && this.events.updated)
  1069. this.socket.on(`event:${this.events.updated.event}`, res => {
  1070. const index = this.rows
  1071. .map(row => row._id)
  1072. .indexOf(
  1073. this.events.updated.id
  1074. .split(".")
  1075. .reduce(
  1076. (previous, current) =>
  1077. (previous && previous[current]) || null,
  1078. res.data
  1079. )
  1080. );
  1081. const row = this.events.updated.item
  1082. .split(".")
  1083. .reduce(
  1084. (previous, current) =>
  1085. (previous && previous[current]) || null,
  1086. res.data
  1087. );
  1088. this.updateData(index, row);
  1089. });
  1090. if (this.events && this.events.removed)
  1091. this.socket.on(`event:${this.events.removed.event}`, res => {
  1092. const index = this.rows
  1093. .map(row => row._id)
  1094. .indexOf(
  1095. this.events.removed.id
  1096. .split(".")
  1097. .reduce(
  1098. (previous, current) =>
  1099. (previous && previous[current]) || null,
  1100. res.data
  1101. )
  1102. );
  1103. this.removeData(index);
  1104. });
  1105. if (this.keyboardShortcuts) {
  1106. // Navigation section
  1107. // Page navigation section
  1108. keyboardShortcuts.registerShortcut("advancedTable.previousPage", {
  1109. keyCode: 37, // 'Left arrow' key
  1110. ctrl: true,
  1111. preventDefault: true,
  1112. handler: () => {
  1113. // Previous page
  1114. console.log("Previous page");
  1115. }
  1116. });
  1117. keyboardShortcuts.registerShortcut("advancedTable.nextPage", {
  1118. keyCode: 39, // 'Right arrow' key
  1119. ctrl: true,
  1120. preventDefault: true,
  1121. handler: () => {
  1122. // Next page
  1123. console.log("Next page");
  1124. }
  1125. });
  1126. keyboardShortcuts.registerShortcut("advancedTable.firstPage", {
  1127. keyCode: 37, // 'Left arrow' key
  1128. ctrl: true,
  1129. shift: true,
  1130. preventDefault: true,
  1131. handler: () => {
  1132. // First page
  1133. console.log("First page");
  1134. }
  1135. });
  1136. keyboardShortcuts.registerShortcut("advancedTable.lastPage", {
  1137. keyCode: 39, // 'Right arrow' key
  1138. ctrl: true,
  1139. shift: true,
  1140. preventDefault: true,
  1141. handler: () => {
  1142. // Last page
  1143. console.log("Last page");
  1144. }
  1145. });
  1146. // Reset localStorage section
  1147. keyboardShortcuts.registerShortcut(
  1148. "advancedTable.resetLocalStorage",
  1149. {
  1150. keyCode: 116, // 'F5' key
  1151. ctrl: true,
  1152. preventDefault: true,
  1153. handler: () => {
  1154. // Reset local storage
  1155. console.log("Reset local storage");
  1156. }
  1157. }
  1158. );
  1159. // Selecting section
  1160. // Popup actions section
  1161. for (let i = 1; i <= 9; i += 1) {
  1162. keyboardShortcuts.registerShortcut(
  1163. `advancedTable.executePopupAction${i}`,
  1164. {
  1165. keyCode: 48 + i, // '1-9' keys, where 49 is 1 and 57 is 9
  1166. ctrl: true,
  1167. preventDefault: true,
  1168. handler: () => {
  1169. // Execute popup action 1-9
  1170. console.log(`Execute popup action ${i}`);
  1171. }
  1172. }
  1173. );
  1174. }
  1175. keyboardShortcuts.registerShortcut(
  1176. `advancedTable.selectPopupAction1`,
  1177. {
  1178. keyCode: 48, // '0' key
  1179. ctrl: true,
  1180. preventDefault: true,
  1181. handler: () => {
  1182. // Select popup action 0
  1183. console.log(`Select popup action`);
  1184. }
  1185. }
  1186. );
  1187. }
  1188. },
  1189. unmounted() {
  1190. window.removeEventListener("resize", this.onWindowResize);
  1191. if (this.storeTableSettingsDebounceTimeout)
  1192. clearTimeout(this.storeTableSettingsDebounceTimeout);
  1193. if (this.keyboardShortcuts) {
  1194. const shortcutNames = [
  1195. "advancedTable.previousPage",
  1196. "advancedTable.nextPage",
  1197. "advancedTable.firstPage",
  1198. "advancedTable.lastPage",
  1199. "advancedTable.resetLocalStorage",
  1200. "advancedTable.executePopupAction1",
  1201. "advancedTable.executePopupAction2",
  1202. "advancedTable.executePopupAction3",
  1203. "advancedTable.executePopupAction4",
  1204. "advancedTable.executePopupAction5",
  1205. "advancedTable.executePopupAction6",
  1206. "advancedTable.executePopupAction7",
  1207. "advancedTable.executePopupAction8",
  1208. "advancedTable.executePopupAction9",
  1209. "advancedTable.selectPopupAction1"
  1210. ];
  1211. shortcutNames.forEach(shortcutName => {
  1212. keyboardShortcuts.unregisterShortcut(shortcutName);
  1213. });
  1214. }
  1215. },
  1216. methods: {
  1217. init() {
  1218. this.getData();
  1219. if (this.query) this.setQuery();
  1220. if (this.events) {
  1221. if (this.events.room)
  1222. this.socket.dispatch(
  1223. "apis.joinRoom",
  1224. this.events.room,
  1225. () => {}
  1226. );
  1227. if (this.events.adminRoom)
  1228. this.socket.dispatch(
  1229. "apis.joinAdminRoom",
  1230. this.events.adminRoom,
  1231. () => {}
  1232. );
  1233. }
  1234. this.filters.forEach(filter => {
  1235. if (filter.autosuggest && filter.autosuggestDataAction) {
  1236. this.socket.dispatch(filter.autosuggestDataAction, res => {
  1237. if (res.status === "success") {
  1238. const { items } = res.data;
  1239. this.autosuggest.allItems[filter.name] = items;
  1240. } else {
  1241. new Toast(res.message);
  1242. }
  1243. });
  1244. }
  1245. });
  1246. },
  1247. getData() {
  1248. this.socket.dispatch(
  1249. this.dataAction,
  1250. this.page,
  1251. this.pageSize,
  1252. this.properties,
  1253. this.sort,
  1254. this.appliedFilters.map(filter => ({
  1255. ...filter,
  1256. filterType: filter.filterType.name
  1257. })),
  1258. this.appliedFilterOperator,
  1259. res => {
  1260. console.log(111, res);
  1261. if (res.status === "success") {
  1262. const { data, count } = res.data;
  1263. this.rows = data.map(row => ({
  1264. ...row,
  1265. selected: false
  1266. }));
  1267. this.count = count;
  1268. } else {
  1269. new Toast(res.message);
  1270. }
  1271. }
  1272. );
  1273. },
  1274. changePageSize() {
  1275. this.page = 1;
  1276. this.getData();
  1277. this.storeTableSettings();
  1278. },
  1279. changePage(page) {
  1280. if (page < 1) return;
  1281. if (page > this.lastPage) return;
  1282. if (page === this.page) return;
  1283. this.page = page;
  1284. this.getData();
  1285. if (this.query) this.setQuery();
  1286. },
  1287. changeSort(column) {
  1288. if (column.sortable) {
  1289. const { sortProperty } = column;
  1290. if (this.sort[sortProperty] === undefined)
  1291. this.sort[sortProperty] = "ascending";
  1292. else if (this.sort[sortProperty] === "ascending")
  1293. this.sort[sortProperty] = "descending";
  1294. else if (this.sort[sortProperty] === "descending")
  1295. delete this.sort[sortProperty];
  1296. this.getData();
  1297. this.storeTableSettings();
  1298. }
  1299. },
  1300. toggleColumnVisibility(column) {
  1301. if (!column.hidable) return false;
  1302. if (this.shownColumns.indexOf(column.name) !== -1) {
  1303. if (this.shownColumns.length <= 3)
  1304. return new Toast(
  1305. `Unable to hide column ${column.displayName}, there must be at least 1 visibile column`
  1306. );
  1307. this.shownColumns.splice(
  1308. this.shownColumns.indexOf(column.name),
  1309. 1
  1310. );
  1311. } else {
  1312. this.shownColumns.push(column.name);
  1313. }
  1314. this.recalculateWidths();
  1315. this.getData();
  1316. return this.storeTableSettings();
  1317. },
  1318. toggleSelectedRow(itemIndex, event) {
  1319. const { shiftKey, ctrlKey } = event;
  1320. // Shift was pressed, so attempt to select all items between the clicked item and last clicked item
  1321. if (shiftKey) {
  1322. // If the clicked item is already selected, prevent default, otherwise the checkbox will be unchecked
  1323. if (this.rows[itemIndex].selected) event.preventDefault();
  1324. // If there is a last clicked item
  1325. if (this.lastSelectedItemIndex >= 0) {
  1326. // Clicked item is lower than last item, so select upwards until it reaches the last selected item
  1327. if (itemIndex > this.lastSelectedItemIndex) {
  1328. for (
  1329. let itemIndexUp = itemIndex;
  1330. itemIndexUp > this.lastSelectedItemIndex;
  1331. itemIndexUp -= 1
  1332. ) {
  1333. this.rows[itemIndexUp].selected = true;
  1334. }
  1335. }
  1336. // Clicked item is higher than last item, so select downwards until it reaches the last selected item
  1337. else if (itemIndex < this.lastSelectedItemIndex) {
  1338. for (
  1339. let itemIndexDown = itemIndex;
  1340. itemIndexDown < this.lastSelectedItemIndex;
  1341. itemIndexDown += 1
  1342. ) {
  1343. this.rows[itemIndexDown].selected = true;
  1344. }
  1345. }
  1346. }
  1347. }
  1348. // Ctrl was pressed, so attempt to unselect all items between the clicked item and last clicked item
  1349. else if (ctrlKey) {
  1350. // If the clicked item is already unselected, prevent default, otherwise the checkbox will be checked
  1351. if (!this.rows[itemIndex].selected) event.preventDefault();
  1352. // If there is a last clicked item
  1353. if (this.lastSelectedItemIndex >= 0) {
  1354. // Clicked item is lower than last item, so unselect upwards until it reaches the last selected item
  1355. if (itemIndex > this.lastSelectedItemIndex) {
  1356. for (
  1357. let itemIndexUp = itemIndex;
  1358. itemIndexUp >= this.lastSelectedItemIndex;
  1359. itemIndexUp -= 1
  1360. ) {
  1361. this.rows[itemIndexUp].selected = false;
  1362. }
  1363. }
  1364. // Clicked item is higher than last item, so unselect downwards until it reaches the last selected item
  1365. else if (itemIndex < this.lastSelectedItemIndex) {
  1366. for (
  1367. let itemIndexDown = itemIndex;
  1368. itemIndexDown <= this.lastSelectedItemIndex;
  1369. itemIndexDown += 1
  1370. ) {
  1371. this.rows[itemIndexDown].selected = false;
  1372. }
  1373. }
  1374. }
  1375. }
  1376. // Neither ctrl nor shift were pressed, so toggle clicked item
  1377. else {
  1378. this.rows[itemIndex].selected = !this.rows[itemIndex].selected;
  1379. }
  1380. // Set the last clicked item to no longer be highlighted, if it exists
  1381. if (this.lastSelectedItemIndex >= 0)
  1382. this.rows[this.lastSelectedItemIndex].highlighted = false;
  1383. // Set the clicked item to be highlighted
  1384. this.rows[itemIndex].highlighted = true;
  1385. },
  1386. toggleAllRows() {
  1387. if (
  1388. this.rows.filter(row => !row.removed).length >
  1389. this.selectedRows.length
  1390. ) {
  1391. this.rows = this.rows.map(row => {
  1392. if (row.removed) return row;
  1393. return { ...row, selected: true };
  1394. });
  1395. } else {
  1396. this.rows = this.rows.map(row => {
  1397. if (row.removed) return row;
  1398. return { ...row, selected: false };
  1399. });
  1400. }
  1401. },
  1402. addFilterItem() {
  1403. this.editingFilters.push({
  1404. data: "",
  1405. filter: this.addFilterValue,
  1406. filterType:
  1407. this.allFilterTypes[this.addFilterValue.defaultFilterType]
  1408. });
  1409. },
  1410. removeFilterItem(index) {
  1411. this.editingFilters.splice(index, 1);
  1412. },
  1413. columnResizingStart(column, event) {
  1414. const eventIsTouch = event.type === "touchstart";
  1415. if (eventIsTouch) {
  1416. // Handle double click from touch (if this method is called for the same column twice in a row within one second)
  1417. if (
  1418. this.lastColumnResizerTapped === column &&
  1419. Date.now() - this.lastColumnResizerTappedDate <= 1000
  1420. ) {
  1421. this.columnResetWidth(column);
  1422. this.lastColumnResizerTapped = null;
  1423. this.lastColumnResizerTappedDate = 0;
  1424. return;
  1425. }
  1426. this.lastColumnResizerTapped = column;
  1427. this.lastColumnResizerTappedDate = Date.now();
  1428. }
  1429. this.resizing.resizing = true;
  1430. this.resizing.resizingColumn = column;
  1431. this.resizing.width = event.target.parentElement.offsetWidth;
  1432. this.resizing.lastX = eventIsTouch
  1433. ? event.targetTouches[0].clientX
  1434. : event.x;
  1435. },
  1436. columnResizing(event) {
  1437. if (this.resizing.resizing) {
  1438. const eventIsTouch = event.type === "touchmove";
  1439. if (!eventIsTouch && event.buttons !== 1) {
  1440. this.resizing.resizing = false;
  1441. this.storeTableSettings();
  1442. }
  1443. const x = eventIsTouch
  1444. ? event.changedTouches[0].clientX
  1445. : event.x;
  1446. this.resizing.width -= this.resizing.lastX - x;
  1447. this.resizing.lastX = x;
  1448. if (
  1449. this.resizing.resizingColumn.minWidth &&
  1450. this.resizing.resizingColumn.maxWidth
  1451. ) {
  1452. this.resizing.resizingColumn.width = Math.max(
  1453. Math.min(
  1454. this.resizing.resizingColumn.maxWidth,
  1455. this.resizing.width
  1456. ),
  1457. this.resizing.resizingColumn.minWidth
  1458. );
  1459. } else if (this.resizing.resizingColumn.minWidth) {
  1460. this.resizing.resizingColumn.width = Math.max(
  1461. this.resizing.width,
  1462. this.resizing.resizingColumn.minWidth
  1463. );
  1464. } else if (this.resizing.resizingColumn.maxWidth) {
  1465. this.resizing.resizingColumn.width = Math.min(
  1466. this.resizing.resizingColumn.maxWidth,
  1467. this.resizing.width
  1468. );
  1469. } else {
  1470. this.resizing.resizingColumn.width = this.resizing.width;
  1471. }
  1472. this.resizing.width = this.resizing.resizingColumn.width;
  1473. console.log(`New width: ${this.resizing.width}px`);
  1474. this.storeTableSettings();
  1475. }
  1476. },
  1477. columnResizingStop() {
  1478. this.resizing.resizing = false;
  1479. this.storeTableSettings();
  1480. },
  1481. columnResetWidth(column) {
  1482. const index = this.orderedColumns.indexOf(column);
  1483. if (column.defaultWidth && !Number.isNaN(column.defaultWidth))
  1484. this.orderedColumns[index].width = column.defaultWidth;
  1485. else if (
  1486. column.calculatedWidth &&
  1487. !Number.isNaN(column.calculatedWidth)
  1488. )
  1489. this.orderedColumns[index].width = column.calculatedWidth;
  1490. this.storeTableSettings();
  1491. },
  1492. filterTypes(filter) {
  1493. if (!filter || !filter.filterTypes) return [];
  1494. return filter.filterTypes.map(
  1495. filterType => this.allFilterTypes[filterType]
  1496. );
  1497. },
  1498. changeFilterType(index) {
  1499. this.editingFilters[index].filterType =
  1500. this.allFilterTypes[
  1501. this.editingFilters[index].filter.defaultFilterType
  1502. ];
  1503. },
  1504. onDragBox(e) {
  1505. const e1 = e || window.event;
  1506. const e1IsTouch = e1.type === "touchstart";
  1507. e1.preventDefault();
  1508. if (e1IsTouch) {
  1509. // Handle double click from touch (if this method is twice in a row within one second)
  1510. if (Date.now() - this.lastBulkActionsTappedDate <= 1000) {
  1511. this.resetBulkActionsPosition();
  1512. this.lastBulkActionsTappedDate = 0;
  1513. return;
  1514. }
  1515. this.lastBulkActionsTappedDate = Date.now();
  1516. }
  1517. this.bulkPopup.pos3 = e1IsTouch
  1518. ? e1.changedTouches[0].clientX
  1519. : e1.clientX;
  1520. this.bulkPopup.pos4 = e1IsTouch
  1521. ? e1.changedTouches[0].clientY
  1522. : e1.clientY;
  1523. document.onmousemove = document.ontouchmove = e => {
  1524. const e2 = e || window.event;
  1525. const e2IsTouch = e2.type === "touchmove";
  1526. if (!e2IsTouch) e2.preventDefault();
  1527. // Get the clientX and clientY
  1528. const e2ClientX = e2IsTouch
  1529. ? e2.changedTouches[0].clientX
  1530. : e2.clientX;
  1531. const e2ClientY = e2IsTouch
  1532. ? e2.changedTouches[0].clientY
  1533. : e2.clientY;
  1534. // calculate the new cursor position:
  1535. this.bulkPopup.pos1 = this.bulkPopup.pos3 - e2ClientX;
  1536. this.bulkPopup.pos2 = this.bulkPopup.pos4 - e2ClientY;
  1537. this.bulkPopup.pos3 = e2ClientX;
  1538. this.bulkPopup.pos4 = e2ClientY;
  1539. // set the element's new position:
  1540. this.bulkPopup.top -= this.bulkPopup.pos2;
  1541. this.bulkPopup.left -= this.bulkPopup.pos1;
  1542. if (this.bulkPopup.top < 0) this.bulkPopup.top = 0;
  1543. if (this.bulkPopup.top > document.body.clientHeight - 50)
  1544. this.bulkPopup.top = document.body.clientHeight - 50;
  1545. if (this.bulkPopup.left < 0) this.bulkPopup.left = 0;
  1546. if (this.bulkPopup.left > document.body.clientWidth - 400)
  1547. this.bulkPopup.left = document.body.clientWidth - 400;
  1548. };
  1549. document.onmouseup = document.ontouchend = () => {
  1550. document.onmouseup = null;
  1551. document.ontouchend = null;
  1552. document.onmousemove = null;
  1553. document.ontouchmove = null;
  1554. };
  1555. },
  1556. resetBulkActionsPosition() {
  1557. this.bulkPopup.top = document.body.clientHeight - 56;
  1558. this.bulkPopup.left = document.body.clientWidth / 2 - 200;
  1559. },
  1560. applyFilterAndGetData() {
  1561. this.appliedFilters = JSON.parse(
  1562. JSON.stringify(this.editingFilters)
  1563. );
  1564. this.appliedFilterOperator = this.filterOperator;
  1565. this.page = 1;
  1566. this.getData();
  1567. this.storeTableSettings();
  1568. },
  1569. recalculateWidths() {
  1570. let noWidthCount = 0;
  1571. let calculatedWidth = 0;
  1572. this.orderedColumns.forEach(column => {
  1573. if (
  1574. this.shownColumns.indexOf(column.name) !== -1 &&
  1575. (column.name !== "select" || this.hasCheckboxes)
  1576. )
  1577. if (
  1578. Number.isFinite(column.width) &&
  1579. !Number.isFinite(column.calculatedWidth)
  1580. ) {
  1581. calculatedWidth += column.width;
  1582. } else if (Number.isFinite(column.defaultWidth)) {
  1583. calculatedWidth += column.defaultWidth;
  1584. } else {
  1585. noWidthCount += 1;
  1586. }
  1587. });
  1588. calculatedWidth = Math.floor(
  1589. (Math.min(this.maxWidth, document.body.clientWidth) -
  1590. calculatedWidth) /
  1591. (noWidthCount - 1)
  1592. );
  1593. this.orderedColumns = this.orderedColumns.map(column => {
  1594. const orderedColumn = column;
  1595. if (this.shownColumns.indexOf(orderedColumn.name) !== -1) {
  1596. let newWidth;
  1597. if (Number.isFinite(orderedColumn.defaultWidth)) {
  1598. newWidth = orderedColumn.defaultWidth;
  1599. } else {
  1600. // eslint-disable-next-line no-param-reassign
  1601. newWidth = orderedColumn.calculatedWidth = Math.min(
  1602. Math.max(
  1603. orderedColumn.minWidth || 100, // fallback 100px min width
  1604. calculatedWidth
  1605. ),
  1606. orderedColumn.maxWidth || 1000 // fallback 1000px max width
  1607. );
  1608. }
  1609. if (newWidth && !Number.isFinite(orderedColumn.width))
  1610. orderedColumn.width = newWidth;
  1611. }
  1612. return orderedColumn;
  1613. });
  1614. },
  1615. columnOrderChanged() {
  1616. this.storeTableSettings();
  1617. },
  1618. getTableSettings() {
  1619. const urlTableSettings = {};
  1620. if (this.query) {
  1621. if (this.$route.query.page)
  1622. urlTableSettings.page = Number.parseInt(
  1623. this.$route.query.page
  1624. );
  1625. if (this.$route.query.pageSize)
  1626. urlTableSettings.pageSize = Number.parseInt(
  1627. this.$route.query.pageSize
  1628. );
  1629. if (this.$route.query.shownColumns)
  1630. urlTableSettings.shownColumns = JSON.parse(
  1631. this.$route.query.shownColumns
  1632. );
  1633. if (this.$route.query.columnOrder)
  1634. urlTableSettings.columnOrder = JSON.parse(
  1635. this.$route.query.columnOrder
  1636. );
  1637. if (this.$route.query.columnWidths)
  1638. urlTableSettings.columnWidths = JSON.parse(
  1639. this.$route.query.columnWidths
  1640. );
  1641. if (this.$route.query.columnSort)
  1642. urlTableSettings.columnSort = JSON.parse(
  1643. this.$route.query.columnSort
  1644. );
  1645. if (this.$route.query.filter)
  1646. urlTableSettings.filter = JSON.parse(
  1647. this.$route.query.filter
  1648. );
  1649. }
  1650. const localStorageTableSettings = JSON.parse(
  1651. localStorage.getItem(`advancedTableSettings:${this.name}`)
  1652. );
  1653. return {
  1654. ...localStorageTableSettings,
  1655. ...urlTableSettings
  1656. };
  1657. },
  1658. storeTableSettings() {
  1659. // Clear debounce timeout
  1660. if (this.storeTableSettingsDebounceTimeout)
  1661. clearTimeout(this.storeTableSettingsDebounceTimeout);
  1662. // Resizing calls this function a lot, so rather than saving dozens of times a second, use debouncing
  1663. this.storeTableSettingsDebounceTimeout = setTimeout(() => {
  1664. if (this.query) this.setQuery();
  1665. this.setLocalStorage();
  1666. }, 250);
  1667. },
  1668. setQuery() {
  1669. const queryObject = {
  1670. ...this.$route.query,
  1671. page: this.page,
  1672. pageSize: this.pageSize,
  1673. filter: JSON.stringify({
  1674. appliedFilters: this.appliedFilters,
  1675. appliedFilterOperator: this.appliedFilterOperator
  1676. }),
  1677. columnSort: JSON.stringify(this.sort),
  1678. columnOrder: JSON.stringify(
  1679. this.orderedColumns.map(column => column.name)
  1680. ),
  1681. columnWidths: JSON.stringify(
  1682. this.orderedColumns.map(column => ({
  1683. name: column.name,
  1684. width: column.width
  1685. }))
  1686. ),
  1687. shownColumns: JSON.stringify(this.shownColumns)
  1688. };
  1689. const queryString = `?${Object.keys(queryObject)
  1690. .map(key => `${key}=${queryObject[key]}`)
  1691. .join("&")}`;
  1692. window.history.replaceState(null, null, queryString);
  1693. },
  1694. setLocalStorage() {
  1695. localStorage.setItem(
  1696. `advancedTableSettings:${this.name}`,
  1697. JSON.stringify({
  1698. pageSize: this.pageSize,
  1699. filter: {
  1700. appliedFilters: this.appliedFilters,
  1701. appliedFilterOperator: this.appliedFilterOperator
  1702. },
  1703. columnSort: this.sort,
  1704. columnOrder: this.orderedColumns.map(column => column.name),
  1705. columnWidths: this.orderedColumns.map(column => ({
  1706. name: column.name,
  1707. width: column.width
  1708. })),
  1709. shownColumns: this.shownColumns
  1710. })
  1711. );
  1712. },
  1713. onWindowResize() {
  1714. // Only change the position if the popup is actually visible
  1715. if (this.selectedRows.length === 0) return;
  1716. if (this.bulkPopup.top < 0) this.bulkPopup.top = 0;
  1717. if (this.bulkPopup.top > document.body.clientHeight - 50)
  1718. this.bulkPopup.top = document.body.clientHeight - 50;
  1719. if (this.bulkPopup.left < 0) this.bulkPopup.left = 0;
  1720. if (this.bulkPopup.left > document.body.clientWidth - 400)
  1721. this.bulkPopup.left = document.body.clientWidth - 400;
  1722. },
  1723. updateData(index, data) {
  1724. this.rows[index] = { ...this.rows[index], ...data, updated: true };
  1725. },
  1726. removeData(index) {
  1727. this.rows[index] = {
  1728. ...this.rows[index],
  1729. selected: false,
  1730. removed: true
  1731. };
  1732. },
  1733. blurFilterInput(filter) {
  1734. this.autosuggest.inputFocussed[filter.filter.name] = false;
  1735. },
  1736. focusFilterInput(filter) {
  1737. this.autosuggest.inputFocussed[filter.filter.name] = true;
  1738. },
  1739. keydownFilterInput(filter) {
  1740. const { name } = filter.filter;
  1741. clearTimeout(this.autosuggest.keydownInputTimeout[name]);
  1742. this.autosuggest.keydownInputTimeout[name] = setTimeout(() => {
  1743. if (filter.data.length > 1) {
  1744. this.autosuggest.items[name] = this.autosuggest.allItems[
  1745. name
  1746. ]?.filter(item =>
  1747. item.toLowerCase().startsWith(filter.data.toLowerCase())
  1748. );
  1749. } else this.autosuggest.items[name] = [];
  1750. }, 1000);
  1751. },
  1752. focusFilterAutosuggestContainer(filter) {
  1753. this.autosuggest.containerFocussed[filter.filter.name] = true;
  1754. },
  1755. blurFilterAutosuggestContainer(filter) {
  1756. this.autosuggest.containerFocussed[filter.filter.name] = false;
  1757. },
  1758. selectAutosuggestItem(index, filter, item) {
  1759. this.editingFilters[index].data = item;
  1760. this.autosuggest.items[filter.filter.name] = [];
  1761. }
  1762. }
  1763. };
  1764. </script>
  1765. <style lang="scss" scoped>
  1766. .night-mode {
  1767. .table-outer-container {
  1768. .table-container .table {
  1769. &,
  1770. thead th {
  1771. background-color: var(--dark-grey-3) !important;
  1772. color: var(--light-grey-2);
  1773. }
  1774. tr {
  1775. th,
  1776. td {
  1777. border-color: var(--dark-grey) !important;
  1778. &:first-child {
  1779. background-color: var(--dark-grey-3) !important;
  1780. }
  1781. }
  1782. &:nth-child(even) {
  1783. &,
  1784. td:first-child {
  1785. background-color: var(--dark-grey-2) !important;
  1786. }
  1787. }
  1788. &:hover,
  1789. &:focus,
  1790. &.highlighted {
  1791. th,
  1792. td {
  1793. &,
  1794. &:first-child {
  1795. background-color: var(--dark-grey-4) !important;
  1796. }
  1797. }
  1798. }
  1799. &.updated td:first-child {
  1800. background-color: var(--primary-color) !important;
  1801. }
  1802. }
  1803. &.has-checkboxes tbody tr {
  1804. td:nth-child(2) {
  1805. background-color: var(--dark-grey-3) !important;
  1806. }
  1807. &:nth-child(even) td:nth-child(2) {
  1808. background-color: var(--dark-grey-2) !important;
  1809. }
  1810. &.updated td:first-child {
  1811. background-color: var(--primary-color) !important;
  1812. }
  1813. &:hover,
  1814. &:focus,
  1815. &.highlighted {
  1816. th,
  1817. td {
  1818. &:nth-child(2) {
  1819. background-color: var(--dark-grey-4) !important;
  1820. }
  1821. }
  1822. }
  1823. }
  1824. }
  1825. .table-header,
  1826. .table-footer {
  1827. background-color: var(--dark-grey-3);
  1828. color: var(--light-grey-2);
  1829. }
  1830. .label.control {
  1831. background-color: var(--dark-grey) !important;
  1832. border-color: var(--grey-3) !important;
  1833. color: var(--white) !important;
  1834. }
  1835. }
  1836. .bulk-popup {
  1837. border: 0;
  1838. background-color: var(--dark-grey-2);
  1839. color: var(--white);
  1840. .material-icons {
  1841. color: var(--white);
  1842. }
  1843. }
  1844. .autosuggest-container {
  1845. background-color: var(--dark-grey) !important;
  1846. .autosuggest-item {
  1847. background-color: var(--dark-grey) !important;
  1848. color: var(--white) !important;
  1849. border-color: var(--dark-grey) !important;
  1850. }
  1851. .autosuggest-item:hover,
  1852. .autosuggest-item:focus {
  1853. background-color: var(--dark-grey-2) !important;
  1854. }
  1855. }
  1856. }
  1857. .table-outer-container {
  1858. border-radius: 5px;
  1859. box-shadow: 0 2px 3px rgba(10, 10, 10, 0.1), 0 0 0 1px rgba(10, 10, 10, 0.1);
  1860. margin: 10px 0;
  1861. overflow: hidden;
  1862. .table-container {
  1863. overflow-x: auto;
  1864. table {
  1865. border-collapse: separate;
  1866. table-layout: fixed;
  1867. thead {
  1868. tr {
  1869. th {
  1870. height: 40px;
  1871. line-height: 40px;
  1872. border: 1px solid var(--light-grey-2);
  1873. border-width: 1px 1px 1px 0;
  1874. padding: 0;
  1875. &:last-child {
  1876. border-width: 1px 0 1px;
  1877. }
  1878. &.sortable {
  1879. cursor: pointer;
  1880. }
  1881. & > div {
  1882. display: flex;
  1883. white-space: nowrap;
  1884. padding: 8px 10px;
  1885. & > span {
  1886. margin-left: 5px;
  1887. &:first-child {
  1888. margin-left: 0;
  1889. margin-right: auto;
  1890. }
  1891. & > .material-icons {
  1892. font-size: 22px;
  1893. position: relative;
  1894. top: 6px;
  1895. cursor: pointer;
  1896. &.active {
  1897. color: var(--primary-color);
  1898. }
  1899. &:hover,
  1900. &:focus {
  1901. filter: brightness(90%);
  1902. }
  1903. }
  1904. }
  1905. }
  1906. }
  1907. }
  1908. }
  1909. tbody {
  1910. tr {
  1911. &.highlighted {
  1912. background-color: var(--light-grey);
  1913. }
  1914. &.updated {
  1915. td:first-child {
  1916. background-color: var(--primary-color) !important;
  1917. }
  1918. }
  1919. td {
  1920. border: 1px solid var(--light-grey-2);
  1921. border-width: 0 1px 1px 0;
  1922. &:last-child {
  1923. border-width: 0 0 1px;
  1924. }
  1925. /deep/ .row-options {
  1926. display: flex;
  1927. justify-content: space-evenly;
  1928. .icon-with-button {
  1929. height: 30px;
  1930. width: 30px;
  1931. }
  1932. }
  1933. }
  1934. &.removed {
  1935. filter: grayscale(100%);
  1936. cursor: not-allowed;
  1937. user-select: none;
  1938. td .removed-overlay {
  1939. position: absolute;
  1940. top: 0;
  1941. left: 0;
  1942. bottom: 0;
  1943. right: 5px;
  1944. z-index: 5;
  1945. }
  1946. }
  1947. }
  1948. }
  1949. }
  1950. table {
  1951. thead tr,
  1952. tbody tr {
  1953. th,
  1954. td {
  1955. position: relative;
  1956. white-space: nowrap;
  1957. text-overflow: ellipsis;
  1958. overflow: hidden;
  1959. &:first-child {
  1960. display: table-cell;
  1961. position: sticky;
  1962. left: 0;
  1963. background-color: var(--white);
  1964. z-index: 2;
  1965. & > .updated-tooltip {
  1966. position: absolute;
  1967. top: 0;
  1968. left: 0;
  1969. bottom: 0;
  1970. right: 0;
  1971. }
  1972. }
  1973. &:nth-child(2) {
  1974. display: none;
  1975. }
  1976. .resizer {
  1977. height: 100%;
  1978. width: 5px;
  1979. background-color: transparent;
  1980. cursor: col-resize;
  1981. position: absolute;
  1982. right: 0;
  1983. top: 0;
  1984. }
  1985. }
  1986. &:nth-child(even) td:first-child {
  1987. background-color: #fafafa;
  1988. }
  1989. &:hover,
  1990. &:focus,
  1991. &.highlighted {
  1992. th,
  1993. td {
  1994. &,
  1995. &:first-child {
  1996. background-color: var(--light-grey);
  1997. }
  1998. }
  1999. }
  2000. }
  2001. &.has-checkboxes {
  2002. thead,
  2003. tbody {
  2004. tr {
  2005. th,
  2006. td {
  2007. &:nth-child(2) {
  2008. display: table-cell;
  2009. position: sticky;
  2010. left: 5px;
  2011. background-color: var(--white);
  2012. z-index: 2;
  2013. }
  2014. }
  2015. &:hover,
  2016. &:focus,
  2017. &.highlighted {
  2018. th,
  2019. td {
  2020. &:nth-child(2) {
  2021. background-color: var(--light-grey);
  2022. }
  2023. }
  2024. }
  2025. &.updated td:first-child {
  2026. background-color: var(--primary-color);
  2027. }
  2028. }
  2029. }
  2030. }
  2031. }
  2032. }
  2033. .table-header,
  2034. .table-footer {
  2035. display: flex;
  2036. flex-direction: row;
  2037. flex-wrap: wrap;
  2038. justify-content: space-between;
  2039. line-height: 36px;
  2040. background-color: var(--white);
  2041. }
  2042. .table-header > div {
  2043. display: flex;
  2044. flex-direction: row;
  2045. > span > .control {
  2046. margin: 5px;
  2047. }
  2048. .filters-indicator {
  2049. line-height: 46px;
  2050. display: flex;
  2051. align-items: center;
  2052. column-gap: 4px;
  2053. }
  2054. }
  2055. .table-footer {
  2056. .page-controls,
  2057. .page-size > .control {
  2058. display: flex;
  2059. flex-direction: row;
  2060. margin-bottom: 0 !important;
  2061. button {
  2062. margin: 5px;
  2063. font-size: 20px;
  2064. }
  2065. p,
  2066. label {
  2067. margin: 5px;
  2068. font-size: 14px;
  2069. font-weight: 600;
  2070. }
  2071. &.select::after {
  2072. top: 18px;
  2073. }
  2074. }
  2075. }
  2076. }
  2077. .control.is-grouped {
  2078. display: flex;
  2079. & > .control {
  2080. &.label {
  2081. height: 36px;
  2082. background-color: var(--white);
  2083. border: 1px solid var(--light-grey-2);
  2084. color: var(--dark-grey-2);
  2085. appearance: none;
  2086. border-radius: 3px;
  2087. font-size: 14px;
  2088. line-height: 34px;
  2089. padding-left: 8px;
  2090. padding-right: 8px;
  2091. }
  2092. &.select.is-expanded > select {
  2093. width: 100%;
  2094. }
  2095. & > input,
  2096. & > select,
  2097. & > .button,
  2098. &.label {
  2099. border-radius: 0;
  2100. }
  2101. &:first-child {
  2102. & > input,
  2103. & > select,
  2104. & > .button,
  2105. &.label {
  2106. border-radius: 5px 0 0 5px;
  2107. }
  2108. }
  2109. &:last-child {
  2110. & > input,
  2111. & > select,
  2112. & > .button,
  2113. &.label {
  2114. border-radius: 0 5px 5px 0;
  2115. }
  2116. }
  2117. & > .button {
  2118. font-size: 22px;
  2119. }
  2120. }
  2121. @media screen and (max-width: 600px) {
  2122. &.advanced-filter {
  2123. flex-wrap: wrap;
  2124. .control.select {
  2125. width: 50%;
  2126. select {
  2127. width: 100%;
  2128. }
  2129. }
  2130. .control {
  2131. margin-bottom: 0 !important;
  2132. &:nth-child(1) select {
  2133. border-radius: 5px 0 0 0;
  2134. }
  2135. &:nth-child(2) select {
  2136. border-radius: 0 5px 0 0;
  2137. }
  2138. &:nth-child(3) input {
  2139. border-radius: 0 0 0 5px;
  2140. }
  2141. &:nth-child(4) button {
  2142. border-radius: 0 0 5px 0;
  2143. }
  2144. }
  2145. }
  2146. }
  2147. }
  2148. .autosuggest-container {
  2149. position: absolute;
  2150. background: var(--white);
  2151. width: calc(100% + 1px);
  2152. top: 35px;
  2153. z-index: 200;
  2154. overflow: auto;
  2155. max-height: 98px;
  2156. clear: both;
  2157. .autosuggest-item {
  2158. padding: 8px;
  2159. display: block;
  2160. border: 1px solid var(--light-grey-2);
  2161. margin-top: -1px;
  2162. line-height: 16px;
  2163. cursor: pointer;
  2164. -webkit-user-select: none;
  2165. -ms-user-select: none;
  2166. -moz-user-select: none;
  2167. user-select: none;
  2168. }
  2169. .autosuggest-item:hover,
  2170. .autosuggest-item:focus {
  2171. background-color: var(--light-grey);
  2172. }
  2173. .autosuggest-item:first-child {
  2174. border-top: none;
  2175. }
  2176. .autosuggest-item:last-child {
  2177. border-radius: 0 0 3px 3px;
  2178. }
  2179. }
  2180. .advanced-filter {
  2181. .control {
  2182. position: relative;
  2183. }
  2184. }
  2185. .advanced-filter-bottom {
  2186. display: flex;
  2187. .button {
  2188. font-size: 16px !important;
  2189. width: 100%;
  2190. }
  2191. .control {
  2192. margin: 0 !important;
  2193. }
  2194. }
  2195. /deep/ .bulk-popup {
  2196. display: flex;
  2197. position: fixed;
  2198. flex-direction: row;
  2199. width: 100%;
  2200. max-width: 400px;
  2201. line-height: 36px;
  2202. z-index: 5;
  2203. border: 1px solid var(--light-grey-3);
  2204. border-radius: 5px;
  2205. box-shadow: 0 14px 28px rgba(0, 0, 0, 0.25), 0 10px 10px rgba(0, 0, 0, 0.22);
  2206. background-color: var(--white);
  2207. color: var(--dark-grey);
  2208. padding: 5px;
  2209. .right {
  2210. display: flex;
  2211. flex-direction: row;
  2212. margin-left: auto;
  2213. }
  2214. .drag-icon {
  2215. position: relative;
  2216. top: 6px;
  2217. color: var(--dark-grey);
  2218. cursor: move;
  2219. }
  2220. .bulk-actions {
  2221. display: flex;
  2222. flex-direction: row;
  2223. width: 100%;
  2224. justify-content: space-evenly;
  2225. .material-icons {
  2226. position: relative;
  2227. top: 6px;
  2228. margin-left: 5px;
  2229. cursor: pointer;
  2230. color: var(--primary-color);
  2231. &:hover,
  2232. &:focus {
  2233. filter: brightness(90%);
  2234. }
  2235. }
  2236. .delete-icon {
  2237. color: var(--dark-red);
  2238. }
  2239. }
  2240. }
  2241. </style>