AdvancedTable.vue 57 KB

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