@hostlink/nuxt-light 1.32.4 → 1.33.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.32.4",
4
+ "version": "1.33.0",
5
5
  "builder": {
6
6
  "@nuxt/module-builder": "1.0.1",
7
7
  "unbuild": "3.5.0"
package/dist/module.mjs CHANGED
@@ -336,10 +336,11 @@ const module = defineNuxtModule({
336
336
  });
337
337
  addImportsDir(resolver.resolve("./runtime/composables"));
338
338
  const files = await resolveFiles(process.cwd() + "/models", ["*"]);
339
+ const files2 = await resolveFiles(process.cwd() + "/app/models", ["*"]);
339
340
  nuxt.options.runtimeConfig.public.light = {
340
341
  model: []
341
342
  };
342
- for (const file of files) {
343
+ for (const file of [...files, ...files2]) {
343
344
  const n1 = "Model_" + file.match(/([a-zA-Z0-9]+)\.ts$/)?.[1];
344
345
  addPlugin({
345
346
  src: file,
@@ -14,6 +14,7 @@ export interface LightModelField {
14
14
  field?: (row: any) => string;
15
15
  component?: Component;
16
16
  componentProps?: any;
17
+ format?: (value: any) => any;
17
18
  }
18
19
  export interface LightModelFields {
19
20
  [key: string]: LightModelField;
@@ -0,0 +1 @@
1
+ export default function (fields: Object): import("#app").AsyncData<any, import("#app").NuxtError<unknown> | null> | undefined;
@@ -0,0 +1,25 @@
1
+ import { toQuery } from "@hostlink/light";
2
+ import { useRoute } from "vue-router";
3
+ import { default as getModelField } from "./getModelField.js";
4
+ import { default as collect } from "./collect.js";
5
+ import { defu } from "defu";
6
+ import { useAsyncData } from "#app";
7
+ export default function(fields) {
8
+ let route = useRoute();
9
+ if (!route.name) {
10
+ return;
11
+ }
12
+ const [module, id_name] = route.name.split("-");
13
+ const id = parseInt(route.params[id_name]);
14
+ let query = {};
15
+ for (const [key, value] of Object.entries(fields)) {
16
+ query[key] = value;
17
+ const f = getModelField(module, key);
18
+ if (f) {
19
+ query = defu(query, f.getGQLField());
20
+ }
21
+ }
22
+ return useAsyncData(async () => {
23
+ return await collect(module, toQuery(query)).where(id_name, id).first();
24
+ });
25
+ }
@@ -0,0 +1 @@
1
+ export default function (fields: Object): Promise<any>;
@@ -0,0 +1,22 @@
1
+ import { toQuery } from "@hostlink/light";
2
+ import { useRoute } from "vue-router";
3
+ import { default as getModelField } from "./getModelField.js";
4
+ import { default as collect } from "./collect.js";
5
+ import { defu } from "defu";
6
+ export default async function(fields) {
7
+ let route = useRoute();
8
+ if (!route.name) {
9
+ return;
10
+ }
11
+ const [module, id_name] = route.name.split("-");
12
+ const id = parseInt(route.params[id_name]);
13
+ let query = {};
14
+ for (const [key, value] of Object.entries(fields)) {
15
+ query[key] = value;
16
+ const f = getModelField(module, key);
17
+ if (f) {
18
+ query = defu(query, f.getGQLField());
19
+ }
20
+ }
21
+ return await collect(module, toQuery(query)).where(id_name, id).first();
22
+ }
@@ -1,9 +1,9 @@
1
1
  <script setup>
2
- import { useLight, getObject, m } from "#imports";
2
+ import { useLight, useAsyncObject, m } from "#imports";
3
3
  import { useRoute } from "vue-router";
4
4
  import { ref } from "vue";
5
5
  const route = useRoute();
6
- const obj = await getObject(["canUpdate"]);
6
+ const { data: obj } = await useAsyncObject({ canUpdate: true, canDelete: true });
7
7
  const light = useLight();
8
8
  const tab = ref("overview");
9
9
  const id = route.params.user_id;
@@ -39,6 +39,7 @@ const reset2fa = async () => {
39
39
  label="Change password"></l-btn>
40
40
  <l-btn to="update-role" icon="sym_o_people" permission="user.role.add" label="Update role"></l-btn>
41
41
  <l-btn label="Reset 2FA" icon="sym_o_key" permission="user.reset2fa" @click="reset2fa"></l-btn>
42
+
42
43
  </template>
43
44
 
44
45
  <q-card flat bordered>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hostlink/nuxt-light",
3
- "version": "1.32.4",
3
+ "version": "1.33.0",
4
4
  "description": "HostLink Nuxt Light Framework",
5
5
  "repository": {
6
6
  "type": "git",