@mixd-id/web-scaffold 0.1.230406388 → 0.1.230406390
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 +1 -1
- package/src/components/List.vue +27 -39
- package/src/components/VirtualTable.vue +2 -1
- package/src/widgets/PresetBar.vue +64 -41
package/package.json
CHANGED
package/src/components/List.vue
CHANGED
|
@@ -86,6 +86,7 @@
|
|
|
86
86
|
|
|
87
87
|
<div class="flex flex-row gap-2 gap-1" v-if="Boolean(toolbar)">
|
|
88
88
|
<Textbox class="flex-1 md:w-[240px]" placeholder="Search..." clearable="1"
|
|
89
|
+
maxlength="100"
|
|
89
90
|
v-model="preset.search"
|
|
90
91
|
@clear="delete preset.search; load()"
|
|
91
92
|
@keyup.enter="load">
|
|
@@ -146,8 +147,8 @@
|
|
|
146
147
|
</template>
|
|
147
148
|
|
|
148
149
|
<template #end>
|
|
149
|
-
<div v-if="data?.hasNext" class="flex justify-center
|
|
150
|
-
<svg v-if="readyState === 4" class="animate-spin
|
|
150
|
+
<div v-if="data?.hasNext" class="flex justify-center pt-3 pb-5">
|
|
151
|
+
<svg v-if="readyState === 4" class="animate-spin w-[21px] h-[21px]" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24"><circle class="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="4"></circle><path class="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"></path></svg>
|
|
151
152
|
<button v-else type="button" class="text-text-300" @click="loadNext()">
|
|
152
153
|
{{ $t('Load More' )}}
|
|
153
154
|
</button>
|
|
@@ -376,17 +377,13 @@ export default{
|
|
|
376
377
|
itemsPerPage: this.data.itemsPerPage,
|
|
377
378
|
})
|
|
378
379
|
.then(data => {
|
|
379
|
-
const firstItem = data.items[0]
|
|
380
|
-
const lastItem = data.items[data.items.length - 1]
|
|
381
|
-
console.log('@load',
|
|
382
|
-
`${firstItem?.id + ':' + firstItem?.name + ':' + firstItem?.lastMessageAt}`,
|
|
383
|
-
`${lastItem?.id + ':' + lastItem?.name + ':' + lastItem?.lastMessageAt}`)
|
|
384
|
-
|
|
385
380
|
generatePivotColumns(this.preset, data.items)
|
|
386
381
|
generateTotalColumns(this.preset, data.items)
|
|
387
382
|
this.loadEnums(data.items)
|
|
388
|
-
|
|
389
|
-
|
|
383
|
+
.then(() => {
|
|
384
|
+
Object.assign(this.data, data ?? {})
|
|
385
|
+
this.$emit('after-load')
|
|
386
|
+
})
|
|
390
387
|
})
|
|
391
388
|
.catch(err => {
|
|
392
389
|
this.toast(err)
|
|
@@ -397,7 +394,7 @@ export default{
|
|
|
397
394
|
},
|
|
398
395
|
|
|
399
396
|
loadNext(){
|
|
400
|
-
if(this.src &&
|
|
397
|
+
if(this.src && this.readyState !== 4 &&
|
|
401
398
|
((this.data ?? {}).hasNext !== false) &&
|
|
402
399
|
!(this.preset.pivot ?? {}).enabled) {
|
|
403
400
|
|
|
@@ -411,15 +408,10 @@ export default{
|
|
|
411
408
|
afterItem,
|
|
412
409
|
})
|
|
413
410
|
.then(data => {
|
|
414
|
-
const firstItem = data.items[0]
|
|
415
|
-
const lastItem = data.items[data.items.length - 1]
|
|
416
|
-
console.log('@loadNext',
|
|
417
|
-
`${afterItem?.id + ':' + afterItem?.name + ':' + afterItem?.lastMessageAt}`,
|
|
418
|
-
`${firstItem?.id + ':' + firstItem?.name + ':' + firstItem?.lastMessageAt}`,
|
|
419
|
-
`${lastItem?.id + ':' + lastItem?.name + ':' + lastItem?.lastMessageAt}`)
|
|
420
|
-
|
|
421
|
-
this.data.items.push(...data.items)
|
|
422
411
|
this.loadEnums(data.items)
|
|
412
|
+
.then(() => {
|
|
413
|
+
this.data.items.push(...data.items)
|
|
414
|
+
})
|
|
423
415
|
})
|
|
424
416
|
.catch(err => this.toast(err))
|
|
425
417
|
.finally(_ => this.readyState = 1)
|
|
@@ -459,10 +451,8 @@ export default{
|
|
|
459
451
|
}
|
|
460
452
|
},
|
|
461
453
|
|
|
462
|
-
loadEnums(items){
|
|
463
|
-
|
|
464
|
-
for(let i in this.preset.columns){
|
|
465
|
-
const column = this.preset.columns[i]
|
|
454
|
+
async loadEnums(items){
|
|
455
|
+
return Promise.all((this.preset.columns ?? []).map(async column => {
|
|
466
456
|
|
|
467
457
|
if(column.enumSrc) {
|
|
468
458
|
|
|
@@ -480,7 +470,7 @@ export default{
|
|
|
480
470
|
if(reqItems.length > 0 && reqItems !== this.lastEnumItems){
|
|
481
471
|
|
|
482
472
|
const [ src, key, attr ] = column.enumSrc.split(':')
|
|
483
|
-
this.socket.send(src, {
|
|
473
|
+
const res = await this.socket.send(src, {
|
|
484
474
|
columns: [
|
|
485
475
|
{ key:attr, visible:true }
|
|
486
476
|
],
|
|
@@ -489,27 +479,25 @@ export default{
|
|
|
489
479
|
key:key, value: [ { operator:'in', value:reqItems } ]
|
|
490
480
|
}
|
|
491
481
|
]
|
|
482
|
+
});
|
|
483
|
+
|
|
484
|
+
(res.items ?? []).forEach(_ => {
|
|
485
|
+
this.enumCache[column.key][_[key]] = {
|
|
486
|
+
text: _[attr] ?? _[key],
|
|
487
|
+
value: _[key],
|
|
488
|
+
}
|
|
492
489
|
})
|
|
493
|
-
.then(res => {
|
|
494
|
-
(res.items ?? []).forEach(_ => {
|
|
495
|
-
this.enumCache[column.key][_[key]] = {
|
|
496
|
-
text: _[attr] ?? _[key],
|
|
497
|
-
value: _[key],
|
|
498
|
-
}
|
|
499
|
-
})
|
|
500
490
|
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
491
|
+
for(let key in this.enumCache[column.key]){
|
|
492
|
+
if(!this.enumCache[column.key][key].text)
|
|
493
|
+
this.enumCache[column.key][key].text = key
|
|
494
|
+
}
|
|
505
495
|
|
|
506
|
-
|
|
507
|
-
})
|
|
508
|
-
.catch(err => this.log('Load enums error', err))
|
|
496
|
+
this.lastEnumItems = reqItems
|
|
509
497
|
}
|
|
510
498
|
}
|
|
511
|
-
}
|
|
512
499
|
|
|
500
|
+
}))
|
|
513
501
|
},
|
|
514
502
|
|
|
515
503
|
loadExt(){
|
|
@@ -57,7 +57,6 @@
|
|
|
57
57
|
<svg class="animate-spin aspect-square w-[16px] h-[16px] text-primary" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24"><circle class="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="4"></circle><path class="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"></path></svg>
|
|
58
58
|
</div>
|
|
59
59
|
</div>
|
|
60
|
-
<slot name="end"></slot>
|
|
61
60
|
</div>
|
|
62
61
|
</div>
|
|
63
62
|
<div v-else-if="visibleColumns.length <= 0 && Array.isArray(columns)" class="text-center p-3 flex-1 min-h-[100%] flex items-center justify-center">
|
|
@@ -67,6 +66,8 @@
|
|
|
67
66
|
<h5 class="text-text-300">No data available</h5>
|
|
68
67
|
</div>
|
|
69
68
|
|
|
69
|
+
<slot name="end"></slot>
|
|
70
|
+
|
|
70
71
|
<div :class="$style.calc" v-if="visibleColumns.length > 0 && cItems && cItems.length > 0" ref="calc">
|
|
71
72
|
<table :class="$style.table">
|
|
72
73
|
<tbody>
|
|
@@ -13,27 +13,36 @@
|
|
|
13
13
|
<slot name="toolbar" :edit="false"></slot>
|
|
14
14
|
</div>
|
|
15
15
|
|
|
16
|
-
<div class="p-
|
|
16
|
+
<div class="p-5">
|
|
17
17
|
<div class="px-2">
|
|
18
18
|
<label class="text-text-300">Presets</label>
|
|
19
19
|
</div>
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
20
|
+
|
|
21
|
+
<ListItem :items="config.presets"
|
|
22
|
+
class="mt-1 rounded-lg overflow-hidden"
|
|
23
|
+
container-class="divide-y divide-text-50"
|
|
24
|
+
@reorder="(from, to) => { config.presets.splice(to, 0, config.presets.splice(from, 1)[0]); apply() }">
|
|
25
|
+
<template v-slot="{ item:_preset, index:idx }">
|
|
26
|
+
<div :class="$style.presetBtn">
|
|
27
|
+
<div data-reorder>
|
|
28
|
+
<svg width="14" height="14" class="fill-text-300" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><path d="M496 288H16c-8.8 0-16 7.2-16 16v32c0 8.8 7.2 16 16 16h480c8.8 0 16-7.2 16-16v-32c0-8.8-7.2-16-16-16zm0-128H16c-8.8 0-16 7.2-16 16v32c0 8.8 7.2 16 16 16h480c8.8 0 16-7.2 16-16v-32c0-8.8-7.2-16-16-16z"/></svg>
|
|
29
|
+
</div>
|
|
30
|
+
<Radio v-model="config.presetIdx" :value="idx" @change="apply()" />
|
|
31
|
+
<button type="button" class="flex-1 py-1 text-left overflow-hidden text-ellipsis whitespace-nowrap"
|
|
32
|
+
@click="config.presetIdx = idx; apply()">
|
|
33
|
+
{{ _preset.name }}
|
|
34
|
+
</button>
|
|
35
|
+
<button type="button"
|
|
36
|
+
:class="$style.presetOptBtn"
|
|
37
|
+
:ref="`presetbtn${idx}`"
|
|
38
|
+
@click="$refs.contextMenu.open($refs[`presetbtn${idx}`], { idx })">
|
|
39
|
+
<svg width="16" height="16" class="fill-text-300 hover:fill-primary" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 128 512"><path d="M64 208c26.5 0 48 21.5 48 48s-21.5 48-48 48-48-21.5-48-48 21.5-48 48-48zM16 104c0 26.5 21.5 48 48 48s48-21.5 48-48-21.5-48-48-48-48 21.5-48 48zm0 304c0 26.5 21.5 48 48 48s48-21.5 48-48-21.5-48-48-48-48 21.5-48 48z"/></svg>
|
|
40
|
+
</button>
|
|
41
|
+
</div>
|
|
42
|
+
</template>
|
|
43
|
+
</ListItem>
|
|
44
|
+
|
|
45
|
+
|
|
37
46
|
</div>
|
|
38
47
|
|
|
39
48
|
<ContextMenu ref="contextMenu" position="bottom-right">
|
|
@@ -88,10 +97,10 @@
|
|
|
88
97
|
<Tabs :items="tabItems[config.type ?? 'list']" v-model="configParams.presetBarTabIndex" />
|
|
89
98
|
</div>
|
|
90
99
|
|
|
91
|
-
<div class="flex-1
|
|
100
|
+
<div class="flex-1 flex">
|
|
92
101
|
|
|
93
|
-
<div v-if="configParams.presetBarTabIndex === 1" class="flex-1 flex flex-col gap-
|
|
94
|
-
<div>
|
|
102
|
+
<div v-if="configParams.presetBarTabIndex === 1" class="flex-1 flex flex-col gap-5 py-5">
|
|
103
|
+
<div class="px-5">
|
|
95
104
|
<Textbox placeholder="Cari..."
|
|
96
105
|
v-model="configParams.columnSearchKey"
|
|
97
106
|
:clearable="true"
|
|
@@ -104,28 +113,30 @@
|
|
|
104
113
|
</Textbox>
|
|
105
114
|
</div>
|
|
106
115
|
|
|
107
|
-
<
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
<
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
<
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
<div>
|
|
120
|
-
<
|
|
116
|
+
<div class="flex-1 overflow-y-auto px-5">
|
|
117
|
+
<ListItem v-if="presetColumns.length > 0"
|
|
118
|
+
:items="presetColumns"
|
|
119
|
+
class="flex-1 bg-transparent"
|
|
120
|
+
body-class="divide-y divide-text-50 rounded-lg border-[1px] border-text-50 bg-base-300"
|
|
121
|
+
@reorder="(from, to) => { presetColumns.splice(to, 0, presetColumns.splice(from, 1)[0]); }">
|
|
122
|
+
<template v-slot="{ item }">
|
|
123
|
+
<div v-if="!item.key.startsWith('_') || (item.key.startsWith('_') && (preset.pivot && preset.pivot.enabled))"
|
|
124
|
+
class="flex flex-row items-center gap-3 px-3 p-1 hover:bg-primary-100">
|
|
125
|
+
<div data-reorder v-if="!configParams.columnSearchKey">
|
|
126
|
+
<svg width="14" height="14" class="fill-text-300" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><path d="M496 288H16c-8.8 0-16 7.2-16 16v32c0 8.8 7.2 16 16 16h480c8.8 0 16-7.2 16-16v-32c0-8.8-7.2-16-16-16zm0-128H16c-8.8 0-16 7.2-16 16v32c0 8.8 7.2 16 16 16h480c8.8 0 16-7.2 16-16v-32c0-8.8-7.2-16-16-16z"/></svg>
|
|
127
|
+
</div>
|
|
128
|
+
<div class="flex-1 flex flex-row gap-2 items-center">
|
|
129
|
+
<div>
|
|
130
|
+
<Checkbox v-model="item.visible" default="true" />
|
|
131
|
+
</div>
|
|
132
|
+
<Textbox v-model="item.label2" :placeholder="item.label"
|
|
133
|
+
class="border-none bg-transparent" :class="$style.columnTextbox"
|
|
134
|
+
item-class="p-1 px-0" />
|
|
121
135
|
</div>
|
|
122
|
-
<Textbox v-model="item.label2" :placeholder="item.label"
|
|
123
|
-
class="border-none bg-transparent" :class="$style.columnTextbox"
|
|
124
|
-
item-class="p-1 px-0" />
|
|
125
136
|
</div>
|
|
126
|
-
</
|
|
127
|
-
</
|
|
128
|
-
</
|
|
137
|
+
</template>
|
|
138
|
+
</ListItem>
|
|
139
|
+
</div>
|
|
129
140
|
</div>
|
|
130
141
|
|
|
131
142
|
<div v-else-if="configParams.presetBarTabIndex === 2" class="flex-1 flex flex-col p-5">
|
|
@@ -794,4 +805,16 @@ export default{
|
|
|
794
805
|
@apply text-text;
|
|
795
806
|
}
|
|
796
807
|
|
|
808
|
+
.presetBtn{
|
|
809
|
+
@apply flex flex-row items-center gap-3 px-3 p-2 hover:bg-text-50;
|
|
810
|
+
}
|
|
811
|
+
|
|
812
|
+
.presetOptBtn{
|
|
813
|
+
@apply pl-2 hidden
|
|
814
|
+
}
|
|
815
|
+
.presetBtn:hover .presetOptBtn{
|
|
816
|
+
@apply flex;
|
|
817
|
+
}
|
|
818
|
+
|
|
819
|
+
|
|
797
820
|
</style>
|