zet-lib 1.0.17 → 1.0.19
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 +175 -19
- package/lib/UI.js +0 -8
- package/lib/index.js +4 -5
- package/lib/zdataTable.js +12 -5
- package/package.json +1 -1
package/lib/Form.js
CHANGED
|
@@ -63,24 +63,24 @@ Form.field = (obj) => {
|
|
|
63
63
|
}
|
|
64
64
|
}
|
|
65
65
|
let type = obj.type || "text",
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
66
|
+
id = Form.addProperty("id", [obj.id]),
|
|
67
|
+
name = obj.name ? ` name="${obj.name}" ` : "",
|
|
68
|
+
title = obj.title || "",
|
|
69
|
+
prepend = obj.prepend || "",
|
|
70
|
+
append = obj.append || "",
|
|
71
|
+
placeholder = Form.addProperty("placeholder", [obj.placeholder]),
|
|
72
|
+
tabindex = Form.addProperty("tabindex", [obj.tabindex]),
|
|
73
|
+
value = obj.value == undefined ? "" : obj.value,
|
|
74
|
+
classview = obj.class ? ` class="${obj.class}" ` : ` class=" " `,
|
|
75
|
+
disabled = obj.disabled ? ` disabled="disabled" ` : '',
|
|
76
|
+
data = obj.data,
|
|
77
|
+
required = obj.required == true ? ` required ` : '',
|
|
78
|
+
table = !obj.table ? "" : obj.table,
|
|
79
|
+
frameworkcss = !obj.frameworkcss ? "bootstrap5" : obj.frameworkcss,
|
|
80
|
+
form_css = !obj.form_css ? "bootstrap" : obj.form_css,
|
|
81
|
+
attributes = !obj.attributes ? {} : obj.attributes,
|
|
82
|
+
style = !obj.style ? "" : ` style=${obj.style} `,
|
|
83
|
+
information = !obj.information ? "" : `<div id="information-${obj.id}" class="form-text">${Util.replaceAll(obj.information.substring(1, (obj.information.length - 1)), "\r\n", "<br>")}</div>`
|
|
84
84
|
;
|
|
85
85
|
//replaceAll("\r\n","<br>")
|
|
86
86
|
let attributeDate = "";
|
|
@@ -420,7 +420,7 @@ Form.field = (obj) => {
|
|
|
420
420
|
displayForm = `${prepend}<input autocomplete="off" autofocus="" ${tabindex} ${style} type="text" ${classview} readonly ${id} ${placeholder} ${required} value="${value}" ${htmlOptions}>${information}${append}`;
|
|
421
421
|
break;
|
|
422
422
|
|
|
423
|
-
|
|
423
|
+
//additionals for form view in view
|
|
424
424
|
case "plaintext" :
|
|
425
425
|
displayForm = `<span class="">${obj.value || ""}</span>`;
|
|
426
426
|
break;
|
|
@@ -501,6 +501,70 @@ Form.breadcrumb = (type, arr) => {
|
|
|
501
501
|
return html;
|
|
502
502
|
};
|
|
503
503
|
|
|
504
|
+
Form.breadcrumbs = (arr) => {
|
|
505
|
+
let html = `<nav style="--bs-breadcrumb-divider: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='8' height='8'%3E%3Cpath d='M2.5 0L1 1.5 3.5 4 1 6.5 2.5 8l4-4-4-4z' fill='currentColor'/%3E%3C/svg%3E");" aria-label="breadcrumb"><ol class="breadcrumb float-end">`;
|
|
506
|
+
arr.map((item) => {
|
|
507
|
+
if (item.active == true) {
|
|
508
|
+
html += `<li class="breadcrumb-item active" aria-current="page">${item.text}</li>`;
|
|
509
|
+
} else {
|
|
510
|
+
html += `<li class="breadcrumb-item"><a href="${item.href}">${item.text}</a></li>`;
|
|
511
|
+
}
|
|
512
|
+
});
|
|
513
|
+
html += `</ol></nav>`;
|
|
514
|
+
return html;
|
|
515
|
+
};
|
|
516
|
+
|
|
517
|
+
Form.breadcrumbIndex = () => {
|
|
518
|
+
return Form.breadcrumbs([
|
|
519
|
+
{text: LANGUAGE['home'], href: "/dashboard"},
|
|
520
|
+
{text: LANGUAGE['grid_list'],active: true}]);
|
|
521
|
+
}
|
|
522
|
+
|
|
523
|
+
Form.breadcrumbCreate = (routeName) => {
|
|
524
|
+
return Form.breadcrumbs( [
|
|
525
|
+
{text: LANGUAGE['home'], href: "/dashboard"},
|
|
526
|
+
{text: LANGUAGE['grid_list'],href: "/" + routeName},
|
|
527
|
+
{text: LANGUAGE['create'], active: true}
|
|
528
|
+
]);
|
|
529
|
+
}
|
|
530
|
+
|
|
531
|
+
Form.breadcrumbUpdate = (routeName,id) => {
|
|
532
|
+
return Form.breadcrumbs( [
|
|
533
|
+
{text: LANGUAGE['home'], href: "/dashboard"},
|
|
534
|
+
{text: LANGUAGE['grid_list'],href: "/" + routeName},
|
|
535
|
+
{text: LANGUAGE['create'], href: "/" + routeName + "/create"},
|
|
536
|
+
{text: LANGUAGE['view'],href: "/" + routeName + "/view/" + id},
|
|
537
|
+
{text: LANGUAGE['update'], active: true}
|
|
538
|
+
]);
|
|
539
|
+
}
|
|
540
|
+
|
|
541
|
+
Form.breadcrumbView = (routeName) => {
|
|
542
|
+
return Form.breadcrumbs( [
|
|
543
|
+
{text: LANGUAGE['home'], href: "/dashboard"},
|
|
544
|
+
{text: LANGUAGE['grid_list'],href: "/" + routeName},
|
|
545
|
+
{text: LANGUAGE['view'], active: true}
|
|
546
|
+
]);
|
|
547
|
+
}
|
|
548
|
+
|
|
549
|
+
Form.breadcrumbImport = (routeName) => {
|
|
550
|
+
return Form.breadcrumbs( [
|
|
551
|
+
{text: LANGUAGE['home'], href: "/dashboard"},
|
|
552
|
+
{text: LANGUAGE['grid_list'],href: "/" + routeName},
|
|
553
|
+
{text: LANGUAGE['create'], href: "/" + routeName + "/create"},
|
|
554
|
+
{text: LANGUAGE['form_import'], active: true}
|
|
555
|
+
]);
|
|
556
|
+
}
|
|
557
|
+
|
|
558
|
+
Form.breadcrumbApproval = (routeName, id) => {
|
|
559
|
+
return Form.breadcrumbs( [
|
|
560
|
+
{text: LANGUAGE['home'], href: "/dashboard"},
|
|
561
|
+
{text: LANGUAGE['grid_list'],href: "/" + routeName},
|
|
562
|
+
{text: LANGUAGE['update'], href: '/' + routeName + '/update/' + id},
|
|
563
|
+
{text: LANGUAGE['create'],href: '/' + routeName + '/create'},
|
|
564
|
+
{text: "Approval", active: true}
|
|
565
|
+
]);
|
|
566
|
+
}
|
|
567
|
+
|
|
504
568
|
Form.grid = (type, obj) => {
|
|
505
569
|
return gridBootstrap5(obj);
|
|
506
570
|
};
|
|
@@ -714,4 +778,96 @@ Form.build = (obj) => {
|
|
|
714
778
|
return html;
|
|
715
779
|
};
|
|
716
780
|
|
|
781
|
+
Form.modal = (obj, LANGUAGE={}) => {
|
|
782
|
+
let attributeData = obj.attributeData, visibles = obj.visibles || [], invisibles = obj.invisibles || [], visiblesHtml = '', invisiblesHtml = '', labelsHtml = '';
|
|
783
|
+
visibles.map((item) => {
|
|
784
|
+
visiblesHtml += `<li data-name="${item}" draggable="true" class="image-li" role="option" aria-grabbed="false"><img src="/assets/icons/eye.svg" class="icons-bg-black"> ${attributeData.labels[item]}</li>`;
|
|
785
|
+
});
|
|
786
|
+
invisibles.map((item) => {
|
|
787
|
+
invisiblesHtml += `<li data-name="${item}" draggable="true" class="image-li" role="option" aria-grabbed="false"><img src="/assets/icons/eye-off.svg" class="icons-bg-black"> ${attributeData.labels[item]}</li>`;
|
|
788
|
+
});
|
|
789
|
+
let no = 1;
|
|
790
|
+
for(let key in attributeData.labels) {
|
|
791
|
+
labelsHtml += `<tr><td>${no}</td><td>${key}</td><td>${attributeData.labels[key]}</td><td><input maxlength="25" type="text" class="form-control" required name="${obj.routeName}[${key}]" value="${attributeData.labels[key]}"></td></tr>`;
|
|
792
|
+
no++;
|
|
793
|
+
}
|
|
794
|
+
const modalFields = Form.modalBuild({
|
|
795
|
+
id: "grid-modal",
|
|
796
|
+
size : "modal-xl",
|
|
797
|
+
header: `<h5 id="dynagrid-1-grid-modal-label" class="modal-title">
|
|
798
|
+
<i class="fa fa-cog"></i> ${LANGUAGE.grid_settings || "Settings Grid"}
|
|
799
|
+
</h5>`,
|
|
800
|
+
body : `<div class="container">
|
|
801
|
+
<form id="form-grid" class="form-vertical kv-form-bs4" action="/${obj.routeName}/grid" method="post">
|
|
802
|
+
<input type="hidden" name="_csrf" value="">
|
|
803
|
+
<div class="dynagrid-column-label">
|
|
804
|
+
${LANGUAGE.grid_configure || "Configure Order and Display of Grid Columns"}
|
|
805
|
+
</div>
|
|
806
|
+
<div class="row">
|
|
807
|
+
<div class="col-sm-5">
|
|
808
|
+
<ul id="gridleft" class="sortable-visible sortable list kv-connected cursor-move gridsortable" aria-dropeffect="move">
|
|
809
|
+
<li data-name="" class="alert alert-info dynagrid-sortable-header disabled">
|
|
810
|
+
${LANGUAGE.grid_visible || "Visible Columns"}
|
|
811
|
+
</li>
|
|
812
|
+
${visiblesHtml}
|
|
813
|
+
</ul>
|
|
814
|
+
</div>
|
|
815
|
+
<div class="col-sm-2 text-center">
|
|
816
|
+
<div class="dynagrid-sortable-separator"><i class="fas fa-arrows-alt-h"></i></div>
|
|
817
|
+
</div>
|
|
818
|
+
<div class="col-sm-5">
|
|
819
|
+
<ul id="gridright"
|
|
820
|
+
class="sortable-hidden sortable list kv-connected cursor-move gridsortable" aria-dropeffect="move">
|
|
821
|
+
<li data-name="" class="alert alert-info dynagrid-sortable-header disabled">${LANGUAGE.grid_invisible || "Hidden / Fixed Columns"}
|
|
822
|
+
</li>
|
|
823
|
+
${invisiblesHtml}
|
|
824
|
+
</ul>
|
|
825
|
+
</div>
|
|
826
|
+
</div>
|
|
827
|
+
<input type="hidden" id="serialize_left" name="serialize_left" value=''/>
|
|
828
|
+
<input type="hidden" id="serialize_right" name="serialize_right" value=''/>
|
|
829
|
+
</form>
|
|
830
|
+
</div> <!-- .dynagrid-config-form -->`,
|
|
831
|
+
footer : `<button type="reset" class="btn btn-default refresh gridreload image-button" title="Abort any changes and reset settings">
|
|
832
|
+
<img src="/assets/icons/refresh.svg" class="icons-bg-black"> ${LANGUAGE.reset || "Reset"}
|
|
833
|
+
</button>
|
|
834
|
+
<button type="button" class="btn btn-primary grid-submit boxy image-button" title="Save grid settings">
|
|
835
|
+
<img src="/assets/icons/send.svg" class="icons-bg-white"> ${LANGUAGE.apply || "Apply"}
|
|
836
|
+
</button>`
|
|
837
|
+
});
|
|
838
|
+
try {
|
|
839
|
+
return modalFields;
|
|
840
|
+
} catch (err) {
|
|
841
|
+
console.log(err);
|
|
842
|
+
}
|
|
843
|
+
};
|
|
844
|
+
|
|
845
|
+
|
|
846
|
+
Form.modalBuild = (obj) => {
|
|
847
|
+
let html = '<!-- Modal -->';
|
|
848
|
+
try {
|
|
849
|
+
const size = obj.size ? `${obj.size}` : "";
|
|
850
|
+
const id = obj.id ? `id="${obj.id}"` : "";
|
|
851
|
+
const headerOptions = Util.attributeOptions(obj.headerOptions || {},{class:"modal-header"});
|
|
852
|
+
const header = obj.header ? `<div ${headerOptions} >${obj.header}<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button></div>`:"";
|
|
853
|
+
const body = obj.body ? obj.body : "";
|
|
854
|
+
const bodyOptions = Util.attributeOptions(obj.bodyOptions || {},{class:"modal-body"});
|
|
855
|
+
const footerOptions = Util.attributeOptions(obj.footerOptions || {},{class:"modal-footer"});
|
|
856
|
+
const footer = obj.footer ? `<div ${footerOptions} >${obj.footer}</div>` : "";
|
|
857
|
+
html += `${Util.newLine}<div class="modal fade " ${id} role="dialog" tabindex="-1">
|
|
858
|
+
<div class="modal-dialog ${size}">
|
|
859
|
+
<div class="modal-content">
|
|
860
|
+
${header}
|
|
861
|
+
<div ${bodyOptions}>${body}</div>
|
|
862
|
+
${footer}
|
|
863
|
+
</div>
|
|
864
|
+
</div>
|
|
865
|
+
</div>`;
|
|
866
|
+
|
|
867
|
+
} catch (error) {
|
|
868
|
+
console.log(error)
|
|
869
|
+
}
|
|
870
|
+
return html;
|
|
871
|
+
};
|
|
872
|
+
|
|
717
873
|
module.exports = Form;
|
package/lib/UI.js
CHANGED
|
@@ -1,14 +1,6 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Created by sintret dev on 8/27/2021.
|
|
3
|
-
* Helper function in the frontend
|
|
4
|
-
*/
|
|
5
|
-
//var MenuCollections = require("./MenuCollections");
|
|
6
|
-
|
|
7
1
|
function UI(req, res) {
|
|
8
2
|
this.Form = require("./Form");
|
|
9
3
|
this.Modal = require("./Modal");
|
|
10
|
-
//this.Util = require("./Util");
|
|
11
|
-
//this.Menu = MenuCollections(req, res);
|
|
12
4
|
}
|
|
13
5
|
|
|
14
6
|
module.exports = UI;
|
package/lib/index.js
CHANGED
|
@@ -6,11 +6,11 @@ module.exports = {
|
|
|
6
6
|
myCache: require('./cache'),
|
|
7
7
|
connection: require('./connection'),
|
|
8
8
|
zdataTable: require('./zdataTable'),
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
zDebug: require('./debug'),
|
|
10
|
+
zForm: require('./Form'),
|
|
11
11
|
io: require('./io'),
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
zMail: require('./Mail'),
|
|
13
|
+
zModal: require('./Modal'),
|
|
14
14
|
moduleLib: require('./moduleLib'),
|
|
15
15
|
tableForm: require('./tableForm'),
|
|
16
16
|
zapp: require('./zapp'),
|
|
@@ -27,4 +27,3 @@ module.exports = {
|
|
|
27
27
|
zCache : require('./zCache'),
|
|
28
28
|
UI : require('./UI')
|
|
29
29
|
};
|
|
30
|
-
|
package/lib/zdataTable.js
CHANGED
|
@@ -33,11 +33,20 @@ class dataTable {
|
|
|
33
33
|
return this.setColumns;
|
|
34
34
|
let html = '';
|
|
35
35
|
for (var key in this.visibles) {
|
|
36
|
-
html += `<th id="data_${key}">${this.visibles[key]}</th>`;
|
|
36
|
+
html += `<th id="data_${key}_label">${this.visibles[key]}</th>`;
|
|
37
37
|
}
|
|
38
38
|
return html;
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
+
get columnsFilter() {
|
|
42
|
+
let html = '<tr class="filters">';
|
|
43
|
+
for (var key in this.visibles) {
|
|
44
|
+
html += `<th id="data_${key}">${this.searchColumns[key]}</th>`;
|
|
45
|
+
}
|
|
46
|
+
html += '</tr>';
|
|
47
|
+
return html;
|
|
48
|
+
}
|
|
49
|
+
|
|
41
50
|
/*
|
|
42
51
|
Create table html header
|
|
43
52
|
*/
|
|
@@ -45,7 +54,7 @@ class dataTable {
|
|
|
45
54
|
if (this.setTable)
|
|
46
55
|
return this.setTable;
|
|
47
56
|
return `<table id="dataTable" class="display table table-hover table-responsive" style="width:100%">
|
|
48
|
-
<thead>${this.columns}</thead>
|
|
57
|
+
<thead>${this.columns} ${this.columnsFilter}</thead>
|
|
49
58
|
</table>`;
|
|
50
59
|
}
|
|
51
60
|
|
|
@@ -113,13 +122,11 @@ class dataTable {
|
|
|
113
122
|
get scripts() {
|
|
114
123
|
let script = '<script type="text/javascript" src="https://cdn.datatables.net/v/bs5/dt-1.11.3/date-1.1.1/fc-4.0.1/fh-3.2.1/r-2.2.9/rg-1.1.4/sc-2.0.5/sl-1.3.4/datatables.min.js"></script>';
|
|
115
124
|
script += `<script>${Util.newLine}`;
|
|
116
|
-
script += `var dataTableFilters = ${JSON.stringify(this.searchColumns)};${Util.newLine}`;
|
|
117
125
|
script += `var dataTableFields = ${JSON.stringify(Object.keys(this.visibles,null,2))};${Util.newLine}`;
|
|
118
126
|
script += `var dataTableTypes = ${JSON.stringify(this.types,null,2)};${Util.newLine}`;
|
|
119
127
|
script += `var dataTableRoute = "${this.routeName}";${Util.newLine}`;
|
|
120
128
|
script += `</script>${Util.newLine}`;
|
|
121
|
-
script += `<script type="text/javascript" src="/js/
|
|
122
|
-
|
|
129
|
+
script += `<script type="text/javascript" src="/js/datatable.js"></script>${Util.newLine}`;
|
|
123
130
|
if (this.searchColumns.FILTERKEY) {
|
|
124
131
|
script += `<script>$(function () { setTimeout(function () { ${this.searchColumns.FILTERKEY} },500) });</script>${Util.newLine}`;
|
|
125
132
|
}
|