zet-lib 1.2.29 → 1.2.31
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/lib/index.js +1 -0
- package/lib/zRoute.js +30 -5
- package/lib/zdataTable.js +14 -1
- package/package.json +2 -2
package/lib/index.js
CHANGED
package/lib/zRoute.js
CHANGED
|
@@ -803,7 +803,7 @@ zRoute.dataTableFilter = (MYMODEL, relations, filter) => {
|
|
|
803
803
|
case 'typeahead':
|
|
804
804
|
dataTable[key] = `<div class="input-group">
|
|
805
805
|
<input type="text" class="form-control" id="${key}Typeahead" autocomplete="off" data-provide="typeahead" id="${key}Typeahead" placeholder="Please type a word" >
|
|
806
|
-
<input type="hidden" id="${key}" class="search" required="" value="">
|
|
806
|
+
<input type="hidden" id="${key}" class="search" required="" value="${value}">
|
|
807
807
|
<span id="${key}Clear" class="input-group-addon input-group-text dropdownadd" title="Clear" style="cursor: pointer;" title=" Add Data "><img src="/assets/icons/ban.svg" class="icons-bg-black" ></span>
|
|
808
808
|
</div>`
|
|
809
809
|
types[key] = 'input'
|
|
@@ -3704,7 +3704,7 @@ zRoute.modelsCache = async () => {
|
|
|
3704
3704
|
obj[table] = {}
|
|
3705
3705
|
}
|
|
3706
3706
|
if (!Util.in_array(key, nots)) {
|
|
3707
|
-
obj[table][`${keys}___${key}`] = `${widgets[key].fields[1]} as ${key}`
|
|
3707
|
+
obj[table][`${keys}___${key}`] = `${widgets[key].fields[1]} as ${key}_${models[keys].table}`
|
|
3708
3708
|
if (Object.prototype.hasOwnProperty.call(models[keys].widgets, key)) {
|
|
3709
3709
|
if (Object.prototype.hasOwnProperty.call(models[keys].widgets[key], 'order_by')) {
|
|
3710
3710
|
if (models[keys].widgets[key].order_by) {
|
|
@@ -3757,12 +3757,17 @@ zRoute.modelsCache = async () => {
|
|
|
3757
3757
|
let item = splits.length > 1 ? splits[1] : key
|
|
3758
3758
|
let arr = []
|
|
3759
3759
|
for (const result of results) {
|
|
3760
|
-
|
|
3760
|
+
if (result[`${item}_${splits[0]}`]) {
|
|
3761
|
+
arr.push({ id: result.id, zname: result[`${item}_${splits[0]}`] })
|
|
3762
|
+
} else {
|
|
3763
|
+
arr.push({ id: result.id, zname: result[item] })
|
|
3764
|
+
}
|
|
3761
3765
|
}
|
|
3762
3766
|
if (orderBy[keys]) {
|
|
3763
3767
|
myCache.set(`${keys}_${key}_${company.id}`, arr)
|
|
3764
3768
|
} else {
|
|
3765
3769
|
const myarray = Util.sortArray(arr, 'zname')
|
|
3770
|
+
//console.log(`${keys}_${key}_${company.id}`)
|
|
3766
3771
|
myCache.set(`${keys}_${key}_${company.id}`, myarray)
|
|
3767
3772
|
}
|
|
3768
3773
|
}
|
|
@@ -3808,7 +3813,11 @@ zRoute.modelsCacheRenew = (table, companyId) => {
|
|
|
3808
3813
|
let item = splits.length > 1 ? splits[1] : key
|
|
3809
3814
|
let arr = []
|
|
3810
3815
|
for (const result of results) {
|
|
3811
|
-
|
|
3816
|
+
if (result[`${item}_${splits[0]}`]) {
|
|
3817
|
+
arr.push({ id: result.id, zname: result[`${item}_${splits[0]}`] })
|
|
3818
|
+
} else {
|
|
3819
|
+
arr.push({ id: result.id, zname: result[item] })
|
|
3820
|
+
}
|
|
3812
3821
|
}
|
|
3813
3822
|
if (orderBy[table]) {
|
|
3814
3823
|
myCache.set(`${table}_${key}_${companyId}`, arr)
|
|
@@ -3825,7 +3834,6 @@ zRoute.modelsCacheRenew = (table, companyId) => {
|
|
|
3825
3834
|
console.log(err)
|
|
3826
3835
|
}
|
|
3827
3836
|
}
|
|
3828
|
-
|
|
3829
3837
|
zRoute.makeFunctionsSystem = () => {
|
|
3830
3838
|
try {
|
|
3831
3839
|
let obj = myCache.get('ZFUNCTIONS')
|
|
@@ -3873,5 +3881,22 @@ zRoute.typeahead = async (req, res) => {
|
|
|
3873
3881
|
let json = myCache.get(name)
|
|
3874
3882
|
res.json(json)
|
|
3875
3883
|
}
|
|
3884
|
+
zRoute.typeaheadpost = async (req, res) => {
|
|
3885
|
+
let table = req.params.table
|
|
3886
|
+
let keys = req.params.field
|
|
3887
|
+
let id = req.body.id
|
|
3888
|
+
const MYMODELS = myCache.get('MYMODELS')
|
|
3889
|
+
let MYMODEL = MYMODELS[table]
|
|
3890
|
+
let WIDGET = MYMODEL.widgets
|
|
3891
|
+
let mytable = WIDGET[keys].table
|
|
3892
|
+
let result = await connection.result({
|
|
3893
|
+
select: `${WIDGET[keys].fields[1]} as zname`,
|
|
3894
|
+
table: mytable,
|
|
3895
|
+
where: {
|
|
3896
|
+
id: id,
|
|
3897
|
+
},
|
|
3898
|
+
})
|
|
3899
|
+
res.json(result.zname)
|
|
3900
|
+
}
|
|
3876
3901
|
|
|
3877
3902
|
module.exports = zRoute
|
package/lib/zdataTable.js
CHANGED
|
@@ -158,9 +158,22 @@ class dataTable {
|
|
|
158
158
|
let typeaheadScript = ''
|
|
159
159
|
for (let key in this.MYMODEL.widgets) {
|
|
160
160
|
if (this.MYMODEL.widgets[key].name == 'typeahead') {
|
|
161
|
-
typeaheadScript += `if($("#${key}").val()){
|
|
161
|
+
typeaheadScript += `if($("#${key}").val()){
|
|
162
|
+
setTimeout(()=>{
|
|
163
|
+
ajaxPost('/ztypeaheadpost/${this.MYMODEL.table}/${key}', {
|
|
164
|
+
id: $("#${key}").val()
|
|
165
|
+
}, function(data) {
|
|
166
|
+
$("#${key}Typeahead").val(data);$("#${key}Typeahead").change();
|
|
167
|
+
$("#${key}").change();
|
|
168
|
+
$("#data_table_${key}").change();
|
|
169
|
+
|
|
170
|
+
})
|
|
171
|
+
},1500)
|
|
172
|
+
};
|
|
173
|
+
`
|
|
162
174
|
}
|
|
163
175
|
}
|
|
176
|
+
|
|
164
177
|
if (typeaheadScript) {
|
|
165
178
|
script += `<script type="text/javascript">$(function () {${typeaheadScript}})</script>${Util.newLine}`
|
|
166
179
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "zet-lib",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.31",
|
|
4
4
|
"description": "zet is a library that part of zet generator.",
|
|
5
5
|
"engines": {
|
|
6
6
|
"node": ">=18"
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"node-cache": "^5.1.2",
|
|
41
41
|
"nodemailer": "^6.9.4",
|
|
42
42
|
"pg": "^8.11.2",
|
|
43
|
-
"pm2": "^5.3.
|
|
43
|
+
"pm2": "^5.3.1",
|
|
44
44
|
"postgres-pool": "^8.1.4",
|
|
45
45
|
"puppeteer": "^21.0.1",
|
|
46
46
|
"qs": "^6.11.2",
|