zet-lib 1.0.57 → 1.0.58
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/zRoleRouter.js +5 -3
- package/lib/zRoute.js +35 -1
- package/package.json +1 -1
package/lib/zRoleRouter.js
CHANGED
|
@@ -300,6 +300,7 @@ const body = `<div class="">
|
|
|
300
300
|
<% for(var i = 0;i < actions.length;i++) { %>
|
|
301
301
|
<th><%= actions[i] %> <input onclick='checkthis("<%= actions[i] %>")' type="checkbox" id="all<%= actions[i] %>"></th>
|
|
302
302
|
<% } %>
|
|
303
|
+
<th>Tabs</th>
|
|
303
304
|
</tr>
|
|
304
305
|
</thead>
|
|
305
306
|
<tbody>
|
|
@@ -307,14 +308,16 @@ const body = `<div class="">
|
|
|
307
308
|
<tr>
|
|
308
309
|
<td>
|
|
309
310
|
<% var ename = routes[i];
|
|
310
|
-
var
|
|
311
|
-
|
|
311
|
+
var handleTag = "handleAccess('"+routes[i]+"')";
|
|
312
|
+
var spanRole = tabs.includes(routes[i]) ? '<span class="handle-access icon-small icons-light" onclick="'+handleTag+'" data-bs-toggle="modal" data-bs-target="#tabaccess" ><img class="icons-bg-blue gridview icon-image" src="/assets/icons/lock-access.svg"></span>' : '' %>
|
|
313
|
+
<a href="/<%- ename %>" target="_blank"><%- ename %></a>
|
|
312
314
|
</td>
|
|
313
315
|
<% for(var x = 0;x < actions.length;x++) { %>
|
|
314
316
|
<td><input name="params[<%= ename %>][<%= actions[x] %>]" class="<%= actions[x] %>"
|
|
315
317
|
<% if(json && json.hasOwnProperty(ename) && json[ename].indexOf(actions[x]) >= 0) { %> <%= 'checked="checked"' %> <% } %> title="Role for <%= routes[i] %> <%= actions[x] %>" type="checkbox">
|
|
316
318
|
</td>
|
|
317
319
|
<% } %>
|
|
320
|
+
<td><%- spanRole %></td>
|
|
318
321
|
</tr>
|
|
319
322
|
<% } %>
|
|
320
323
|
</tbody>
|
|
@@ -456,7 +459,6 @@ const js = `<script>
|
|
|
456
459
|
$(".body-access").html(data);
|
|
457
460
|
}))
|
|
458
461
|
}
|
|
459
|
-
$(".handle-access").on("click", (e)=> handleAccess(e.target.text));
|
|
460
462
|
$(".btn-save-tab").on("click",(e) => {
|
|
461
463
|
let queryform = $("#tabform").serializeArray();
|
|
462
464
|
ajaxPost('/zrole/post-access', {
|
package/lib/zRoute.js
CHANGED
|
@@ -2092,7 +2092,41 @@ zRoute.viewFormsSync = async (req, res, MYMODEL, data = {}) => {
|
|
|
2092
2092
|
const MYMODELS = myCache.get('MYMODELS')
|
|
2093
2093
|
const relations = await zRoute.relations(req, res, MYMODEL.table)
|
|
2094
2094
|
let forms = zRoute.viewForm(req, res, MYMODEL, relations, data)
|
|
2095
|
-
//
|
|
2095
|
+
//add tabs role
|
|
2096
|
+
if (MYMODEL.hasOwnProperty('hasTabs') && MYMODEL.hasTabs) {
|
|
2097
|
+
let script = ''
|
|
2098
|
+
//MYMODEL.tabs.map((table))
|
|
2099
|
+
script += `$(()=> {
|
|
2100
|
+
ajaxPost('/ztab-access',{table:"${MYMODEL.table}"},(data)=> {
|
|
2101
|
+
let dataTabs = ${MYMODEL.hasOwnProperty('tabs') ? JSON.stringify(MYMODEL.tabs) : []};
|
|
2102
|
+
let viewAccess = data.view || [];
|
|
2103
|
+
let createAccess = data.create || [];
|
|
2104
|
+
let editAccess = data.edit || [];
|
|
2105
|
+
let deleteAccess = data.delete || [];
|
|
2106
|
+
dataTabs.map((_, index)=> {
|
|
2107
|
+
if(!deleteAccess[index]) {
|
|
2108
|
+
setTimeout(function () {$("#arr"+index).find(".icons-danger").remove();},1000)
|
|
2109
|
+
}
|
|
2110
|
+
if(!editAccess[index]) {
|
|
2111
|
+
$("#arr"+index).find("input").attr("disabled",true);
|
|
2112
|
+
$("#arr"+index).find("select").attr("disabled",true);
|
|
2113
|
+
}
|
|
2114
|
+
if(!createAccess[index]) {
|
|
2115
|
+
$("#arr"+index).find(".btn-plus").remove();
|
|
2116
|
+
$("#arr"+index).find("input").attr("disabled",true);
|
|
2117
|
+
$("#arr"+index).find("select").attr("disabled",true);
|
|
2118
|
+
}
|
|
2119
|
+
if(!viewAccess[index]) {
|
|
2120
|
+
$("#arr"+index).remove();
|
|
2121
|
+
$(".arr"+index).remove();
|
|
2122
|
+
}
|
|
2123
|
+
})
|
|
2124
|
+
});
|
|
2125
|
+
});
|
|
2126
|
+
`
|
|
2127
|
+
moduleLib.addScript(req, res, script)
|
|
2128
|
+
}
|
|
2129
|
+
|
|
2096
2130
|
let tables = []
|
|
2097
2131
|
for (let key in forms.obj) {
|
|
2098
2132
|
if (forms.obj[key].type == 'table') {
|