12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223 |
- <template>
- <div>
- <div
- class="table-outer-container"
- @mousemove="columnResizingMouseMove($event)"
- >
- <div class="table-header">
- <div>
- <tippy
- v-if="filters.length > 0"
- :touch="true"
- :interactive="true"
- placement="bottom"
- theme="search"
- ref="search"
- trigger="click"
- >
- <button class="button is-info">
- <i class="material-icons icon-with-button"
- >filter_list</i
- >
- Filters
- </button>
- <template #content>
- <div class="control is-grouped input-with-button">
- <p class="control select is-expanded">
- <select v-model="addFilterValue">
- <option
- v-for="type in filters"
- :key="type.name"
- :value="type"
- >
- {{ type.displayName }}
- </option>
- </select>
- </p>
- <p class="control">
- <button
- class="button material-icons is-success"
- @click="addFilterItem()"
- >
- control_point
- </button>
- </p>
- </div>
- <div
- v-for="(filter, index) in editingFilters"
- :key="`filter-${index}`"
- class="control is-grouped is-expanded"
- >
- <div class="control select">
- <select
- v-model="filter.filter"
- @change="changeFilterType(index)"
- >
- <option
- v-for="type in filters"
- :key="type.name"
- :value="type"
- >
- {{ type.displayName }}
- </option>
- </select>
- </div>
- <div class="control select">
- <select
- v-model="filter.filterType"
- :disabled="!filter.filterType"
- >
- <option
- v-for="filterType in filterTypes(
- filter.filter
- )"
- :key="filterType.name"
- :value="filterType.name"
- :selected="
- filter.filter
- .defaultFilterType ===
- filterType.name
- "
- >
- {{ filterType.displayName }}
- </option>
- </select>
- </div>
- <p class="control is-expanded">
- <input
- v-model="filter.data"
- class="input"
- type="text"
- placeholder="Search value"
- :disabled="!filter.filterType"
- />
- </p>
- <div class="control">
- <button
- class="button material-icons is-danger"
- @click="removeFilterItem(index)"
- >
- remove_circle_outline
- </button>
- </div>
- </div>
- <div
- v-if="editingFilters.length > 1"
- class="control is-expanded is-grouped"
- >
- <label class="control label"
- >Filter operator</label
- >
- <div class="control select is-expanded">
- <select v-model="filterOperator">
- <option
- v-for="operator in filterOperators"
- :key="operator.name"
- :value="operator.name"
- >
- {{ operator.displayName }}
- </option>
- </select>
- </div>
- </div>
- <div
- class="advanced-filter-bottom"
- v-if="editingFilters.length > 0"
- >
- <div class="control is-expanded">
- <button
- class="button is-info"
- @click="applyFilterAndGetData()"
- >
- <i
- class="
- material-icons
- icon-with-button
- "
- >filter_list</i
- >
- Apply filters
- </button>
- </div>
- </div>
- <div
- class="advanced-filter-bottom"
- v-else-if="editingFilters.length === 0"
- >
- <div class="control is-expanded">
- <button
- class="button is-info"
- @click="applyFilterAndGetData()"
- >
- <i
- class="
- material-icons
- icon-with-button
- "
- >filter_list</i
- >
- Apply filters
- </button>
- </div>
- </div>
- </template>
- </tippy>
- <tippy
- v-if="appliedFilters.length > 0"
- :touch="true"
- :interactive="true"
- theme="info"
- ref="activeFilters"
- >
- <div class="filters-indicator">
- {{ appliedFilters.length }}
- <i class="material-icons" @click.prevent="true"
- >filter_list</i
- >
- </div>
- <template #content>
- <p
- v-for="(filter, index) in appliedFilters"
- :key="`filter-${index}`"
- >
- {{ filter.filter.displayName }}
- {{ filter.filterType }} "{{ filter.data }}"
- {{
- appliedFilters.length === index + 1
- ? ""
- : filterOperator
- }}
- </p>
- </template>
- </tippy>
- <i
- v-else
- class="filters-indicator material-icons"
- content="No active filters"
- v-tippy="{ theme: 'info' }"
- >
- filter_list_off
- </i>
- </div>
- <div>
- <tippy
- v-if="hidableSortedColumns.length > 0"
- :touch="true"
- :interactive="true"
- placement="bottom"
- theme="dropdown"
- ref="editColumns"
- trigger="click"
- >
- <a class="button is-info" @click.prevent="true">
- <i class="material-icons icon-with-button">tune</i>
- Columns
- </a>
- <template #content>
- <draggable
- item-key="name"
- v-model="orderedColumns"
- v-bind="columnDragOptions"
- tag="div"
- draggable=".item-draggable"
- class="nav-dropdown-items"
- >
- <template #item="{ element: column }">
- <button
- v-if="column.name !== 'select'"
- :class="{
- sortable: column.sortable,
- 'item-draggable': column.draggable,
- 'nav-item': true
- }"
- @click.prevent="
- toggleColumnVisibility(column)
- "
- >
- <p
- class="
- control
- is-expanded
- checkbox-control
- "
- >
- <label class="switch">
- <input
- v-if="column.hidable"
- type="checkbox"
- :id="index"
- :checked="
- shownColumns.indexOf(
- column.name
- ) !== -1
- "
- @click="
- toggleColumnVisibility(
- column
- )
- "
- />
- <span
- :class="{
- slider: true,
- round: true,
- disabled:
- !column.hidable
- }"
- ></span>
- </label>
- <label :for="index">
- <span></span>
- <p>{{ column.displayName }}</p>
- </label>
- </p>
- </button>
- </template>
- </draggable>
- </template>
- </tippy>
- </div>
- </div>
- <div class="table-container">
- <table class="table">
- <thead>
- <draggable
- item-key="name"
- v-model="orderedColumns"
- v-bind="columnDragOptions"
- tag="tr"
- draggable=".item-draggable"
- >
- <template #item="{ element: column }">
- <th
- :class="{
- sortable: column.sortable,
- 'item-draggable': column.draggable
- }"
- :style="{
- minWidth: `${column.minWidth}px`,
- width: `${column.width}px`,
- maxWidth: `${column.maxWidth}px`
- }"
- v-if="
- shownColumns.indexOf(column.name) !== -1
- "
- >
- <p
- v-if="column.name === 'select'"
- class="checkbox"
- >
- <input
- type="checkbox"
- :checked="
- data.length ===
- selectedRows.length
- "
- @click="toggleAllRows()"
- />
- </p>
- <div v-else>
- <span>
- {{ column.displayName }}
- </span>
- <span
- v-if="column.pinable"
- content="Toggle Pinned Column"
- v-tippy
- @click="togglePinnedColumn(column)"
- >
- <span
- :class="{
- 'material-icons': true,
- active:
- pinnedColumns.indexOf(
- column.name
- ) !== -1
- }"
- >
- push_pin
- </span>
- </span>
- <span
- v-if="column.sortable"
- :content="`Sort by ${column.displayName}`"
- v-tippy
- >
- <span
- v-if="
- !sort[column.sortProperty]
- "
- class="material-icons"
- @click="changeSort(column)"
- >
- unfold_more
- </span>
- <span
- v-if="
- sort[
- column.sortProperty
- ] === 'ascending'
- "
- class="material-icons active"
- @click="changeSort(column)"
- >
- expand_more
- </span>
- <span
- v-if="
- sort[
- column.sortProperty
- ] === 'descending'
- "
- class="material-icons active"
- @click="changeSort(column)"
- >
- expand_less
- </span>
- </span>
- </div>
- <div
- class="resizer"
- v-if="column.resizable"
- @mousedown.prevent.stop="
- columnResizingMouseDown(
- column,
- $event
- )
- "
- @mouseup="columnResizingMouseUp()"
- @dblclick="columnResetWidth(column)"
- ></div>
- </th>
- </template>
- </draggable>
- </thead>
- <tbody>
- <tr
- v-for="(item, itemIndex) in data"
- :key="item._id"
- :class="{
- selected: item.selected,
- highlighted: item.highlighted
- }"
- >
- <td
- v-for="column in sortedFilteredColumns"
- :key="`${item._id}-${column.name}`"
- >
- <slot
- :name="`column-${column.name}`"
- :item="item"
- v-if="
- column.properties.length === 0 ||
- column.properties.every(
- property =>
- item[property] !== undefined
- )
- "
- ></slot>
- <p
- class="checkbox"
- v-if="column.name === 'select'"
- >
- <input
- type="checkbox"
- :checked="item.selected"
- @click="
- toggleSelectedRow(itemIndex, $event)
- "
- />
- </p>
- <div
- class="resizer"
- v-if="column.resizable"
- @mousedown.prevent.stop="
- columnResizingMouseDown(column, $event)
- "
- @mouseup="columnResizingMouseUp()"
- @dblclick="columnResetWidth(column)"
- ></div>
- </td>
- </tr>
- </tbody>
- </table>
- </div>
- <div class="table-footer">
- <div class="page-controls">
- <button
- :class="{ disabled: page === 1 }"
- class="button is-primary material-icons"
- :disabled="page === 1"
- @click="changePage(1)"
- content="First Page"
- v-tippy
- >
- skip_previous
- </button>
- <button
- :class="{ disabled: page === 1 }"
- class="button is-primary material-icons"
- :disabled="page === 1"
- @click="changePage(page - 1)"
- content="Previous Page"
- v-tippy
- >
- fast_rewind
- </button>
- <p>Page {{ page }} / {{ lastPage }}</p>
- <button
- :class="{ disabled: page === lastPage }"
- class="button is-primary material-icons"
- :disabled="page === lastPage"
- @click="changePage(page + 1)"
- content="Next Page"
- v-tippy
- >
- fast_forward
- </button>
- <button
- :class="{ disabled: page === lastPage }"
- class="button is-primary material-icons"
- :disabled="page === lastPage"
- @click="changePage(lastPage)"
- content="Last Page"
- v-tippy
- >
- skip_next
- </button>
- </div>
- <div class="page-size">
- <div class="control">
- <label class="label">Items per page</label>
- <p class="control select">
- <select
- v-model.number="pageSize"
- @change="changePageSize()"
- >
- <option value="10">10</option>
- <option value="25">25</option>
- <option value="50">50</option>
- <option value="100">100</option>
- <option value="250">250</option>
- <option value="500">500</option>
- <option value="1000">1000</option>
- </select>
- </p>
- </div>
- </div>
- </div>
- </div>
- <div
- v-if="selectedRows.length > 0"
- class="bulk-popup"
- :style="{
- top: bulkPopup.top + 'px',
- left: bulkPopup.left + 'px'
- }"
- >
- <button
- class="button is-primary"
- :content="
- selectedRows.length === 1
- ? `${selectedRows.length} row selected`
- : `${selectedRows.length} rows selected`
- "
- v-tippy
- >
- {{ selectedRows.length }}
- </button>
- <slot name="bulk-actions" :item="selectedRows" />
- <div class="right">
- <slot name="bulk-actions-right" :item="selectedRows" />
- <span
- class="material-icons drag-icon"
- @mousedown.left="onDragBox"
- @dblclick="resetBulkActionsPosition()"
- >
- drag_indicator
- </span>
- </div>
- </div>
- </div>
- </template>
- <script>
- import { mapGetters } from "vuex";
- import draggable from "vuedraggable";
- import Toast from "toasters";
- import ws from "@/ws";
- export default {
- components: {
- draggable
- },
- props: {
- /*
- Column properties:
- name: Unique lowercase name
- displayName: Nice name for the column header
- properties: The properties this column needs to show data
- sortable: Boolean for whether the order of a particular column can be changed
- sortProperty: The property the backend will sort on if this column gets sorted, e.g. title
- hidable: Boolean for whether a column can be hidden
- defaultVisibility: Default visibility for a column, either "shown" or "hidden"
- draggable: Boolean for whether a column can be dragged/reordered,
- resizable: Boolean for whether a column can be resized
- minWidth: Minimum width of column, e.g. 50px
- width: Width of column, e.g. 100px
- maxWidth: Maximum width of column, e.g. 150px
- */
- columnDefault: { type: Object, default: () => {} },
- columns: { type: Array, default: null },
- filters: { type: Array, default: null },
- dataAction: { type: String, default: null }
- },
- data() {
- return {
- page: 1,
- pageSize: 10,
- data: [],
- count: 0, // TODO Rename
- sort: {},
- orderedColumns: [],
- shownColumns: [],
- pinnedColumns: ["select"],
- columnDragOptions() {
- return {
- animation: 200,
- group: "columns",
- disabled: false,
- ghostClass: "draggable-list-ghost",
- filter: ".ignore-elements",
- fallbackTolerance: 50
- };
- },
- editingFilters: [],
- appliedFilters: [],
- filterOperator: "or",
- appliedFilterOperator: "or",
- filterOperators: [
- {
- name: "or",
- displayName: "OR"
- },
- {
- name: "and",
- displayName: "AND"
- },
- {
- name: "nor",
- displayName: "NOR"
- }
- ],
- resizing: {},
- allFilterTypes: {
- contains: {
- name: "contains",
- displayName: "Contains"
- },
- exact: {
- name: "exact",
- displayName: "Exact"
- },
- regex: {
- name: "regex",
- displayName: "Regex"
- }
- },
- bulkPopup: {
- top: 0,
- left: 0,
- pos1: 0,
- pos2: 0,
- pos3: 0,
- pos4: 0
- }
- };
- },
- computed: {
- properties() {
- return Array.from(
- new Set(
- this.sortedFilteredColumns.flatMap(
- column => column.properties
- )
- )
- );
- },
- lastPage() {
- return Math.ceil(this.count / this.pageSize);
- },
- sortedFilteredColumns() {
- return this.orderedColumns.filter(
- column => this.shownColumns.indexOf(column.name) !== -1
- );
- },
- hidableSortedColumns() {
- return this.orderedColumns.filter(column => column.hidable);
- },
- lastSelectedItemIndex() {
- return this.data.findIndex(item => item.highlighted);
- },
- selectedRows() {
- return this.data.filter(data => data.selected);
- },
- ...mapGetters({
- socket: "websockets/getSocket"
- })
- },
- mounted() {
- const columns = [
- {
- name: "select",
- displayName: "",
- properties: [],
- sortable: false,
- hidable: false,
- draggable: false,
- resizable: false,
- pinable: false,
- minWidth: 47,
- width: 47,
- maxWidth: 47
- },
- ...this.columns
- ];
- this.orderedColumns = columns.map(column => ({
- ...this.columnDefault,
- ...column
- }));
- // A column will be shown if the defaultVisibility is set to shown, OR if the defaultVisibility is not set to shown and hidable is false
- this.shownColumns = columns
- .filter(column => column.defaultVisibility !== "hidden")
- .map(column => column.name);
- const pageSize = parseInt(localStorage.getItem("adminPageSize"));
- if (!Number.isNaN(pageSize)) this.pageSize = pageSize;
- this.resetBulkActionsPosition();
- ws.onConnect(this.init);
- },
- methods: {
- init() {
- this.getData();
- },
- getData() {
- this.socket.dispatch(
- this.dataAction,
- this.page,
- this.pageSize,
- this.properties,
- this.sort,
- this.appliedFilters,
- this.appliedFilterOperator,
- res => {
- console.log(111, res);
- if (res.status === "success") {
- const { data, count } = res.data;
- this.data = data;
- this.count = count;
- } else {
- new Toast(res.message);
- }
- }
- );
- },
- changePageSize() {
- this.getData();
- localStorage.setItem("adminPageSize", this.pageSize);
- },
- changePage(page) {
- if (page < 1) return;
- if (page > this.lastPage) return;
- if (page === this.page) return;
- this.page = page;
- this.getData();
- },
- changeSort(column) {
- if (column.sortable) {
- const { sortProperty } = column;
- if (this.sort[sortProperty] === undefined)
- this.sort[sortProperty] = "ascending";
- else if (this.sort[sortProperty] === "ascending")
- this.sort[sortProperty] = "descending";
- else if (this.sort[sortProperty] === "descending")
- delete this.sort[sortProperty];
- this.getData();
- }
- },
- toggleColumnVisibility(column) {
- if (this.shownColumns.indexOf(column.name) !== -1) {
- if (this.shownColumns.length <= 2)
- return new Toast(
- `Unable to hide column ${column.displayName}, there must be at least 1 visibile column`
- );
- this.shownColumns.splice(
- this.shownColumns.indexOf(column.name),
- 1
- );
- } else {
- this.shownColumns.push(column.name);
- }
- return this.getData();
- },
- togglePinnedColumn(column) {
- if (this.pinnedColumns.indexOf(column.name) !== -1) {
- this.pinnedColumns.splice(
- this.pinnedColumns.indexOf(column.name),
- 1
- );
- } else {
- this.pinnedColumns.push(column.name);
- }
- },
- toggleSelectedRow(itemIndex, event) {
- const { shiftKey } = event;
- // Shift was pressed, so attempt to select all items between the clicked item and last clicked item
- if (shiftKey) {
- // If there is a last clicked item
- if (this.lastSelectedItemIndex >= 0) {
- // Clicked item is lower than last item, so select upwards until it reaches the last selected item
- if (itemIndex > this.lastSelectedItemIndex) {
- for (
- let itemIndexUp = itemIndex;
- itemIndexUp > this.lastSelectedItemIndex;
- itemIndexUp -= 1
- ) {
- this.data[itemIndexUp].selected = true;
- }
- }
- // Clicked item is higher than last item, so select downwards until it reaches the last selected item
- else if (itemIndex < this.lastSelectedItemIndex) {
- for (
- let itemIndexDown = itemIndex;
- itemIndexDown < this.lastSelectedItemIndex;
- itemIndexDown += 1
- ) {
- this.data[itemIndexDown].selected = true;
- }
- }
- }
- } else {
- this.data[itemIndex].selected = !this.data[itemIndex].selected;
- }
- // Set the last clicked item to no longer be highlighted, if it exists
- if (this.lastSelectedItemIndex >= 0)
- this.data[this.lastSelectedItemIndex].highlighted = false;
- // Set the clicked item to be highlighted
- this.data[itemIndex].highlighted = true;
- },
- toggleAllRows() {
- if (this.data.length > this.selectedRows.length) {
- this.data = this.data.map(row => ({ ...row, selected: true }));
- } else {
- this.data = this.data.map(row => ({ ...row, selected: false }));
- }
- },
- addFilterItem() {
- this.editingFilters.push({
- data: "",
- filter: this.addFilterValue,
- filterType: this.addFilterValue.defaultFilterType
- });
- },
- removeFilterItem(index) {
- this.editingFilters.splice(index, 1);
- },
- columnResizingMouseDown(column, event) {
- this.resizing.resizing = true;
- this.resizing.resizingColumn = column;
- this.resizing.width = event.target.parentElement.offsetWidth;
- this.resizing.lastX = event.x;
- },
- columnResizingMouseMove(event) {
- if (this.resizing.resizing) {
- if (event.buttons !== 1) {
- this.resizing.resizing = false;
- }
- this.resizing.width -= this.resizing.lastX - event.x;
- this.resizing.lastX = event.x;
- if (
- this.resizing.resizingColumn.minWidth &&
- this.resizing.resizingColumn.maxWidth
- ) {
- this.resizing.resizingColumn.width = Math.max(
- Math.min(
- this.resizing.resizingColumn.maxWidth,
- this.resizing.width
- ),
- this.resizing.resizingColumn.minWidth
- );
- } else if (this.resizing.resizingColumn.minWidth) {
- this.resizing.resizingColumn.width = Math.max(
- this.resizing.width,
- this.resizing.resizingColumn.minWidth
- );
- } else if (this.resizing.resizingColumn.maxWidth) {
- this.resizing.resizingColumn.width = Math.min(
- this.resizing.resizingColumn.maxWidth,
- this.resizing.width
- );
- } else {
- this.resizing.resizingColumn.width = this.resizing.width;
- }
- console.log(`New width: ${this.resizing.width}px`);
- }
- },
- columnResizingMouseUp() {
- this.resizing.resizing = false;
- },
- columnResetWidth(column) {
- // eslint-disable-next-line no-param-reassign
- column.minWidth = column.maxWidth = "";
- },
- filterTypes(filter) {
- if (!filter || !filter.filterTypes) return [];
- return filter.filterTypes.map(
- filterType => this.allFilterTypes[filterType]
- );
- },
- changeFilterType(index) {
- this.editingFilters[index].filterType =
- this.editingFilters[index].filter.defaultFilterType;
- },
- onDragBox(e) {
- const e1 = e || window.event;
- e1.preventDefault();
- this.bulkPopup.pos3 = e1.clientX;
- this.bulkPopup.pos4 = e1.clientY;
- document.onmousemove = e => {
- const e2 = e || window.event;
- e2.preventDefault();
- // calculate the new cursor position:
- this.bulkPopup.pos1 = this.bulkPopup.pos3 - e.clientX;
- this.bulkPopup.pos2 = this.bulkPopup.pos4 - e.clientY;
- this.bulkPopup.pos3 = e.clientX;
- this.bulkPopup.pos4 = e.clientY;
- // set the element's new position:
- this.bulkPopup.top -= this.bulkPopup.pos2;
- this.bulkPopup.left -= this.bulkPopup.pos1;
- if (this.bulkPopup.top < 0) this.bulkPopup.top = 0;
- if (this.bulkPopup.top > document.body.clientHeight - 50)
- this.bulkPopup.top = document.body.clientHeight - 50;
- if (this.bulkPopup.left < 0) this.bulkPopup.left = 0;
- if (this.bulkPopup.left > document.body.clientWidth - 400)
- this.bulkPopup.left = document.body.clientWidth - 400;
- };
- document.onmouseup = () => {
- document.onmouseup = null;
- document.onmousemove = null;
- };
- },
- resetBulkActionsPosition() {
- this.bulkPopup.top = document.body.clientHeight - 56;
- this.bulkPopup.left = document.body.clientWidth / 2 - 200;
- },
- applyFilterAndGetData() {
- this.appliedFilters = JSON.parse(
- JSON.stringify(this.editingFilters)
- );
- this.appliedFilterOperator = this.filterOperator;
- this.getData();
- }
- }
- };
- </script>
- <style lang="scss" scoped>
- .night-mode {
- .table-outer-container {
- .table-container .table {
- &,
- thead th {
- background-color: var(--dark-grey-3);
- color: var(--light-grey-2);
- }
- tr {
- &:nth-child(even) {
- background-color: var(--dark-grey-2);
- }
- &:hover,
- &:focus,
- &.highlighted {
- background-color: var(--dark-grey-4);
- }
- }
- th,
- td {
- border-color: var(--dark-grey) !important;
- }
- }
- .table-header,
- .table-footer {
- background-color: var(--dark-grey-3);
- color: var(--light-grey-2);
- }
- }
- .bulk-popup {
- border: 0;
- background-color: var(--dark-grey-2);
- color: var(--white);
- .material-icons {
- color: var(--white);
- }
- }
- }
- .table-outer-container {
- border-radius: 5px;
- box-shadow: 0 2px 3px rgba(10, 10, 10, 0.1), 0 0 0 1px rgba(10, 10, 10, 0.1);
- margin: 10px 0;
- overflow: hidden;
- .table-container {
- overflow-x: auto;
- table {
- border-collapse: separate;
- table-layout: fixed;
- thead {
- tr {
- th {
- height: 40px;
- line-height: 40px;
- border: 1px solid var(--light-grey-2);
- border-width: 1px 1px 1px 0;
- &:last-child {
- border-width: 1px 0 1px;
- }
- &.sortable {
- cursor: pointer;
- }
- & > div {
- display: flex;
- white-space: nowrap;
- & > span {
- margin-left: 5px;
- &:first-child {
- margin-left: 0;
- margin-right: auto;
- }
- & > .material-icons {
- font-size: 22px;
- position: relative;
- top: 6px;
- cursor: pointer;
- &.active {
- color: var(--primary-color);
- }
- &:hover,
- &:focus {
- filter: brightness(90%);
- }
- }
- }
- }
- }
- }
- }
- tbody {
- tr {
- &.highlighted {
- background-color: var(--light-grey);
- }
- td {
- border: 1px solid var(--light-grey-2);
- border-width: 0 1px 1px 0;
- &:last-child {
- border-width: 0 0 1px;
- }
- }
- }
- }
- }
- table thead tr th,
- table tbody tr td {
- position: relative;
- white-space: nowrap;
- text-overflow: ellipsis;
- overflow: hidden;
- .resizer {
- height: 100%;
- width: 5px;
- background-color: transparent;
- cursor: col-resize;
- position: absolute;
- right: 0;
- top: 0;
- }
- }
- }
- .table-header,
- .table-footer {
- display: flex;
- flex-direction: row;
- flex-wrap: wrap;
- justify-content: space-between;
- line-height: 36px;
- background-color: var(--white);
- }
- .table-header > div {
- display: flex;
- flex-direction: row;
- > span > .button {
- margin: 5px;
- }
- .filters-indicator {
- line-height: 46px;
- display: flex;
- align-items: center;
- column-gap: 4px;
- }
- }
- .table-footer {
- .page-controls,
- .page-size > .control {
- display: flex;
- flex-direction: row;
- margin-bottom: 0 !important;
- button {
- margin: 5px;
- font-size: 20px;
- }
- p,
- label {
- margin: 5px;
- font-size: 14px;
- font-weight: 600;
- }
- &.select::after {
- top: 18px;
- }
- }
- }
- }
- .control.is-grouped {
- display: flex;
- & > .control {
- &.label {
- height: 36px;
- background-color: var(--white);
- border: 1px solid var(--light-grey-2);
- color: var(--dark-grey-2);
- appearance: none;
- border-radius: 3px;
- font-size: 14px;
- line-height: 34px;
- padding-left: 8px;
- padding-right: 8px;
- }
- &.select.is-expanded > select {
- width: 100%;
- }
- & > input,
- & > select,
- & > .button,
- &.label {
- border-radius: 0;
- }
- &:first-child {
- & > input,
- & > select,
- & > .button,
- &.label {
- border-radius: 5px 0 0 5px;
- }
- }
- &:last-child {
- & > input,
- & > select,
- & > .button,
- &.label {
- border-radius: 0 5px 5px 0;
- }
- }
- & > .button {
- font-size: 22px;
- }
- }
- }
- .advanced-filter-bottom {
- display: flex;
- .button {
- font-size: 16px !important;
- width: 100%;
- }
- .control {
- margin: 0 !important;
- }
- }
- .bulk-popup {
- display: flex;
- position: fixed;
- flex-direction: row;
- width: 100%;
- max-width: 400px;
- line-height: 36px;
- z-index: 5;
- border: 1px solid var(--light-grey-3);
- border-radius: 5px;
- box-shadow: 0 14px 28px rgba(0, 0, 0, 0.25), 0 10px 10px rgba(0, 0, 0, 0.22);
- background-color: var(--white);
- color: var(--dark-grey);
- padding: 5px;
- .right {
- display: flex;
- flex-direction: row;
- margin-left: auto;
- }
- .drag-icon {
- position: relative;
- top: 6px;
- color: var(--dark-grey);
- cursor: move;
- }
- }
- </style>
|