@hostlink/nuxt-light 1.21.2 → 1.21.3

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.21.2",
4
+ "version": "1.21.3",
5
5
  "builder": {
6
6
  "@nuxt/module-builder": "0.8.4",
7
7
  "unbuild": "2.0.0"
@@ -0,0 +1,72 @@
1
+ <script setup>
2
+ import { useDialogPluginComponent } from 'quasar'
3
+
4
+ const props = defineProps({
5
+ // ...your custom props
6
+ })
7
+
8
+ // this is part of our example (so not required)
9
+ function onOKClick(value) {
10
+
11
+
12
+ //nullable are boolean values
13
+ value.fields.forEach((field) => {
14
+ field.nullable = field.nullable ? true : false;
15
+
16
+ })
17
+
18
+
19
+ // on OK, it is REQUIRED to
20
+ // call onDialogOK (with optional payload)
21
+ onDialogOK(value)
22
+ // or with payload: onDialogOK({ ... })
23
+ // ...and it will also hide the dialog automatically
24
+ }
25
+
26
+ defineEmits([
27
+ // REQUIRED; need to specify some events that your
28
+ // component will emit through useDialogPluginComponent()
29
+ ...useDialogPluginComponent.emits
30
+ ])
31
+
32
+ const { dialogRef, onDialogHide, onDialogOK, onDialogCancel } = useDialogPluginComponent()
33
+ const types = ["varchar", "int", "date", "time", "datetime", "timestamp", "text", "blob", "json", "jsonb", "uuid", "boolean", "decimal", "float", "double", "real", "numeric", "smallint", "bigint", "tinyint", "mediumint", "char", "binary", "varbinary", "enum"]
34
+
35
+ </script>
36
+ <template>
37
+
38
+ <q-dialog ref="dialogRef" full-width>
39
+ <q-card class="q-dialog-plugin">
40
+ <q-toolbar>
41
+ <q-toolbar-title>Create Table</q-toolbar-title>
42
+ <q-space />
43
+ <q-btn dense flat icon="sym_o_close" v-close-popup />
44
+ </q-toolbar>
45
+ <form-kit type="l-form" :bordered="false" @submit="onOKClick" :value="{
46
+ name: '',
47
+ fields: [],
48
+ }" :action="false" #default="{ value }">
49
+
50
+ <form-kit type="l-input" name="name" label="Name" validation="required" />
51
+
52
+ <form-kit type="l-repeater" name="fields">
53
+ <div class="row q-gutter-sm">
54
+ <form-kit type="l-input" name="name" label="Name" validation="required" class="col" />
55
+
56
+ <form-kit type="l-select" name="type" label="Type" :options="types" validation="required"
57
+ class="col" />
58
+ <form-kit type="l-input" name="length" label="Length" class="col" number />
59
+ <form-kit type="l-input" name="default" label="Default" class="col" />
60
+ </div>
61
+
62
+ <div class="row">
63
+ <form-kit type="l-checkbox" name="nullable" label="Nullable" />
64
+ </div>
65
+ </form-kit>
66
+
67
+ </form-kit>
68
+
69
+
70
+ </q-card>
71
+ </q-dialog>
72
+ </template>
@@ -1,52 +1,14 @@
1
1
  <script setup lang="ts">
