@hostlink/nuxt-light 0.0.91 → 0.0.93
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 +2 -2
- package/dist/runtime/components/l-app.vue +9 -2
- package/dist/runtime/components/l-item.vue +0 -1
- package/dist/runtime/components/l-link.vue +2 -9
- package/dist/runtime/components/l-list.vue +19 -3
- package/dist/runtime/components/l-table.vue +22 -7
- package/dist/runtime/index.d.ts +2 -0
- package/dist/runtime/index.mjs +14 -0
- package/dist/runtime/lib/getGQLFields.mjs +5 -1
- package/dist/runtime/lib/getID.d.ts +1 -1
- package/dist/runtime/lib/getID.mjs +2 -10
- package/dist/runtime/lib/index.d.ts +1 -2
- package/dist/runtime/lib/index.mjs +0 -2
- package/dist/runtime/lib/list.d.ts +7 -1
- package/dist/runtime/lib/list.mjs +35 -32
- package/dist/runtime/lib/listObject.d.ts +2 -1
- package/dist/runtime/lib/listObject.mjs +8 -17
- package/dist/runtime/lib/loadObject.mjs +2 -2
- package/dist/runtime/pages/Permission/add.vue +2 -2
- package/dist/runtime/pages/Permission/export.vue +2 -2
- package/dist/runtime/pages/System/view_as.vue +1 -6
- package/dist/runtime/pages/Translate/index.vue +1 -1
- package/dist/runtime/pages/User/index.vue +1 -1
- package/dist/runtime/types/User.mjs +8 -0
- package/package.json +1 -1
- package/dist/runtime/lib/listData.d.ts +0 -1
- package/dist/runtime/lib/listData.mjs +0 -33
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -45,7 +45,6 @@ const module = defineNuxtModule({
|
|
|
45
45
|
{ name: "getObject", from },
|
|
46
46
|
{ name: "loadObject", from },
|
|
47
47
|
{ name: "list", from },
|
|
48
|
-
{ name: "listData", from },
|
|
49
48
|
{ name: "m", from },
|
|
50
49
|
{ name: "q", from },
|
|
51
50
|
{ name: "removeObject", from },
|
|
@@ -60,7 +59,8 @@ const module = defineNuxtModule({
|
|
|
60
59
|
{ name: "getModelColumns", from },
|
|
61
60
|
{ name: "getModelFields", from },
|
|
62
61
|
{ name: "getModelField", from },
|
|
63
|
-
{ name: "getGQLFields", from }
|
|
62
|
+
{ name: "getGQLFields", from },
|
|
63
|
+
{ name: "sv", from }
|
|
64
64
|
]);
|
|
65
65
|
addPlugin({
|
|
66
66
|
src: resolver.resolve("./runtime/plugin"),
|
|
@@ -1,15 +1,22 @@
|
|
|
1
1
|
<script setup>
|
|
2
|
-
import { useLight } from "#imports";
|
|
2
|
+
import { useLight, watch } from "#imports";
|
|
3
3
|
import { useRuntimeConfig } from 'nuxt/app'
|
|
4
4
|
import { setApiUrl } from '@hostlink/light'
|
|
5
5
|
import { Dialog } from 'quasar'
|
|
6
6
|
import { q } from '../'
|
|
7
|
+
import { useRoute } from "#vue-router";
|
|
7
8
|
const config = useRuntimeConfig();
|
|
8
9
|
setApiUrl(config?.public?.apiBase ?? '/api/');
|
|
9
10
|
|
|
11
|
+
const route = useRoute();
|
|
12
|
+
const light = useLight()
|
|
13
|
+
|
|
14
|
+
light.setCurrentRoute(route);
|
|
15
|
+
watch(route, (to, from) => {
|
|
16
|
+
light.setCurrentRoute(to);
|
|
17
|
+
});
|
|
10
18
|
|
|
11
19
|
let app = null
|
|
12
|
-
const light = useLight()
|
|
13
20
|
try {
|
|
14
21
|
app = (await q({ app: ['company', 'companyLogo', 'logged', 'twoFactorAuthentication', 'googleClientId'] })).app;
|
|
15
22
|
light.setCompany(app.company);
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
<script setup>
|
|
2
|
-
import { useRouter } from "vue-router"
|
|
3
2
|
const props = defineProps({
|
|
4
3
|
to: {
|
|
5
4
|
type: String,
|
|
@@ -11,15 +10,9 @@ const props = defineProps({
|
|
|
11
10
|
default: "primary"
|
|
12
11
|
},
|
|
13
12
|
})
|
|
14
|
-
const router = useRouter();
|
|
15
|
-
const navigate = () => {
|
|
16
|
-
if (props.to) {
|
|
17
|
-
router.push(props.to);
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
13
|
</script>
|
|
21
14
|
<template>
|
|
22
|
-
<
|
|
15
|
+
<router-link :to="props.to" style="text-decoration: underline; color:var(--q-primary)">
|
|
23
16
|
<slot />
|
|
24
|
-
</
|
|
17
|
+
</router-link>
|
|
25
18
|
</template>
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
<script setup>
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
3
|
const props = defineProps({
|
|
6
4
|
modelValue: {
|
|
7
5
|
type: Object
|
|
@@ -11,11 +9,29 @@ const props = defineProps({
|
|
|
11
9
|
}
|
|
12
10
|
})
|
|
13
11
|
|
|
12
|
+
function getTo(field) {
|
|
13
|
+
|
|
14
|
+
const raw=field.getRaw();
|
|
15
|
+
|
|
16
|
+
if (raw.to) {
|
|
17
|
+
if (raw.to instanceof Function) {
|
|
18
|
+
return raw.to(props.modelValue);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
if (typeof raw.to == 'string') {
|
|
22
|
+
return raw.to;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
return null;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
|
|
14
30
|
</script>
|
|
15
31
|
<template>
|
|
16
32
|
<q-list bordered separator>
|
|
17
33
|
<template v-if="fields">
|
|
18
|
-
<l-item v-for="field in fields" :label="field.getRaw().label">
|
|
34
|
+
<l-item v-for="field in fields" :label="field.getRaw().label" :to="getTo(field)">
|
|
19
35
|
{{ field.getFormattedValue(props.modelValue) }}
|
|
20
36
|
</l-item>
|
|
21
37
|
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
2
|
import { useQuasar, QTable } from 'quasar';
|
|
3
|
-
import { ref, computed, onMounted, useSlots,
|
|
4
|
-
import { t, deleteObject, q,
|
|
5
|
-
import { toQuery } from '@hostlink/light'
|
|
3
|
+
import { ref, computed, onMounted, useSlots, useAttrs } from "vue";
|
|
4
|
+
import { t, deleteObject, q, useLight, GQLFieldBuilder } from '../';
|
|
6
5
|
|
|
7
6
|
const errors = ref<InstanceType<any>>([]);
|
|
8
7
|
|
|
@@ -408,7 +407,17 @@ const attrs = {
|
|
|
408
407
|
}
|
|
409
408
|
|
|
410
409
|
const filter = ref('');
|
|
410
|
+
|
|
411
|
+
const toColumns = props.columns?.filter((col: any) => {
|
|
412
|
+
return col.to;
|
|
413
|
+
}).map((col: any) => {
|
|
414
|
+
col.slot_name = 'body-cell-' + col.name;
|
|
415
|
+
return col;
|
|
416
|
+
|
|
417
|
+
})
|
|
418
|
+
|
|
411
419
|
</script>
|
|
420
|
+
|
|
412
421
|
<template>
|
|
413
422
|
<template v-if="errors.length > 0">
|
|
414
423
|
<div class="q-gutter-sm">
|
|
@@ -417,7 +426,8 @@ const filter = ref('');
|
|
|
417
426
|
</template>
|
|
418
427
|
|
|
419
428
|
<template v-if="debug">
|
|
420
|
-
<pre>
|
|
429
|
+
<pre>
|
|
430
|
+
primaryKey:{{ primaryKey }}
|
|
421
431
|
modelName:{{ modelName }}
|
|
422
432
|
filters:{{ filters }}
|
|
423
433
|
pagination:{{ pagination }}
|
|
@@ -430,6 +440,7 @@ const filter = ref('');
|
|
|
430
440
|
rows:{{ props.rows }}
|
|
431
441
|
</template>
|
|
432
442
|
|
|
443
|
+
|
|
433
444
|
<q-table v-bind="attrs" :row-key="rowKey" :loading="loading" :rows="rows" ref="table" @request="onRequest"
|
|
434
445
|
:rows-per-page-label="$t(props.rowsPerPageLabel)" :columns="renderColumns"
|
|
435
446
|
:rows-per-page-options="rowsPerPageOptions" :selection="selection" v-model:pagination="pagination" :filter="filter">
|
|
@@ -443,15 +454,19 @@ const filter = ref('');
|
|
|
443
454
|
|
|
444
455
|
<q-btn v-if="fullscreen" flat round dense :icon="props.inFullscreen ? 'fullscreen_exit' : 'fullscreen'"
|
|
445
456
|
@click="props.toggleFullscreen" class="q-ml-md" />
|
|
446
|
-
|
|
447
|
-
|
|
448
457
|
</template>
|
|
449
458
|
|
|
450
|
-
|
|
451
459
|
<template v-for="s in ss" v-slot:[s]="props">
|
|
452
460
|
<slot :name="s" v-bind="props"></slot>
|
|
453
461
|
</template>
|
|
454
462
|
|
|
463
|
+
<template v-for="col in toColumns" v-slot:[col.slot_name]="props">
|
|
464
|
+
<q-td :props="props">
|
|
465
|
+
<l-link :to="col.to(props.row)">
|
|
466
|
+
{{ col.field(props.row) }}
|
|
467
|
+
</l-link>
|
|
468
|
+
</q-td>
|
|
469
|
+
</template>
|
|
455
470
|
|
|
456
471
|
<template #body-cell-_actions="props">
|
|
457
472
|
<q-td :props="props" auto-width>
|
package/dist/runtime/index.d.ts
CHANGED
|
@@ -9,6 +9,8 @@ interface Light {
|
|
|
9
9
|
setCompany(company: string): void;
|
|
10
10
|
getCompanyLogo(): string;
|
|
11
11
|
setCompanyLogo(logo: string): void;
|
|
12
|
+
setCurrentRoute(to: any, from: any): void;
|
|
13
|
+
getID(): Number | null;
|
|
12
14
|
}
|
|
13
15
|
export declare const useLight: () => Light;
|
|
14
16
|
export * from "./lib";
|
package/dist/runtime/index.mjs
CHANGED
|
@@ -5,6 +5,7 @@ const app = {
|
|
|
5
5
|
company: "",
|
|
6
6
|
companyLogo: ""
|
|
7
7
|
};
|
|
8
|
+
let currentRoute = null;
|
|
8
9
|
export const useLight = () => {
|
|
9
10
|
return {
|
|
10
11
|
setCompany: (company) => {
|
|
@@ -42,6 +43,19 @@ export const useLight = () => {
|
|
|
42
43
|
},
|
|
43
44
|
setStyles(s) {
|
|
44
45
|
styles = s;
|
|
46
|
+
},
|
|
47
|
+
setCurrentRoute(to, from) {
|
|
48
|
+
currentRoute = to;
|
|
49
|
+
},
|
|
50
|
+
getID() {
|
|
51
|
+
if (currentRoute == null)
|
|
52
|
+
return null;
|
|
53
|
+
let name = currentRoute.name?.toString();
|
|
54
|
+
if (name == void 0)
|
|
55
|
+
return 0;
|
|
56
|
+
let parts = name.split("-");
|
|
57
|
+
const keyname = parts[1];
|
|
58
|
+
return parseInt(currentRoute.params[keyname]);
|
|
45
59
|
}
|
|
46
60
|
};
|
|
47
61
|
};
|
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
import GQLFieldBuilder from "./GQLFieldBuilder.mjs";
|
|
2
|
+
import { getModelField } from "@hostlink/light";
|
|
2
3
|
export default (name, fields) => {
|
|
3
4
|
const builder = GQLFieldBuilder();
|
|
4
5
|
fields.forEach((field) => {
|
|
5
|
-
|
|
6
|
+
const modelField = getModelField(name, field);
|
|
7
|
+
if (modelField) {
|
|
8
|
+
builder.add(modelField.getGQLField());
|
|
9
|
+
}
|
|
6
10
|
});
|
|
7
11
|
return builder.get();
|
|
8
12
|
};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const _default: () => Number;
|
|
1
|
+
declare const _default: () => Number | null;
|
|
2
2
|
export default _default;
|
|
@@ -1,12 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
const route = useRoute();
|
|
1
|
+
import { useLight } from "../index.mjs";
|
|
3
2
|
export default () => {
|
|
4
|
-
|
|
5
|
-
if (name == void 0)
|
|
6
|
-
return 0;
|
|
7
|
-
let parts = name.split("-");
|
|
8
|
-
const module = parts[0];
|
|
9
|
-
const moduleLower = module.charAt(0).toLowerCase() + module.slice(1);
|
|
10
|
-
const keyname = parts[1];
|
|
11
|
-
return parseInt(route.params[keyname]);
|
|
3
|
+
return useLight().getID();
|
|
12
4
|
};
|
|
@@ -4,7 +4,6 @@ import getApiUrl from "./getApiUrl";
|
|
|
4
4
|
import getCurrentUser from "./getCurrentUser";
|
|
5
5
|
import getObject from "./getObject";
|
|
6
6
|
import list from "./list";
|
|
7
|
-
import listData from "./listData";
|
|
8
7
|
import m from "./m";
|
|
9
8
|
import q from "./q";
|
|
10
9
|
import removeObject from "./removeObject";
|
|
@@ -22,4 +21,4 @@ declare const notify: (message: string, color?: string) => void;
|
|
|
22
21
|
import getID from "./getID";
|
|
23
22
|
declare const getApiBase: () => {};
|
|
24
23
|
import { getGQLFields } from '@hostlink/light';
|
|
25
|
-
export { addObject, f, getApiUrl, getCurrentUser, getObject, list,
|
|
24
|
+
export { addObject, f, getApiUrl, getCurrentUser, getObject, list, m, q, removeObject, t, updateObject, notify, getID, deleteObject, listObject, isGranted, getApiBase, loadObject, GQLFieldBuilder, getModelField, getModelFields, getModelColumns, getGQLFields };
|
|
@@ -6,7 +6,6 @@ import getApiUrl from "./getApiUrl.mjs";
|
|
|
6
6
|
import getCurrentUser from "./getCurrentUser.mjs";
|
|
7
7
|
import getObject from "./getObject.mjs";
|
|
8
8
|
import list from "./list.mjs";
|
|
9
|
-
import listData from "./listData.mjs";
|
|
10
9
|
import m from "./m.mjs";
|
|
11
10
|
import q from "./q.mjs";
|
|
12
11
|
import removeObject from "./removeObject.mjs";
|
|
@@ -40,7 +39,6 @@ export {
|
|
|
40
39
|
getCurrentUser,
|
|
41
40
|
getObject,
|
|
42
41
|
list,
|
|
43
|
-
listData,
|
|
44
42
|
m,
|
|
45
43
|
q,
|
|
46
44
|
removeObject,
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
import { Fields } from "@hostlink/light";
|
|
2
|
+
export default function list(name: string, props?: {
|
|
3
|
+
sort?: string;
|
|
4
|
+
filters?: object;
|
|
5
|
+
offset?: number;
|
|
6
|
+
limit?: number;
|
|
7
|
+
} | null, fields?: Fields): Promise<any>;
|
|
@@ -1,35 +1,38 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
import { query, toQuery } from "@hostlink/light";
|
|
2
|
+
export default async function list(name, props = null, fields = []) {
|
|
3
|
+
let q = {};
|
|
4
|
+
if (props) {
|
|
5
|
+
if (props.sort) {
|
|
6
|
+
q.__args = q.__args || {};
|
|
7
|
+
q.__args.sort = props.sort;
|
|
8
|
+
}
|
|
9
|
+
if (props.filters) {
|
|
10
|
+
q.__args = q.__args || {};
|
|
11
|
+
q.__args.filters = props.filters;
|
|
12
|
+
}
|
|
7
13
|
}
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
14
|
+
q.data = {};
|
|
15
|
+
if (props) {
|
|
16
|
+
if (props.offset) {
|
|
17
|
+
q.data.__args = q.data.__args || {};
|
|
18
|
+
q.data.__args.offset = props.offset;
|
|
19
|
+
}
|
|
20
|
+
if (props.limit) {
|
|
21
|
+
q.data.__args = q.data.__args || {};
|
|
22
|
+
q.data.__args.limit = props.limit;
|
|
23
|
+
}
|
|
13
24
|
}
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
props.done({
|
|
28
|
-
rows: data.data,
|
|
29
|
-
total: data.meta.total,
|
|
30
|
-
key: data.meta.key,
|
|
31
|
-
name: data.meta.name
|
|
32
|
-
});
|
|
33
|
-
}
|
|
34
|
-
return data.data;
|
|
25
|
+
q.data = {
|
|
26
|
+
...q.data,
|
|
27
|
+
...toQuery(fields)
|
|
28
|
+
};
|
|
29
|
+
q.meta = {
|
|
30
|
+
total: true,
|
|
31
|
+
key: true,
|
|
32
|
+
name: true
|
|
33
|
+
};
|
|
34
|
+
const resp = await query({
|
|
35
|
+
[`list${name}`]: q
|
|
36
|
+
});
|
|
37
|
+
return resp[`list${name}`];
|
|
35
38
|
}
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import { Fields } from "@hostlink/light";
|
|
2
|
+
export default function listObject(name: string, filters: {} | undefined, sort: string, offset: number, limit: number, fields?: Fields): Promise<any>;
|
|
@@ -1,19 +1,10 @@
|
|
|
1
|
-
import
|
|
2
|
-
import f from "./f.mjs";
|
|
1
|
+
import list from "./list.mjs";
|
|
3
2
|
export default async function listObject(name, filters = {}, sort, offset, limit, fields = []) {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
let params = {};
|
|
12
|
-
if (sort) {
|
|
13
|
-
params.sort = sort;
|
|
14
|
-
}
|
|
15
|
-
if (filters) {
|
|
16
|
-
params.filters = filters;
|
|
17
|
-
}
|
|
18
|
-
return await q(`list${name}`, params, [f("data", offset_limit, fields), f("meta", ["total", "key", "name"])]);
|
|
3
|
+
const resp = await list(name, {
|
|
4
|
+
filters,
|
|
5
|
+
sort,
|
|
6
|
+
offset,
|
|
7
|
+
limit
|
|
8
|
+
}, fields);
|
|
9
|
+
return resp.data;
|
|
19
10
|
}
|
|
@@ -31,10 +31,10 @@ const onSave = async () => {
|
|
|
31
31
|
|
|
32
32
|
<l-input label="Permission name" v-model="obj.value" required></l-input>
|
|
33
33
|
|
|
34
|
-
<
|
|
34
|
+
<l-field label="Roles" stack-label>
|
|
35
35
|
<q-option-group type="checkbox" :options="roles" v-model="obj.roles" inline>
|
|
36
36
|
</q-option-group>
|
|
37
|
-
</
|
|
37
|
+
</l-field>
|
|
38
38
|
|
|
39
39
|
</l-form>
|
|
40
40
|
|
|
@@ -62,10 +62,10 @@ const submit = () => {
|
|
|
62
62
|
<template>
|
|
63
63
|
<l-page>
|
|
64
64
|
<l-form submit-label="Export" submit-icon="sym_o_download" @submit="submit">
|
|
65
|
-
<
|
|
65
|
+
<l-field label="Roles" stack-label>
|
|
66
66
|
<q-option-group type="checkbox" :options="roles" v-model="obj.roles" inline>
|
|
67
67
|
</q-option-group>
|
|
68
|
-
</
|
|
68
|
+
</l-field>
|
|
69
69
|
</l-form>
|
|
70
70
|
|
|
71
71
|
|
|
@@ -2,11 +2,7 @@
|
|
|
2
2
|
import { list, m } from '../../'
|
|
3
3
|
import { useRouter } from "vue-router"
|
|
4
4
|
|
|
5
|
-
let users = await list("User",
|
|
6
|
-
fields: [
|
|
7
|
-
"user_id", "username", "name", "roles"
|
|
8
|
-
]
|
|
9
|
-
});
|
|
5
|
+
let { data: users } = await list("User", null, ["user_id", "username", "name", "roles"]);
|
|
10
6
|
|
|
11
7
|
let columns = [
|
|
12
8
|
{
|
|
@@ -44,7 +40,6 @@ const onCickView = async (id) => {
|
|
|
44
40
|
</script>
|
|
45
41
|
<template>
|
|
46
42
|
<l-page>
|
|
47
|
-
|
|
48
43
|
<q-table flat :columns="columns" :rows="users">
|
|
49
44
|
<template #body-cell-view="props">
|
|
50
45
|
<q-td :props="props">
|
|
@@ -4,7 +4,7 @@ import getModelColumns from "../../lib/getModelColumns";
|
|
|
4
4
|
const onRequest = async (request) => {
|
|
5
5
|
request.loadObjects("User", { status: status.value });
|
|
6
6
|
};
|
|
7
|
-
const columns = getModelColumns("User", ["username", "first_name", "label_name", "email", "phone", "join_date", "status"]);
|
|
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
|
|
|
@@ -40,4 +40,12 @@ export default {
|
|
|
40
40
|
return ["Active", "Inactive"][value];
|
|
41
41
|
}
|
|
42
42
|
}
|
|
43
|
+
/* ,
|
|
44
|
+
test: {
|
|
45
|
+
label: "Test",
|
|
46
|
+
name: "_test",
|
|
47
|
+
to: (row: any) => `/User/${row.user_id}/view`,
|
|
48
|
+
gqlField: ["user_id", "first_name"],
|
|
49
|
+
field: (row: any) => row.first_name,
|
|
50
|
+
} */
|
|
43
51
|
};
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export default function listData(name: string, props?: any, fields?: Array<string | Object> | Object): Promise<any>;
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { query, toQuery } from "@hostlink/light";
|
|
2
|
-
export default async function listData(name, props = {}, fields = []) {
|
|
3
|
-
let json = {};
|
|
4
|
-
if (props.sort) {
|
|
5
|
-
json.__args = json.__args || {};
|
|
6
|
-
json.__args.sort = props.sort;
|
|
7
|
-
}
|
|
8
|
-
if (props.filters) {
|
|
9
|
-
json.__args = json.__args || {};
|
|
10
|
-
json.__args.filters = props.filters;
|
|
11
|
-
}
|
|
12
|
-
json.data = {};
|
|
13
|
-
if (props.offset) {
|
|
14
|
-
json.data.__args = json.data.__args || {};
|
|
15
|
-
json.data.__args.offset = props.offset;
|
|
16
|
-
}
|
|
17
|
-
if (props.limit) {
|
|
18
|
-
json.data.__args = json.data.__args || {};
|
|
19
|
-
json.data.__args.limit = props.limit;
|
|
20
|
-
}
|
|
21
|
-
Object.entries(toQuery(fields)).forEach(([key, value]) => {
|
|
22
|
-
json.data[key] = value;
|
|
23
|
-
});
|
|
24
|
-
json.meta = {
|
|
25
|
-
total: true,
|
|
26
|
-
key: true,
|
|
27
|
-
name: true
|
|
28
|
-
};
|
|
29
|
-
const q = {};
|
|
30
|
-
q[`list${name}`] = json;
|
|
31
|
-
let data = await query(q);
|
|
32
|
-
return data[`list${name}`];
|
|
33
|
-
}
|