AdvancedTable.vue 59 KB

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