2
- import { q, m } from '#imports'
3
- import { useQuasar } from 'quasar'
4
-
5
- const $q = useQuasar()
6
-
7
- const modelValue = defineModel<{
2
+ const emits = defineEmits(["submit"])
3
+ defineProps<{
8
4
  file_manager: string
9
- revision: string
10
5
  }>()
11
-
12
- const onSubmit = async (d, form) => {
13
- let data = [];
14
- Object.keys(d).forEach((key) => {
15
- data.push({
16
- name: key,
17
- value: d[key]
18
- })
19
- })
20
- await m("updateAppConfigs", {
21
- data
22
- })
23
- //update the modelValue
24
- Object.keys(d).forEach((key) => {
25
- modelValue.value[key] = d[key]
26
- })
27
-
28
- $q.notify({
29
- message: "Settings saved",
30
- color: "positive"
31
- })
32
- }
33
-
34
-
35
6
  </script>
36
-
37
7
  <template>
38
- <FormKit type="l-form" :bordered="false" :value="{
39
- file_manager: modelValue.file_manager,
40
- revision: modelValue.revision
41
- }" @submit="onSubmit">
42
- <q-field :label="$t('File Manager')" stack-label>
43
- <FormKit type="l-checkbox" label="Show" name="file_manager" true-value="1" false-value="0" />
8
+ <form-kit type="l-form" :bordered="false" :value="$props" @submit="$emit('submit', $event)">
9
+ <q-field :label="$t('File Manager')" stack-label :color="$light.color">
10
+ <form-kit type="l-checkbox" label="Show" name="file_manager" true-value="1" false-value="0" />
44
11
  </q-field>
45
-
46
- <FormKit type="l-select" label="Revision" name="revision" use-input use-chips multiple hide-dropdown-icon
47
- input-debounce="0" new-value-mode="add-unique" />
48
-
49
-
50
- </FormKit>
12
+ </form-kit>
51
13
 
52
14
  </template>
