@niyamulahsan/create-deskapp 1.2.4 → 1.2.6
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/package.json +16 -16
- package/template/.env.example +20 -13
- package/template/AGENTS.md +699 -0
- package/template/package.json +3 -0
- package/template/src/config/app.ts +26 -24
- package/template/src/config/winsetup.ts +93 -91
- package/template/src/core/api/binding-error.ts +57 -0
- package/template/src/core/api/bindings.generated.ts +2 -0
- package/template/src/core/api/generate.manifest.ts +84 -80
- package/template/src/core/api/registry.ts +58 -48
- package/template/src/core/config.ts +101 -99
- package/template/src/core/database/aggregate.ts +89 -85
- package/template/src/core/database/config.ts +50 -48
- package/template/src/core/database/connection.ts +116 -114
- package/template/src/core/database/migrate-hooks.ts +86 -84
- package/template/src/core/database/paginate.ts +226 -224
- package/template/src/core/database/reset.ts +21 -19
- package/template/src/core/database/seed.ts +169 -167
- package/template/src/core/database/status.ts +37 -35
- package/template/src/core/env.ts +108 -106
- package/template/src/core/facade.ts +63 -61
- package/template/src/core/maker/db/fresh.ts +10 -8
- package/template/src/core/maker/db/generate.ts +13 -11
- package/template/src/core/maker/db/helpers.ts +92 -96
- package/template/src/core/maker/db/migrate.ts +37 -35
- package/template/src/core/maker/db/mod.ts +93 -91
- package/template/src/core/maker/db/module-migrate.ts +56 -54
- package/template/src/core/maker/db/push.ts +23 -21
- package/template/src/core/maker/db/reset.ts +8 -6
- package/template/src/core/maker/db/seed.ts +9 -7
- package/template/src/core/maker/db/status.ts +8 -6
- package/template/src/core/maker/help.ts +59 -57
- package/template/src/core/maker/make/controller.ts +25 -22
- package/template/src/core/maker/make/helpers.ts +97 -91
- package/template/src/core/maker/make/mod.ts +69 -67
- package/template/src/core/maker/make/model.ts +16 -14
- package/template/src/core/maker/make/module.ts +53 -39
- package/template/src/core/maker/make/seeder.ts +23 -21
- package/template/src/core/maker/make/test.ts +33 -30
- package/template/src/core/maker/mod.ts +85 -83
- package/template/src/core/maker/run/mod.ts +134 -132
- package/template/src/core/maker/stub.ts +26 -24
- package/template/src/core/maker/stubs/controller/controller.controller.stub +57 -55
- package/template/src/core/maker/stubs/controller/controller.schema.stub +18 -13
- package/template/src/core/maker/stubs/facade/facade.stub +21 -0
- package/template/src/core/maker/stubs/model/model.stub +10 -8
- package/template/src/core/maker/stubs/seeder/seeder.stub +18 -16
- package/template/src/core/maker/stubs/test/test.stub +9 -7
- package/template/src/core/maker/sync-config.ts +93 -94
- package/template/src/core/utils/password.ts +29 -27
- package/template/src/core/utils/playwright.ts +123 -121
- package/template/src/core/utils/queue.ts +68 -66
- package/template/src/core/utils/scheduler.ts +62 -60
- package/template/src/core/utils/storage.ts +3 -1
- package/template/src/core/utils/validation.ts +37 -35
- package/template/src/database/schema.ts +2 -0
- package/template/src/main.ts +120 -118
- package/template/src/modules/app/__tests__/demo.controller.test.ts +75 -0
- package/template/src/modules/app/__tests__/net.controller.test.ts +65 -0
- package/template/src/modules/app/__tests__/playwright.controller.test.ts +50 -0
- package/template/src/modules/app/__tests__/storage.controller.test.ts +114 -0
- package/template/src/modules/app/__tests__/window.controller.test.ts +98 -0
- package/template/src/modules/app/controllers/demo.controller.ts +120 -118
- package/template/src/modules/app/controllers/net.controller.ts +50 -48
- package/template/src/modules/app/controllers/playwright.controller.ts +142 -140
- package/template/src/modules/app/controllers/storage.controller.ts +231 -229
- package/template/src/modules/app/controllers/window.controller.ts +2 -0
- package/template/src/modules/app/facade.ts +21 -0
- package/template/src/preload.ts +25 -2
- package/template/src/ui/src/App.vue +4 -2
- package/template/src/ui/src/app.ts +38 -23
- package/template/src/ui/src/bindings.d.ts +18 -16
- package/template/src/ui/src/components/Button.vue +34 -32
- package/template/src/ui/src/components/Checkbox.vue +26 -29
- package/template/src/ui/src/components/Input.vue +221 -227
- package/template/src/ui/src/components/InputGroup.vue +141 -0
- package/template/src/ui/src/components/InputPasswordToggle.vue +204 -0
- package/template/src/ui/src/components/Modal.vue +65 -55
- package/template/src/ui/src/components/Spinner.vue +44 -42
- package/template/src/ui/src/components/Switch.vue +62 -65
- package/template/src/ui/src/components/TextArea.vue +108 -121
- package/template/src/ui/src/components/Toast.vue +55 -56
- package/template/src/ui/src/components/datatable/DataTableSkeleton.vue +100 -98
- package/template/src/ui/src/components/datatable/Pagination.vue +153 -125
- package/template/src/ui/src/components/datatable/SelectOpption.vue +36 -35
- package/template/src/ui/src/components/datatable/index.vue +336 -258
- package/template/src/ui/src/env.d.ts +16 -13
- package/template/src/ui/src/global.d.ts +21 -2
- package/template/src/ui/src/helpers/nformatter.ts +12 -10
- package/template/src/ui/src/pages/dashboard/index.vue +690 -687
- package/template/src/ui/src/plugins/browserDetect.ts +57 -0
- package/template/src/ui/src/plugins/gum.ts +576 -549
- package/template/src/ui/src/plugins/pulse.ts +181 -147
- package/template/src/ui/src/plugins/routeProgress.ts +89 -0
- package/template/src/ui/src/router/index.ts +44 -25
- package/template/src/ui/src/stores/example.ts +2 -0
- package/template/src/ui/vite.config.ts +40 -38
- package/template/src/window/app-menu.ts +89 -87
- package/template/src/window/config.ts +14 -12
- package/template/src/window/context-menu.ts +23 -21
- package/template/src/window/dialogs.ts +92 -90
- package/template/src/window/manager.ts +2 -0
- package/template/src/window/native.ts +47 -45
- package/template/src/window/tray.ts +132 -130
|
@@ -1,258 +1,336 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
<
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
</
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
import
|
|
74
|
-
import
|
|
75
|
-
import
|
|
76
|
-
import Checkbox from "@/ui/components/Checkbox.vue";
|
|
77
|
-
import
|
|
78
|
-
import {
|
|
79
|
-
import
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
/**
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
const
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
.
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
1
|
+
<!-- ./src/ui/src/components/datatable/index.vue -->
|
|
2
|
+
|
|
3
|
+
<template>
|
|
4
|
+
<div class="card border">
|
|
5
|
+
<div class="card-header" :class="{ 'd-none': !(props.removable || props.searchable || props.optionable) }">
|
|
6
|
+
<div class="row align-items-center gx-1">
|
|
7
|
+
<div class="col-12 col-md-3">
|
|
8
|
+
<SelectOption :is-options="props.optionable" :option="props.option" :selectedoption="selectedoption" @change="handleSizeChange" />
|
|
9
|
+
</div>
|
|
10
|
+
<div class="col-12 col-md-9">
|
|
11
|
+
<slot name="extra-tools"></slot>
|
|
12
|
+
<div class="d-flex align-items-center justify-content-center justify-content-md-end">
|
|
13
|
+
<div v-if="checked.checkcolumn.length > 0" class="me-1" :class="{ 'd-none': !props.removable }">
|
|
14
|
+
<Button type="button" class="btn btn-outline-danger" @click.prevent="remove">
|
|
15
|
+
<i class="bi bi-trash"></i>
|
|
16
|
+
</Button>
|
|
17
|
+
</div>
|
|
18
|
+
<div class="d-flex align-items-center" :class="{ 'd-none': !props.searchable }">
|
|
19
|
+
<Button class="btn btn-outline-secondary rounded-0 rounded-start" type="button" @click="searchMe">
|
|
20
|
+
<i class="bi bi-search"></i>
|
|
21
|
+
</Button>
|
|
22
|
+
<Input
|
|
23
|
+
v-model="searchdata"
|
|
24
|
+
type="text"
|
|
25
|
+
class="w-auto shadow-none rounded-0 rounded-end"
|
|
26
|
+
topclass="mb-0"
|
|
27
|
+
placeholder="Search..."
|
|
28
|
+
@keyup.enter="searchMe"
|
|
29
|
+
@keyup.delete="searchMe"
|
|
30
|
+
/>
|
|
31
|
+
</div>
|
|
32
|
+
</div>
|
|
33
|
+
</div>
|
|
34
|
+
</div>
|
|
35
|
+
</div>
|
|
36
|
+
<div class="card-body">
|
|
37
|
+
<slot name="extra"></slot>
|
|
38
|
+
<div class="table-responsive">
|
|
39
|
+
<table class="table table-bordered table-striped border-custom table-sm align-middle m-0 datatable no-shrink-table">
|
|
40
|
+
<slot name="customhead"></slot>
|
|
41
|
+
<thead :class="{ 'd-none': slots.customhead }">
|
|
42
|
+
<tr>
|
|
43
|
+
<th class="align-middle" :class="{ 'd-none': !props.removable || !view.current_page }">
|
|
44
|
+
<Checkbox v-model="checked.check" topclass="ms-2" :value="checked.check" :disabled="props.disabled" @click="checkAll" />
|
|
45
|
+
</th>
|
|
46
|
+
<th class="text-center align-middle" :class="{ 'd-none': !props.countable }">#</th>
|
|
47
|
+
<slot name="thead"></slot>
|
|
48
|
+
</tr>
|
|
49
|
+
</thead>
|
|
50
|
+
|
|
51
|
+
<slot name="custombody"></slot>
|
|
52
|
+
<tbody :class="{ 'd-none': slots.custombody }">
|
|
53
|
+
<tr v-for="(dt, i) in tableRows" :key="`${dt.id}-${i}`">
|
|
54
|
+
<td class="align-middle" :class="{ 'd-none': !props.removable || !view.current_page }">
|
|
55
|
+
<Checkbox v-model="checked.checkcolumn" topclass="ms-2" :value="dt.id" :disabled="props.disabled" @change="updateChecked" />
|
|
56
|
+
</td>
|
|
57
|
+
<td class="text-center align-middle" :class="{ 'd-none': !props.countable }">
|
|
58
|
+
{{ view.current_page ? view.per_page * (view.current_page - 1) + (i + 1) : i + 1 }}
|
|
59
|
+
</td>
|
|
60
|
+
<slot name="tbody" :td="dt"></slot>
|
|
61
|
+
</tr>
|
|
62
|
+
</tbody>
|
|
63
|
+
</table>
|
|
64
|
+
</div>
|
|
65
|
+
</div>
|
|
66
|
+
<div class="card-footer" :class="{ 'd-none': view.total <= view.data.length }">
|
|
67
|
+
<Pagination :data="view" @change="handlePageChange" />
|
|
68
|
+
</div>
|
|
69
|
+
</div>
|
|
70
|
+
</template>
|
|
71
|
+
|
|
72
|
+
<script setup lang="ts">
|
|
73
|
+
import { debounce } from "lodash-es";
|
|
74
|
+
import { computed, reactive, ref, useSlots, watch, watchEffect } from "vue";
|
|
75
|
+
import Button from "@/ui/components/Button.vue";
|
|
76
|
+
import Checkbox from "@/ui/components/Checkbox.vue";
|
|
77
|
+
import Input from "@/ui/components/Input.vue";
|
|
78
|
+
import { type GumTransport, useGum } from "@/ui/plugins/gum";
|
|
79
|
+
import Pagination from "./Pagination.vue";
|
|
80
|
+
import SelectOption from "./SelectOpption.vue";
|
|
81
|
+
|
|
82
|
+
interface DataRow {
|
|
83
|
+
id: string | number;
|
|
84
|
+
[key: string]: any;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
interface DataPageState {
|
|
88
|
+
data: DataRow[];
|
|
89
|
+
current_page: number;
|
|
90
|
+
last_page: number;
|
|
91
|
+
per_page: number;
|
|
92
|
+
total: number;
|
|
93
|
+
from: number | null;
|
|
94
|
+
to: number | null;
|
|
95
|
+
path: string;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
interface DataTableProps {
|
|
99
|
+
/**
|
|
100
|
+
* Self-fetch mode: binding name (`app.demo.table`) or REST endpoint that returns
|
|
101
|
+
* the paginate envelope. The table owns its state and reloads when `path` changes.
|
|
102
|
+
*/
|
|
103
|
+
path?: string;
|
|
104
|
+
/**
|
|
105
|
+
* Parent-owned mode: the paginate envelope (e.g. a Pinia store's list). When set,
|
|
106
|
+
* the table renders it instead of fetching `path`, so the page owns the rows.
|
|
107
|
+
*/
|
|
108
|
+
data?: Partial<DataPageState> | null;
|
|
109
|
+
/**
|
|
110
|
+
* Fetcher mode: the built-in controls (search, size, page) call this instead of
|
|
111
|
+
* self-fetching `path` — e.g. `:fetcher="store.index"`. Called through `gum.getWith`.
|
|
112
|
+
*/
|
|
113
|
+
fetcher?: (params: Record<string, unknown>) => Promise<unknown>;
|
|
114
|
+
/**
|
|
115
|
+
* Extra query params merged into every fetch/control call, so filters in the URL
|
|
116
|
+
* or on the page survive a search or a page change.
|
|
117
|
+
*/
|
|
118
|
+
filters?: Record<string, unknown>;
|
|
119
|
+
search?: string;
|
|
120
|
+
loop?: DataRow[] | false;
|
|
121
|
+
option?: Array<string | number>;
|
|
122
|
+
removable?: boolean;
|
|
123
|
+
countable?: boolean;
|
|
124
|
+
searchable?: boolean;
|
|
125
|
+
optionable?: boolean;
|
|
126
|
+
disabled?: boolean;
|
|
127
|
+
/** Per-table transport override: "bindings" (SQLite, default from GumPlugin) or "http". */
|
|
128
|
+
transport?: GumTransport;
|
|
129
|
+
/** HTTP transport only: base URL prepended to `path`. */
|
|
130
|
+
baseURL?: string;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
const props = withDefaults(defineProps<DataTableProps>(), {
|
|
134
|
+
filters: () => ({}),
|
|
135
|
+
search: "",
|
|
136
|
+
loop: false,
|
|
137
|
+
option: () => [10, 25, 50],
|
|
138
|
+
removable: true,
|
|
139
|
+
countable: true,
|
|
140
|
+
searchable: true,
|
|
141
|
+
optionable: true,
|
|
142
|
+
disabled: false
|
|
143
|
+
});
|
|
144
|
+
const gum = useGum();
|
|
145
|
+
|
|
146
|
+
const slots = useSlots();
|
|
147
|
+
|
|
148
|
+
const emit = defineEmits<(event: "remove", value: Array<string | number>) => void>();
|
|
149
|
+
|
|
150
|
+
// Internal envelope for self-fetch mode; `view` falls back to the parent's `data` when given.
|
|
151
|
+
const state = reactive<DataPageState>({
|
|
152
|
+
data: [],
|
|
153
|
+
current_page: 1,
|
|
154
|
+
last_page: 1,
|
|
155
|
+
per_page: Number(props.option[0]) || 15,
|
|
156
|
+
total: 0,
|
|
157
|
+
from: null,
|
|
158
|
+
to: null,
|
|
159
|
+
path: props.path ?? ""
|
|
160
|
+
});
|
|
161
|
+
|
|
162
|
+
const loading = ref(false);
|
|
163
|
+
|
|
164
|
+
// checkbox select
|
|
165
|
+
let checked = reactive<{ check: boolean; checkcolumn: Array<string | number> }>({
|
|
166
|
+
check: false,
|
|
167
|
+
checkcolumn: []
|
|
168
|
+
});
|
|
169
|
+
const checkAll = () => {
|
|
170
|
+
if (!checked.check) {
|
|
171
|
+
view.value.data.forEach((dt: DataRow) => {
|
|
172
|
+
if (!checked.checkcolumn.includes(dt.id)) {
|
|
173
|
+
checked.checkcolumn.push(dt.id);
|
|
174
|
+
}
|
|
175
|
+
});
|
|
176
|
+
} else {
|
|
177
|
+
checked.checkcolumn = [];
|
|
178
|
+
}
|
|
179
|
+
};
|
|
180
|
+
const updateChecked = () => (checked.checkcolumn.length === view.value.data.length ? (checked.check = true) : (checked.check = false));
|
|
181
|
+
|
|
182
|
+
// remove from parent
|
|
183
|
+
const remove = () => {
|
|
184
|
+
emit("remove", checked.checkcolumn);
|
|
185
|
+
checked.check = false;
|
|
186
|
+
};
|
|
187
|
+
|
|
188
|
+
// for change data size show
|
|
189
|
+
const selectedoption = ref<string | number | undefined>(Number(props.option[0]));
|
|
190
|
+
|
|
191
|
+
/** Normalize any paginate envelope (the parent's `data` or a fetch result) into a full `DataPageState`. */
|
|
192
|
+
const toEnvelope = (d: Partial<DataPageState>): DataPageState => ({
|
|
193
|
+
data: Array.isArray(d.data) ? d.data : [],
|
|
194
|
+
current_page: Number(d.current_page) || 1,
|
|
195
|
+
last_page: Number(d.last_page) || 1,
|
|
196
|
+
per_page: Number(d.per_page) || Number(selectedoption.value) || 15,
|
|
197
|
+
total: Number(d.total) || 0,
|
|
198
|
+
from: d.from ?? null,
|
|
199
|
+
to: d.to ?? null,
|
|
200
|
+
path: d.path ?? props.path ?? ""
|
|
201
|
+
});
|
|
202
|
+
|
|
203
|
+
/** Pull the paginate envelope out of a fetch result, tolerating a `{ data }` wrapper. */
|
|
204
|
+
const readEnvelope = (value: unknown): Partial<DataPageState> | null => {
|
|
205
|
+
if (!value || typeof value !== "object") return null;
|
|
206
|
+
const v = value as Record<string, unknown>;
|
|
207
|
+
if (Array.isArray(v.data)) return v as Partial<DataPageState>;
|
|
208
|
+
const inner = v.data;
|
|
209
|
+
if (inner && typeof inner === "object" && Array.isArray((inner as Record<string, unknown>).data)) {
|
|
210
|
+
return inner as Partial<DataPageState>;
|
|
211
|
+
}
|
|
212
|
+
return null;
|
|
213
|
+
};
|
|
214
|
+
|
|
215
|
+
/** What the table renders: the parent's `data` when provided, else the internal self-fetch `state`. */
|
|
216
|
+
const view = computed<DataPageState>(() => (props.data ? toEnvelope(props.data) : state));
|
|
217
|
+
|
|
218
|
+
const tableRows = computed<DataRow[]>(() => (props.loop ? props.loop : view.value.data));
|
|
219
|
+
|
|
220
|
+
// search data
|
|
221
|
+
const searchdata = ref(props.search || "");
|
|
222
|
+
const searchMe = debounce(() => {
|
|
223
|
+
load(1);
|
|
224
|
+
}, 500);
|
|
225
|
+
|
|
226
|
+
/** Extra query params merged last, so a caller-supplied filter survives a search/page/size change. */
|
|
227
|
+
const buildQuery = (page?: number): Record<string, unknown> => ({
|
|
228
|
+
page: page ?? view.value.current_page,
|
|
229
|
+
size: selectedoption.value,
|
|
230
|
+
search: searchdata.value,
|
|
231
|
+
...props.filters
|
|
232
|
+
});
|
|
233
|
+
|
|
234
|
+
/**
|
|
235
|
+
* One entry point for every built-in control (search, size, page).
|
|
236
|
+
*
|
|
237
|
+
* - Fetcher mode (`:fetcher`): calls the parent's fetcher through `gum.getWith` and
|
|
238
|
+
* adopts the envelope it returns (or lets the parent's `data` prop drive the view).
|
|
239
|
+
* - Path mode (default): fetches the binding/endpoint in-process with
|
|
240
|
+
* `gum.get(path, { navigate: false })` and fills the internal `state`.
|
|
241
|
+
*/
|
|
242
|
+
const load = async (page?: number) => {
|
|
243
|
+
const query = buildQuery(page);
|
|
244
|
+
loading.value = true;
|
|
245
|
+
try {
|
|
246
|
+
if (props.fetcher) {
|
|
247
|
+
const fetcher = props.fetcher;
|
|
248
|
+
const res = await gum.getWith({
|
|
249
|
+
fetcher: () => fetcher(query),
|
|
250
|
+
query,
|
|
251
|
+
navigate: false,
|
|
252
|
+
transport: props.transport,
|
|
253
|
+
baseURL: props.baseURL
|
|
254
|
+
});
|
|
255
|
+
if (!props.data) Object.assign(state, toEnvelope(readEnvelope(res) ?? {}));
|
|
256
|
+
} else if (props.path) {
|
|
257
|
+
const res = await gum.get(props.path, {
|
|
258
|
+
navigate: false,
|
|
259
|
+
transport: props.transport,
|
|
260
|
+
baseURL: props.baseURL,
|
|
261
|
+
query
|
|
262
|
+
});
|
|
263
|
+
Object.assign(state, toEnvelope(readEnvelope(res) ?? {}));
|
|
264
|
+
}
|
|
265
|
+
checked.checkcolumn = [];
|
|
266
|
+
checked.check = false;
|
|
267
|
+
} finally {
|
|
268
|
+
loading.value = false;
|
|
269
|
+
}
|
|
270
|
+
};
|
|
271
|
+
|
|
272
|
+
const handleSizeChange = (value: string | number) => {
|
|
273
|
+
selectedoption.value = value;
|
|
274
|
+
load(1);
|
|
275
|
+
};
|
|
276
|
+
|
|
277
|
+
const handlePageChange = (pageNo: string | number) => {
|
|
278
|
+
let p = parseInt(String(pageNo), 10);
|
|
279
|
+
if (Number.isNaN(p) || p < 1) p = 1;
|
|
280
|
+
if (p > view.value.last_page) p = view.value.last_page;
|
|
281
|
+
load(p);
|
|
282
|
+
};
|
|
283
|
+
|
|
284
|
+
// watch instance
|
|
285
|
+
watchEffect(() => {
|
|
286
|
+
if (props.option.length) {
|
|
287
|
+
const match = props.option.find((x) => Number(x) === Number(view.value.per_page)) ?? props.option[0];
|
|
288
|
+
selectedoption.value = match;
|
|
289
|
+
}
|
|
290
|
+
searchdata.value = props.search || "";
|
|
291
|
+
});
|
|
292
|
+
|
|
293
|
+
// initial + subsequent loads when `path` changes (self-fetch mode only)
|
|
294
|
+
watch(
|
|
295
|
+
() => props.path,
|
|
296
|
+
() => {
|
|
297
|
+
if (props.path && !props.data && !props.loop) load();
|
|
298
|
+
},
|
|
299
|
+
{ immediate: true }
|
|
300
|
+
);
|
|
301
|
+
|
|
302
|
+
// external search term change re-queries from page 1 (self-fetch mode only)
|
|
303
|
+
watch(
|
|
304
|
+
() => props.search,
|
|
305
|
+
() => {
|
|
306
|
+
if (props.path && !props.data && !props.loop) load(1);
|
|
307
|
+
}
|
|
308
|
+
);
|
|
309
|
+
|
|
310
|
+
defineExpose({ load, state, view, loading });
|
|
311
|
+
</script>
|
|
312
|
+
|
|
313
|
+
<style lang="scss" scoped>
|
|
314
|
+
.border-custom {
|
|
315
|
+
border-color: var(--dk-table-border, #cccccc) !important;
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
.no-shrink-table th,
|
|
319
|
+
.no-shrink-table td {
|
|
320
|
+
white-space: nowrap;
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
/* By default (large screens and up) do not force a min-width:
|
|
324
|
+
allow table to size normally so no horizontal scrollbar on large screens */
|
|
325
|
+
@media (min-width: 992px) {
|
|
326
|
+
.no-shrink-table {
|
|
327
|
+
min-width: 0;
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
@media (max-width: 991.98px) {
|
|
332
|
+
.no-shrink-table {
|
|
333
|
+
min-width: 1000px;
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
</style>
|
|
@@ -1,13 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
1
|
+
// ./src/ui/src/env.d.ts
|
|
2
|
+
|
|
3
|
+
/// <reference types="vite/client" />
|
|
4
|
+
/// <reference path="./bindings.d.ts" />
|
|
5
|
+
|
|
6
|
+
declare const md: any & {
|
|
7
|
+
__invoke: (name: string, ...args: unknown[]) => Promise<unknown>;
|
|
8
|
+
[key: string]: any;
|
|
9
|
+
};
|
|
10
|
+
/** @deprecated alias for `md` (kept for compatibility) */
|
|
11
|
+
// declare const bindings: typeof md;
|
|
12
|
+
|
|
13
|
+
interface Window {
|
|
14
|
+
md: typeof md;
|
|
15
|
+
bindings: typeof bindings;
|
|
16
|
+
}
|