zet-lib 1.2.44 → 1.2.46
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/Form.js +2 -16
- package/lib/zAppRouter.js +3 -3
- package/lib/zRoute.js +6 -23
- package/lib/zdataTable.js +27 -12
- package/package.json +1 -1
package/lib/Form.js
CHANGED
|
@@ -864,22 +864,8 @@ Form.modal = (obj, LANGUAGE = {}) => {
|
|
|
864
864
|
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
|
|
865
865
|
</div>
|
|
866
866
|
<div class="modal-body">
|
|
867
|
-
<
|
|
868
|
-
|
|
869
|
-
<div class="mb-3">
|
|
870
|
-
<div class="form-check">
|
|
871
|
-
<input class="form-check-input" type="checkbox" id="check-all-grid">
|
|
872
|
-
<label class="form-check-label" for="check-all-grid">
|
|
873
|
-
Lock/UnLock All
|
|
874
|
-
</label>
|
|
875
|
-
</div>
|
|
876
|
-
</div>
|
|
877
|
-
</fieldset>
|
|
878
|
-
</form>
|
|
879
|
-
|
|
880
|
-
</div>
|
|
881
|
-
<div class="modal-footer">
|
|
882
|
-
<button type="button" class="btn btn-primary btn-save-lock"> ${LANGUAGE.apply || 'Apply'}</button>
|
|
867
|
+
<button title="Lock" style="background-color: #DC4C64; color:white" class="btn btn-save-lock boxy-small dimens2x image-button" type="button"><img src="/assets/icons/lock.svg" class="icons-bg-white"> Lock</button>
|
|
868
|
+
<button title="Unlock" style="background-color: #14A44D; color:white" class="btn btn-save-unlock boxy-small dimens2x image-button" type="button"><img src="/assets/icons/lock-open.svg" class="icons-bg-white"> Unlock</button>
|
|
883
869
|
</div>
|
|
884
870
|
</div>
|
|
885
871
|
</div>
|
package/lib/zAppRouter.js
CHANGED
|
@@ -1305,15 +1305,15 @@ router.post('/zlock-unlock/:table', async (req, res) => {
|
|
|
1305
1305
|
let tableRole = myrole.params[table] || []
|
|
1306
1306
|
let hasAccess = tableRole.includes('lock') ? true : false
|
|
1307
1307
|
if (hasAccess) {
|
|
1308
|
+
let type = req.body.type
|
|
1308
1309
|
let datas = req.body.datas || []
|
|
1309
1310
|
if (datas.length > 0) {
|
|
1310
1311
|
for (const data of datas) {
|
|
1311
|
-
let id = data.name.replace('
|
|
1312
|
-
let value = data.value
|
|
1312
|
+
let id = data.name.replace('ck[', '').replace(']', '')
|
|
1313
1313
|
await connection.update({
|
|
1314
1314
|
table: table,
|
|
1315
1315
|
data: {
|
|
1316
|
-
lock:
|
|
1316
|
+
lock: type,
|
|
1317
1317
|
},
|
|
1318
1318
|
where: {
|
|
1319
1319
|
id: id,
|
package/lib/zRoute.js
CHANGED
|
@@ -662,24 +662,6 @@ zRoute.relations = async (req, res, table) => {
|
|
|
662
662
|
zRoute.dataTableFilterSync = async (req, res, MYMODEL, filter) => {
|
|
663
663
|
const relations = await zRoute.relations(req, res, MYMODEL.table)
|
|
664
664
|
zRoute.moduleLib(req, res, MYMODEL, relations)
|
|
665
|
-
/*let typeaheads = [];
|
|
666
|
-
let scriptForm = '';
|
|
667
|
-
let head = '';
|
|
668
|
-
let end ='';
|
|
669
|
-
for(let key in MYMODEL.widgets){
|
|
670
|
-
if(MYMODEL.widgets[key].name == "typeahead") {
|
|
671
|
-
typeaheads.push(key)
|
|
672
|
-
let typeaheadObj = moduleLib.typeahead(req, res, `#${key}Typeahead`)
|
|
673
|
-
scriptForm += typeaheadObj.script
|
|
674
|
-
head = typeaheadObj.head
|
|
675
|
-
end = typeaheadObj.end
|
|
676
|
-
}
|
|
677
|
-
}
|
|
678
|
-
if(typeaheads.length > 0) {
|
|
679
|
-
res.locals.moduleHead = head
|
|
680
|
-
res.locals.moduleEnd = end
|
|
681
|
-
moduleLib.addScript(req,res,scriptForm)
|
|
682
|
-
}*/
|
|
683
665
|
const dataTable = zRoute.dataTableFilter(MYMODEL, relations, filter)
|
|
684
666
|
return dataTable
|
|
685
667
|
}
|
|
@@ -716,6 +698,9 @@ zRoute.dataTableFilter = (MYMODEL, relations, filter) => {
|
|
|
716
698
|
if (key == 'id') {
|
|
717
699
|
types[key] = 'input'
|
|
718
700
|
dataTable[key] = `<input type="number" class="search" placeholder="${fields[key].title}" value="${value}" id="data_table_${key}" >`
|
|
701
|
+
} else if (key == 'no') {
|
|
702
|
+
types[key] = 'input'
|
|
703
|
+
dataTable[key] = `<input type="checkbox" class="form-check-input" id="ck_all" >`
|
|
719
704
|
} else {
|
|
720
705
|
if (widgets.hasOwnProperty(key)) {
|
|
721
706
|
const widgetName = widgets[key].name
|
|
@@ -866,9 +851,7 @@ zRoute.dataTableData = (key, value, MYMODEL, relations, myid = '') => {
|
|
|
866
851
|
let myvalue = value
|
|
867
852
|
var widgetName = MYMODEL.widgets[key] ? MYMODEL.widgets[key].name : ''
|
|
868
853
|
if (key == 'lock') {
|
|
869
|
-
|
|
870
|
-
let selected2 = value == 1 ? 'selected' : ''
|
|
871
|
-
myvalue = `<select name="lock[${myid}]" class="lockdatagrid" id="lock${myid}"><option value="0" ${selected1}>Unlock</option><option value="1" ${selected2}>Lock</option></select>`
|
|
854
|
+
myvalue = value == 1 ? 'Lock' : 'Unlock'
|
|
872
855
|
} else {
|
|
873
856
|
if (widgetName) {
|
|
874
857
|
switch (widgetName) {
|
|
@@ -1930,7 +1913,7 @@ zRoute.listData = async (req, res, MYMODEL, zRole, actionButtonsFn) => {
|
|
|
1930
1913
|
let arr = []
|
|
1931
1914
|
fields.forEach(function (item) {
|
|
1932
1915
|
if (item == 'no') {
|
|
1933
|
-
arr.push(index + 1 + parseInt(body.start))
|
|
1916
|
+
arr.push(index + 1 + parseInt(body.start) + ` <input type="checkbox" name="ck[${row.id}]" id="ck_${row.id}" class="form-check-input ck">`)
|
|
1934
1917
|
} else if (item == 'actionColumn') {
|
|
1935
1918
|
let buttons = !actionButtonsFn(levels, row, MYMODEL.table) ? zRoute.actionButtons(levels, row, MYMODEL.table) : actionButtonsFn(levels, row, MYMODEL.table)
|
|
1936
1919
|
arr.push(buttons)
|
|
@@ -2484,7 +2467,7 @@ zRoute.viewForm = (req, res, MYMODEL, relations, data = {}) => {
|
|
|
2484
2467
|
let value = ''
|
|
2485
2468
|
for (let key in obj) {
|
|
2486
2469
|
if (widgets.hasOwnProperty(key)) {
|
|
2487
|
-
let className = 'form-control-plaintext '
|
|
2470
|
+
let className = 'form-control form-control-plaintext '
|
|
2488
2471
|
if (widgets[key].float) {
|
|
2489
2472
|
className += ` boxy-small`
|
|
2490
2473
|
} else {
|
package/lib/zdataTable.js
CHANGED
|
@@ -123,7 +123,7 @@ class dataTable {
|
|
|
123
123
|
html += `<button title="${LANGUAGE.import_info}" class="btn buttons-copy buttons-html5 copy gridimport boxy-small dimens2x image-button" tabindex="0" type="button"><img src="/assets/icons/database-import.svg" class="icons-bg-black"> ${LANGUAGE.import}</span></span></button>`
|
|
124
124
|
}
|
|
125
125
|
if (this.levels.lock) {
|
|
126
|
-
html += `<button title="Lock/Unlock" style="background-color: #
|
|
126
|
+
html += `<button title="Lock/Unlock" style="background-color: #332D2D; color:white" class="btn btn-danger buttons-lock buttons-html5 copy gridlock boxy-small dimens2x image-button" tabindex="0" data-bs-toggle="modal" data-bs-target="#grid-lock" type="button"><img src="/assets/icons/cloud-lock.svg" class="icons-bg-white"> Lock/Unlock</span></span></button>`
|
|
127
127
|
}
|
|
128
128
|
html += `<button title="${LANGUAGE.settings}" class="btn buttons-excel buttons-html5 setting gridsettings boxy-small dimens2x image-button" tabindex="0" type="button" data-bs-toggle="modal" data-bs-target="#grid-modal"><img src="/assets/icons/settings.svg" class="icons-bg-black"> ${LANGUAGE.settings}</button>`
|
|
129
129
|
html += `<button class="btn refresh gridreload boxy-small dimens2x image-button" title="${LANGUAGE.grid_refresh}" tabindex="0" aria-controls="DataTables_Table_0" type="button"><img src="/assets/icons/refresh.svg" class="icons-bg-black"></button>`
|
|
@@ -183,25 +183,40 @@ class dataTable {
|
|
|
183
183
|
script += `<script type="text/javascript">$(function () {${typeaheadScript}})</script>${Util.newLine}`
|
|
184
184
|
}
|
|
185
185
|
script += `<script type="text/javascript">
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
}
|
|
194
|
-
|
|
186
|
+
$(function () {
|
|
187
|
+
$("#ck_all").on('click', function () {
|
|
188
|
+
if($(this).is(':checked')) {
|
|
189
|
+
$(".ck").prop('checked',true)
|
|
190
|
+
} else {
|
|
191
|
+
$(".ck").prop('checked',false)
|
|
192
|
+
}
|
|
193
|
+
})
|
|
194
|
+
|
|
195
195
|
$(".btn-save-lock").on("click", function () {
|
|
196
196
|
ajaxPost('/zlock-unlock/${this.MYMODEL.table}', {
|
|
197
|
-
|
|
197
|
+
type : 1,
|
|
198
|
+
datas: $(".ck").serializeArray()
|
|
198
199
|
}, function (data) {
|
|
199
200
|
toastrForm(data);
|
|
200
201
|
if(data.status ==1) {
|
|
201
202
|
location.href='';
|
|
202
203
|
}
|
|
203
204
|
})
|
|
204
|
-
})
|
|
205
|
+
})
|
|
206
|
+
|
|
207
|
+
$(".btn-save-unlock").on("click", function () {
|
|
208
|
+
ajaxPost('/zlock-unlock/${this.MYMODEL.table}', {
|
|
209
|
+
type : 0,
|
|
210
|
+
datas: $(".ck").serializeArray()
|
|
211
|
+
}, function (data) {
|
|
212
|
+
toastrForm(data);
|
|
213
|
+
if(data.status ==1) {
|
|
214
|
+
location.href='';
|
|
215
|
+
}
|
|
216
|
+
})
|
|
217
|
+
})
|
|
218
|
+
|
|
219
|
+
})</script>${Util.newLine}`
|
|
205
220
|
|
|
206
221
|
return script
|
|
207
222
|
}
|