@@ -53,7 +53,7 @@ const types = ["varchar", "int", "date", "time", "datetime", "timestamp", "text"
53
53
  <form-kit type="l-input" name="length" label="Length" />
54
54
  <form-kit type="l-input" name="default" label="Default" />
55
55
  <form-kit type="l-checkbox" name="nullable" label="Nullable" />
56
- <form-kit type="l-checkbox" name="autoincrement" label="Autoincrement" />
56
+ <form-kit type="l-checkbox" name="autoincrement" label="Auto increment" />
57
57
  </form-kit>
58
58
 
59
59
 
@@ -10,6 +10,7 @@ const i18n = useI18n();
10
10
  const quasar = useQuasar();
11
11
  const $q = quasar;
12
12
 
13
+
13
14
  const { system } = await q({
14
15
  system: {
15
16
  maxUploadSize: true
@@ -28,6 +29,7 @@ export interface LFileProps {
28
29
  stackLabel?: boolean;
29
30
  path?: string;
30
31
  accept?: string;
32
+ driveIndex?: number;
31
33
  }
32
34
 
33
35
  const props = withDefaults(defineProps<LFileProps>(), {
@@ -40,6 +42,7 @@ const props = withDefaults(defineProps<LFileProps>(), {
40
42
  stackLabel: undefined,
41
43
  path: "",
42
44
  accept: "*",
45
+ driveIndex: 0
43
46
  });
44
47
 
45
48
  const emit = defineEmits(["update:modelValue"]);
@@ -96,7 +99,8 @@ const onUploadFile = async () => {
96
99
  });
97
100
 
98
101
  try {
99
- let v = await m("fsUploadFile", {
102
+ let v = await m("lightDriveUploadFile", {
103
+ index: props.driveIndex,
100
104
  path: props.path,
101
105
  file: uploadFile.value,
102
106
  rename: rename.value
@@ -124,7 +128,7 @@ const onUploadFile = async () => {
124
128
 
125
129
  </script>
126
130
  <template>
127
- <q-input v-bind="attrs" v-model="localValue" hide-bottom-space>
131
+ <l-input v-bind="attrs" v-model="localValue" hide-bottom-space>
128
132
  <q-dialog v-model="show" persistent transition-show="scale" transition-hide="scale">
129
133
  <l-card style="width:300px">
130
134
  <q-card-section>
@@ -147,5 +151,5 @@ const onUploadFile = async () => {
147
151
  <template v-for="(s, name) in $slots" v-slot:[name]="props" :key="name">
148
152
  <slot :name="name" v-bind="props ?? {}"></slot>
149
153
  </template>
150
- </q-input>
154
+ </l-input>
151
155
  </template>
@@ -14,6 +14,7 @@ export interface LFileProps {
14
14
  dense?: boolean;
15
15
  square?: boolean;
16
16
  stackLabel?: boolean;
17
+
17
18
  }
18
19
 
19
20
  const props = withDefaults(defineProps<LFileProps>(), {
@@ -59,12 +60,12 @@ const attrs = computed(() => {
59
60
 
60
61
  </script>
61
62
  <template>
62
- <q-input v-bind="attrs" v-model="localValue" hide-bottom-space>
63
+ <l-input v-bind="attrs" v-model="localValue" hide-bottom-space>
63
64
  <q-dialog v-model="show" full-height full-width>
64
65
  <l-file-manager closable @close="show = false" @input="onInput"></l-file-manager>
65
66
  </q-dialog>
66
67
  <template v-slot:prepend>
67
68
  <q-btn dense flat round icon="sym_o_folder" @click="show = true"></q-btn>
68
69
  </template>
69
- </q-input>
70
+ </l-input>
70
71
  </template>
@@ -32,12 +32,16 @@ const showToolbar = computed(() => {
32
32
  }
33
33
  });
34
34
 
35
- let title = props.title || route.path.split("/")[1].replace(/([a-z])(?=[A-Z])/g, '$1 ').replace(/([A-Z]*)(?=[A-Z][a-z])/g, '$1 ')
35
+ const title = computed(() => {
36
+ let t = props.title || route.path.split("/")[1].replace(/([a-z])(?=[A-Z])/g, '$1 ').replace(/([A-Z]*)(?=[A-Z][a-z])/g, '$1 ')
37
+ //remove double space
38
+ t = t.replace(/\s\s+/g, ' ');
39
+ //trim title
40
+ t = t.trim()
41
+ return t
42
+ })
43
+
36
44
 
37
- //remove double space
38
- title = title.replace(/\s\s+/g, ' ');
39
- //trim title
40
- title = title.trim()
41
45
  const module = route.path.split("/")[1];
42
46
  const onDelete = async () => {
43
47
 
@@ -40,10 +40,10 @@ const attrs = {
40
40
 
41
41
  </script>
42
42
  <template>
43
- <q-file v-model="value" :label="context.label" v-bind="attrs" :error="error" :error-message="errorMessage"
43
+ <l-file v-model="value" :label="context.label" v-bind="attrs" :error="error" :error-message="errorMessage"
44
44
  @blur="onBlur">
45
45
  <template v-for="(s, name) in $slots" v-slot:[name]="props" :key="name">
46
46
  <slot :name="name" v-bind="props ?? {}"></slot>
47
47
  </template>
48
- </q-file>
48
+ </l-file>
49
49
  </template>
@@ -1,5 +1,5 @@
1
1
  <script setup>
2
- import { ref, computed } from 'vue'
2
+ import { computed } from 'vue'
3
3
  import { useDragAndDrop } from "@formkit/drag-and-drop/vue";
4
4
  import { animations } from "@formkit/drag-and-drop";
5
5
 
@@ -74,26 +74,26 @@ const isAllowMoveDown = (index) => {
74
74
 
75
75
  <div ref="parent">
76
76
  <FormKit type="group" v-for="(item, index) in items" :index="index" :key="item">
77
- <q-card class="q-mb-sm" flat>
77
+ <q-card class="q-mb-sm" flat bordered>
78
78
  <q-card-section>
79
79
  <div class="row q-col-gutter-md">
80
80
  <div class="col-shrink">
81
- <div class="q-mb-sm" v-if="sortable">
81
+ <div class="q-mb-xs" v-if="sortable">
82
82
  <q-btn icon="sym_o_drag_handle" dense unelevated :color="$light.color"
83
83
  style="cursor: grab;" class="l-repeater-handle">
84
84
  </q-btn>
85
85
  </div>
86
- <div class="q-mb-sm" v-if="sortable">
86
+ <div class="q-mb-xs" v-if="sortable">
87
87
  <!-- up -->
88
88
  <q-btn type="button" @click="onMoveUp(index)" icon="sym_o_arrow_upward"
89
89
  :color="$light.color" dense unelevated :disable="!isAllowMoveUp(index)" />
90
90
  </div>
91
91
 
92
- <div class="q-mb-sm">
92
+ <div class="q-mb-xs">
93
93
  <q-btn type="button" @click="onRemove" icon="sym_o_remove" :color="$light.color"
94
94
  dense unelevated :disable="!isAllowRemove" />
95
95
  </div>
96
- <div class="q-mb-sm" v-if="sortable">
96
+ <div class="q-mb-xs" v-if="sortable">
97
97
  <!-- down -->
98
98
  <q-btn type="button" @click="onMoveDown(index)" icon="sym_o_arrow_downward"
99
99
  :color="$light.color" dense unelevated :disable="!isAllowMoveDown(index)" />
@@ -1,37 +1,38 @@
1
- import { type FormKitInputs } from '@formkit/inputs';
2
- declare module '@formkit/inputs' {
3
- interface FormKitInputProps<Props extends FormKitInputs<Props>> {
4
- lInput: {
5
- type: 'l-input';
6
- name: string;
7
- label: string;
8
- number?: string;
9
- dense?: boolean;
10
- };
11
- lCheckbox: {
12
- type: 'l-checkbox';
13
- name: string;
14
- label: string;
15
- dense?: boolean;
16
- };
17
- lDatePicker: {
18
- type: 'l-date-picker';
19
- name: string;
20
- label: string;
21
- dense?: boolean;
22
- };
23
- lForm: {
24
- type: 'l-form';
25
- gutter?: 'none' | 'xs' | 'sm' | 'md' | 'lg' | 'xl';
26
- bordered?: boolean;
27
- };
28
- lSelect: {
29
- type: 'l-select';
30
- name: string;
31
- label: string;
32
- options: Array<any>;
33
- dense?: boolean;
34
- };
35
- }
36
- }
37
- export * from "./lib/index.js";
1
+ import { type FormKitInputs } from '@formkit/inputs';
2
+
3
+ declare module '@formkit/inputs' {
4
+ export interface FormKitInputProps<Props extends FormKitInputs<Props>> {
5
+ lInput: {
6
+ type: 'l-input';
7
+ name: string;
8
+ label: string;
9
+ number?: string;
10
+ dense?: boolean;
11
+ },
12
+ lCheckbox: {
13
+ type: 'l-checkbox';
14
+ name: string;
15
+ label: string;
16
+ dense?: boolean;
17
+ },
18
+ lDatePicker: {
19
+ type: 'l-date-picker';
20
+ name: string;
21
+ label: string;
22
+ dense?: boolean;
23
+ },
24
+ lForm: {
25
+ type: 'l-form';
26
+ gutter?: 'none' | 'xs' | 'sm' | 'md' | 'lg' | 'xl';
27
+ bordered?: boolean;
28
+ },
29
+ lSelect: {
30
+ type: 'l-select';
31
+ name: string;
32
+ label: string;
33
+ options: Array<any>;
34
+ dense?: boolean;
35
+ optionsDense?: boolean;
36
+ },
37
+ }
38
+ }
@@ -227,7 +227,6 @@ declare const light: {
227
227
  clear: string;
228
228
  set: string;
229
229
  search: string;
230
- filter: string;
231
230
  remove: string;
232
231
  ok: string;
233
232
  cancel: string;
@@ -235,6 +234,7 @@ declare const light: {
235
234
  reset: string;
236
235
  update: string;
237
236
  create: string;
237
+ filter: string;
238
238
  refresh: string;
239
239
  };
240
240
  date: {
@@ -261,10 +261,10 @@ declare const light: {
261
261
  pagination: (start: number, end: number, total: number) => string;
262
262
  };
263
263
  editor: {
264
- bold: string;
265
264
  left: string;
266
265
  right: string;
267
266
  center: string;
267
+ bold: string;
268
268
  align: string;
269
269
  url: string;
270
270
  italic: string;
@@ -357,10 +357,10 @@ declare const light: {
357
357
  };
358
358
  editor: {
359
359
  size: string;
360
- bold: string;
361
360
  left: string;
362
361
  right: string;
363
362
  center: string;
363
+ bold: string;
364
364
  align: string;
365
365
  italic: string;
366
366
  strikethrough: string;
@@ -445,8 +445,8 @@ declare const light: {
445
445
  };
446
446
  uploader: {
447
447
  clear: string;
448
- add: string;
449
448
  done: string;
449
+ add: string;
450
450
  upload: string;
451
451
  removeQueue: string;
452
452
  removeUploaded: string;
@@ -832,7 +832,6 @@ export declare const useLight: () => {
832
832
  clear: string;
833
833
  set: string;
834
834
  search: string;
835
- filter: string;
836
835
  remove: string;
837
836
  ok: string;
838
837
  cancel: string;
@@ -840,6 +839,7 @@ export declare const useLight: () => {
840
839
  reset: string;
841
840
  update: string;
842
841
  create: string;
842
+ filter: string;
843
843
  refresh: string;
844
844
  };
845
845
  date: {
@@ -866,10 +866,10 @@ export declare const useLight: () => {
866
866
  pagination: (start: number, end: number, total: number) => string;
867
867
  };
868
868
  editor: {
869
- bold: string;
870
869
  left: string;
871
870
  right: string;
872
871
  center: string;
872
+ bold: string;
873
873
  align: string;
874
874
  url: string;
875
875
  italic: string;
@@ -962,10 +962,10 @@ export declare const useLight: () => {
962
962
  };
963
963
  editor: {
964
964
  size: string;
965
- bold: string;
966
965
  left: string;
967
966
  right: string;
968
967
  center: string;
968
+ bold: string;
969
969
  align: string;
970
970
  italic: string;
971
971
  strikethrough: string;
@@ -1050,8 +1050,8 @@ export declare const useLight: () => {
1050
1050
  };
1051
1051
  uploader: {
1052
1052
  clear: string;
1053
- add: string;
1054
1053
  done: string;
1054
+ add: string;
1055
1055
  upload: string;
1056
1056
  removeQueue: string;
1057
1057
  removeUploaded: string;
@@ -203,6 +203,12 @@ const light = reactive({
203
203
  watch(() => light.theme, async () => {
204
204
  await light.setStyle("theme", light.theme);
205
205
  });
206
+ watch(() => light.color, async () => {
207
+ await m("updateMyStyle", {
208
+ name: "color",
209
+ value: light.color
210
+ });
211
+ });
206
212
  },
207
213
  isGranted(right) {
208
214
  if (right === void 0) return true;
@@ -230,12 +236,6 @@ export const createLight = (opts) => {
230
236
  };
231
237
  };
232
238
  let currentRoute = null;
233
- watch(() => light.color, async () => {
234
- await m("updateMyStyle", {
235
- name: "color",
236
- value: light.color
237
- });
238
- });
239
239
  export const useLight = () => {
240
240
  light.$q = useQuasar();
241
241
  return light;
@@ -1,23 +1,38 @@
1
1
  <script setup>
2
2
  import { useQuasar } from 'quasar'
3
- import { q, m, notify } from '#imports'
4
- import { ref } from "vue"
3
+ import { q, m, notify, useAsyncData } from '#imports'
5
4
  import { useI18n } from 'vue-i18n';
6
5
  const { t } = useI18n();
7
6
  const qua = useQuasar();
8
- const quasar = useQuasar();
7
+ const { data, refresh } = await useAsyncData('role', async () => {
8
+
9
+ const data = await q({
10
+ app: {
11
+ roles: {
12
+ name: true,
13
+ canDelete: true,
14
+ canUpdate: true,
15
+ children: true,
16
+ user: {
17
+ name: true,
18
+ user_id: true
19
+ }
20
+ },
21
+ listUser: {
22
+ data: {
23
+ user_id: true,
24
+ name: true
25
+ }
26
+ }
27
+ }
28
+ });
29
+ return data.app;
30
+ })
9
31
 
10
- const loadData = async () => {
11
- return await q("listRole", ["name", "canDelete", "canUpdate", "children", {
12
- user: ["name", "user_id"]
13
- }]);
14
- }
15
- const roles = ref(await loadData());
16
- let role_options = roles.value.map(r => ({ label: r.name, value: r.name }))
17
32
 
18
- const users = (await q("listUser", [{
19
- data: ["user_id", "name"]
20
- }])).data;
33
+ let role_options = data.value.roles.map(r => ({ label: r.name, value: r.name }))
34
+
35
+ let users = data.value.listUser.data;
21
36
 
22
37
  const onDelete = async (role) => {
23
38
  //confirm
@@ -28,9 +43,9 @@ const onDelete = async (role) => {
28
43
  persistent: true,
29
44
  }).onOk(async () => {
30
45
 
31
- m("deleteRole", { name: role })
32
- //refresh
33
- roles.value = await loadData();
46
+ await m("deleteRole", { name: role })
47
+ refresh();
48
+
34
49
  });
35
50
 
36
51
  }
@@ -66,8 +81,8 @@ const onRemoveChild = async (value, child) => {
66
81
  //notify
67
82
  notify("Role removed from role")
68
83
 
69
- //refresh
70
- roles.value = await loadData();
84
+ refresh();
85
+
71
86
  }
72
87
 
73
88
  const onAddChild = async (value, child) => {
@@ -79,9 +94,8 @@ const onAddChild = async (value, child) => {
79
94
 
80
95
  //notify
81
96
  notify("Role added to role")
97
+ refresh();
82
98
 
83
- //refresh
84
- roles.value = await loadData();
85
99
  }
86
100
 
87
101
  const onAddUser = async (value, user) => {
@@ -94,8 +108,7 @@ const onAddUser = async (value, user) => {
94
108
  //notify
95
109
  notify("User added to role")
96
110
 
97
- //refresh
98
- roles.value = await loadData();
111
+ refresh();
99
112
  }
100
113
 
101
114
  const onRemoveUser = async (value, user) => {
@@ -104,31 +117,27 @@ const onRemoveUser = async (value, user) => {
104
117
  user_id: user.value.user_id
105
118
 
106
119
  });
107
-
108
120
  //notify
109
121
  notify("User removed from role")
110
-
111
- //refresh
112
- roles.value = await loadData();
122
+ refresh();
113
123
  }
114
124
  </script>
115
125
 
116
126
  <template>
117
127
  <l-page>
118
- <q-table :rows="roles" flat bordered :columns="columns" :rows-per-page-options="[0]" dense>
128
+ <q-table :rows="data.roles" flat bordered :columns="columns" :rows-per-page-options="[0]" dense>
119
129
  <template #body-cell-_can_delete="props">
120
130
  <q-td auto-width>
121
131
  <q-btn v-if="props.row.canDelete" flat round dense icon="sym_o_delete"
122
132
  @click="onDelete(props.row.name)" />
123
-
124
133
  </q-td>
125
134
  </template>
126
135
 
127
136
  <template #body-cell-children="props">
128
137
  <q-td>
129
138
  <q-select :options="role_options" v-model="props.row.children" multiple use-chips dense
130
- @remove="onRemoveChild(props.row.name, $event)" @add="onAddChild(props.row.name, $event)">
131
-
139
+ @remove="onRemoveChild(props.row.name, $event)" @add="onAddChild(props.row.name, $event)"
140
+ :color="$light.color">
132
141
  </q-select>
133
142
  </q-td>
134
143
  </template>
@@ -136,7 +145,7 @@ const onRemoveUser = async (value, user) => {
136
145
  <q-td>
137
146
  <q-select :options="users" v-model="props.row.user" multiple use-chips dense option-label="name"
138
147
  option-value="user_id" @add="onAddUser(props.row.name, $event)"
139
- @remove="onRemoveUser(props.row.name, $event)">
148
+ @remove="onRemoveUser(props.row.name, $event)" :color="$light.color">
140
149
 
141
150
  </q-select>
142
151
  </q-td>
@@ -33,7 +33,7 @@ const onClickDownload = async () => {
33
33
  }
34
34
  </script>
35
35
  <template>
36
- <l-page>
36
+ <l-page title="Database backup">
37
37
  <l-btn label="Download" icon="sym_o_download" @click="onClickDownload"></l-btn>
38
38
  </l-page>
39
39
  </template>