@hostlink/nuxt-light 1.45.5 → 1.46.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/module.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "light",
3
3
  "configKey": "light",
4
- "version": "1.45.5",
4
+ "version": "1.46.0",
5
5
  "builder": {
6
6
  "@nuxt/module-builder": "1.0.2",
7
7
  "unbuild": "3.6.1"
@@ -1,8 +1,16 @@
1
1
  <script setup>
2
- import { computed } from "vue";
2
+ import { computed, ref, watch } from "vue";
3
3
  import { useLight } from "#imports";
4
4
  const light = useLight();
5
5
  const props = defineProps(["value", "dense"]);
6
+ const favMenuExpanded = ref(
7
+ typeof window !== "undefined" ? JSON.parse(localStorage.getItem("fav-menu-expanded") || "false") : false
8
+ );
9
+ watch(favMenuExpanded, (newValue) => {
10
+ if (typeof window !== "undefined") {
11
+ localStorage.setItem("fav-menu-expanded", JSON.stringify(newValue));
12
+ }
13
+ });
6
14
  const color1 = computed(() => {
7
15
  return light.getColorValue();
8
16
  });
@@ -18,7 +26,8 @@ const color2 = computed(() => {
18
26
  </style>
19
27
 
20
28
  <template>
21
- <q-expansion-item :label="$t('My favorite')" :dense="dense" icon="sym_o_favorite">
29
+ <q-expansion-item :label="$t('My favorite')" :dense="dense" icon="sym_o_favorite"
30
+ v-model="favMenuExpanded">
22
31
  <q-list class="q-pl-md menu-list" :dense="dense">
23
32
  <q-item v-ripple :to="item.path" v-for="item in value">
24
33
  <q-item-section avatar>
@@ -22,6 +22,7 @@ export type LTableProps = QTableProps & {
22
22
  addComponent?: Dialog;
23
23
  addComponentProps?: any;
24
24
  rows?: Array<any>;
25
+ name?: string;
25
26
  };
26
27
  export interface LTableRequest {
27
28
  sort: string;
@@ -59,11 +60,11 @@ export interface LTableRequest {
59
60
  }) => void;
60
61
  }
61
62
  declare function requestServerInteraction(): void;
62
- declare var __VLS_91: any, __VLS_94: string, __VLS_95: any, __VLS_117: any, __VLS_184: string, __VLS_185: any;
63
+ declare var __VLS_91: any, __VLS_94: string, __VLS_95: any, __VLS_117: any, __VLS_204: string, __VLS_205: any;
63
64
  type __VLS_Slots = {} & {
64
65
  [K in NonNullable<typeof __VLS_94>]?: (props: typeof __VLS_95) => any;
65
66
  } & {
66
- [K in NonNullable<typeof __VLS_184>]?: (props: typeof __VLS_185) => any;
67
+ [K in NonNullable<typeof __VLS_204>]?: (props: typeof __VLS_205) => any;
67
68
  } & {
68
69
  actions?: (props: typeof __VLS_91) => any;
69
70
  } & {
@@ -7,6 +7,7 @@ import model from "../composables/model";
7
7
  import { toQuery } from "@hostlink/light";
8
8
  import { list } from "#imports";
9
9
  import { useI18n } from "vue-i18n";
10
+ import { useStorage } from "@vueuse/core";
10
11
  const $q = useQuasar();
11
12
  const { t } = useI18n();
12
13
  const errors = ref([]);
@@ -75,7 +76,7 @@ const props = defineProps({
75
76
  sortBy: null,
76
77
  descending: true,
77
78
  page: 1,
78
- rowsPerPage: 10
79
+ rowsPerPage: 20
79
80
  };
80
81
  } },
81
82
  rowsPerPageOptions: { type: null, required: false, default: () => [5, 10, 20, 50, 100, 0] },
@@ -100,7 +101,8 @@ const props = defineProps({
100
101
  searchable: { type: Boolean, required: false, default: false },
101
102
  onRequestData: { type: Function, required: false },
102
103
  addComponent: { type: Object, required: false },
103
- addComponentProps: { type: null, required: false }
104
+ addComponentProps: { type: null, required: false },
105
+ name: { type: String, required: false }
104
106
  });
105
107
  const isServerSide = props.rows == void 0;
106
108
  const light = useLight();
@@ -299,21 +301,22 @@ const getFilterValue = () => {
299
301
  props.columns?.forEach((col) => {
300
302
  if (col.searchable) {
301
303
  if (filters[col.name] !== null && filters[col.name] !== "" && filters[col.name] !== void 0) {
304
+ const k = col.searchIndex ?? col.name;
302
305
  if (col.searchType == "number") {
303
- f[col.name] = filters[col.name];
306
+ f[k] = filters[col.name];
304
307
  } else if (col.searchType == "date") {
305
- if (filters[col.name].from) {
306
- f[col.name] = {
308
+ if (filters[k].from) {
309
+ f[k] = {
307
310
  between: [filters[col.name].from, filters[col.name].to]
308
311
  };
309
312
  }
310
313
  } else if (col.searchType == "select") {
311
- f[col.name] = filters[col.name];
314
+ f[k] = filters[col.name];
312
315
  } else {
313
316
  if (col.searchMethod == "equals") {
314
- f[col.name] = filters[col.name];
317
+ f[k] = filters[col.name];
315
318
  } else {
316
- f[col.name] = {
319
+ f[k] = {
317
320
  contains: filters[col.name]
318
321
  };
319
322
  }
@@ -454,11 +457,19 @@ const searchSelectFilter = (val, update, name) => {
454
457
  });
455
458
  }
456
459
  };
460
+ const showTopRight = computed(() => {
461
+ return props.searchable || props.name && (props.columns && props.columns.length > 0);
462
+ });
463
+ const hidableColumns = computed(() => {
464
+ return props.columns?.filter((c) => !c.required) || [];
465
+ });
466
+ const visibleColumns = props.name ? useStorage(`l-table-visible-columns-${props.name}`, hidableColumns.value.map((c) => c.name)) : ref(hidableColumns.value.map((c) => c.name));
457
467
  </script>
458
468
 
459
469
  <template>
460
470
  <q-table v-bind="attrs" :loading="loading" :rows="rows" ref="table" @request="onLocalRequest" :columns="columns"
461
- v-model:pagination="pagination" :filter="filter" v-model:selected="localSelected" :color="$light.color">
471
+ v-model:pagination="pagination" :filter="filter" v-model:selected="localSelected" :color="$light.color"
472
+ :visible-columns="visibleColumns">
462
473
 
463
474
  <template #header="props">
464
475
  <q-tr :props="props">
@@ -544,17 +555,26 @@ const searchSelectFilter = (val, update, name) => {
544
555
  </template>
545
556
 
546
557
 
547
- <template #top-right="props" v-if="searchable">
548
- <q-input v-if="searchable" outlined dense debounce="300" v-model="filter" :placeholder="$t('Search')"
549
- :color="$light.color">
558
+ <template #top-right="props" v-if="showTopRight">
559
+ <q-input outlined dense debounce="300" v-model="filter" :placeholder="$t('Search')" :color="$light.color"
560
+ v-if="searchable">
550
561
  <template v-slot:append>
551
562
  <q-icon name="search" />
552
563
  </template>
553
564
  </q-input>
554
565
 
555
-
556
-
557
-
566
+ <q-icon name="sym_o_view_column" size="sm" class="cursor-pointer" :color="$light.color">
567
+ <q-popup-proxy>
568
+ <q-card>
569
+ <q-card-section>
570
+ <div v-for="column in hidableColumns" :key="column.name" class="q-mb-xs">
571
+ <q-checkbox v-model="visibleColumns" :val="column.name" :label="column.label"
572
+ :color="$light.color" dense />
573
+ </div>
574
+ </q-card-section>
575
+ </q-card>
576
+ </q-popup-proxy>
577
+ </q-icon>
558
578
  </template>
559
579
 
560
580
 
@@ -577,12 +597,12 @@ const searchSelectFilter = (val, update, name) => {
577
597
 
578
598
  <template v-if="col.searchType == 'number'">
579
599
  <q-input style="min-width: 80px;" dense clearable filled square
580
- v-model.number="filters[col.searchIndex ?? col.name]" @keydown.enter.prevent="onFilters"
581
- @clear="onFilters" mask="##########" :enterkeyhint="$t('search')"></q-input>
600
+ v-model.number="filters[col.name]" @keydown.enter.prevent="onFilters" @clear="onFilters"
601
+ mask="##########" :enterkeyhint="$t('search')"></q-input>
582
602
  </template>
583
603
 
584
604
  <template v-if="col.searchType == 'select'">
585
- <q-select dense clearable filled square v-model="filters[col.searchIndex ?? col.name]"
605
+ <q-select dense clearable filled square v-model="filters[col.name]"
586
606
  @update:model-value="onFilters" options-dense :options="localSearchOptions[col.name]"
587
607
  emit-value map-options :multiple="col.searchMultiple" :color="$light.color" use-input
588
608
  input-debounce="0" @filter="(val, update) => {
@@ -592,14 +612,13 @@ const searchSelectFilter = (val, update, name) => {
592
612
 
593
613
  <template v-if="col.searchType == 'date'">
594
614
  <l-date-picker dense clearable filled square :outlined="false" hide-bottom-space
595
- v-model="filters[col.searchIndex ?? col.name]" @update:model-value="onFilters" range
596
- @clear="onFilters" />
615
+ v-model="filters[col.name]" @update:model-value="onFilters" range @clear="onFilters" />
597
616
  </template>
598
617
 
599
618
  <template v-if="!col.searchType || col.searchType == 'text'">
600
- <q-input style="min-width: 80px;" dense clearable filled square
601
- v-model="filters[col.searchIndex ?? col.name]" @keydown.enter.prevent="onFilters"
602
- @clear="onFilters" :enterkeyhint="$t('search')" :color="$light.color"></q-input>
619
+ <q-input style="min-width: 80px;" dense clearable filled square v-model="filters[col.name]"
620
+ @keydown.enter.prevent="onFilters" @clear="onFilters" :enterkeyhint="$t('search')"
621
+ :color="$light.color"></q-input>
603
622
 
604
623
  </template>
605
624
 
@@ -22,6 +22,7 @@ export type LTableProps = QTableProps & {
22
22
  addComponent?: Dialog;
23
23
  addComponentProps?: any;
24
24
  rows?: Array<any>;
25
+ name?: string;
25
26
  };
26
27
  export interface LTableRequest {
27
28
  sort: string;
@@ -59,11 +60,11 @@ export interface LTableRequest {
59
60
  }) => void;
60
61
  }
61
62
  declare function requestServerInteraction(): void;
62
- declare var __VLS_91: any, __VLS_94: string, __VLS_95: any, __VLS_117: any, __VLS_184: string, __VLS_185: any;
63
+ declare var __VLS_91: any, __VLS_94: string, __VLS_95: any, __VLS_117: any, __VLS_204: string, __VLS_205: any;
63
64
  type __VLS_Slots = {} & {
64
65
  [K in NonNullable<typeof __VLS_94>]?: (props: typeof __VLS_95) => any;
65
66
  } & {
66
- [K in NonNullable<typeof __VLS_184>]?: (props: typeof __VLS_185) => any;
67
+ [K in NonNullable<typeof __VLS_204>]?: (props: typeof __VLS_205) => any;
67
68
  } & {
68
69
  actions?: (props: typeof __VLS_91) => any;
69
70
  } & {
@@ -13,6 +13,7 @@ declare const _default: {
13
13
  label: string;
14
14
  sortable: boolean;
15
15
  searchable: boolean;
16
+ required: boolean;
16
17
  };
17
18
  first_name: {
18
19
  label: string;
@@ -15,7 +15,8 @@ export default {
15
15
  username: {
16
16
  label: "Username",
17
17
  sortable: true,
18
- searchable: true
18
+ searchable: true,
19
+ required: true
19
20
  //cellClass: (row: any) => (row.username == "admin" ? "text-danger" : ""),
20
21
  /* backgroundColor: (row: any) => {
21
22
 
@@ -22,7 +22,7 @@ const columns = model("User").columns({
22
22
  <l-tabs route>
23
23
  <l-tab label="Active" name="active">
24
24
  <l-table ref="table" row-key="user_id" @request-data="onRequest" :columns="columns"
25
- :actions="['view', 'edit', 'delete']"></l-table>
25
+ :actions="['view', 'edit', 'delete']" name="user-index-active"></l-table>
26
26
  </l-tab>
27
27
  <l-tab label="Inactive" name="inactive">
28
28
  <l-table row-key="user_id" @request-data="onRequest" :columns="columns"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hostlink/nuxt-light",
3
- "version": "1.45.5",
3
+ "version": "1.46.0",
4
4
  "description": "HostLink Nuxt Light Framework",
5
5
  "repository": {
6
6
  "type": "git",