AdvancedTable.vue 40 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646
  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.name"
  103. :selected="
  104. filter.filter
  105. .defaultFilterType ===
  106. filterType.name
  107. "
  108. >
  109. {{ filterType.displayName }}
  110. </option>
  111. </select>
  112. </div>
  113. <p class="control is-expanded">
  114. <input
  115. v-model="filter.data"
  116. class="input"
  117. type="text"
  118. placeholder="Search value"
  119. :disabled="!filter.filterType"
  120. @keydown.enter="applyFilterAndGetData()"
  121. />
  122. </p>
  123. <div class="control">
  124. <button
  125. class="button material-icons is-danger"
  126. @click="removeFilterItem(index)"
  127. >
  128. remove_circle_outline
  129. </button>
  130. </div>
  131. </div>
  132. <div
  133. v-if="editingFilters.length > 0"
  134. class="control is-expanded is-grouped"
  135. >
  136. <label class="control label"
  137. >Filter operator</label
  138. >
  139. <div class="control select is-expanded">
  140. <select v-model="filterOperator">
  141. <option
  142. v-for="operator in filterOperators"
  143. :key="operator.name"
  144. :value="operator.name"
  145. >
  146. {{ operator.displayName }}
  147. </option>
  148. </select>
  149. </div>
  150. </div>
  151. <div
  152. class="advanced-filter-bottom"
  153. v-if="editingFilters.length > 0"
  154. >
  155. <div class="control is-expanded">
  156. <button
  157. class="button is-info"
  158. @click="applyFilterAndGetData()"
  159. >
  160. <i
  161. class="
  162. material-icons
  163. icon-with-button
  164. "
  165. >filter_list</i
  166. >
  167. Apply filters
  168. </button>
  169. </div>
  170. </div>
  171. <div
  172. class="advanced-filter-bottom"
  173. v-else-if="editingFilters.length === 0"
  174. >
  175. <div class="control is-expanded">
  176. <button
  177. class="button is-info"
  178. @click="applyFilterAndGetData()"
  179. >
  180. <i
  181. class="
  182. material-icons
  183. icon-with-button
  184. "
  185. >filter_list</i
  186. >
  187. Apply filters
  188. </button>
  189. </div>
  190. </div>
  191. </template>
  192. </tippy>
  193. <tippy
  194. v-if="appliedFilters.length > 0"
  195. :touch="true"
  196. :interactive="true"
  197. theme="info"
  198. ref="activeFilters"
  199. >
  200. <div class="filters-indicator">
  201. {{ appliedFilters.length }}
  202. <i class="material-icons" @click.prevent="true"
  203. >filter_list</i
  204. >
  205. </div>
  206. <template #content>
  207. <p
  208. v-for="(filter, index) in appliedFilters"
  209. :key="`filter-${index}`"
  210. >
  211. {{ filter.filter.displayName }}
  212. {{
  213. appliedFilters.length === 1 &&
  214. appliedFilterOperator === "nor"
  215. ? "not"
  216. : ""
  217. }}
  218. {{ filter.filterType }} "{{ filter.data }}"
  219. {{
  220. appliedFilters.length === index + 1
  221. ? ""
  222. : appliedFilterOperator
  223. }}
  224. </p>
  225. </template>
  226. </tippy>
  227. <i
  228. v-else
  229. class="filters-indicator material-icons"
  230. content="No active filters"
  231. v-tippy="{ theme: 'info' }"
  232. >
  233. filter_list_off
  234. </i>
  235. </div>
  236. <div>
  237. <tippy
  238. v-if="hidableSortedColumns.length > 0"
  239. :touch="true"
  240. :interactive="true"
  241. placement="bottom-end"
  242. theme="dropdown"
  243. ref="editColumns"
  244. trigger="click"
  245. @show="
  246. () => {
  247. showColumnsDropdown = true;
  248. }
  249. "
  250. @hide="
  251. () => {
  252. showColumnsDropdown = false;
  253. }
  254. "
  255. >
  256. <div class="control has-addons" ref="trigger">
  257. <button class="button is-primary">
  258. <i class="material-icons icon-with-button"
  259. >tune</i
  260. >
  261. Columns
  262. </button>
  263. <button class="button">
  264. <i class="material-icons">
  265. {{
  266. showColumnsDropdown
  267. ? "expand_more"
  268. : "expand_less"
  269. }}
  270. </i>
  271. </button>
  272. </div>
  273. <template #content>
  274. <draggable
  275. item-key="name"
  276. v-model="orderedColumns"
  277. v-bind="columnDragOptions"
  278. tag="div"
  279. draggable=".item-draggable"
  280. class="nav-dropdown-items"
  281. @change="columnOrderChanged"
  282. >
  283. <template #item="{ element: column }">
  284. <button
  285. v-if="
  286. column.name !== 'select' &&
  287. column.name !== 'placeholder'
  288. "
  289. :class="{
  290. sortable: column.sortable,
  291. 'item-draggable': column.draggable,
  292. 'nav-item': true
  293. }"
  294. @click.prevent="
  295. toggleColumnVisibility(column)
  296. "
  297. >
  298. <p
  299. class="
  300. control
  301. is-expanded
  302. checkbox-control
  303. "
  304. >
  305. <label class="switch">
  306. <input
  307. v-if="column.hidable"
  308. type="checkbox"
  309. :id="index"
  310. :checked="
  311. shownColumns.indexOf(
  312. column.name
  313. ) !== -1
  314. "
  315. @click="
  316. toggleColumnVisibility(
  317. column
  318. )
  319. "
  320. />
  321. <span
  322. :class="{
  323. slider: true,
  324. round: true,
  325. disabled:
  326. !column.hidable
  327. }"
  328. ></span>
  329. </label>
  330. <label :for="index">
  331. <span></span>
  332. <p>{{ column.displayName }}</p>
  333. </label>
  334. </p>
  335. </button>
  336. </template>
  337. </draggable>
  338. </template>
  339. </tippy>
  340. </div>
  341. </div>
  342. <div class="table-container">
  343. <table class="table">
  344. <thead>
  345. <draggable
  346. item-key="name"
  347. v-model="orderedColumns"
  348. v-bind="columnDragOptions"
  349. tag="tr"
  350. handle=".handle"
  351. draggable=".item-draggable"
  352. @change="columnOrderChanged"
  353. >
  354. <template #item="{ element: column }">
  355. <th
  356. v-if="
  357. !(
  358. column.name === 'select' &&
  359. data.length === 0
  360. ) &&
  361. shownColumns.indexOf(column.name) !== -1
  362. "
  363. :class="{
  364. sortable: column.sortable,
  365. 'item-draggable': column.draggable
  366. }"
  367. :style="{
  368. minWidth: Number.isNaN(column.minWidth)
  369. ? column.minWidth
  370. : `${column.minWidth}px`,
  371. width: Number.isNaN(column.width)
  372. ? column.width
  373. : `${column.width}px`,
  374. maxWidth: Number.isNaN(column.maxWidth)
  375. ? column.maxWidth
  376. : `${column.maxWidth}px`
  377. }"
  378. >
  379. <div v-if="column.name === 'select'">
  380. <p class="checkbox">
  381. <input
  382. type="checkbox"
  383. :checked="
  384. data.length ===
  385. selectedRows.length
  386. "
  387. @click="toggleAllRows()"
  388. />
  389. </p>
  390. </div>
  391. <div v-else class="handle">
  392. <span>
  393. {{ column.displayName }}
  394. </span>
  395. <span
  396. v-if="column.sortable"
  397. :content="`Sort by ${column.displayName}`"
  398. v-tippy
  399. >
  400. <span
  401. v-if="
  402. !sort[column.sortProperty]
  403. "
  404. class="material-icons"
  405. @click="changeSort(column)"
  406. >
  407. unfold_more
  408. </span>
  409. <span
  410. v-if="
  411. sort[
  412. column.sortProperty
  413. ] === 'ascending'
  414. "
  415. class="material-icons active"
  416. @click="changeSort(column)"
  417. >
  418. expand_more
  419. </span>
  420. <span
  421. v-if="
  422. sort[
  423. column.sortProperty
  424. ] === 'descending'
  425. "
  426. class="material-icons active"
  427. @click="changeSort(column)"
  428. >
  429. expand_less
  430. </span>
  431. </span>
  432. </div>
  433. <div
  434. class="resizer"
  435. v-if="column.resizable"
  436. @mousedown.prevent.stop="
  437. columnResizingStart(column, $event)
  438. "
  439. @touchstart.prevent.stop="
  440. columnResizingStart(column, $event)
  441. "
  442. @mouseup="columnResizingStop()"
  443. @touchend="columnResizingStop()"
  444. @dblclick="columnResetWidth(column)"
  445. ></div>
  446. </th>
  447. </template>
  448. </draggable>
  449. </thead>
  450. <tbody>
  451. <tr
  452. v-for="(item, itemIndex) in data"
  453. :key="item._id"
  454. :class="{
  455. selected: item.selected,
  456. highlighted: item.highlighted
  457. }"
  458. >
  459. <td
  460. v-for="column in sortedFilteredColumns"
  461. :key="`${item._id}-${column.name}`"
  462. >
  463. <slot
  464. :name="`column-${column.name}`"
  465. :item="item"
  466. v-if="
  467. column.properties.length === 0 ||
  468. column.properties.every(
  469. property =>
  470. item[property] !== undefined
  471. )
  472. "
  473. ></slot>
  474. <p
  475. class="checkbox"
  476. v-if="column.name === 'select'"
  477. >
  478. <input
  479. type="checkbox"
  480. :checked="item.selected"
  481. @click="
  482. toggleSelectedRow(itemIndex, $event)
  483. "
  484. />
  485. </p>
  486. <div
  487. class="resizer"
  488. v-if="column.resizable"
  489. @mousedown.prevent.stop="
  490. columnResizingStart(column, $event)
  491. "
  492. @touchstart.prevent.stop="
  493. columnResizingStart(column, $event)
  494. "
  495. @mouseup="columnResizingStop()"
  496. @touchend="columnResizingStop()"
  497. @dblclick="columnResetWidth(column)"
  498. ></div>
  499. </td>
  500. </tr>
  501. </tbody>
  502. </table>
  503. </div>
  504. <div class="table-footer">
  505. <div class="page-controls">
  506. <button
  507. :class="{ disabled: page === 1 }"
  508. class="button is-primary material-icons"
  509. :disabled="page === 1"
  510. @click="changePage(1)"
  511. content="First Page"
  512. v-tippy
  513. >
  514. skip_previous
  515. </button>
  516. <button
  517. :class="{ disabled: page === 1 }"
  518. class="button is-primary material-icons"
  519. :disabled="page === 1"
  520. @click="changePage(page - 1)"
  521. content="Previous Page"
  522. v-tippy
  523. >
  524. fast_rewind
  525. </button>
  526. <p>Page {{ page }} / {{ lastPage }}</p>
  527. <button
  528. :class="{ disabled: page === lastPage }"
  529. class="button is-primary material-icons"
  530. :disabled="page === lastPage"
  531. @click="changePage(page + 1)"
  532. content="Next Page"
  533. v-tippy
  534. >
  535. fast_forward
  536. </button>
  537. <button
  538. :class="{ disabled: page === lastPage }"
  539. class="button is-primary material-icons"
  540. :disabled="page === lastPage"
  541. @click="changePage(lastPage)"
  542. content="Last Page"
  543. v-tippy
  544. >
  545. skip_next
  546. </button>
  547. </div>
  548. <div class="page-size">
  549. <div class="control">
  550. <label class="label">Items per page</label>
  551. <p class="control select">
  552. <select
  553. v-model.number="pageSize"
  554. @change="changePageSize()"
  555. >
  556. <option value="10">10</option>
  557. <option value="25">25</option>
  558. <option value="50">50</option>
  559. <option value="100">100</option>
  560. <option value="250">250</option>
  561. <option value="500">500</option>
  562. <option value="1000">1000</option>
  563. </select>
  564. </p>
  565. </div>
  566. </div>
  567. </div>
  568. </div>
  569. <div
  570. v-if="selectedRows.length > 0"
  571. class="bulk-popup"
  572. :style="{
  573. top: bulkPopup.top + 'px',
  574. left: bulkPopup.left + 'px'
  575. }"
  576. >
  577. <button
  578. class="button is-primary"
  579. :content="
  580. selectedRows.length === 1
  581. ? `${selectedRows.length} row selected`
  582. : `${selectedRows.length} rows selected`
  583. "
  584. v-tippy="{ theme: 'info' }"
  585. >
  586. {{ selectedRows.length }}
  587. </button>
  588. <slot name="bulk-actions" :item="selectedRows" />
  589. <div class="right">
  590. <slot name="bulk-actions-right" :item="selectedRows" />
  591. <span
  592. class="material-icons drag-icon"
  593. @mousedown.left="onDragBox"
  594. @touchstart="onDragBox"
  595. @dblclick="resetBulkActionsPosition()"
  596. >
  597. drag_indicator
  598. </span>
  599. </div>
  600. </div>
  601. </div>
  602. </template>
  603. <script>
  604. import { mapGetters } from "vuex";
  605. import draggable from "vuedraggable";
  606. import Toast from "toasters";
  607. import ws from "@/ws";
  608. export default {
  609. components: {
  610. draggable
  611. },
  612. props: {
  613. /*
  614. Column properties:
  615. name: Unique lowercase name
  616. displayName: Nice name for the column header
  617. properties: The properties this column needs to show data
  618. sortable: Boolean for whether the order of a particular column can be changed
  619. sortProperty: The property the backend will sort on if this column gets sorted, e.g. title
  620. hidable: Boolean for whether a column can be hidden
  621. defaultVisibility: Default visibility for a column, either "shown" or "hidden"
  622. draggable: Boolean for whether a column can be dragged/reordered,
  623. resizable: Boolean for whether a column can be resized
  624. minWidth: Minimum width of column, e.g. 50px
  625. width: Width of column, e.g. 100px
  626. maxWidth: Maximum width of column, e.g. 150px
  627. */
  628. columnDefault: { type: Object, default: () => {} },
  629. columns: { type: Array, default: null },
  630. filters: { type: Array, default: null },
  631. dataAction: { type: String, default: null },
  632. name: { type: String, default: null }
  633. },
  634. data() {
  635. return {
  636. page: 1,
  637. pageSize: 10,
  638. data: [],
  639. count: 0, // TODO Rename
  640. sort: {},
  641. orderedColumns: [],
  642. shownColumns: [],
  643. columnDragOptions() {
  644. return {
  645. animation: 200,
  646. group: "columns",
  647. disabled: false,
  648. ghostClass: "draggable-list-ghost",
  649. filter: ".ignore-elements",
  650. fallbackTolerance: 50
  651. };
  652. },
  653. editingFilters: [],
  654. appliedFilters: [],
  655. filterOperator: "or",
  656. appliedFilterOperator: "or",
  657. filterOperators: [
  658. {
  659. name: "or",
  660. displayName: "OR"
  661. },
  662. {
  663. name: "and",
  664. displayName: "AND"
  665. },
  666. {
  667. name: "nor",
  668. displayName: "NOR"
  669. }
  670. ],
  671. resizing: {},
  672. allFilterTypes: {
  673. contains: {
  674. name: "contains",
  675. displayName: "Contains"
  676. },
  677. exact: {
  678. name: "exact",
  679. displayName: "Exact"
  680. },
  681. regex: {
  682. name: "regex",
  683. displayName: "Regex"
  684. }
  685. },
  686. bulkPopup: {
  687. top: 0,
  688. left: 0,
  689. pos1: 0,
  690. pos2: 0,
  691. pos3: 0,
  692. pos4: 0
  693. },
  694. addFilterValue: null,
  695. showFiltersDropdown: false,
  696. showColumnsDropdown: false,
  697. lastColumnResizerTapped: null,
  698. lastColumnResizerTappedDate: 0,
  699. lastBulkActionsTappedDate: 0
  700. };
  701. },
  702. computed: {
  703. properties() {
  704. return Array.from(
  705. new Set(
  706. this.sortedFilteredColumns.flatMap(
  707. column => column.properties
  708. )
  709. )
  710. );
  711. },
  712. lastPage() {
  713. return Math.ceil(this.count / this.pageSize);
  714. },
  715. sortedFilteredColumns() {
  716. return this.orderedColumns.filter(
  717. column => this.shownColumns.indexOf(column.name) !== -1
  718. );
  719. },
  720. hidableSortedColumns() {
  721. return this.orderedColumns.filter(column => column.hidable);
  722. },
  723. lastSelectedItemIndex() {
  724. return this.data.findIndex(item => item.highlighted);
  725. },
  726. selectedRows() {
  727. return this.data.filter(data => data.selected);
  728. },
  729. ...mapGetters({
  730. socket: "websockets/getSocket"
  731. })
  732. },
  733. watch: {
  734. selectedRows(newSelectedRows, oldSelectedRows) {
  735. // If selected rows goes from zero to one or more selected, trigger onWindowResize, as otherwise the popup could be out of bounds
  736. if (oldSelectedRows.length === 0 && newSelectedRows.length > 0)
  737. this.onWindowResize();
  738. }
  739. },
  740. mounted() {
  741. const tableSettings = this.getTableSettings();
  742. this.orderedColumns = [
  743. {
  744. name: "select",
  745. displayName: "",
  746. properties: [],
  747. sortable: false,
  748. hidable: false,
  749. draggable: false,
  750. resizable: false,
  751. minWidth: 47,
  752. defaultWidth: 47,
  753. maxWidth: 47
  754. },
  755. ...this.columns.map(column => ({
  756. ...this.columnDefault,
  757. ...column
  758. })),
  759. {
  760. name: "placeholder",
  761. displayName: "",
  762. properties: [],
  763. sortable: false,
  764. hidable: false,
  765. draggable: false,
  766. resizable: false,
  767. minWidth: "auto",
  768. width: "auto",
  769. maxWidth: "auto"
  770. }
  771. ].sort((columnA, columnB) => {
  772. // Always places select column in the first position
  773. if (columnA.name === "select") return -1;
  774. // Always places placeholder column in the last position
  775. if (columnB.name === "placeholder") return -1;
  776. // If there are no table settings stored, use default ordering
  777. if (!tableSettings || !tableSettings.columnOrder) return 0;
  778. const indexA = tableSettings.columnOrder.indexOf(columnA.name);
  779. const indexB = tableSettings.columnOrder.indexOf(columnB.name);
  780. // If either of the columns is not stored in the table settings, use default ordering
  781. if (indexA === -1 || indexB === -1) return 0;
  782. return indexA - indexB;
  783. });
  784. this.shownColumns = this.orderedColumns
  785. .filter(column => {
  786. // If table settings exist, use shownColumns from settings to determine which columns to show
  787. if (tableSettings && tableSettings.shownColumns)
  788. return (
  789. tableSettings.shownColumns.indexOf(column.name) !== -1
  790. );
  791. // Table settings don't exist, only show if the default visibility isn't hidden
  792. return column.defaultVisibility !== "hidden";
  793. })
  794. .map(column => column.name);
  795. this.recalculateWidths();
  796. if (tableSettings) {
  797. // If table settings' pageSize is an integer, use it for the pageSize
  798. if (Number.isInteger(tableSettings?.pageSize))
  799. this.pageSize = tableSettings.pageSize;
  800. // If table settings' columnSort exists, sort all still existing columns based on table settings' columnSort object
  801. if (tableSettings.columnSort) {
  802. Object.entries(tableSettings.columnSort).forEach(
  803. ([columnName, sortDirection]) => {
  804. if (
  805. this.columns.find(
  806. column => column.name === columnName
  807. )
  808. )
  809. this.sort[columnName] = sortDirection;
  810. }
  811. );
  812. }
  813. // If table settings' columnWidths exists, load the stored widths into the columns
  814. if (tableSettings.columnWidths) {
  815. this.orderedColumns = this.orderedColumns.map(orderedColumn => {
  816. const columnWidth = tableSettings.columnWidths.find(
  817. column => column.name === orderedColumn.name
  818. )?.width;
  819. if (columnWidth)
  820. return { ...orderedColumn, width: columnWidth };
  821. return orderedColumn;
  822. });
  823. }
  824. if (
  825. tableSettings.filter &&
  826. tableSettings.filter.appliedFilters &&
  827. tableSettings.filter.appliedFilterOperator
  828. ) {
  829. const { appliedFilters, appliedFilterOperator } =
  830. tableSettings.filter;
  831. // Set the applied filter operator and filter operator to the value stored in table settings
  832. this.appliedFilterOperator = this.filterOperator =
  833. appliedFilterOperator;
  834. // Set the applied filters and editing filters to the value stored in table settings, for all filters that are allowed
  835. this.appliedFilters = appliedFilters.filter(appliedFilter =>
  836. this.filters.find(
  837. filter => appliedFilter.filter.name === filter.name
  838. )
  839. );
  840. this.editingFilters = appliedFilters.filter(appliedFilter =>
  841. this.filters.find(
  842. filter => appliedFilter.filter.name === filter.name
  843. )
  844. );
  845. }
  846. }
  847. this.resetBulkActionsPosition();
  848. this.$nextTick(() => {
  849. this.onWindowResize();
  850. window.addEventListener("resize", this.onWindowResize);
  851. });
  852. ws.onConnect(this.init);
  853. },
  854. unmounted() {
  855. window.removeEventListener("resize", this.onWindowResize);
  856. },
  857. methods: {
  858. init() {
  859. this.getData();
  860. },
  861. getData() {
  862. this.socket.dispatch(
  863. this.dataAction,
  864. this.page,
  865. this.pageSize,
  866. this.properties,
  867. this.sort,
  868. this.appliedFilters,
  869. this.appliedFilterOperator,
  870. res => {
  871. console.log(111, res);
  872. if (res.status === "success") {
  873. const { data, count } = res.data;
  874. this.data = data.map(row => ({
  875. ...row,
  876. selected: false
  877. }));
  878. this.count = count;
  879. } else {
  880. new Toast(res.message);
  881. }
  882. }
  883. );
  884. },
  885. changePageSize() {
  886. this.getData();
  887. this.storeTableSettings();
  888. },
  889. changePage(page) {
  890. if (page < 1) return;
  891. if (page > this.lastPage) return;
  892. if (page === this.page) return;
  893. this.page = page;
  894. this.getData();
  895. },
  896. changeSort(column) {
  897. if (column.sortable) {
  898. const { sortProperty } = column;
  899. if (this.sort[sortProperty] === undefined)
  900. this.sort[sortProperty] = "ascending";
  901. else if (this.sort[sortProperty] === "ascending")
  902. this.sort[sortProperty] = "descending";
  903. else if (this.sort[sortProperty] === "descending")
  904. delete this.sort[sortProperty];
  905. this.getData();
  906. this.storeTableSettings();
  907. }
  908. },
  909. toggleColumnVisibility(column) {
  910. if (this.shownColumns.indexOf(column.name) !== -1) {
  911. if (this.shownColumns.length <= 3)
  912. return new Toast(
  913. `Unable to hide column ${column.displayName}, there must be at least 1 visibile column`
  914. );
  915. this.shownColumns.splice(
  916. this.shownColumns.indexOf(column.name),
  917. 1
  918. );
  919. } else {
  920. this.shownColumns.push(column.name);
  921. }
  922. this.recalculateWidths();
  923. this.getData();
  924. return this.storeTableSettings();
  925. },
  926. toggleSelectedRow(itemIndex, event) {
  927. const { shiftKey, ctrlKey } = event;
  928. // Shift was pressed, so attempt to select all items between the clicked item and last clicked item
  929. if (shiftKey) {
  930. // If the clicked item is already selected, prevent default, otherwise the checkbox will be unchecked
  931. if (this.data[itemIndex].selected) event.preventDefault();
  932. // If there is a last clicked item
  933. if (this.lastSelectedItemIndex >= 0) {
  934. // Clicked item is lower than last item, so select upwards until it reaches the last selected item
  935. if (itemIndex > this.lastSelectedItemIndex) {
  936. for (
  937. let itemIndexUp = itemIndex;
  938. itemIndexUp > this.lastSelectedItemIndex;
  939. itemIndexUp -= 1
  940. ) {
  941. this.data[itemIndexUp].selected = true;
  942. }
  943. }
  944. // Clicked item is higher than last item, so select downwards until it reaches the last selected item
  945. else if (itemIndex < this.lastSelectedItemIndex) {
  946. for (
  947. let itemIndexDown = itemIndex;
  948. itemIndexDown < this.lastSelectedItemIndex;
  949. itemIndexDown += 1
  950. ) {
  951. this.data[itemIndexDown].selected = true;
  952. }
  953. }
  954. }
  955. }
  956. // Ctrl was pressed, so attempt to unselect all items between the clicked item and last clicked item
  957. else if (ctrlKey) {
  958. // If the clicked item is already unselected, prevent default, otherwise the checkbox will be checked
  959. if (!this.data[itemIndex].selected) event.preventDefault();
  960. // If there is a last clicked item
  961. if (this.lastSelectedItemIndex >= 0) {
  962. // Clicked item is lower than last item, so unselect upwards until it reaches the last selected item
  963. if (itemIndex > this.lastSelectedItemIndex) {
  964. for (
  965. let itemIndexUp = itemIndex;
  966. itemIndexUp >= this.lastSelectedItemIndex;
  967. itemIndexUp -= 1
  968. ) {
  969. this.data[itemIndexUp].selected = false;
  970. }
  971. }
  972. // Clicked item is higher than last item, so unselect downwards until it reaches the last selected item
  973. else if (itemIndex < this.lastSelectedItemIndex) {
  974. for (
  975. let itemIndexDown = itemIndex;
  976. itemIndexDown <= this.lastSelectedItemIndex;
  977. itemIndexDown += 1
  978. ) {
  979. this.data[itemIndexDown].selected = false;
  980. }
  981. }
  982. }
  983. }
  984. // Neither ctrl nor shift were pressed, so toggle clicked item
  985. else {
  986. this.data[itemIndex].selected = !this.data[itemIndex].selected;
  987. }
  988. // Set the last clicked item to no longer be highlighted, if it exists
  989. if (this.lastSelectedItemIndex >= 0)
  990. this.data[this.lastSelectedItemIndex].highlighted = false;
  991. // Set the clicked item to be highlighted
  992. this.data[itemIndex].highlighted = true;
  993. },
  994. toggleAllRows() {
  995. if (this.data.length > this.selectedRows.length) {
  996. this.data = this.data.map(row => ({ ...row, selected: true }));
  997. } else {
  998. this.data = this.data.map(row => ({ ...row, selected: false }));
  999. }
  1000. },
  1001. addFilterItem() {
  1002. this.editingFilters.push({
  1003. data: "",
  1004. filter: this.addFilterValue,
  1005. filterType: this.addFilterValue.defaultFilterType
  1006. });
  1007. },
  1008. removeFilterItem(index) {
  1009. this.editingFilters.splice(index, 1);
  1010. },
  1011. columnResizingStart(column, event) {
  1012. const eventIsTouch = event.type === "touchstart";
  1013. if (eventIsTouch) {
  1014. // Handle double click from touch (if this method is called for the same column twice in a row within one second)
  1015. if (
  1016. this.lastColumnResizerTapped === column &&
  1017. Date.now() - this.lastColumnResizerTappedDate <= 1000
  1018. ) {
  1019. this.columnResetWidth(column);
  1020. this.lastColumnResizerTapped = null;
  1021. this.lastColumnResizerTappedDate = 0;
  1022. return;
  1023. }
  1024. this.lastColumnResizerTapped = column;
  1025. this.lastColumnResizerTappedDate = Date.now();
  1026. }
  1027. this.resizing.resizing = true;
  1028. this.resizing.resizingColumn = column;
  1029. this.resizing.width = event.target.parentElement.offsetWidth;
  1030. this.resizing.lastX = eventIsTouch
  1031. ? event.targetTouches[0].clientX
  1032. : event.x;
  1033. },
  1034. columnResizing(event) {
  1035. if (this.resizing.resizing) {
  1036. const eventIsTouch = event.type === "touchmove";
  1037. if (!eventIsTouch && event.buttons !== 1) {
  1038. this.resizing.resizing = false;
  1039. this.storeTableSettings();
  1040. }
  1041. const x = eventIsTouch
  1042. ? event.changedTouches[0].clientX
  1043. : event.x;
  1044. this.resizing.width -= this.resizing.lastX - x;
  1045. this.resizing.lastX = x;
  1046. if (
  1047. this.resizing.resizingColumn.minWidth &&
  1048. this.resizing.resizingColumn.maxWidth
  1049. ) {
  1050. this.resizing.resizingColumn.width = Math.max(
  1051. Math.min(
  1052. this.resizing.resizingColumn.maxWidth,
  1053. this.resizing.width
  1054. ),
  1055. this.resizing.resizingColumn.minWidth
  1056. );
  1057. } else if (this.resizing.resizingColumn.minWidth) {
  1058. this.resizing.resizingColumn.width = Math.max(
  1059. this.resizing.width,
  1060. this.resizing.resizingColumn.minWidth
  1061. );
  1062. } else if (this.resizing.resizingColumn.maxWidth) {
  1063. this.resizing.resizingColumn.width = Math.min(
  1064. this.resizing.resizingColumn.maxWidth,
  1065. this.resizing.width
  1066. );
  1067. } else {
  1068. this.resizing.resizingColumn.width = this.resizing.width;
  1069. }
  1070. this.resizing.width = this.resizing.resizingColumn.width;
  1071. console.log(`New width: ${this.resizing.width}px`);
  1072. this.storeTableSettings();
  1073. }
  1074. },
  1075. columnResizingStop() {
  1076. this.resizing.resizing = false;
  1077. this.storeTableSettings();
  1078. },
  1079. columnResetWidth(column) {
  1080. const index = this.orderedColumns.indexOf(column);
  1081. if (column.defaultWidth && !Number.isNaN(column.defaultWidth))
  1082. this.orderedColumns[index].width = column.defaultWidth;
  1083. else if (
  1084. column.calculatedWidth &&
  1085. !Number.isNaN(column.calculatedWidth)
  1086. )
  1087. this.orderedColumns[index].width = column.calculatedWidth;
  1088. this.storeTableSettings();
  1089. },
  1090. filterTypes(filter) {
  1091. if (!filter || !filter.filterTypes) return [];
  1092. return filter.filterTypes.map(
  1093. filterType => this.allFilterTypes[filterType]
  1094. );
  1095. },
  1096. changeFilterType(index) {
  1097. this.editingFilters[index].filterType =
  1098. this.editingFilters[index].filter.defaultFilterType;
  1099. },
  1100. onDragBox(e) {
  1101. const e1 = e || window.event;
  1102. const e1IsTouch = e1.type === "touchstart";
  1103. e1.preventDefault();
  1104. if (e1IsTouch) {
  1105. // Handle double click from touch (if this method is twice in a row within one second)
  1106. if (Date.now() - this.lastBulkActionsTappedDate <= 1000) {
  1107. this.resetBulkActionsPosition();
  1108. this.lastBulkActionsTappedDate = 0;
  1109. return;
  1110. }
  1111. this.lastBulkActionsTappedDate = Date.now();
  1112. }
  1113. this.bulkPopup.pos3 = e1IsTouch
  1114. ? e1.changedTouches[0].clientX
  1115. : e1.clientX;
  1116. this.bulkPopup.pos4 = e1IsTouch
  1117. ? e1.changedTouches[0].clientY
  1118. : e1.clientY;
  1119. document.onmousemove = document.ontouchmove = e => {
  1120. const e2 = e || window.event;
  1121. const e2IsTouch = e2.type === "touchmove";
  1122. if (!e2IsTouch) e2.preventDefault();
  1123. // Get the clientX and clientY
  1124. const e2ClientX = e2IsTouch
  1125. ? e2.changedTouches[0].clientX
  1126. : e2.clientX;
  1127. const e2ClientY = e2IsTouch
  1128. ? e2.changedTouches[0].clientY
  1129. : e2.clientY;
  1130. // calculate the new cursor position:
  1131. this.bulkPopup.pos1 = this.bulkPopup.pos3 - e2ClientX;
  1132. this.bulkPopup.pos2 = this.bulkPopup.pos4 - e2ClientY;
  1133. this.bulkPopup.pos3 = e2ClientX;
  1134. this.bulkPopup.pos4 = e2ClientY;
  1135. // set the element's new position:
  1136. this.bulkPopup.top -= this.bulkPopup.pos2;
  1137. this.bulkPopup.left -= this.bulkPopup.pos1;
  1138. if (this.bulkPopup.top < 0) this.bulkPopup.top = 0;
  1139. if (this.bulkPopup.top > document.body.clientHeight - 50)
  1140. this.bulkPopup.top = document.body.clientHeight - 50;
  1141. if (this.bulkPopup.left < 0) this.bulkPopup.left = 0;
  1142. if (this.bulkPopup.left > document.body.clientWidth - 400)
  1143. this.bulkPopup.left = document.body.clientWidth - 400;
  1144. };
  1145. document.onmouseup = document.ontouchend = () => {
  1146. document.onmouseup = null;
  1147. document.ontouchend = null;
  1148. document.onmousemove = null;
  1149. document.ontouchmove = null;
  1150. };
  1151. },
  1152. resetBulkActionsPosition() {
  1153. this.bulkPopup.top = document.body.clientHeight - 56;
  1154. this.bulkPopup.left = document.body.clientWidth / 2 - 200;
  1155. },
  1156. applyFilterAndGetData() {
  1157. this.appliedFilters = JSON.parse(
  1158. JSON.stringify(this.editingFilters)
  1159. );
  1160. this.appliedFilterOperator = this.filterOperator;
  1161. this.getData();
  1162. this.storeTableSettings();
  1163. },
  1164. recalculateWidths() {
  1165. let noWidthCount = 0;
  1166. let calculatedWidth = 0;
  1167. this.orderedColumns.forEach(column => {
  1168. if (this.shownColumns.indexOf(column.name) !== -1)
  1169. if (
  1170. Number.isFinite(column.width) &&
  1171. !Number.isFinite(column.calculatedWidth)
  1172. ) {
  1173. calculatedWidth += column.width;
  1174. } else if (Number.isFinite(column.defaultWidth)) {
  1175. calculatedWidth += column.defaultWidth;
  1176. } else {
  1177. noWidthCount += 1;
  1178. }
  1179. });
  1180. calculatedWidth = Math.floor(
  1181. // max-width of table is 1880px
  1182. (Math.min(1880, document.body.clientWidth) - calculatedWidth) /
  1183. (noWidthCount - 1)
  1184. );
  1185. this.orderedColumns = this.orderedColumns.map(column => {
  1186. const orderedColumn = column;
  1187. if (this.shownColumns.indexOf(orderedColumn.name) !== -1) {
  1188. let newWidth;
  1189. if (Number.isFinite(orderedColumn.defaultWidth)) {
  1190. newWidth = orderedColumn.defaultWidth;
  1191. } else {
  1192. // eslint-disable-next-line no-param-reassign
  1193. newWidth = orderedColumn.calculatedWidth = Math.min(
  1194. Math.max(
  1195. orderedColumn.minWidth || 100, // fallback 100px min width
  1196. calculatedWidth
  1197. ),
  1198. orderedColumn.maxWidth || 1000 // fallback 1000px max width
  1199. );
  1200. }
  1201. if (newWidth && !Number.isFinite(orderedColumn.width))
  1202. orderedColumn.width = newWidth;
  1203. }
  1204. return orderedColumn;
  1205. });
  1206. },
  1207. columnOrderChanged() {
  1208. this.storeTableSettings();
  1209. },
  1210. getTableSettings() {
  1211. return JSON.parse(
  1212. localStorage.getItem(`advancedTableSettings:${this.name}`)
  1213. );
  1214. },
  1215. storeTableSettings() {
  1216. // Clear debounce timeout
  1217. if (this.storeTableSettingsDebounceTimeout)
  1218. clearTimeout(this.storeTableSettingsDebounceTimeout);
  1219. // Resizing calls this function a lot, so rather than saving dozens of times a second, use debouncing
  1220. this.storeTableSettingsDebounceTimeout = setTimeout(() => {
  1221. localStorage.setItem(
  1222. `advancedTableSettings:${this.name}`,
  1223. JSON.stringify({
  1224. pageSize: this.pageSize,
  1225. filter: {
  1226. appliedFilters: this.appliedFilters,
  1227. appliedFilterOperator: this.appliedFilterOperator
  1228. },
  1229. columnSort: this.sort,
  1230. columnOrder: this.orderedColumns.map(
  1231. column => column.name
  1232. ),
  1233. columnWidths: this.orderedColumns.map(column => ({
  1234. name: column.name,
  1235. width: column.width
  1236. })),
  1237. shownColumns: this.shownColumns
  1238. })
  1239. );
  1240. }, 250);
  1241. },
  1242. onWindowResize() {
  1243. // Only change the position if the popup is actually visible
  1244. if (this.selectedRows.length === 0) return;
  1245. if (this.bulkPopup.top < 0) this.bulkPopup.top = 0;
  1246. if (this.bulkPopup.top > document.body.clientHeight - 50)
  1247. this.bulkPopup.top = document.body.clientHeight - 50;
  1248. if (this.bulkPopup.left < 0) this.bulkPopup.left = 0;
  1249. if (this.bulkPopup.left > document.body.clientWidth - 400)
  1250. this.bulkPopup.left = document.body.clientWidth - 400;
  1251. }
  1252. }
  1253. };
  1254. </script>
  1255. <style lang="scss" scoped>
  1256. .night-mode {
  1257. .table-outer-container {
  1258. .table-container .table {
  1259. &,
  1260. thead th {
  1261. background-color: var(--dark-grey-3);
  1262. color: var(--light-grey-2);
  1263. }
  1264. tr {
  1265. th,
  1266. td {
  1267. border-color: var(--dark-grey) !important;
  1268. &:first-child {
  1269. background-color: var(--dark-grey-3) !important;
  1270. }
  1271. }
  1272. &:nth-child(even) {
  1273. &,
  1274. td:first-child {
  1275. background-color: var(--dark-grey-2) !important;
  1276. }
  1277. }
  1278. &:hover,
  1279. &:focus,
  1280. &.highlighted {
  1281. th,
  1282. td {
  1283. &,
  1284. &:first-child {
  1285. background-color: var(--dark-grey-4) !important;
  1286. }
  1287. }
  1288. }
  1289. }
  1290. }
  1291. .table-header,
  1292. .table-footer {
  1293. background-color: var(--dark-grey-3);
  1294. color: var(--light-grey-2);
  1295. }
  1296. .label.control {
  1297. background-color: var(--dark-grey) !important;
  1298. border-color: var(--grey-3) !important;
  1299. color: var(--white) !important;
  1300. }
  1301. }
  1302. .bulk-popup {
  1303. border: 0;
  1304. background-color: var(--dark-grey-2);
  1305. color: var(--white);
  1306. .material-icons {
  1307. color: var(--white);
  1308. }
  1309. }
  1310. }
  1311. .table-outer-container {
  1312. border-radius: 5px;
  1313. box-shadow: 0 2px 3px rgba(10, 10, 10, 0.1), 0 0 0 1px rgba(10, 10, 10, 0.1);
  1314. margin: 10px 0;
  1315. overflow: hidden;
  1316. .table-container {
  1317. overflow-x: auto;
  1318. table {
  1319. border-collapse: separate;
  1320. table-layout: fixed;
  1321. thead {
  1322. tr {
  1323. th {
  1324. height: 40px;
  1325. line-height: 40px;
  1326. border: 1px solid var(--light-grey-2);
  1327. border-width: 1px 1px 1px 0;
  1328. padding: 0;
  1329. &:last-child {
  1330. border-width: 1px 0 1px;
  1331. }
  1332. &.sortable {
  1333. cursor: pointer;
  1334. }
  1335. & > div {
  1336. display: flex;
  1337. white-space: nowrap;
  1338. padding: 8px 10px;
  1339. & > span {
  1340. margin-left: 5px;
  1341. &:first-child {
  1342. margin-left: 0;
  1343. margin-right: auto;
  1344. }
  1345. & > .material-icons {
  1346. font-size: 22px;
  1347. position: relative;
  1348. top: 6px;
  1349. cursor: pointer;
  1350. &.active {
  1351. color: var(--primary-color);
  1352. }
  1353. &:hover,
  1354. &:focus {
  1355. filter: brightness(90%);
  1356. }
  1357. }
  1358. }
  1359. }
  1360. }
  1361. }
  1362. }
  1363. tbody {
  1364. tr {
  1365. &.highlighted {
  1366. background-color: var(--light-grey);
  1367. }
  1368. td {
  1369. border: 1px solid var(--light-grey-2);
  1370. border-width: 0 1px 1px 0;
  1371. &:last-child {
  1372. border-width: 0 0 1px;
  1373. }
  1374. }
  1375. }
  1376. }
  1377. }
  1378. table thead tr,
  1379. table tbody tr {
  1380. th,
  1381. td {
  1382. position: relative;
  1383. white-space: nowrap;
  1384. text-overflow: ellipsis;
  1385. overflow: hidden;
  1386. &:first-child {
  1387. position: sticky;
  1388. left: 0;
  1389. background-color: var(--white);
  1390. z-index: 2;
  1391. }
  1392. .resizer {
  1393. height: 100%;
  1394. width: 5px;
  1395. background-color: transparent;
  1396. cursor: col-resize;
  1397. position: absolute;
  1398. right: 0;
  1399. top: 0;
  1400. }
  1401. }
  1402. &:nth-child(even) td:first-child {
  1403. background-color: #fafafa;
  1404. }
  1405. &:hover,
  1406. &:focus,
  1407. &.highlighted {
  1408. th,
  1409. td {
  1410. &,
  1411. &:first-child {
  1412. background-color: var(--light-grey);
  1413. }
  1414. }
  1415. }
  1416. }
  1417. }
  1418. .table-header,
  1419. .table-footer {
  1420. display: flex;
  1421. flex-direction: row;
  1422. flex-wrap: wrap;
  1423. justify-content: space-between;
  1424. line-height: 36px;
  1425. background-color: var(--white);
  1426. }
  1427. .table-header > div {
  1428. display: flex;
  1429. flex-direction: row;
  1430. > span > .control {
  1431. margin: 5px;
  1432. }
  1433. .filters-indicator {
  1434. line-height: 46px;
  1435. display: flex;
  1436. align-items: center;
  1437. column-gap: 4px;
  1438. }
  1439. }
  1440. .table-footer {
  1441. .page-controls,
  1442. .page-size > .control {
  1443. display: flex;
  1444. flex-direction: row;
  1445. margin-bottom: 0 !important;
  1446. button {
  1447. margin: 5px;
  1448. font-size: 20px;
  1449. }
  1450. p,
  1451. label {
  1452. margin: 5px;
  1453. font-size: 14px;
  1454. font-weight: 600;
  1455. }
  1456. &.select::after {
  1457. top: 18px;
  1458. }
  1459. }
  1460. }
  1461. }
  1462. .control.is-grouped {
  1463. display: flex;
  1464. & > .control {
  1465. &.label {
  1466. height: 36px;
  1467. background-color: var(--white);
  1468. border: 1px solid var(--light-grey-2);
  1469. color: var(--dark-grey-2);
  1470. appearance: none;
  1471. border-radius: 3px;
  1472. font-size: 14px;
  1473. line-height: 34px;
  1474. padding-left: 8px;
  1475. padding-right: 8px;
  1476. }
  1477. &.select.is-expanded > select {
  1478. width: 100%;
  1479. }
  1480. & > input,
  1481. & > select,
  1482. & > .button,
  1483. &.label {
  1484. border-radius: 0;
  1485. }
  1486. &:first-child {
  1487. & > input,
  1488. & > select,
  1489. & > .button,
  1490. &.label {
  1491. border-radius: 5px 0 0 5px;
  1492. }
  1493. }
  1494. &:last-child {
  1495. & > input,
  1496. & > select,
  1497. & > .button,
  1498. &.label {
  1499. border-radius: 0 5px 5px 0;
  1500. }
  1501. }
  1502. & > .button {
  1503. font-size: 22px;
  1504. }
  1505. }
  1506. @media screen and (max-width: 500px) {
  1507. &.advanced-filter {
  1508. flex-wrap: wrap;
  1509. .control.select {
  1510. width: 50%;
  1511. select {
  1512. width: 100%;
  1513. }
  1514. }
  1515. .control {
  1516. margin-bottom: 0 !important;
  1517. &:nth-child(1) select {
  1518. border-radius: 5px 0 0 0;
  1519. }
  1520. &:nth-child(2) select {
  1521. border-radius: 0 5px 0 0;
  1522. }
  1523. &:nth-child(3) input {
  1524. border-radius: 0 0 0 5px;
  1525. }
  1526. &:nth-child(4) button {
  1527. border-radius: 0 0 5px 0;
  1528. }
  1529. }
  1530. }
  1531. }
  1532. }
  1533. .advanced-filter-bottom {
  1534. display: flex;
  1535. .button {
  1536. font-size: 16px !important;
  1537. width: 100%;
  1538. }
  1539. .control {
  1540. margin: 0 !important;
  1541. }
  1542. }
  1543. .bulk-popup {
  1544. display: flex;
  1545. position: fixed;
  1546. flex-direction: row;
  1547. width: 100%;
  1548. max-width: 400px;
  1549. line-height: 36px;
  1550. z-index: 5;
  1551. border: 1px solid var(--light-grey-3);
  1552. border-radius: 5px;
  1553. box-shadow: 0 14px 28px rgba(0, 0, 0, 0.25), 0 10px 10px rgba(0, 0, 0, 0.22);
  1554. background-color: var(--white);
  1555. color: var(--dark-grey);
  1556. padding: 5px;
  1557. .right {
  1558. display: flex;
  1559. flex-direction: row;
  1560. margin-left: auto;
  1561. }
  1562. .drag-icon {
  1563. position: relative;
  1564. top: 6px;
  1565. color: var(--dark-grey);
  1566. cursor: move;
  1567. }
  1568. }
  1569. </style>