zet-lib 1.5.29 → 2.0.0

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.
Files changed (49) hide show
  1. package/lib/Modal.js +85 -30
  2. package/lib/Model.js +118 -2
  3. package/lib/config_generator.js +24 -0
  4. package/lib/generatorApi.js +1328 -0
  5. package/lib/generatorApp.js +1342 -0
  6. package/lib/generatorModel.js +733 -0
  7. package/lib/lang_en.js +115 -0
  8. package/lib/routes/api.js +52 -0
  9. package/lib/routes/index.js +9 -0
  10. package/lib/views/error.ejs +3 -0
  11. package/lib/views/generatorjs.ejs +855 -852
  12. package/lib/views/zgenerator/bootstrap3/_form.ejs +24 -0
  13. package/lib/views/zgenerator/bootstrap3/create.ejs +9 -0
  14. package/lib/views/zgenerator/bootstrap3/createjs.ejs +3 -0
  15. package/lib/views/zgenerator/bootstrap3/import.ejs +52 -0
  16. package/lib/views/zgenerator/bootstrap3/importjs.ejs +3 -0
  17. package/lib/views/zgenerator/bootstrap3/index.ejs +29 -0
  18. package/lib/views/zgenerator/bootstrap3/indexcss.ejs +1 -0
  19. package/lib/views/zgenerator/bootstrap3/indexjs.ejs +307 -0
  20. package/lib/views/zgenerator/bootstrap3/update.ejs +8 -0
  21. package/lib/views/zgenerator/bootstrap3/updatejs.ejs +3 -0
  22. package/lib/views/zgenerator/bootstrap3/view.ejs +57 -0
  23. package/lib/views/zgenerator/head.ejs +12 -0
  24. package/lib/views/zgenerator/index.ejs +271 -0
  25. package/lib/views/zgenerator/indexcss.ejs +87 -0
  26. package/lib/views/zgenerator/indexjs.ejs +705 -0
  27. package/lib/views/zgenerator/layout.ejs +198 -0
  28. package/lib/views/zgenerator/manual_basic.ejs +2 -0
  29. package/lib/views/zgenerator/manual_dropdown.ejs +126 -0
  30. package/lib/views/zgenerator/manual_modules.ejs +192 -0
  31. package/lib/views/zgenerator/manual_virtual.ejs +143 -0
  32. package/lib/views/zgenerator/mini.ejs +341 -0
  33. package/lib/views/zgenerator/routerApp.ejs +359 -0
  34. package/lib/views/zgenerator/views/_form.ejs +25 -0
  35. package/lib/views/zgenerator/views/approval.ejs +42 -0
  36. package/lib/views/zgenerator/views/create.ejs +7 -0
  37. package/lib/views/zgenerator/views/createjs.ejs +16 -0
  38. package/lib/views/zgenerator/views/import.ejs +49 -0
  39. package/lib/views/zgenerator/views/importjs.ejs +4 -0
  40. package/lib/views/zgenerator/views/index.ejs +9 -0
  41. package/lib/views/zgenerator/views/indexcss.ejs +2 -0
  42. package/lib/views/zgenerator/views/indexjs.ejs +2 -0
  43. package/lib/views/zgenerator/views/preview.ejs +34 -0
  44. package/lib/views/zgenerator/views/update.ejs +7 -0
  45. package/lib/views/zgenerator/views/updatejs.ejs +16 -0
  46. package/lib/views/zgenerator/views/view.ejs +36 -0
  47. package/lib/zGeneratorRouter.js +177 -153
  48. package/lib/zRoute.js +14 -3
  49. package/package.json +1 -1
package/lib/Modal.js CHANGED
@@ -1,36 +1,43 @@
1
- const Util = require("./Util");
1
+ const Util = require('./Util')
2
2
  const Modal = {};
3
3
 
