@hostlink/nuxt-light 1.45.5 → 1.46.1

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.1",
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>
@@ -10,8 +10,7 @@ const props = defineProps({
10
10
  tag: { type: null, required: false }
11
11
  });
12
12
  function getTo(field) {
13
- console.log(field);
14
- const raw = field.getRaw();
13
+ const raw = field;
15
14
  if (raw.to) {
16
15
  if (raw.to instanceof Function) {
17
16
  return raw.to(props.modelValue);
@@ -27,7 +26,7 @@ function getTo(field) {
27
26
  <template>
28
27
  <q-list v-bind="$props">
29
28
  <template v-if="fields">
30
- <l-item v-for="field in fields" :label="field.getRaw().label" :to="getTo(field)">
29
+ <l-item v-for="field in fields" :label="field.label" :to="getTo(field)">
31
30
  {{ field.getFormattedValue(props.modelValue) }}
32
31
  </l-item>
33
32
 
@@ -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,8 +7,11 @@ 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";
11
+ import { useRoute } from "#imports";
10
12
  const $q = useQuasar();
11
13
  const { t } = useI18n();
14
+ const $route = useRoute();
12
15
  const errors = ref([]);
13
16
  const props = defineProps({
14
17
  fullscreen: { type: Boolean, required: false, skipCheck: true, default: false },
@@ -75,7 +78,7 @@ const props = defineProps({
75
78
  sortBy: null,
76
79
  descending: true,
77
80
  page: 1,
78
- rowsPerPage: 10
81
+ rowsPerPage: 20
79
82
  };
80
83
  } },
81
84
  rowsPerPageOptions: { type: null, required: false, default: () => [5, 10, 20, 50, 100, 0] },
@@ -100,7 +103,8 @@ const props = defineProps({
100
103
  searchable: { type: Boolean, required: false, default: false },
101
104
  onRequestData: { type: Function, required: false },
102
105
  addComponent: { type: Object, required: false },
103
- addComponentProps: { type: null, required: false }
106
+ addComponentProps: { type: null, required: false },
107
+ name: { type: String, required: false }
104
108
  });
105
109
  const isServerSide = props.rows == void 0;
106
110
  const light = useLight();
@@ -299,21 +303,22 @@ const getFilterValue = () => {
299
303
  props.columns?.forEach((col) => {
300
304
  if (col.searchable) {
301
305
  if (filters[col.name] !== null && filters[col.name] !== "" && filters[col.name] !== void 0) {
306
+ const k = col.searchIndex ?? col.name;
302
307
  if (col.searchType == "number") {
303
- f[col.name] = filters[col.name];
308
+ f[k] = filters[col.name];
304
309
  } else if (col.searchType == "date") {
305
- if (filters[col.name].from) {
306
- f[col.name] = {
310
+ if (filters[k].from) {
311
+ f[k] = {
307
312
  between: [filters[col.name].from, filters[col.name].to]
308
313
  };
309
314
  }
310
315
  } else if (col.searchType == "select") {
311
- f[col.name] = filters[col.name];
316
+ f[k] = filters[col.name];
312
317
  } else {
313
318
  if (col.searchMethod == "equals") {
314
- f[col.name] = filters[col.name];
319
+ f[k] = filters[col.name];
315
320
  } else {
316
- f[col.name] = {
321
+ f[k] = {
317
322
  contains: filters[col.name]
318
323
  };
319
324
  }
@@ -454,12 +459,25 @@ const searchSelectFilter = (val, update, name) => {
454
459
  });
455
460
  }
456
461
  };
462
+ const showTopRight = computed(() => {
463
+ return props.searchable || props.name && (props.columns && props.columns.length > 0);
464
+ });
465
+ const hidableColumns = computed(() => {
466
+ return props.columns?.filter((c) => !c.required) || [];
467
+ });
468
+ const simpleRouteName = computed(() => {
469
+ if ($route.name && typeof $route.name == "string") {
470
+ return $route.name;
471
+ }
472
+ return "";
473
+ });
474
+ const visibleColumns = props.name ? useStorage("l-table-visible-columns-" + simpleRouteName.value + "-" + props.name, hidableColumns.value.map((c) => c.name)) : ref(hidableColumns.value.map((c) => c.name));
457
475
  </script>
458
476
 
459
477
  <template>
460
478
  <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">
462
-
479
+ v-model:pagination="pagination" :filter="filter" v-model:selected="localSelected" :color="$light.color"
480
+ :visible-columns="visibleColumns">
463
481
  <template #header="props">
464
482
  <q-tr :props="props">
465
483
  <q-td v-if="selection != 'none'" auto-width>
@@ -480,6 +498,7 @@ const searchSelectFilter = (val, update, name) => {
480
498
  </template>
481
499
 
482
500
 
501
+
483
502
  <template #top-left v-if="addComponent">
484
503
  <q-btn icon="sym_o_add" :label="$t('Add')" :color="$light.color" @click="onAdd" outline />
485
504
  </template>
@@ -544,17 +563,26 @@ const searchSelectFilter = (val, update, name) => {
544
563
  </template>
545
564
 
546
565
 
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">
566
+ <template #top-right="props" v-if="showTopRight">
567
+ <q-input outlined dense debounce="300" v-model="filter" :placeholder="$t('Search')" :color="$light.color"
568
+ v-if="searchable">
550
569
  <template v-slot:append>
551
570
  <q-icon name="search" />
552
571
  </template>
553
572
  </q-input>
554
573
 
555
-
556
-
557
-
574
+ <q-icon name="sym_o_view_column" size="sm" class="cursor-pointer" :color="$light.color">
575
+ <q-popup-proxy>
576
+ <q-card>
577
+ <q-card-section>
578
+ <div v-for="column in hidableColumns" :key="column.name" class="q-mb-xs">
579
+ <q-checkbox v-model="visibleColumns" :val="column.name" :label="column.label"
580
+ :color="$light.color" dense />
581
+ </div>
582
+ </q-card-section>
583
+ </q-card>
584
+ </q-popup-proxy>
585
+ </q-icon>
558
586
  </template>
559
587
 
560
588
 
@@ -577,12 +605,12 @@ const searchSelectFilter = (val, update, name) => {
577
605
 
578
606
  <template v-if="col.searchType == 'number'">
579
607
  <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>
608
+ v-model.number="filters[col.name]" @keydown.enter.prevent="onFilters" @clear="onFilters"
609
+ mask="##########" :enterkeyhint="$t('search')"></q-input>
582
610
  </template>
583
611
 
584
612
  <template v-if="col.searchType == 'select'">
585
- <q-select dense clearable filled square v-model="filters[col.searchIndex ?? col.name]"
613
+ <q-select dense clearable filled square v-model="filters[col.name]"
586
614
  @update:model-value="onFilters" options-dense :options="localSearchOptions[col.name]"
587
615
  emit-value map-options :multiple="col.searchMultiple" :color="$light.color" use-input
588
616
  input-debounce="0" @filter="(val, update) => {
@@ -592,14 +620,13 @@ const searchSelectFilter = (val, update, name) => {
592
620
 
593
621
  <template v-if="col.searchType == 'date'">
594
622
  <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" />
623
+ v-model="filters[col.name]" @update:model-value="onFilters" range @clear="onFilters" />
597
624
  </template>
598
625
 
599
626
  <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>
627
+ <q-input style="min-width: 80px;" dense clearable filled square v-model="filters[col.name]"
628
+ @keydown.enter.prevent="onFilters" @clear="onFilters" :enterkeyhint="$t('search')"
629
+ :color="$light.color"></q-input>
603
630
 
604
631
  </template>
605
632
 
@@ -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
  } & {
@@ -4,9 +4,10 @@ export default (model, names) => {
4
4
  for (let name of names) {
5
5
  const field = getModelField(model, name);
6
6
  if (!field) continue;
7
- const option = field.getRaw();
8
- option.name = field.getName();
9
- columns.push(option);
7
+ if (!field.name) {
8
+ field.name = name;
9
+ }
10
+ columns.push(field);
10
11
  }
11
12
  return columns;
12
13
  };
@@ -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="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.1",
4
4
  "description": "HostLink Nuxt Light Framework",
5
5
  "repository": {
6
6
  "type": "git",