@hostlink/nuxt-light 0.0.82 → 0.0.84
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 +1 -1
- package/dist/module.mjs +7 -3
- package/dist/runtime/components/l-app-main.vue +4 -0
- package/dist/runtime/components/l-list.vue +8 -31
- package/dist/runtime/lib/SystemValue.d.ts +4 -0
- package/dist/runtime/lib/SystemValue.mjs +22 -0
- package/dist/runtime/lib/getGQLFields.d.ts +2 -0
- package/dist/runtime/lib/getGQLFields.mjs +8 -0
- package/dist/runtime/lib/getModelColumns.d.ts +2 -0
- package/dist/runtime/lib/getModelColumns.mjs +13 -0
- package/dist/runtime/lib/getModelFields.d.ts +1 -0
- package/dist/runtime/lib/getModelFields.mjs +11 -0
- package/dist/runtime/lib/getObject.mjs +4 -4
- package/dist/runtime/lib/index.d.ts +4 -4
- package/dist/runtime/lib/index.mjs +6 -6
- package/dist/runtime/lib/loadSV.d.ts +3 -0
- package/dist/runtime/lib/loadSV.mjs +4 -0
- package/dist/runtime/lib/sv.d.ts +1 -0
- package/dist/runtime/lib/sv.mjs +5 -0
- package/dist/runtime/pages/User/_user_id/edit.vue +1 -1
- package/dist/runtime/pages/User/_user_id/view.vue +3 -2
- package/dist/runtime/pages/User/index.vue +3 -2
- package/dist/runtime/pages/UserLog/index.vue +2 -2
- package/dist/runtime/plugin.mjs +5 -4
- package/dist/runtime/types/User.d.ts +1 -1
- package/dist/runtime/types/User.mjs +3 -1
- package/package.json +2 -2
- package/dist/runtime/lib/defineObject.d.ts +0 -3
- package/dist/runtime/lib/defineObject.mjs +0 -5
- package/dist/runtime/lib/getObjectColumn.d.ts +0 -2
- package/dist/runtime/lib/getObjectColumn.mjs +0 -15
- package/dist/runtime/lib/getObjectColumns.d.ts +0 -2
- package/dist/runtime/lib/getObjectColumns.mjs +0 -19
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -36,6 +36,7 @@ const module = defineNuxtModule({
|
|
|
36
36
|
});
|
|
37
37
|
const from = resolver.resolve("./runtime/lib");
|
|
38
38
|
const index = resolver.resolve("./runtime/index");
|
|
39
|
+
const SystemValue = resolver.resolve("./runtime/lib/SystemValue");
|
|
39
40
|
addImports([
|
|
40
41
|
{ name: "addObject", from },
|
|
41
42
|
{ name: "f", from },
|
|
@@ -53,9 +54,12 @@ const module = defineNuxtModule({
|
|
|
53
54
|
{ name: "listObject", from },
|
|
54
55
|
{ name: "useLight", from: index },
|
|
55
56
|
{ name: "isGranted", from },
|
|
56
|
-
{ name: "
|
|
57
|
-
{ name: "
|
|
58
|
-
{ name: "
|
|
57
|
+
{ name: "sv", from },
|
|
58
|
+
{ name: "loadSV", from: SystemValue },
|
|
59
|
+
{ name: "getSV", from: SystemValue },
|
|
60
|
+
{ name: "getModelColumns", from },
|
|
61
|
+
{ name: "getModelFields", from },
|
|
62
|
+
{ name: "getModelField", from }
|
|
59
63
|
]);
|
|
60
64
|
addPlugin({
|
|
61
65
|
src: resolver.resolve("./runtime/plugin"),
|
|
@@ -5,6 +5,10 @@ import { useLight, q, getCurrentUser, m, f } from '../';
|
|
|
5
5
|
import { ref, computed, reactive, provide, watch } from 'vue';
|
|
6
6
|
import { useRuntimeConfig } from 'nuxt/app';
|
|
7
7
|
|
|
8
|
+
//download system value
|
|
9
|
+
import { download } from './../lib/SystemValue'
|
|
10
|
+
await download();
|
|
11
|
+
|
|
8
12
|
const config = useRuntimeConfig();
|
|
9
13
|
|
|
10
14
|
const appVersion = config.public.appVersion ?? '0.0.1';
|
|
@@ -1,45 +1,22 @@
|
|
|
1
|
-
<script setup>
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { ModelField } from '@hostlink/light';
|
|
3
|
+
|
|
2
4
|
|
|
3
5
|
const props = defineProps({
|
|
4
6
|
modelValue: {
|
|
5
7
|
type: Object
|
|
6
8
|
},
|
|
7
|
-
|
|
8
|
-
type: Array
|
|
9
|
+
fields: {
|
|
10
|
+
type: Array<ModelField>
|
|
9
11
|
}
|
|
10
12
|
})
|
|
11
13
|
|
|
12
|
-
const getValue = (column) => {
|
|
13
|
-
|
|
14
|
-
//type of column field is function
|
|
15
|
-
if (column.field && typeof column.field == 'function') {
|
|
16
|
-
return column.field(props.modelValue);
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
//if field is string
|
|
20
|
-
if (column.field && typeof column.field == 'string') {
|
|
21
|
-
return props.modelValue[column.field];
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
return props.modelValue[column.name];
|
|
25
|
-
|
|
26
|
-
}
|
|
27
|
-
const getDisplayValue = (column) => {
|
|
28
|
-
const value = getValue(column);
|
|
29
|
-
|
|
30
|
-
if (column.format) {
|
|
31
|
-
return column.format(value);
|
|
32
|
-
}
|
|
33
|
-
return value;
|
|
34
|
-
|
|
35
|
-
}
|
|
36
|
-
|
|
37
14
|
</script>
|
|
38
15
|
<template>
|
|
39
16
|
<q-list bordered separator>
|
|
40
|
-
<template v-if="
|
|
41
|
-
<l-item v-for="
|
|
42
|
-
{{
|
|
17
|
+
<template v-if="fields">
|
|
18
|
+
<l-item v-for="field in fields" :label="field.getRaw().label">
|
|
19
|
+
{{ field.getFormattedValue(props.modelValue as any) }}
|
|
43
20
|
</l-item>
|
|
44
21
|
|
|
45
22
|
</template>
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import sv from "./sv.mjs";
|
|
2
|
+
import { cache } from "./sv.mjs";
|
|
3
|
+
export const sv_data = [];
|
|
4
|
+
export const loadSV = (name) => {
|
|
5
|
+
sv_data.push(name);
|
|
6
|
+
};
|
|
7
|
+
export const download = async () => {
|
|
8
|
+
for (let i = 0; i < sv_data.length; i++) {
|
|
9
|
+
const name = sv_data[i];
|
|
10
|
+
await sv(name);
|
|
11
|
+
}
|
|
12
|
+
};
|
|
13
|
+
export const getSV = (name, value) => {
|
|
14
|
+
const data = cache[name];
|
|
15
|
+
let result = "";
|
|
16
|
+
data.forEach((item) => {
|
|
17
|
+
if (item.value == value) {
|
|
18
|
+
result = item.label;
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
return result;
|
|
22
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { getModelField } from "@hostlink/light";
|
|
2
|
+
export default (model, names) => {
|
|
3
|
+
let columns = [];
|
|
4
|
+
for (let name of names) {
|
|
5
|
+
const field = getModelField(model, name);
|
|
6
|
+
if (!field)
|
|
7
|
+
continue;
|
|
8
|
+
const option = field.getRaw();
|
|
9
|
+
option.name = field.getName();
|
|
10
|
+
columns.push(option);
|
|
11
|
+
}
|
|
12
|
+
return columns;
|
|
13
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const getModelFields: (model: string, names: string[]) => any;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { getModelField } from "@hostlink/light";
|
|
2
|
+
export const getModelFields = (model, names) => {
|
|
3
|
+
let fields = [];
|
|
4
|
+
for (let name of names) {
|
|
5
|
+
const field = getModelField(model, name);
|
|
6
|
+
if (!field)
|
|
7
|
+
continue;
|
|
8
|
+
fields.push(field);
|
|
9
|
+
}
|
|
10
|
+
return fields;
|
|
11
|
+
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useRoute } from "vue-router";
|
|
2
2
|
import loadObject from "./loadObject.mjs";
|
|
3
|
-
import
|
|
3
|
+
import { getModelField } from "@hostlink/light";
|
|
4
4
|
export default async function(fields = []) {
|
|
5
5
|
let route = useRoute();
|
|
6
6
|
if (!route.name) {
|
|
@@ -15,9 +15,9 @@ export default async function(fields = []) {
|
|
|
15
15
|
}
|
|
16
16
|
let fs = fields.map((field) => {
|
|
17
17
|
if (typeof field == "string") {
|
|
18
|
-
const
|
|
19
|
-
if (
|
|
20
|
-
return
|
|
18
|
+
const f = getModelField(module, field);
|
|
19
|
+
if (f) {
|
|
20
|
+
return f.getGQLField();
|
|
21
21
|
}
|
|
22
22
|
}
|
|
23
23
|
return field;
|
|
@@ -15,10 +15,10 @@ import listObject from "./listObject";
|
|
|
15
15
|
import loadObject from "./loadObject";
|
|
16
16
|
import isGranted from "./isGranted";
|
|
17
17
|
import GQLFieldBuilder from "./GQLFieldBuilder";
|
|
18
|
-
import
|
|
19
|
-
import
|
|
18
|
+
import { getModelField } from "@hostlink/light";
|
|
19
|
+
import { getModelFields } from './getModelFields';
|
|
20
|
+
import getModelColumns from './getModelColumns';
|
|
20
21
|
declare const notify: (message: string, color?: string) => void;
|
|
21
22
|
import getID from "./getID";
|
|
22
23
|
declare const getApiBase: () => {};
|
|
23
|
-
|
|
24
|
-
export { addObject, f, getApiUrl, getCurrentUser, getObject, list, listData, m, q, removeObject, t, updateObject, notify, getID, deleteObject, listObject, isGranted, getApiBase, loadObject, GQLFieldBuilder, defineObject, getObjectColumns, getObjectColumn };
|
|
24
|
+
export { addObject, f, getApiUrl, getCurrentUser, getObject, list, listData, m, q, removeObject, t, updateObject, notify, getID, deleteObject, listObject, isGranted, getApiBase, loadObject, GQLFieldBuilder, getModelField, getModelFields, getModelColumns };
|
|
@@ -17,8 +17,9 @@ import listObject from "./listObject.mjs";
|
|
|
17
17
|
import loadObject from "./loadObject.mjs";
|
|
18
18
|
import isGranted from "./isGranted.mjs";
|
|
19
19
|
import GQLFieldBuilder from "./GQLFieldBuilder.mjs";
|
|
20
|
-
import
|
|
21
|
-
import
|
|
20
|
+
import { getModelField } from "@hostlink/light";
|
|
21
|
+
import { getModelFields } from "./getModelFields.mjs";
|
|
22
|
+
import getModelColumns from "./getModelColumns.mjs";
|
|
22
23
|
const notify = function(message, color = "green") {
|
|
23
24
|
Notify.create({
|
|
24
25
|
message,
|
|
@@ -31,7 +32,6 @@ const getApiBase = () => {
|
|
|
31
32
|
const config = useRuntimeConfig();
|
|
32
33
|
return config?.public?.apiBase ?? "/api/";
|
|
33
34
|
};
|
|
34
|
-
import defineObject from "./defineObject.mjs";
|
|
35
35
|
export {
|
|
36
36
|
addObject,
|
|
37
37
|
f,
|
|
@@ -53,7 +53,7 @@ export {
|
|
|
53
53
|
getApiBase,
|
|
54
54
|
loadObject,
|
|
55
55
|
GQLFieldBuilder,
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
56
|
+
getModelField,
|
|
57
|
+
getModelFields,
|
|
58
|
+
getModelColumns
|
|
59
59
|
};
|
package/dist/runtime/lib/sv.d.ts
CHANGED
package/dist/runtime/lib/sv.mjs
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import { query } from "@hostlink/light";
|
|
2
|
+
export const cache = {};
|
|
2
3
|
export default async (name) => {
|
|
4
|
+
if (cache[name]) {
|
|
5
|
+
return cache[name];
|
|
6
|
+
}
|
|
3
7
|
const resp = await query({
|
|
4
8
|
systemValue: {
|
|
5
9
|
__args: {
|
|
@@ -7,5 +11,6 @@ export default async (name) => {
|
|
|
7
11
|
}
|
|
8
12
|
}
|
|
9
13
|
});
|
|
14
|
+
cache[name] = resp.systemValue;
|
|
10
15
|
return resp.systemValue;
|
|
11
16
|
};
|
|
@@ -13,7 +13,7 @@ const obj = reactive(await getObject(["first_name", "last_name", "email", "phone
|
|
|
13
13
|
<l-col md="6" gutter="md">
|
|
14
14
|
<l-input label="First name" v-model="obj.first_name" required />
|
|
15
15
|
<l-input label="Last name" v-model="obj.last_name" />
|
|
16
|
-
<l-input label="Email" v-model="obj.email" required type="email"
|
|
16
|
+
<l-input label="Email" v-model="obj.email" required type="email" />
|
|
17
17
|
</l-col>
|
|
18
18
|
<l-col md="6" gutter="md">
|
|
19
19
|
<l-input label="Phone" v-model="obj.phone" />
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
<script setup>
|
|
2
|
-
import { getObject,
|
|
2
|
+
import { getObject, getModelFields } from '../../../';
|
|
3
3
|
const obj = await getObject(["user_id", "username", "first_name", "last_name", "email", "phone", "roles", 'status', 'join_date']);
|
|
4
|
+
|
|
4
5
|
</script>
|
|
5
6
|
|
|
6
7
|
<template>
|
|
@@ -11,7 +12,7 @@ const obj = await getObject(["user_id", "username", "first_name", "last_name", "
|
|
|
11
12
|
</template>
|
|
12
13
|
|
|
13
14
|
<l-card>
|
|
14
|
-
<l-list v-model="obj" :
|
|
15
|
+
<l-list v-model="obj" :fields="getModelFields('User', [
|
|
15
16
|
'username',
|
|
16
17
|
'first_name',
|
|
17
18
|
'last_name',
|
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
<script setup>
|
|
2
2
|
import { ref } from 'vue'
|
|
3
|
-
import
|
|
3
|
+
import getModelColumns from "../../lib/getModelColumns";
|
|
4
4
|
const onRequest = async (request) => {
|
|
5
5
|
request.loadObjects("User", { status: status.value });
|
|
6
6
|
};
|
|
7
|
-
const columns =
|
|
7
|
+
const columns = getModelColumns("User", ["username", "first_name", "label_name", "email", "phone", "join_date", "status"]);
|
|
8
8
|
const status = ref("0");
|
|
9
9
|
</script>
|
|
10
10
|
|
|
11
11
|
<template>
|
|
12
12
|
<l-page>
|
|
13
|
+
|
|
13
14
|
<l-tabs v-model="status">
|
|
14
15
|
<l-tab label="Active" name="0">
|
|
15
16
|
<l-table row-key="user_id" @request="onRequest" :columns="columns" :actions="['view', 'edit', 'delete']">
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<script setup>
|
|
2
|
-
import
|
|
3
|
-
const columns =
|
|
2
|
+
import getModelColumns from "../../lib/getModelColumns";
|
|
3
|
+
const columns = getModelColumns("UserLog", ["userlog_id", "username", "login_dt", "logout_dt", "result", "user_agent"]);
|
|
4
4
|
</script>
|
|
5
5
|
<template>
|
|
6
6
|
<l-page>
|
package/dist/runtime/plugin.mjs
CHANGED
|
@@ -6,15 +6,16 @@ import "./assets/main.css";
|
|
|
6
6
|
import message_en from "./locales/en.json";
|
|
7
7
|
import message_zh from "./locales/zh-hk.json";
|
|
8
8
|
import routes from "./routes.mjs";
|
|
9
|
+
import { defineModel } from "@hostlink/light";
|
|
9
10
|
localStorage.getItem("locale") || localStorage.setItem("locale", "en");
|
|
10
|
-
import { useLight
|
|
11
|
+
import { useLight } from "./index.mjs";
|
|
11
12
|
import TypeUser from "./types/User.mjs";
|
|
12
13
|
import TypeUserLog from "./types/UserLog.mjs";
|
|
13
14
|
import TypeSystemValue from "./types/SystemValue.mjs";
|
|
14
15
|
export default defineNuxtPlugin((nuxtApp) => {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
defineModel("User", TypeUser);
|
|
17
|
+
defineModel("UserLog", TypeUserLog);
|
|
18
|
+
defineModel("SystemValue", TypeSystemValue);
|
|
18
19
|
nuxtApp.vueApp.config.errorHandler = (error) => {
|
|
19
20
|
console.log(error);
|
|
20
21
|
const light = useLight();
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { loadSV, getSV } from "./../lib/SystemValue.mjs";
|
|
2
|
+
loadSV("UserStatus");
|
|
1
3
|
export default {
|
|
2
4
|
username: {
|
|
3
5
|
label: "Username",
|
|
@@ -37,7 +39,7 @@ export default {
|
|
|
37
39
|
status: {
|
|
38
40
|
label: "Status",
|
|
39
41
|
format: (value) => {
|
|
40
|
-
return
|
|
42
|
+
return getSV("UserStatus", value);
|
|
41
43
|
}
|
|
42
44
|
}
|
|
43
45
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hostlink/nuxt-light",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.84",
|
|
4
4
|
"description": "HostLink Nuxt Light Framework",
|
|
5
5
|
"repository": "@hostlink/nuxt-light",
|
|
6
6
|
"license": "MIT",
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"route-gen": "node route-generate.mjs"
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@hostlink/light": "^0.0
|
|
37
|
+
"@hostlink/light": "^1.0.0",
|
|
38
38
|
"@nuxt/kit": "^3.7.4",
|
|
39
39
|
"@nuxt/module-builder": "^0.5.2",
|
|
40
40
|
"@quasar/extras": "^1.16.6",
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { getData } from "./defineObject.mjs";
|
|
2
|
-
export default (type, name) => {
|
|
3
|
-
let data = getData();
|
|
4
|
-
if (!data[type])
|
|
5
|
-
return;
|
|
6
|
-
if (!data[type][name])
|
|
7
|
-
return;
|
|
8
|
-
let options = data[type][name];
|
|
9
|
-
if (!options)
|
|
10
|
-
return;
|
|
11
|
-
if (!options.name) {
|
|
12
|
-
options.name = name;
|
|
13
|
-
}
|
|
14
|
-
return options;
|
|
15
|
-
};
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { getData } from "./defineObject.mjs";
|
|
2
|
-
export default (type, names) => {
|
|
3
|
-
let data = getData();
|
|
4
|
-
let columns = [];
|
|
5
|
-
for (let name of names) {
|
|
6
|
-
if (!data[type])
|
|
7
|
-
continue;
|
|
8
|
-
if (!data[type][name])
|
|
9
|
-
continue;
|
|
10
|
-
let options = data[type][name];
|
|
11
|
-
if (!options)
|
|
12
|
-
continue;
|
|
13
|
-
if (!options.name) {
|
|
14
|
-
options.name = name;
|
|
15
|
-
}
|
|
16
|
-
columns.push(options);
|
|
17
|
-
}
|
|
18
|
-
return columns;
|
|
19
|
-
};
|