AdvancedTable.vue 57 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393
  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: true,
  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. this.rows[itemIndexUp].selected = true;
  1356. }
  1357. }
  1358. // Clicked item is higher than last item, so select downwards until it reaches the last selected item
  1359. else if (itemIndex < this.lastSelectedItemIndex) {
  1360. for (
  1361. let itemIndexDown = itemIndex;
  1362. itemIndexDown < this.lastSelectedItemIndex;
  1363. itemIndexDown += 1
  1364. ) {
  1365. this.rows[itemIndexDown].selected = true;
  1366. }
  1367. }
  1368. }
  1369. }
  1370. // Ctrl was pressed, so attempt to unselect all items between the clicked item and last clicked item
  1371. else if (ctrlKey) {
  1372. // If the clicked item is already unselected, prevent default, otherwise the checkbox will be checked
  1373. if (!this.rows[itemIndex].selected) event.preventDefault();
  1374. // If there is a last clicked item
  1375. if (this.lastSelectedItemIndex >= 0) {
  1376. // Clicked item is lower than last item, so unselect upwards until it reaches the last selected item
  1377. if (itemIndex > this.lastSelectedItemIndex) {
  1378. for (
  1379. let itemIndexUp = itemIndex;
  1380. itemIndexUp >= this.lastSelectedItemIndex;
  1381. itemIndexUp -= 1
  1382. ) {
  1383. this.rows[itemIndexUp].selected = false;
  1384. }
  1385. }
  1386. // Clicked item is higher than last item, so unselect downwards until it reaches the last selected item
  1387. else if (itemIndex < this.lastSelectedItemIndex) {
  1388. for (
  1389. let itemIndexDown = itemIndex;
  1390. itemIndexDown <= this.lastSelectedItemIndex;
  1391. itemIndexDown += 1
  1392. ) {
  1393. this.rows[itemIndexDown].selected = false;
  1394. }
  1395. }
  1396. }
  1397. }
  1398. // Neither ctrl nor shift were pressed, so toggle clicked item
  1399. else {
  1400. this.rows[itemIndex].selected = !this.rows[itemIndex].selected;
  1401. }
  1402. // Set the last clicked item to no longer be highlighted, if it exists
  1403. if (this.lastSelectedItemIndex >= 0)
  1404. this.rows[this.lastSelectedItemIndex].highlighted = false;
  1405. // Set the clicked item to be highlighted
  1406. this.rows[itemIndex].highlighted = true;
  1407. },
  1408. toggleAllRows() {
  1409. if (
  1410. this.rows.filter(row => !row.removed).length >
  1411. this.selectedRows.length
  1412. ) {
  1413. this.rows = this.rows.map(row => {
  1414. if (row.removed) return row;
  1415. return { ...row, selected: true };
  1416. });
  1417. } else {
  1418. this.rows = this.rows.map(row => {
  1419. if (row.removed) return row;
  1420. return { ...row, selected: false };
  1421. });
  1422. }
  1423. },
  1424. addFilterItem() {
  1425. this.editingFilters.push({
  1426. data: "",
  1427. filter: this.addFilterValue,
  1428. filterType:
  1429. this.allFilterTypes[this.addFilterValue.defaultFilterType]
  1430. });
  1431. },
  1432. removeFilterItem(index) {
  1433. this.editingFilters.splice(index, 1);
  1434. },
  1435. columnResizingStart(column, event) {
  1436. const eventIsTouch = event.type === "touchstart";
  1437. if (eventIsTouch) {
  1438. // Handle double click from touch (if this method is called for the same column twice in a row within one second)
  1439. if (
  1440. this.lastColumnResizerTapped === column &&
  1441. Date.now() - this.lastColumnResizerTappedDate <= 1000
  1442. ) {
  1443. this.columnResetWidth(column);
  1444. this.lastColumnResizerTapped = null;
  1445. this.lastColumnResizerTappedDate = 0;
  1446. return;
  1447. }
  1448. this.lastColumnResizerTapped = column;
  1449. this.lastColumnResizerTappedDate = Date.now();
  1450. }
  1451. this.resizing.resizing = true;
  1452. this.resizing.resizingColumn = column;
  1453. this.resizing.width = event.target.parentElement.offsetWidth;
  1454. this.resizing.lastX = eventIsTouch
  1455. ? event.targetTouches[0].clientX
  1456. : event.x;
  1457. },
  1458. columnResizing(event) {
  1459. if (this.resizing.resizing) {
  1460. const eventIsTouch = event.type === "touchmove";
  1461. if (!eventIsTouch && event.buttons !== 1) {
  1462. this.resizing.resizing = false;
  1463. this.storeTableSettings();
  1464. }
  1465. const x = eventIsTouch
  1466. ? event.changedTouches[0].clientX
  1467. : event.x;
  1468. this.resizing.width -= this.resizing.lastX - x;
  1469. this.resizing.lastX = x;
  1470. if (
  1471. this.resizing.resizingColumn.minWidth &&
  1472. this.resizing.resizingColumn.maxWidth
  1473. ) {
  1474. this.resizing.resizingColumn.width = Math.max(
  1475. Math.min(
  1476. this.resizing.resizingColumn.maxWidth,
  1477. this.resizing.width
  1478. ),
  1479. this.resizing.resizingColumn.minWidth
  1480. );
  1481. } else if (this.resizing.resizingColumn.minWidth) {
  1482. this.resizing.resizingColumn.width = Math.max(
  1483. this.resizing.width,
  1484. this.resizing.resizingColumn.minWidth
  1485. );
  1486. } else if (this.resizing.resizingColumn.maxWidth) {
  1487. this.resizing.resizingColumn.width = Math.min(
  1488. this.resizing.resizingColumn.maxWidth,
  1489. this.resizing.width
  1490. );
  1491. } else {
  1492. this.resizing.resizingColumn.width = this.resizing.width;
  1493. }
  1494. this.resizing.width = this.resizing.resizingColumn.width;
  1495. console.log(`New width: ${this.resizing.width}px`);
  1496. this.storeTableSettings();
  1497. }
  1498. },
  1499. columnResizingStop() {
  1500. this.resizing.resizing = false;
  1501. this.storeTableSettings();
  1502. },
  1503. columnResetWidth(column) {
  1504. const index = this.orderedColumns.indexOf(column);
  1505. if (column.defaultWidth && !Number.isNaN(column.defaultWidth))
  1506. this.orderedColumns[index].width = column.defaultWidth;
  1507. else if (
  1508. column.calculatedWidth &&
  1509. !Number.isNaN(column.calculatedWidth)
  1510. )
  1511. this.orderedColumns[index].width = column.calculatedWidth;
  1512. this.storeTableSettings();
  1513. },
  1514. filterTypes(filter) {
  1515. if (!filter || !filter.filterTypes) return [];
  1516. return filter.filterTypes.map(
  1517. filterType => this.allFilterTypes[filterType]
  1518. );
  1519. },
  1520. changeFilterType(index) {
  1521. this.editingFilters[index].filterType =
  1522. this.allFilterTypes[
  1523. this.editingFilters[index].filter.defaultFilterType
  1524. ];
  1525. },
  1526. onDragBox(e) {
  1527. const e1 = e || window.event;
  1528. const e1IsTouch = e1.type === "touchstart";
  1529. e1.preventDefault();
  1530. if (e1IsTouch) {
  1531. // Handle double click from touch (if this method is twice in a row within one second)
  1532. if (Date.now() - this.lastBulkActionsTappedDate <= 1000) {
  1533. this.resetBulkActionsPosition();
  1534. this.lastBulkActionsTappedDate = 0;
  1535. return;
  1536. }
  1537. this.lastBulkActionsTappedDate = Date.now();
  1538. }
  1539. this.bulkPopup.pos3 = e1IsTouch
  1540. ? e1.changedTouches[0].clientX
  1541. : e1.clientX;
  1542. this.bulkPopup.pos4 = e1IsTouch
  1543. ? e1.changedTouches[0].clientY
  1544. : e1.clientY;
  1545. document.onmousemove = document.ontouchmove = e => {
  1546. const e2 = e || window.event;
  1547. const e2IsTouch = e2.type === "touchmove";
  1548. if (!e2IsTouch) e2.preventDefault();
  1549. // Get the clientX and clientY
  1550. const e2ClientX = e2IsTouch
  1551. ? e2.changedTouches[0].clientX
  1552. : e2.clientX;
  1553. const e2ClientY = e2IsTouch
  1554. ? e2.changedTouches[0].clientY
  1555. : e2.clientY;
  1556. // calculate the new cursor position:
  1557. this.bulkPopup.pos1 = this.bulkPopup.pos3 - e2ClientX;
  1558. this.bulkPopup.pos2 = this.bulkPopup.pos4 - e2ClientY;
  1559. this.bulkPopup.pos3 = e2ClientX;
  1560. this.bulkPopup.pos4 = e2ClientY;
  1561. // set the element's new position:
  1562. this.bulkPopup.top -= this.bulkPopup.pos2;
  1563. this.bulkPopup.left -= this.bulkPopup.pos1;
  1564. if (this.bulkPopup.top < 0) this.bulkPopup.top = 0;
  1565. if (this.bulkPopup.top > document.body.clientHeight - 50)
  1566. this.bulkPopup.top = document.body.clientHeight - 50;
  1567. if (this.bulkPopup.left < 0) this.bulkPopup.left = 0;
  1568. if (this.bulkPopup.left > document.body.clientWidth - 400)
  1569. this.bulkPopup.left = document.body.clientWidth - 400;
  1570. };
  1571. document.onmouseup = document.ontouchend = () => {
  1572. document.onmouseup = null;
  1573. document.ontouchend = null;
  1574. document.onmousemove = null;
  1575. document.ontouchmove = null;
  1576. };
  1577. },
  1578. resetBulkActionsPosition() {
  1579. this.bulkPopup.top = document.body.clientHeight - 56;
  1580. this.bulkPopup.left = document.body.clientWidth / 2 - 200;
  1581. },
  1582. applyFilterAndGetData() {
  1583. this.appliedFilters = JSON.parse(
  1584. JSON.stringify(this.editingFilters)
  1585. );
  1586. this.appliedFilterOperator = this.filterOperator;
  1587. this.page = 1;
  1588. this.getData();
  1589. this.storeTableSettings();
  1590. },
  1591. recalculateWidths() {
  1592. let noWidthCount = 0;
  1593. let calculatedWidth = 0;
  1594. this.orderedColumns.forEach(column => {
  1595. if (this.shownColumns.indexOf(column.name) !== -1)
  1596. if (
  1597. Number.isFinite(column.width) &&
  1598. !Number.isFinite(column.calculatedWidth)
  1599. ) {
  1600. calculatedWidth += column.width;
  1601. } else if (Number.isFinite(column.defaultWidth)) {
  1602. calculatedWidth += column.defaultWidth;
  1603. } else {
  1604. noWidthCount += 1;
  1605. }
  1606. });
  1607. calculatedWidth = Math.floor(
  1608. (Math.min(this.maxWidth, document.body.clientWidth) -
  1609. calculatedWidth) /
  1610. (noWidthCount - 1)
  1611. );
  1612. this.orderedColumns = this.orderedColumns.map(column => {
  1613. const orderedColumn = column;
  1614. if (this.shownColumns.indexOf(orderedColumn.name) !== -1) {
  1615. let newWidth;
  1616. if (Number.isFinite(orderedColumn.defaultWidth)) {
  1617. newWidth = orderedColumn.defaultWidth;
  1618. } else {
  1619. // eslint-disable-next-line no-param-reassign
  1620. newWidth = orderedColumn.calculatedWidth = Math.min(
  1621. Math.max(
  1622. orderedColumn.minWidth || 100, // fallback 100px min width
  1623. calculatedWidth
  1624. ),
  1625. orderedColumn.maxWidth || 1000 // fallback 1000px max width
  1626. );
  1627. }
  1628. if (newWidth && !Number.isFinite(orderedColumn.width))
  1629. orderedColumn.width = newWidth;
  1630. }
  1631. return orderedColumn;
  1632. });
  1633. },
  1634. columnOrderChanged() {
  1635. this.storeTableSettings();
  1636. },
  1637. getTableSettings() {
  1638. const urlTableSettings = {};
  1639. if (this.query) {
  1640. if (this.$route.query.page)
  1641. urlTableSettings.page = Number.parseInt(
  1642. this.$route.query.page
  1643. );
  1644. if (this.$route.query.pageSize)
  1645. urlTableSettings.pageSize = Number.parseInt(
  1646. this.$route.query.pageSize
  1647. );
  1648. if (this.$route.query.shownColumns)
  1649. urlTableSettings.shownColumns = JSON.parse(
  1650. this.$route.query.shownColumns
  1651. );
  1652. if (this.$route.query.columnOrder)
  1653. urlTableSettings.columnOrder = JSON.parse(
  1654. this.$route.query.columnOrder
  1655. );
  1656. if (this.$route.query.columnWidths)
  1657. urlTableSettings.columnWidths = JSON.parse(
  1658. this.$route.query.columnWidths
  1659. );
  1660. if (this.$route.query.columnSort)
  1661. urlTableSettings.columnSort = JSON.parse(
  1662. this.$route.query.columnSort
  1663. );
  1664. if (this.$route.query.filter)
  1665. urlTableSettings.filter = JSON.parse(
  1666. this.$route.query.filter
  1667. );
  1668. }
  1669. const localStorageTableSettings = JSON.parse(
  1670. localStorage.getItem(`advancedTableSettings:${this.name}`)
  1671. );
  1672. return {
  1673. ...localStorageTableSettings,
  1674. ...urlTableSettings
  1675. };
  1676. },
  1677. storeTableSettings() {
  1678. // Clear debounce timeout
  1679. if (this.storeTableSettingsDebounceTimeout)
  1680. clearTimeout(this.storeTableSettingsDebounceTimeout);
  1681. // Resizing calls this function a lot, so rather than saving dozens of times a second, use debouncing
  1682. this.storeTableSettingsDebounceTimeout = setTimeout(() => {
  1683. if (this.query) this.setQuery();
  1684. this.setLocalStorage();
  1685. }, 250);
  1686. },
  1687. setQuery() {
  1688. const queryObject = {
  1689. ...this.$route.query,
  1690. page: this.page,
  1691. pageSize: this.pageSize,
  1692. filter: JSON.stringify({
  1693. appliedFilters: this.appliedFilters,
  1694. appliedFilterOperator: this.appliedFilterOperator
  1695. }),
  1696. columnSort: JSON.stringify(this.sort),
  1697. columnOrder: JSON.stringify(
  1698. this.orderedColumns.map(column => column.name)
  1699. ),
  1700. columnWidths: JSON.stringify(
  1701. this.orderedColumns.map(column => ({
  1702. name: column.name,
  1703. width: column.width
  1704. }))
  1705. ),
  1706. shownColumns: JSON.stringify(this.shownColumns)
  1707. };
  1708. const queryString = `?${Object.keys(queryObject)
  1709. .map(key => `${key}=${queryObject[key]}`)
  1710. .join("&")}`;
  1711. window.history.replaceState(null, null, queryString);
  1712. },
  1713. setLocalStorage() {
  1714. localStorage.setItem(
  1715. `advancedTableSettings:${this.name}`,
  1716. JSON.stringify({
  1717. pageSize: this.pageSize,
  1718. filter: {
  1719. appliedFilters: this.appliedFilters,
  1720. appliedFilterOperator: this.appliedFilterOperator
  1721. },
  1722. columnSort: this.sort,
  1723. columnOrder: this.orderedColumns.map(column => column.name),
  1724. columnWidths: this.orderedColumns.map(column => ({
  1725. name: column.name,
  1726. width: column.width
  1727. })),
  1728. shownColumns: this.shownColumns
  1729. })
  1730. );
  1731. },
  1732. onWindowResize() {
  1733. // Only change the position if the popup is actually visible
  1734. if (this.selectedRows.length === 0) return;
  1735. if (this.bulkPopup.top < 0) this.bulkPopup.top = 0;
  1736. if (this.bulkPopup.top > document.body.clientHeight - 50)
  1737. this.bulkPopup.top = document.body.clientHeight - 50;
  1738. if (this.bulkPopup.left < 0) this.bulkPopup.left = 0;
  1739. if (this.bulkPopup.left > document.body.clientWidth - 400)
  1740. this.bulkPopup.left = document.body.clientWidth - 400;
  1741. },
  1742. updateData(index, data) {
  1743. this.rows[index] = { ...this.rows[index], ...data, updated: true };
  1744. },
  1745. removeData(index) {
  1746. this.rows[index] = {
  1747. ...this.rows[index],
  1748. selected: false,
  1749. removed: true
  1750. };
  1751. },
  1752. blurFilterInput(filter) {
  1753. this.autosuggest.inputFocussed[filter.filter.name] = false;
  1754. },
  1755. focusFilterInput(filter) {
  1756. this.autosuggest.inputFocussed[filter.filter.name] = true;
  1757. },
  1758. keydownFilterInput(filter) {
  1759. const { name } = filter.filter;
  1760. clearTimeout(this.autosuggest.keydownInputTimeout[name]);
  1761. this.autosuggest.keydownInputTimeout[name] = setTimeout(() => {
  1762. if (filter.data.length > 1) {
  1763. this.autosuggest.items[name] = this.autosuggest.allItems[
  1764. name
  1765. ]?.filter(item =>
  1766. item.toLowerCase().startsWith(filter.data.toLowerCase())
  1767. );
  1768. } else this.autosuggest.items[name] = [];
  1769. }, 1000);
  1770. },
  1771. focusFilterAutosuggestContainer(filter) {
  1772. this.autosuggest.containerFocussed[filter.filter.name] = true;
  1773. },
  1774. blurFilterAutosuggestContainer(filter) {
  1775. this.autosuggest.containerFocussed[filter.filter.name] = false;
  1776. },
  1777. selectAutosuggestItem(index, filter, item) {
  1778. this.editingFilters[index].data = item;
  1779. this.autosuggest.items[filter.filter.name] = [];
  1780. }
  1781. }
  1782. };
  1783. </script>
  1784. <style lang="scss" scoped>
  1785. .night-mode {
  1786. .table-outer-container {
  1787. .table-container .table {
  1788. &,
  1789. thead th {
  1790. background-color: var(--dark-grey-3) !important;
  1791. color: var(--light-grey-2);
  1792. }
  1793. tr {
  1794. th,
  1795. td {
  1796. border-color: var(--dark-grey) !important;
  1797. &:first-child {
  1798. background-color: var(--dark-grey-3) !important;
  1799. }
  1800. }
  1801. &:nth-child(even) {
  1802. &,
  1803. td:first-child {
  1804. background-color: var(--dark-grey-2) !important;
  1805. }
  1806. }
  1807. &:hover,
  1808. &:focus,
  1809. &.highlighted {
  1810. th,
  1811. td {
  1812. &,
  1813. &:first-child {
  1814. background-color: var(--dark-grey-4) !important;
  1815. }
  1816. }
  1817. }
  1818. &.updated td:first-child {
  1819. background-color: var(--primary-color) !important;
  1820. }
  1821. }
  1822. &.has-checkboxes tbody tr {
  1823. td:nth-child(2) {
  1824. background-color: var(--dark-grey-3) !important;
  1825. }
  1826. &:nth-child(even) td:nth-child(2) {
  1827. background-color: var(--dark-grey-2) !important;
  1828. }
  1829. &.updated td:first-child {
  1830. background-color: var(--primary-color) !important;
  1831. }
  1832. &:hover,
  1833. &:focus,
  1834. &.highlighted {
  1835. th,
  1836. td {
  1837. &:nth-child(2) {
  1838. background-color: var(--dark-grey-4) !important;
  1839. }
  1840. }
  1841. }
  1842. }
  1843. }
  1844. .table-header,
  1845. .table-footer {
  1846. background-color: var(--dark-grey-3);
  1847. color: var(--light-grey-2);
  1848. }
  1849. .table-no-results {
  1850. background-color: var(--dark-grey-3);
  1851. color: var(--light-grey-2);
  1852. border-color: var(--dark-grey) !important;
  1853. }
  1854. .label.control {
  1855. background-color: var(--dark-grey) !important;
  1856. border-color: var(--grey-3) !important;
  1857. color: var(--white) !important;
  1858. }
  1859. }
  1860. .bulk-popup {
  1861. border: 0;
  1862. background-color: var(--dark-grey-2);
  1863. color: var(--white);
  1864. .material-icons {
  1865. color: var(--white);
  1866. }
  1867. }
  1868. .autosuggest-container {
  1869. background-color: var(--dark-grey) !important;
  1870. .autosuggest-item {
  1871. background-color: var(--dark-grey) !important;
  1872. color: var(--white) !important;
  1873. border-color: var(--dark-grey) !important;
  1874. }
  1875. .autosuggest-item:hover,
  1876. .autosuggest-item:focus {
  1877. background-color: var(--dark-grey-2) !important;
  1878. }
  1879. }
  1880. }
  1881. .table-outer-container {
  1882. border-radius: 5px;
  1883. box-shadow: 0 2px 3px rgba(10, 10, 10, 0.1), 0 0 0 1px rgba(10, 10, 10, 0.1);
  1884. margin: 10px 0;
  1885. overflow: hidden;
  1886. .table-container {
  1887. overflow-x: auto;
  1888. table {
  1889. border-collapse: separate;
  1890. table-layout: fixed;
  1891. thead {
  1892. tr {
  1893. th {
  1894. height: 40px;
  1895. line-height: 40px;
  1896. border: 1px solid var(--light-grey-2);
  1897. border-width: 1px 1px 1px 0;
  1898. padding: 0;
  1899. &:last-child {
  1900. border-width: 1px 0 1px;
  1901. }
  1902. &.sortable {
  1903. cursor: pointer;
  1904. }
  1905. & > div {
  1906. display: flex;
  1907. white-space: nowrap;
  1908. padding: 8px 10px;
  1909. & > span {
  1910. margin-left: 5px;
  1911. &:first-child {
  1912. margin-left: 0;
  1913. margin-right: auto;
  1914. }
  1915. & > .material-icons {
  1916. font-size: 22px;
  1917. position: relative;
  1918. top: 6px;
  1919. cursor: pointer;
  1920. &.active {
  1921. color: var(--primary-color);
  1922. }
  1923. &:hover,
  1924. &:focus {
  1925. filter: brightness(90%);
  1926. }
  1927. }
  1928. }
  1929. }
  1930. }
  1931. }
  1932. }
  1933. tbody {
  1934. tr {
  1935. &.highlighted {
  1936. background-color: var(--light-grey);
  1937. }
  1938. &.updated {
  1939. td:first-child {
  1940. background-color: var(--primary-color) !important;
  1941. }
  1942. }
  1943. td {
  1944. border: 1px solid var(--light-grey-2);
  1945. border-width: 0 1px 1px 0;
  1946. &:last-child {
  1947. border-width: 0 0 1px;
  1948. }
  1949. /deep/ .row-options {
  1950. display: flex;
  1951. justify-content: space-evenly;
  1952. .icon-with-button {
  1953. height: 30px;
  1954. width: 30px;
  1955. }
  1956. }
  1957. }
  1958. &.removed {
  1959. filter: grayscale(100%);
  1960. cursor: not-allowed;
  1961. user-select: none;
  1962. td .removed-overlay {
  1963. position: absolute;
  1964. top: 0;
  1965. left: 0;
  1966. bottom: 0;
  1967. right: 5px;
  1968. z-index: 5;
  1969. }
  1970. }
  1971. }
  1972. }
  1973. }
  1974. table {
  1975. thead tr,
  1976. tbody tr {
  1977. th,
  1978. td {
  1979. position: relative;
  1980. white-space: nowrap;
  1981. text-overflow: ellipsis;
  1982. overflow: hidden;
  1983. &:first-child {
  1984. display: table-cell;
  1985. position: sticky;
  1986. left: 0;
  1987. background-color: var(--white);
  1988. z-index: 2;
  1989. & > .updated-tooltip {
  1990. position: absolute;
  1991. top: 0;
  1992. left: 0;
  1993. bottom: 0;
  1994. right: 0;
  1995. }
  1996. }
  1997. .resizer {
  1998. height: 100%;
  1999. width: 5px;
  2000. background-color: transparent;
  2001. cursor: col-resize;
  2002. position: absolute;
  2003. right: 0;
  2004. top: 0;
  2005. }
  2006. }
  2007. &:nth-child(even) td:first-child {
  2008. background-color: #fafafa;
  2009. }
  2010. &:hover,
  2011. &:focus,
  2012. &.highlighted {
  2013. th,
  2014. td {
  2015. &,
  2016. &:first-child {
  2017. background-color: var(--light-grey);
  2018. }
  2019. }
  2020. }
  2021. }
  2022. &.has-checkboxes {
  2023. thead,
  2024. tbody {
  2025. tr {
  2026. th,
  2027. td {
  2028. &:nth-child(2) {
  2029. display: table-cell;
  2030. position: sticky;
  2031. left: 5px;
  2032. background-color: var(--white);
  2033. z-index: 2;
  2034. }
  2035. }
  2036. &:hover,
  2037. &:focus,
  2038. &.highlighted {
  2039. th,
  2040. td {
  2041. &:nth-child(2) {
  2042. background-color: var(--light-grey);
  2043. }
  2044. }
  2045. }
  2046. &.updated td:first-child {
  2047. background-color: var(--primary-color);
  2048. }
  2049. }
  2050. }
  2051. }
  2052. }
  2053. }
  2054. .table-header,
  2055. .table-footer {
  2056. display: flex;
  2057. flex-direction: row;
  2058. flex-wrap: wrap;
  2059. justify-content: space-between;
  2060. line-height: 36px;
  2061. background-color: var(--white);
  2062. }
  2063. .table-header > div {
  2064. display: flex;
  2065. flex-direction: row;
  2066. > span > .control {
  2067. margin: 5px;
  2068. }
  2069. .filters-indicator {
  2070. line-height: 46px;
  2071. display: flex;
  2072. align-items: center;
  2073. column-gap: 4px;
  2074. }
  2075. }
  2076. .table-footer {
  2077. .page-controls,
  2078. .page-size > .control {
  2079. display: flex;
  2080. flex-direction: row;
  2081. margin-bottom: 0 !important;
  2082. button {
  2083. margin: 5px;
  2084. font-size: 20px;
  2085. }
  2086. p,
  2087. label {
  2088. margin: 5px;
  2089. font-size: 14px;
  2090. font-weight: 600;
  2091. }
  2092. &.select::after {
  2093. top: 18px;
  2094. }
  2095. }
  2096. }
  2097. .table-no-results {
  2098. display: flex;
  2099. flex-direction: row;
  2100. justify-content: center;
  2101. border-bottom: 1px solid var(--light-grey-2);
  2102. font-size: 18px;
  2103. line-height: 50px;
  2104. background-color: var(--white);
  2105. }
  2106. }
  2107. .control.is-grouped {
  2108. display: flex;
  2109. & > .control {
  2110. &.label {
  2111. height: 36px;
  2112. background-color: var(--white);
  2113. border: 1px solid var(--light-grey-2);
  2114. color: var(--dark-grey-2);
  2115. appearance: none;
  2116. border-radius: 3px;
  2117. font-size: 14px;
  2118. line-height: 34px;
  2119. padding-left: 8px;
  2120. padding-right: 8px;
  2121. }
  2122. &.select.is-expanded > select {
  2123. width: 100%;
  2124. }
  2125. & > input,
  2126. & > select,
  2127. & > .button,
  2128. &.label {
  2129. border-radius: 0;
  2130. }
  2131. &:first-child {
  2132. & > input,
  2133. & > select,
  2134. & > .button,
  2135. &.label {
  2136. border-radius: 5px 0 0 5px;
  2137. }
  2138. }
  2139. &:last-child {
  2140. & > input,
  2141. & > select,
  2142. & > .button,
  2143. &.label {
  2144. border-radius: 0 5px 5px 0;
  2145. }
  2146. }
  2147. & > .button {
  2148. font-size: 22px;
  2149. }
  2150. }
  2151. @media screen and (max-width: 600px) {
  2152. &.advanced-filter {
  2153. flex-wrap: wrap;
  2154. .control.select {
  2155. width: 50%;
  2156. select {
  2157. width: 100%;
  2158. }
  2159. }
  2160. .control {
  2161. margin-bottom: 0 !important;
  2162. &:nth-child(1) select {
  2163. border-radius: 5px 0 0 0;
  2164. }
  2165. &:nth-child(2) select {
  2166. border-radius: 0 5px 0 0;
  2167. }
  2168. &:nth-child(3) input {
  2169. border-radius: 0 0 0 5px;
  2170. }
  2171. &:nth-child(4) button {
  2172. border-radius: 0 0 5px 0;
  2173. }
  2174. }
  2175. }
  2176. }
  2177. }
  2178. .autosuggest-container {
  2179. position: absolute;
  2180. background: var(--white);
  2181. width: calc(100% + 1px);
  2182. top: 35px;
  2183. z-index: 200;
  2184. overflow: auto;
  2185. max-height: 98px;
  2186. clear: both;
  2187. .autosuggest-item {
  2188. padding: 8px;
  2189. display: block;
  2190. border: 1px solid var(--light-grey-2);
  2191. margin-top: -1px;
  2192. line-height: 16px;
  2193. cursor: pointer;
  2194. -webkit-user-select: none;
  2195. -ms-user-select: none;
  2196. -moz-user-select: none;
  2197. user-select: none;
  2198. }
  2199. .autosuggest-item:hover,
  2200. .autosuggest-item:focus {
  2201. background-color: var(--light-grey);
  2202. }
  2203. .autosuggest-item:first-child {
  2204. border-top: none;
  2205. }
  2206. .autosuggest-item:last-child {
  2207. border-radius: 0 0 3px 3px;
  2208. }
  2209. }
  2210. .advanced-filter {
  2211. .control {
  2212. position: relative;
  2213. }
  2214. }
  2215. .advanced-filter-bottom {
  2216. display: flex;
  2217. .button {
  2218. font-size: 16px !important;
  2219. width: 100%;
  2220. }
  2221. .control {
  2222. margin: 0 !important;
  2223. }
  2224. }
  2225. /deep/ .bulk-popup {
  2226. display: flex;
  2227. position: fixed;
  2228. flex-direction: row;
  2229. width: 100%;
  2230. max-width: 400px;
  2231. line-height: 36px;
  2232. z-index: 5;
  2233. border: 1px solid var(--light-grey-3);
  2234. border-radius: 5px;
  2235. box-shadow: 0 14px 28px rgba(0, 0, 0, 0.25), 0 10px 10px rgba(0, 0, 0, 0.22);
  2236. background-color: var(--white);
  2237. color: var(--dark-grey);
  2238. padding: 5px;
  2239. .right {
  2240. display: flex;
  2241. flex-direction: row;
  2242. margin-left: auto;
  2243. }
  2244. .drag-icon {
  2245. position: relative;
  2246. top: 6px;
  2247. color: var(--dark-grey);
  2248. cursor: move;
  2249. }
  2250. .bulk-actions {
  2251. display: flex;
  2252. flex-direction: row;
  2253. width: 100%;
  2254. justify-content: space-evenly;
  2255. .material-icons {
  2256. position: relative;
  2257. top: 6px;
  2258. margin-left: 5px;
  2259. cursor: pointer;
  2260. color: var(--primary-color);
  2261. &:hover,
  2262. &:focus {
  2263. filter: brightness(90%);
  2264. }
  2265. }
  2266. .delete-icon {
  2267. color: var(--dark-red);
  2268. }
  2269. }
  2270. }
  2271. </style>