@mixd-id/web-scaffold 0.1.240411059 → 0.1.240411060
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
CHANGED
package/src/components/List.vue
CHANGED
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
:enumCache="enumCache"
|
|
14
14
|
:controller="controller"
|
|
15
15
|
:preset-key="presetKey"
|
|
16
|
+
:use-assistant="useAssistant"
|
|
16
17
|
@apply="load">
|
|
17
18
|
|
|
18
19
|
<template #toolbar>
|
|
@@ -329,9 +330,13 @@ export default{
|
|
|
329
330
|
itemsFn: Function,
|
|
330
331
|
onSignalFn: Function,
|
|
331
332
|
searchable: {
|
|
332
|
-
type:
|
|
333
|
+
type: undefined,
|
|
333
334
|
default: true
|
|
334
335
|
},
|
|
336
|
+
useAssistant: {
|
|
337
|
+
type: undefined,
|
|
338
|
+
default: false
|
|
339
|
+
}
|
|
335
340
|
},
|
|
336
341
|
|
|
337
342
|
methods: {
|
|
@@ -1064,7 +1069,7 @@ export default{
|
|
|
1064
1069
|
},
|
|
1065
1070
|
|
|
1066
1071
|
canSearch(){
|
|
1067
|
-
return this.searchable // this.preset.columns.some(_ => 'search' in _)
|
|
1072
|
+
return [ 1, true, 'true' ].includes(this.searchable) // this.preset.columns.some(_ => 'search' in _)
|
|
1068
1073
|
},
|
|
1069
1074
|
|
|
1070
1075
|
sidebar(){
|
|
@@ -1072,7 +1077,7 @@ export default{
|
|
|
1072
1077
|
if(!this.configParams.sidebar || !('open' in this.configParams.sidebar))
|
|
1073
1078
|
this.configParams.sidebar = {
|
|
1074
1079
|
open: false,
|
|
1075
|
-
width:
|
|
1080
|
+
width: 360
|
|
1076
1081
|
}
|
|
1077
1082
|
|
|
1078
1083
|
return this.configParams.sidebar
|
|
@@ -1135,7 +1140,8 @@ export default{
|
|
|
1135
1140
|
|
|
1136
1141
|
provide(){
|
|
1137
1142
|
return {
|
|
1138
|
-
listStyle: this.$style
|
|
1143
|
+
listStyle: this.$style,
|
|
1144
|
+
load: this.load
|
|
1139
1145
|
}
|
|
1140
1146
|
},
|
|
1141
1147
|
|
package/src/utils/list.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import dayjs from "dayjs";
|
|
2
|
-
import
|
|
2
|
+
import Sequelize from 'sequelize'
|
|
3
3
|
import {groupBy} from './helpers.mjs'
|
|
4
4
|
|
|
5
5
|
const ftWildcard = (key) => {
|
|
@@ -22,6 +22,7 @@ const getValue = (filter, opt) => {
|
|
|
22
22
|
const { key, operator } = filter
|
|
23
23
|
const keyColumns = groupBy(columns, 'key')
|
|
24
24
|
const type = ((keyColumns[key] ?? [])[0] ?? {}).type
|
|
25
|
+
const { Op } = opt.Sequelize ?? Sequelize
|
|
25
26
|
|
|
26
27
|
let whereObj = {}
|
|
27
28
|
|
|
@@ -375,6 +376,7 @@ const filtersToSequelizeWhere = async(filters, opt) => {
|
|
|
375
376
|
|
|
376
377
|
let whereArr = []
|
|
377
378
|
let replacements = []
|
|
379
|
+
const { literal, Op } = opt.Sequelize ?? Sequelize
|
|
378
380
|
|
|
379
381
|
const getValue = (filter, opt) => {
|
|
380
382
|
|
|
@@ -642,6 +644,7 @@ const filtersToSequelizeWhere = async(filters, opt) => {
|
|
|
642
644
|
default:
|
|
643
645
|
switch(operator) {
|
|
644
646
|
case '=':
|
|
647
|
+
case 'eq':
|
|
645
648
|
whereObj = {
|
|
646
649
|
[key]:{
|
|
647
650
|
[Op.eq]: filter.value
|
|
@@ -649,7 +652,6 @@ const filtersToSequelizeWhere = async(filters, opt) => {
|
|
|
649
652
|
}
|
|
650
653
|
break
|
|
651
654
|
|
|
652
|
-
case 'eq':
|
|
653
655
|
case 'not':
|
|
654
656
|
whereObj = {
|
|
655
657
|
[key]:{
|
|
@@ -716,6 +718,17 @@ const filtersToSequelizeWhere = async(filters, opt) => {
|
|
|
716
718
|
}
|
|
717
719
|
}
|
|
718
720
|
break
|
|
721
|
+
|
|
722
|
+
case 'notEmpty':
|
|
723
|
+
whereObj = {
|
|
724
|
+
[key]:{
|
|
725
|
+
[Op.or]: [
|
|
726
|
+
{ [Op.ne]: null },
|
|
727
|
+
{ [Op.ne]: '' }
|
|
728
|
+
]
|
|
729
|
+
}
|
|
730
|
+
}
|
|
731
|
+
break
|
|
719
732
|
}
|
|
720
733
|
break
|
|
721
734
|
}
|
|
@@ -723,8 +736,6 @@ const filtersToSequelizeWhere = async(filters, opt) => {
|
|
|
723
736
|
return whereObj
|
|
724
737
|
}
|
|
725
738
|
|
|
726
|
-
//console.log(util.inspect(filters, false, null, true))
|
|
727
|
-
|
|
728
739
|
for(let filter of filters) {
|
|
729
740
|
if (filter.enabled === false) continue
|
|
730
741
|
|
|
@@ -762,8 +773,6 @@ const filtersToSequelizeWhere = async(filters, opt) => {
|
|
|
762
773
|
}
|
|
763
774
|
}
|
|
764
775
|
|
|
765
|
-
//console.log(util.inspect(whereArr, false, null, true))
|
|
766
|
-
|
|
767
776
|
return {
|
|
768
777
|
where: {
|
|
769
778
|
[Op.and]: whereArr
|
|
@@ -772,11 +781,13 @@ const filtersToSequelizeWhere = async(filters, opt) => {
|
|
|
772
781
|
}
|
|
773
782
|
}
|
|
774
783
|
|
|
775
|
-
const afterItemToSequelizeWhere = async (order, afterItem) => {
|
|
784
|
+
const afterItemToSequelizeWhere = async (order, afterItem, opt = {}) => {
|
|
776
785
|
if(!afterItem){
|
|
777
786
|
return { where:{}, replacements:[] }
|
|
778
787
|
}
|
|
779
788
|
|
|
789
|
+
const { Op } = opt.Sequelize ?? Sequelize
|
|
790
|
+
|
|
780
791
|
if(order.filter((_) => _[0] === 'id').length <= 0){
|
|
781
792
|
order.push([ 'id', 'desc' ])
|
|
782
793
|
}
|
|
@@ -827,6 +838,7 @@ const searchToSequelizeWhere = async (search, params) => {
|
|
|
827
838
|
}
|
|
828
839
|
|
|
829
840
|
const { match } = params
|
|
841
|
+
const { literal } = params.Sequelize ?? Sequelize
|
|
830
842
|
|
|
831
843
|
let where = {}
|
|
832
844
|
let replacements = []
|
|
@@ -851,8 +863,7 @@ const chartToSequelizeWhere = async (chart, opt) => {
|
|
|
851
863
|
const { model, where, replacements } = opt
|
|
852
864
|
const { type } = chart
|
|
853
865
|
const { xAxis, yAxis } = chart[type] ?? {}
|
|
854
|
-
|
|
855
|
-
//console.log(util.inspect(chart, false, null, true ))
|
|
866
|
+
const { literal, Op } = opt.Sequelize ?? Sequelize
|
|
856
867
|
|
|
857
868
|
let attributes = []
|
|
858
869
|
let group = []
|
|
@@ -1004,15 +1015,6 @@ const chartToSequelizeWhere = async (chart, opt) => {
|
|
|
1004
1015
|
break
|
|
1005
1016
|
}
|
|
1006
1017
|
|
|
1007
|
-
/*console.log(
|
|
1008
|
-
util.inspect({
|
|
1009
|
-
attributes,
|
|
1010
|
-
group,
|
|
1011
|
-
order,
|
|
1012
|
-
include
|
|
1013
|
-
}, false, null, true)
|
|
1014
|
-
)*/
|
|
1015
|
-
|
|
1016
1018
|
return {
|
|
1017
1019
|
attributes,
|
|
1018
1020
|
group,
|
|
@@ -1023,6 +1025,7 @@ const chartToSequelizeWhere = async (chart, opt) => {
|
|
|
1023
1025
|
|
|
1024
1026
|
const pivotToSequelizeWhere = async (pivot, opt) => {
|
|
1025
1027
|
const { model, sorts = [] } = opt
|
|
1028
|
+
const { fn, literal, Op, DataTypes } = opt.Sequelize ?? Sequelize
|
|
1026
1029
|
|
|
1027
1030
|
const attributes = []
|
|
1028
1031
|
const group = []
|
|
@@ -1199,8 +1202,6 @@ const sortsToSequelizeWhere = async (sorts, opt) => {
|
|
|
1199
1202
|
order.push([ 'id', (order[0] ?? [])[1] ?? 'desc' ])
|
|
1200
1203
|
}
|
|
1201
1204
|
|
|
1202
|
-
//console.log(util.inspect(sorts, false, null, true /* enable colors */))
|
|
1203
|
-
|
|
1204
1205
|
return {
|
|
1205
1206
|
order
|
|
1206
1207
|
}
|
|
@@ -1211,9 +1212,8 @@ const filtersToSequelizeInclude = async(filters, opt, includes) => {
|
|
|
1211
1212
|
return includes
|
|
1212
1213
|
}
|
|
1213
1214
|
|
|
1214
|
-
|
|
1215
|
+
const { Op } = opt.Sequelize ?? Sequelize
|
|
1215
1216
|
|
|
1216
|
-
// Generate where object
|
|
1217
1217
|
let whereObj = {}
|
|
1218
1218
|
for(let filter of filters) {
|
|
1219
1219
|
if (filter.enabled === false) continue
|
|
@@ -1249,9 +1249,7 @@ const filtersToSequelizeInclude = async(filters, opt, includes) => {
|
|
|
1249
1249
|
}
|
|
1250
1250
|
}
|
|
1251
1251
|
}
|
|
1252
|
-
//console.log('whereObj', util.inspect(whereObj, false, null, true /* enable colors */))
|
|
1253
1252
|
|
|
1254
|
-
// Apply where to includes
|
|
1255
1253
|
for(let key in whereObj){
|
|
1256
1254
|
|
|
1257
1255
|
const keyParts = key.split('.')
|
|
@@ -1279,8 +1277,6 @@ const filtersToSequelizeInclude = async(filters, opt, includes) => {
|
|
|
1279
1277
|
include.required = true
|
|
1280
1278
|
}
|
|
1281
1279
|
|
|
1282
|
-
//console.log('includes', util.inspect(includes, false, null, true /* enable colors */))
|
|
1283
|
-
|
|
1284
1280
|
return includes
|
|
1285
1281
|
}
|
|
1286
1282
|
|
|
@@ -1300,15 +1296,18 @@ const syntaxSearchToSequelizeOpt = async(search, opt) => {
|
|
|
1300
1296
|
}
|
|
1301
1297
|
}
|
|
1302
1298
|
|
|
1303
|
-
const presetToSequelizeList = async(preset, {
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1299
|
+
const presetToSequelizeList = async(preset, opt = {}) => {
|
|
1300
|
+
let {
|
|
1301
|
+
conn,
|
|
1302
|
+
model,
|
|
1303
|
+
config,
|
|
1304
|
+
where:initialWhere,
|
|
1305
|
+
replacements: initialReplacements,
|
|
1306
|
+
include,
|
|
1307
|
+
order:initialOrder,
|
|
1308
|
+
logging = false
|
|
1309
|
+
} = opt
|
|
1310
|
+
|
|
1312
1311
|
if(!model) return {}
|
|
1313
1312
|
|
|
1314
1313
|
const updatedAtField = model.rawAttributes['updatedAt'] ?? model.rawAttributes['updated_at']
|
|
@@ -1321,6 +1320,7 @@ const presetToSequelizeList = async(preset, {
|
|
|
1321
1320
|
}
|
|
1322
1321
|
|
|
1323
1322
|
const { itemsPerPage = 20, filters = [], sorts, pivot, afterItem, search, id, uid } = preset;
|
|
1323
|
+
const { Op } = opt.Sequelize ?? Sequelize
|
|
1324
1324
|
|
|
1325
1325
|
let where = {}
|
|
1326
1326
|
const replacements = []
|
|
@@ -1348,7 +1348,8 @@ const presetToSequelizeList = async(preset, {
|
|
|
1348
1348
|
|
|
1349
1349
|
const { where:filterWhere, replacements:filterReplacements } = await filtersToSequelizeWhere(filters, {
|
|
1350
1350
|
config,
|
|
1351
|
-
model
|
|
1351
|
+
model,
|
|
1352
|
+
Sequelize: opt.Sequelize
|
|
1352
1353
|
})
|
|
1353
1354
|
|
|
1354
1355
|
let searchWhere = {}, searchReplacements = []
|
|
@@ -1366,7 +1367,8 @@ const presetToSequelizeList = async(preset, {
|
|
|
1366
1367
|
|
|
1367
1368
|
if(match !== null){
|
|
1368
1369
|
const searchOpt = await searchToSequelizeWhere(search, {
|
|
1369
|
-
match
|
|
1370
|
+
match,
|
|
1371
|
+
Sequelize: opt.Sequelize
|
|
1370
1372
|
})
|
|
1371
1373
|
searchWhere = searchOpt.where
|
|
1372
1374
|
searchReplacements = searchOpt.replacements
|
|
@@ -1381,7 +1383,8 @@ const presetToSequelizeList = async(preset, {
|
|
|
1381
1383
|
if(pivot && pivot.enabled){
|
|
1382
1384
|
const { attributes, group, order } = await pivotToSequelizeWhere(pivot, {
|
|
1383
1385
|
model,
|
|
1384
|
-
conn
|
|
1386
|
+
conn,
|
|
1387
|
+
Sequelize: opt.Sequelize
|
|
1385
1388
|
})
|
|
1386
1389
|
|
|
1387
1390
|
return {
|
|
@@ -1400,11 +1403,14 @@ const presetToSequelizeList = async(preset, {
|
|
|
1400
1403
|
...searchReplacements
|
|
1401
1404
|
],
|
|
1402
1405
|
group,
|
|
1403
|
-
order
|
|
1406
|
+
order,
|
|
1407
|
+
logging
|
|
1404
1408
|
}
|
|
1405
1409
|
}
|
|
1406
1410
|
else{
|
|
1407
|
-
const { where:afterItemWhere } = await afterItemToSequelizeWhere(order, afterItem
|
|
1411
|
+
const { where:afterItemWhere } = await afterItemToSequelizeWhere(order, afterItem, {
|
|
1412
|
+
Sequelize: opt.Sequelize
|
|
1413
|
+
})
|
|
1408
1414
|
|
|
1409
1415
|
return {
|
|
1410
1416
|
where: {
|
|
@@ -1425,7 +1431,8 @@ const presetToSequelizeList = async(preset, {
|
|
|
1425
1431
|
...filterReplacements,
|
|
1426
1432
|
...searchReplacements
|
|
1427
1433
|
],
|
|
1428
|
-
itemsPerPage
|
|
1434
|
+
itemsPerPage,
|
|
1435
|
+
logging
|
|
1429
1436
|
}
|
|
1430
1437
|
}
|
|
1431
1438
|
}
|
|
@@ -246,6 +246,7 @@ const getValue = (filter, opt) => {
|
|
|
246
246
|
|
|
247
247
|
default:
|
|
248
248
|
switch(operator) {
|
|
249
|
+
case 'eq':
|
|
249
250
|
case '=':
|
|
250
251
|
withoutKey ?
|
|
251
252
|
whereObj = {
|
|
@@ -256,7 +257,6 @@ const getValue = (filter, opt) => {
|
|
|
256
257
|
}
|
|
257
258
|
break
|
|
258
259
|
|
|
259
|
-
case 'eq':
|
|
260
260
|
case 'not':
|
|
261
261
|
withoutKey ?
|
|
262
262
|
whereObj = {
|
|
@@ -638,6 +638,7 @@ const filtersToSequelizeWhere = async(filters, opt) => {
|
|
|
638
638
|
|
|
639
639
|
default:
|
|
640
640
|
switch(operator) {
|
|
641
|
+
case 'eq':
|
|
641
642
|
case '=':
|
|
642
643
|
whereObj = {
|
|
643
644
|
[key]:{
|
|
@@ -646,7 +647,6 @@ const filtersToSequelizeWhere = async(filters, opt) => {
|
|
|
646
647
|
}
|
|
647
648
|
break
|
|
648
649
|
|
|
649
|
-
case 'eq':
|
|
650
650
|
case 'not':
|
|
651
651
|
whereObj = {
|
|
652
652
|
[key]:{
|
|
@@ -126,6 +126,21 @@
|
|
|
126
126
|
</ContextMenu>
|
|
127
127
|
</div>
|
|
128
128
|
|
|
129
|
+
<div class="p-5" v-if="['true', 1, true].includes(useAssistant)">
|
|
130
|
+
<div class="px-2 flex flex-col gap-1">
|
|
131
|
+
<div class="flex flex-row gap-2">
|
|
132
|
+
<div class="flex-1">
|
|
133
|
+
<label class="text-text-300">AI Assistant</label>
|
|
134
|
+
</div>
|
|
135
|
+
<div v-if="$isDebugMode" class="flex flex-row gap-2">
|
|
136
|
+
<button type="button" class="text-primary text-sm" @click="log(config)">Config</button>
|
|
137
|
+
<button type="button" class="text-primary text-sm" @click="log(preset)">Preset</button>
|
|
138
|
+
</div>
|
|
139
|
+
</div>
|
|
140
|
+
<Textarea rows="6" placeholder="Generate preset based on text" v-model="generateText" />
|
|
141
|
+
<Button ref="generateBtn" class="w-[100px] mt-2" :state="canGenerate ? 1 : -1" @click="generatePreset">Generate</Button>
|
|
142
|
+
</div>
|
|
143
|
+
</div>
|
|
129
144
|
|
|
130
145
|
</div>
|
|
131
146
|
|
|
@@ -598,7 +613,7 @@ export default{
|
|
|
598
613
|
|
|
599
614
|
emits: [ 'apply' ],
|
|
600
615
|
|
|
601
|
-
inject: [ 'appStyle', 'confirm', 'socket' ],
|
|
616
|
+
inject: [ 'alert', 'appStyle', 'confirm', 'load', 'socket' ],
|
|
602
617
|
|
|
603
618
|
props: {
|
|
604
619
|
|
|
@@ -610,6 +625,11 @@ export default{
|
|
|
610
625
|
|
|
611
626
|
enumCache: Object,
|
|
612
627
|
|
|
628
|
+
useAssistant: {
|
|
629
|
+
type: undefined,
|
|
630
|
+
default: false
|
|
631
|
+
}
|
|
632
|
+
|
|
613
633
|
},
|
|
614
634
|
|
|
615
635
|
methods: {
|
|
@@ -708,6 +728,48 @@ export default{
|
|
|
708
728
|
return this.preset.columns.filter(_ => _.key === key).pop() ?? {}
|
|
709
729
|
},
|
|
710
730
|
|
|
731
|
+
generatePreset(){
|
|
732
|
+
if(!this.generateText) return
|
|
733
|
+
|
|
734
|
+
this.$refs.generateBtn.setState(2)
|
|
735
|
+
this.socket.send(`${this.controller}.prompt-ai-assistance`, {
|
|
736
|
+
text: this.generateText
|
|
737
|
+
})
|
|
738
|
+
.then(preset => {
|
|
739
|
+
|
|
740
|
+
/*preset = {
|
|
741
|
+
columns: [
|
|
742
|
+
{ key: 'code', label: 'Kode' },
|
|
743
|
+
{ key: 'loginCode', label: 'NIP' },
|
|
744
|
+
{ key: 'bertemuDengan', label: 'Bertemu Dengan' }
|
|
745
|
+
],
|
|
746
|
+
filters: [
|
|
747
|
+
{
|
|
748
|
+
key: 'createdAt',
|
|
749
|
+
value: [ { operator: '=', value: [ '2024-07-05' ] } ]
|
|
750
|
+
}
|
|
751
|
+
]
|
|
752
|
+
}*/
|
|
753
|
+
|
|
754
|
+
preset.uid = 'ai-assistant'
|
|
755
|
+
preset.name = !preset.name ? 'AI Assistant' : preset.name
|
|
756
|
+
|
|
757
|
+
let index = this.config.presets.findIndex(_ => _.uid === preset.uid)
|
|
758
|
+
if(index < 0){
|
|
759
|
+
this.config.presets.push(preset)
|
|
760
|
+
}
|
|
761
|
+
else {
|
|
762
|
+
Object.assign(this.config.presets[index], preset)
|
|
763
|
+
this.load()
|
|
764
|
+
}
|
|
765
|
+
|
|
766
|
+
this.configParams.presetIdx = preset.uid
|
|
767
|
+
|
|
768
|
+
})
|
|
769
|
+
.catch(err => this.alert(err))
|
|
770
|
+
.finally(_ => this.$refs.generateBtn?.resetState())
|
|
771
|
+
},
|
|
772
|
+
|
|
711
773
|
duplicate(item){
|
|
712
774
|
const newItem = JSON.parse(JSON.stringify(item))
|
|
713
775
|
newItem.name = `${item.name} (Copy)`
|
|
@@ -720,7 +782,7 @@ export default{
|
|
|
720
782
|
remove(item){
|
|
721
783
|
if(this.config.presets.length > 1){
|
|
722
784
|
this.confirm('Remove this preset?', () => {
|
|
723
|
-
this.config.presets.splice(this.config.presets.
|
|
785
|
+
this.config.presets.splice(this.config.presets.findIndex(_ => _.uid === item.uid), 1)
|
|
724
786
|
})
|
|
725
787
|
}
|
|
726
788
|
},
|
|
@@ -860,6 +922,10 @@ export default{
|
|
|
860
922
|
}
|
|
861
923
|
|
|
862
924
|
return this.configParams.presetBar
|
|
925
|
+
},
|
|
926
|
+
|
|
927
|
+
canGenerate(){
|
|
928
|
+
return this.generateText.length > 0
|
|
863
929
|
}
|
|
864
930
|
|
|
865
931
|
},
|
|
@@ -879,6 +945,7 @@ export default{
|
|
|
879
945
|
...((this.config ?? {}).chart !== false ? [{ text:'Chart', value:4 }] : []),
|
|
880
946
|
]
|
|
881
947
|
},
|
|
948
|
+
generateText: 'List kunjungan tgl 5 juli, hanya kolom kode, nip kolektor dan bertemu dengan'
|
|
882
949
|
}
|
|
883
950
|
},
|
|
884
951
|
|
|
@@ -166,8 +166,10 @@ export default{
|
|
|
166
166
|
},
|
|
167
167
|
|
|
168
168
|
addPivot(type, obj){
|
|
169
|
-
if(!this.pivot[type])
|
|
169
|
+
if(!Array.isArray(this.pivot[type])){
|
|
170
170
|
this.pivot[type] = []
|
|
171
|
+
}
|
|
172
|
+
console.log(this.pivot[type])
|
|
171
173
|
|
|
172
174
|
this.pivot[type].push(Object.assign({}, obj))
|
|
173
175
|
this.apply()
|