4
- Modal.grid = (frameworkcss = "bootstrap5",obj, LANGUAGE={}) => {
5
- let attributeData = obj.attributeData, visibles = obj.visibles || [], invisibles = obj.invisibles || [], visiblesHtml = '', invisiblesHtml = '', labelsHtml = '';
4
+ Modal.grid = (frameworkcss = "bootstrap3",obj) => {
5
+ var attributeData = obj.attributeData, visibles = obj.visibles || [], invisibles = obj.invisibles || [], visiblesHtml = '', invisiblesHtml = '', labelsHtml = '';
6
6
  visibles.map((item) => {
7
- 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>`;
7
+ visiblesHtml += `<li data-name="${item}" draggable="true" role="option" aria-grabbed="false"><span class="fa fa-eye"></span> ${attributeData.labels[item]}</li>`;
8
8
  });
9
9
  invisibles.map((item) => {
10
- 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>`;
10
+ invisiblesHtml += `<li data-name="${item}" draggable="true" role="option" aria-grabbed="false"><span class="fa fa-eye-slash"></span> ${attributeData.labels[item]}</li>`;
11
11
  });
12
- let no = 1;
13
- for(let key in attributeData.labels) {
14
- 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>`;
12
+ var no = 1;
13
+ for(var key in attributeData.labels) {
14
+ labelsHtml += `<tr>
15
+ <td>${no}</td>
16
+ <td>${key}</td>
17
+ <td>${attributeData.labels[key]}</td>
18
+ <td><input maxlength="25" type="text" class="form-control" required name="${obj.routeName}[${key}]" value="${attributeData.labels[key]}"></td>
19
+ </tr>`;
15
20
  no++;
16
21
  }
17
- const modalFields = Modal.build({
22
+
23
+
24
+ var modalFields = Modal.build({
18
25
  id: "grid-modal",
19
26
  size : "modal-xl",
20
27
  header: `<h5 id="dynagrid-1-grid-modal-label" class="modal-title">
21
- <i class="fa fa-cog"></i> ${LANGUAGE.grid_settings || "Settings Grid"}
28
+ <i class="fa fa-cog"></i> Settings Grid
22
29
  </h5>`,
23
30
  body : `<div class="container">
24
31
  <form id="form-grid" class="form-vertical kv-form-bs4" action="/${obj.routeName}/grid" method="post">
25
32
  <input type="hidden" name="_csrf" value="">
26
33
  <div class="dynagrid-column-label">
27
- ${LANGUAGE.grid_configure || "Configure Order and Display of Grid Columns"}
34
+ Configure Order and Display of Grid Columns
28
35
  </div>
29
36
  <div class="row">
30
37
  <div class="col-sm-5">
31
38
  <ul id="gridleft" class="sortable-visible sortable list kv-connected cursor-move gridsortable" aria-dropeffect="move">
32
39
  <li data-name="" class="alert alert-info dynagrid-sortable-header disabled">
33
- ${LANGUAGE.grid_visible || "Visible Columns"}
40
+ Visible Columns
34
41
  </li>
35
42
  ${visiblesHtml}
36
43
  </ul>
@@ -41,7 +48,7 @@ Modal.grid = (frameworkcss = "bootstrap5",obj, LANGUAGE={}) => {
41
48
  <div class="col-sm-5">
42
49
  <ul id="gridright"
43
50
  class="sortable-hidden sortable list kv-connected cursor-move gridsortable" aria-dropeffect="move">
44
- <li data-name="" class="alert alert-info dynagrid-sortable-header disabled">${LANGUAGE.grid_invisible || "Hidden / Fixed Columns"}
51
+ <li data-name="" class="alert alert-info dynagrid-sortable-header disabled">Hidden / Fixed Columns
45
52
  </li>
46
53
  ${invisiblesHtml}
47
54
  </ul>
@@ -51,32 +58,79 @@ Modal.grid = (frameworkcss = "bootstrap5",obj, LANGUAGE={}) => {
51
58
  <input type="hidden" id="serialize_right" name="serialize_right" value=''/>
52
59
  </form>
53
60
  </div> <!-- .dynagrid-config-form -->`,
54
- footer : `<button type="reset" class="btn btn-default refresh gridreload image-button" title="Abort any changes and reset settings">
55
- <img src="/assets/icons/refresh.svg" class="icons-bg-black"> ${LANGUAGE.reset || "Reset"}
61
+ footer : `<button type="reset" class="btn btn-default grid-reset" title="Abort any changes and reset settings">
62
+ <i class="fa fa-refresh"></i> Reset
56
63
  </button>
57
- <button type="button" class="btn btn-primary grid-submit boxy image-button" title="Save grid settings">
58
- <img src="/assets/icons/send.svg" class="icons-bg-white"> ${LANGUAGE.apply || "Apply"}
64
+ <button type="button" class="btn btn-primary grid-submit" title="Save grid settings">
65
+ <i class="fa fa-paper-plane"></i> Apply
59
66
  </button>`
60
67
  });
68
+
69
+
70
+
71
+ var modalLabel = Modal.build({
72
+ id: "grid-labels",
73
+ size : "modal-lg",
74
+ header : `<h5 id="dynagrid-1-grid-modal-label" class="modal-title">
75
+ <i class="fa fa-font fa-fw"></i> Labels Configuration
76
+ </h5>`,
77
+ body : `<div class="dynagrid-config-form">
78
+ <form id="form-labels" class="form-vertical" action="/${obj.routeName}/labels" method="post">
79
+ <input type="hidden" name="_csrf" value="==">
80
+
81
+ <div class="dynagrid-column-label">
82
+ Configure Field Labeling
83
+ </div>
84
+
85
+ <div class="row">
86
+ <div class="col-sm-12">
87
+ <table class="table table-condensed table-striped">
88
+ <thead>
89
+ <tr>
90
+ <th>#</th>
91
+ <th>Fields</th>
92
+ <th>Default</th>
93
+ <th>Custom</th>
94
+ </tr>
95
+ </thead>
96
+ <tbody>
97
+ ${labelsHtml}
98
+ </tbody>
99
+ </table>
100
+ </div>
101
+ </div>
102
+
103
+ </form>
104
+ </div> <!-- .dynagrid-config-form -->`,
105
+ footer : ` <button type="reset" class="btn btn-default label-reset" title="Abort any changes and reset settings">
106
+ <i class="fa fa-refresh"></i> Reset
107
+ </button>
108
+ <button type="button" class="btn btn-primary labels-submit" title="Save grid settings">
109
+ <i class="fa fa-paper-plane"></i> Submit
110
+ </button>`
111
+
112
+ });
113
+
61
114
  try {
62
- return modalFields;
115
+ return modalFields + modalLabel;
63
116
  } catch (err) {
64
117
  console.log(err);
65
118
  }
66
- };
119
+ }
120
+
67
121
 
68
122
  Modal.build = (obj) => {
69
- let html = '<!-- Modal -->';
123
+ var html = '<!-- Modal -->';
70
124
  try {
71
- const size = obj.size ? `${obj.size}` : "";
72
- const id = obj.id ? `id="${obj.id}"` : "";
73
- const headerOptions = Util.attributeOptions(obj.headerOptions || {},{class:"modal-header"});
74
- const header = obj.header ? `<div ${headerOptions} >${obj.header}<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button></div>`:"";
75
- const body = obj.body ? obj.body : "";
76
- const bodyOptions = Util.attributeOptions(obj.bodyOptions || {},{class:"modal-body"});
77
- const footerOptions = Util.attributeOptions(obj.footerOptions || {},{class:"modal-footer"});
78
- const footer = obj.footer ? `<div ${footerOptions} >${obj.footer}</div>` : "";
79
- html += `${Util.newLine}<div class="modal fade " ${id} role="dialog" tabindex="-1">
125
+ var size = obj.size ? `${obj.size}` : "";
126
+ var id = obj.id ? `id="${obj.id}"` : "";
127
+ var headerOptions = Util.attributeOptions(obj.headerOptions || {},{class:"modal-header"});
128
+ var header = obj.header ? `<div ${headerOptions} >${obj.header}<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button></div>`:"";
129
+ var body = obj.body ? obj.body : "";
130
+ var bodyOptions = Util.attributeOptions(obj.bodyOptions || {},{class:"modal-body"});
131
+ var footerOptions = Util.attributeOptions(obj.footerOptions || {},{class:"modal-footer"});
132
+ var footer = obj.footer ? `<div ${footerOptions} >${obj.footer}</div>` : "";
133
+ html += `${Util.newLine}<div class="modal fade" ${id} role="dialog" tabindex="-1">
80
134
  <div class="modal-dialog ${size}">
81
135
  <div class="modal-content">
82
136
  ${header}
@@ -89,7 +143,8 @@ Modal.build = (obj) => {
89
143
  } catch (error) {
90
144
  console.log(error)
91
145
  }
146
+
92
147
  return html;
93
- };
148
+ }
94
149
 
95
150
  module.exports = Modal;
package/lib/Model.js CHANGED
@@ -1,4 +1,9 @@
1
- const Util = require("./Util");
1
+ /**
2
+ * Universal class Model
3
+ * Created by sintret dev on 9/23/2021.
4
+ */
5
+
6
+ const Util = require('./Util');
2
7
 
3
8
  /*
4
9
  properties
@@ -85,7 +90,8 @@ Model.keys = {
85
90
  relation: "Select (relation to other module)",
86
91
  image: "Image Upload",
87
92
  file: "File Upload",
88
- dropzone: "Drop Files",
93
+ dropzone: "DropZone Files",
94
+ dropbox: "DropBox",
89
95
  email: "Email",
90
96
  password: "Password",
91
97
  datepicker: "Date Picker",
@@ -174,6 +180,66 @@ Model.dropzone = {
174
180
  category: "json_array",
175
181
  };
176
182
 
183
+ Model.dropbox = {
184
+ properties: ["required", "unique", "tabindex", "hidden"],
185
+ labels: {
186
+ required: "Required",
187
+ unique: "Unique",
188
+ tabindex: "Tab Index",
189
+ hidden: "Hidden",
190
+ },
191
+ defaultValues: {
192
+ required: false,
193
+ unique: false,
194
+ tabindex: 1,
195
+ hidden: false,
196
+ },
197
+ typies: {
198
+ required: {
199
+ tag: "input",
200
+ type: "checkbox",
201
+ },
202
+ unique: {
203
+ tag: "input",
204
+ type: "checkbox",
205
+ },
206
+ tabindex: {
207
+ tag: "input",
208
+ type: "number",
209
+ },
210
+ hidden: {
211
+ tag: "input",
212
+ type: "checkbox",
213
+ },
214
+ },
215
+ comment: (obj) => {
216
+ return `json_array`;
217
+ },
218
+ sql: (key, MYMODEL, obj = {}) => {
219
+ const required = !obj.required ? "NULL" : "NOT NULL";
220
+ let defaultValue = "";
221
+ if (!obj.defaultValue) {
222
+ defaultValue = ``;
223
+ } else if (obj.defaultValue == "null") {
224
+ defaultValue = `ALTER TABLE "${MYMODEL.table}" ALTER COLUMN "${key}" SET DEFAULT NULL;`;
225
+ } else {
226
+ defaultValue = `ALTER TABLE "${MYMODEL.table}" ALTER COLUMN "${key}" SET DEFAULT '${obj.defaultValue}';`;
227
+ }
228
+ //ALTER TABLE zuser_company ADD CONSTRAINT fk_user_company_role FOREIGN KEY (role_id) REFERENCES zrole (id);
229
+ return {
230
+ defaultValue: defaultValue,
231
+ column: `ALTER TABLE "${MYMODEL.table}" ADD COLUMN "${key}" jsonb[];`,
232
+ index: "",
233
+ foreignKey: "",
234
+ };
235
+ },
236
+ columnType: (obj = {}) => {
237
+ return `json_array`;
238
+ },
239
+ category: "json_array",
240
+ };
241
+
242
+
177
243
  Model.text = {
178
244
  properties: [
179
245
  "required",
@@ -833,6 +899,9 @@ Model.number = {
833
899
  "defaultValue",
834
900
  "inputGroupLeft",
835
901
  "inputGroupRight",
902
+ "digitDecimal",
903
+ "decimalPlaces",
904
+ "thousandSeparator",
836
905
  "information",
837
906
  ],
838
907
  attributes: ["min", "max"],
@@ -846,6 +915,9 @@ Model.number = {
846
915
  defaultValue: "Default Value",
847
916
  inputGroupLeft: "Input Group Left",
848
917
  inputGroupRight: "Input Group Right",
918
+ digitDecimal:"Digit Decimal",
919
+ decimalPlaces:"Decimal Places",
920
+ thousandSeparator:"Use 1000 Separator",
849
921
  information: "Additional Information",
850
922
  },
851
923
  defaultValues: {
@@ -858,6 +930,9 @@ Model.number = {
858
930
  defaultValue: null,
859
931
  inputGroupLeft: "",
860
932
  inputGroupRight: "",
933
+ digitDecimal: 0,
934
+ decimalPlaces:",",
935
+ thousandSeparator:".",
861
936
  information: "",
862
937
  },
863
938
  typies: {
@@ -897,6 +972,18 @@ Model.number = {
897
972
  tag: "input",
898
973
  type: "text",
899
974
  },
975
+ digitDecimal: {
976
+ tag: "input",
977
+ type: "number",
978
+ },
979
+ decimalPlaces: {
980
+ tag: "input",
981
+ type: "text",
982
+ },
983
+ thousandSeparator: {
984
+ tag: "input",
985
+ type: "text",
986
+ },
900
987
  information: {
901
988
  tag: "textarea",
902
989
  type: "",
@@ -3170,6 +3257,35 @@ for (let k in Model.keys) {
3170
3257
  };
3171
3258
  }
3172
3259
 
3260
+
3261
+ //for visibles/invisible select for grid
3262
+ Model[k].properties.push("visibles");
3263
+ Model[k].labels.visibles = "Visibles/Invisibles";
3264
+ Model[k].defaultValues.visibles = 0
3265
+ Model[k].typies.visibles = {
3266
+ tag: "select",
3267
+ type: "",
3268
+ dropdown: {
3269
+ "0": "Invisible",
3270
+ "1": "Visible",
3271
+ },
3272
+ };
3273
+
3274
+
3275
+ //for visibles/invisible select for grid
3276
+ Model[k].properties.push("no_visible");
3277
+ Model[k].labels.no_visible = "Visibles/Invisibles";
3278
+ Model[k].defaultValues.no_visible = 1
3279
+ let idxs = {}
3280
+ for(let i =1; i<=30;i++) {
3281
+ idxs[i]=i
3282
+ }
3283
+ Model[k].typies.no_visible = {
3284
+ tag: "select",
3285
+ type: "",
3286
+ dropdown: idxs,
3287
+ };
3288
+
3173
3289
  //console.log(k)
3174
3290
  }
3175
3291
 
@@ -0,0 +1,24 @@
1
+ module.exports = {
2
+ newLine: '\r\n',
3
+ tab: '\t',
4
+ //table list is not for generate
5
+ notGenerateTable: ['index', 'uploads', 'js', 'css', 'log','generator'],
6
+ //notGenerateTable:[],
7
+ //list is hide for form, maybe for automation
8
+ notRenderField: ['id', 'createdAt', 'updatedAt', 'createdBy', 'updatedBy', 'companyId', 'created_at', 'updated_at','updated_by', 'created_by', 'modified_by', 'company_id', 'token', 'version', 'signin_method', 'lastLogin', 'last_login', 'forgotPassword', 'forgot_password','lock'],
9
+ //images field list
10
+ imagesName: [
11
+ 'image', 'images','logo','file', 'files'
12
+ ],
13
+ commonField: ['full_name', 'name', 'title', 'fullname', 'username', 'firstname', 'firstName', 'code', 'nik', 'employeeName'],
14
+ createdUpdatedBy: ['createdBy', 'updatedBy', 'created_by', 'updated_by'],
15
+ createdUpdatedAt: ['createdAt','updatedAt','created_at','updated_at'],
16
+ timeAt: ['createdAt','updatedAt','created_at','updated_at','modified_at'],
17
+ //your user table for login and session
18
+ userTable: 'zuser',
19
+ userId: 'user_id',
20
+ userFieldName: 'fullname',
21
+ companyId: 'company_id',
22
+ company_id: 'company_id',
23
+ userCompanyTable: 'zuser_company', //blank if not used
24
+ }