AdvancedTable.vue 58 KB

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