zet-lib 1.0.32 → 1.0.34
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/moduleLib.js +1 -1
- package/lib/views/generator_layout.ejs +1 -267
- package/lib/views/generatorjs.ejs +739 -739
- package/lib/zGeneratorRouter.js +10 -7
- package/lib/zRoute.js +22 -13
- package/package.json +1 -1
- package/lib/views/generator.ejs +0 -533
|
@@ -1,811 +1,811 @@
|
|
|
1
1
|
<!-- set to localStorage -->
|
|
2
2
|
<script>
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
var datas = <%- JSON.stringify(JSON.stringify(datas,null,2)) %>;
|
|
4
|
+
var is_approval = "<%- approvalDatas.is_approval %>";
|
|
5
|
+
var sorting = "<%- sorting%>";
|
|
6
6
|
</script>
|
|
7
7
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/ace/1.15.0/ace.js"></script>
|
|
8
8
|
<script>
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
9
|
+
var others = {}
|
|
10
|
+
var container_time = '';
|
|
11
|
+
//end container
|
|
12
|
+
var editor_hardcode_grid = ace.edit("hardcode_grid");
|
|
13
|
+
editor_hardcode_grid.getSession().setMode("ace/mode/javascript");
|
|
14
|
+
var editor_router = ace.edit("router");
|
|
15
|
+
editor_router.getSession().setMode("ace/mode/javascript");
|
|
16
|
+
|
|
17
|
+
var editor_index_ejs = ace.edit("index_ejs");
|
|
18
|
+
editor_index_ejs.getSession().setMode("ace/mode/ejs");
|
|
19
|
+
//editor_index_ejs.setValue(datas.index_ejs);
|
|
20
|
+
|
|
21
|
+
var editor_indexcss_ejs = ace.edit("indexcss_ejs");
|
|
22
|
+
editor_indexcss_ejs.getSession().setMode("ace/mode/ejs");
|
|
23
|
+
//editor_indexcss_ejs.setValue(datas.indexcss_ejs);
|
|
24
|
+
|
|
25
|
+
var editor_indexjs_ejs = ace.edit("indexjs_ejs");
|
|
26
|
+
editor_indexjs_ejs.getSession().setMode("ace/mode/ejs");
|
|
27
|
+
//editor_indexjs_ejs.setValue(datas.indexjs_ejs);
|
|
28
|
+
|
|
29
|
+
var editor_form_ejs = ace.edit("form_ejs");
|
|
30
|
+
editor_form_ejs.getSession().setMode("ace/mode/ejs");
|
|
31
|
+
//editor_form_ejs.setValue(datas.form_ejs);
|
|
32
|
+
|
|
33
|
+
var editor_create_ejs = ace.edit("create_ejs");
|
|
34
|
+
editor_create_ejs.getSession().setMode("ace/mode/ejs");
|
|
35
|
+
//editor_create_ejs.setValue(datas.create_ejs);
|
|
36
|
+
|
|
37
|
+
var editor_createjs_ejs = ace.edit("createjs_ejs");
|
|
38
|
+
editor_createjs_ejs.getSession().setMode("ace/mode/ejs");
|
|
39
|
+
//editor_createjs_ejs.setValue(datas.createjs_ejs);
|
|
40
|
+
|
|
41
|
+
var editor_update_ejs = ace.edit("update_ejs");
|
|
42
|
+
editor_update_ejs.getSession().setMode("ace/mode/ejs");
|
|
43
|
+
//editor_update_ejs.setValue(datas.update_ejs);
|
|
44
|
+
|
|
45
|
+
var editor_updatejs_ejs = ace.edit("updatejs_ejs");
|
|
46
|
+
editor_updatejs_ejs.getSession().setMode("ace/mode/ejs");
|
|
47
|
+
//editor_updatejs_ejs.setValue(datas.updatejs_ejs);
|
|
48
|
+
|
|
49
|
+
var editor_import_ejs = ace.edit("import_ejs");
|
|
50
|
+
editor_import_ejs.getSession().setMode("ace/mode/ejs");
|
|
51
|
+
//editor_import_ejs.setValue(datas.import_ejs);
|
|
52
|
+
|
|
53
|
+
var editor_importjs_ejs = ace.edit("importjs_ejs");
|
|
54
|
+
editor_importjs_ejs.getSession().setMode("ace/mode/ejs");
|
|
55
|
+
//editor_importjs_ejs.setValue(datas.importjs_ejs);
|
|
56
|
+
|
|
57
|
+
var editor_view_ejs = ace.edit("view_ejs");
|
|
58
|
+
editor_view_ejs.getSession().setMode("ace/mode/ejs");
|
|
59
|
+
//editor_view_ejs.setValue(datas.view_ejs);
|
|
60
60
|
</script>
|
|
61
61
|
|
|
62
62
|
<script>
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
63
|
+
var loadForm = function(){
|
|
64
|
+
ajaxPost("/<%- routeName%>/load-form",{
|
|
65
|
+
table : $("#table").val()
|
|
66
|
+
}, function (html) {
|
|
67
|
+
var obj = html.data;
|
|
68
|
+
editor_router.setValue(obj.router);
|
|
69
|
+
editor_index_ejs.setValue(obj.index_ejs);
|
|
70
|
+
editor_indexcss_ejs.setValue(obj.indexcss_ejs);
|
|
71
|
+
editor_indexjs_ejs.setValue(obj.indexjs_ejs);
|
|
72
|
+
editor_form_ejs.setValue(obj.form_ejs);
|
|
73
|
+
editor_create_ejs.setValue(obj.create_ejs);
|
|
74
|
+
editor_createjs_ejs.setValue(obj.createjs_ejs);
|
|
75
|
+
editor_update_ejs.setValue(obj.update_ejs);
|
|
76
|
+
editor_updatejs_ejs.setValue(obj.updatejs_ejs);
|
|
77
|
+
editor_import_ejs.setValue(obj.import_ejs);
|
|
78
|
+
editor_importjs_ejs.setValue(obj.importjs_ejs);
|
|
79
|
+
editor_view_ejs.setValue(obj.view_ejs);
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
82
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
}
|
|
83
|
+
function toName(str, separator) {
|
|
84
|
+
if(str && str.length) {
|
|
85
|
+
separator = separator || "_";
|
|
86
|
+
str = str.trim();
|
|
87
|
+
return str.replace(/\s+/g, separator).toLowerCase();
|
|
89
88
|
}
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
function click_setting(elem) {
|
|
92
|
+
var name = elem.data("name"),
|
|
93
|
+
label = elem.data("label"),
|
|
94
|
+
table = $("#table").val(),
|
|
95
|
+
caption = elem.data("type");
|
|
96
|
+
$("#modal_setting_label").html(`Setting ${label} <span class="badge bg-primary text-dark">${caption}</span>`);
|
|
97
|
+
$("#body_content").html("Loading...");
|
|
98
|
+
$("body").find("#delete_field").attr("data-name", name);
|
|
99
|
+
|
|
100
|
+
ajaxPost("/<%- routeName%>/setting_field",{
|
|
101
|
+
name : name,
|
|
102
|
+
table : table
|
|
103
|
+
}, function (html) {
|
|
104
|
+
$("#body_content").html(html);
|
|
105
|
+
let val = 'id';
|
|
106
|
+
if($("#relation_table").length) {
|
|
107
|
+
dropdownRelations("relation_table", "relation_name", "relation_concat",$("#relation_table").data("value"),$("#relation_name").data("value"), $("#relation_concat").data("value"));
|
|
108
|
+
}
|
|
109
|
+
if($("#typeahead_table").length) {
|
|
110
|
+
val = $("body").find("#typeahead_concat").attr("value");
|
|
111
|
+
dropdownRelations("typeahead_table", "typeahead_name", "typeahead_concat",$("#typeahead_table").data("value"),$("#typeahead_name").data("value"), val);
|
|
112
|
+
}
|
|
113
|
+
if($("#table_table").length) {
|
|
114
|
+
dropdownRelations("table_table", "relation_name","",$("#table_table").data("value"));
|
|
115
|
+
}
|
|
116
|
+
if($("#multi_line_editor_table").length) {
|
|
117
|
+
dropdownRelations("multi_line_editor_table", "relation_name","",$("#multi_line_editor_table").data("value"));
|
|
118
|
+
$(".editor").froalaEditor({height: 400});
|
|
119
|
+
var samp = $("<samp></samp>");
|
|
120
|
+
var text = `<p><h3>List Fields :</h3></p>`;
|
|
121
|
+
text += getFieldsFromTable($("#multi_line_editor_table").val(), name);
|
|
122
|
+
$("#multi_line_editor_table").closest("div").append(samp);
|
|
123
|
+
samp.html(text);
|
|
124
|
+
|
|
125
|
+
$("#multi_line_editor_table").on("change", function () {
|
|
126
|
+
var text = `<p><h3>List Fields :</h3></p>`;
|
|
127
|
+
text += getFieldsFromTable($(this).val(), name);
|
|
128
|
+
samp.html(text);
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
if($("#dropdown_multi_table").length) {
|
|
132
|
+
dropdownRelations("dropdown_multi_table", "dropdown_multi_name","",$("#dropdown_multi_table").data("value"),$("#dropdown_multi_name").data("value"));
|
|
133
|
+
}
|
|
134
|
+
});
|
|
135
|
+
$("#modal_setting").modal("show");
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
function dropdownRelations(elemTable, elemField, elemConcat, value, fieldValue, concatValue) {
|
|
139
|
+
elemTable = elemTable || "relationtable";
|
|
140
|
+
elemField = elemField || "relationfield";
|
|
141
|
+
elemConcat = elemConcat || "relationconcat";
|
|
142
|
+
value = value || "";
|
|
143
|
+
fieldValue = fieldValue || "";
|
|
144
|
+
concatValue = concatValue || "id";
|
|
145
|
+
|
|
146
|
+
let html = '';
|
|
147
|
+
let elementTable = $("body").find("#"+elemTable);
|
|
148
|
+
if(!elementTable.length){
|
|
149
|
+
return;
|
|
150
|
+
}
|
|
151
|
+
let tableHtml = '';
|
|
152
|
+
for(let key in ZFIELDS) {
|
|
153
|
+
let selected = value == key ? " selected " : "";
|
|
154
|
+
tableHtml += `<option value="${key}" ${selected}>${ZFIELDS[key].name}</option>`;
|
|
155
|
+
}
|
|
156
|
+
elementTable.html(tableHtml);
|
|
157
|
+
let currentRelation = elementTable.val();
|
|
158
|
+
let elementField = $("body").find("#"+elemField);
|
|
159
|
+
//var concatValue = "id";
|
|
160
|
+
for(let key in ZFIELDS[currentRelation].labels) {
|
|
161
|
+
let selected = fieldValue == key ? " selected " : "";
|
|
162
|
+
//concatValue = fieldValue == key ? key : "id";
|
|
163
|
+
html += `<option value="${key}" ${selected}>${ZFIELDS[currentRelation].labels[key]}</option>`;
|
|
164
|
+
}
|
|
165
|
+
elementField.html(html);
|
|
166
|
+
$("#"+elemConcat).val(concatValue);
|
|
167
|
+
$("#"+elemConcat).attr("value",concatValue);
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
function getFieldsFromTable(table, name) {
|
|
171
|
+
let html =`<ul class="list-group">`;
|
|
172
|
+
let nots = ["id","company_id","created_by","created_at","updated_by","updated_at"];
|
|
173
|
+
for(let key in ZFIELDS[table].labels) {
|
|
174
|
+
if(nots.indexOf(key) <= -1) {
|
|
175
|
+
html += `<li class="list-group-item"><button onclick="copyToClipboard('[[[${key}_${name}]]]');" type="button" class="btn-copy-code btn btn-outline-grey btn-sm px-2 waves-effect" title="Copy Text" ><i class="fa fa-copy mr-1"></i> ${key} </button> <input type="text" name="${name}[fields][${key}_${name}]" value="${ZFIELDS[table].labels[key]}"></li>`;
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
html += `</ul>`
|
|
179
|
+
return html;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
|
|
183
|
+
$(function () {
|
|
184
|
+
let counter = $(".divtabs").length || 1;
|
|
185
|
+
function selectTable(table) {
|
|
186
|
+
if (!table) return false;
|
|
187
|
+
ajaxPost('/<%- routeName%>/fields',{table: table}, function (json) {
|
|
188
|
+
$("#divfields").show();
|
|
189
|
+
$(".card-script").show();
|
|
190
|
+
$("#results").hide();
|
|
191
|
+
$("#contentfields").html(json.html);
|
|
192
|
+
$("#tabs").html(json.tabview);
|
|
193
|
+
$("#divtablist").html(json.tabBox)
|
|
194
|
+
counter = json.count;
|
|
195
|
+
$("ol.mydragable").sortable({
|
|
196
|
+
group: 'mydragable',
|
|
197
|
+
nested: false,
|
|
198
|
+
//pullPlaceholder: false,
|
|
199
|
+
isValidTarget: function ($item, container) {
|
|
200
|
+
if($item.hasClass("add-container")) {
|
|
201
|
+
return false;
|
|
202
|
+
} else if($item.hasClass("icon-trash")) {
|
|
203
|
+
return false;
|
|
204
|
+
} else {
|
|
205
|
+
return true;
|
|
115
206
|
}
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
$("#multi_line_editor_table").on("change", function () {
|
|
126
|
-
var text = `<p><h3>List Fields :</h3></p>`;
|
|
127
|
-
text += getFieldsFromTable($(this).val(), name);
|
|
128
|
-
samp.html(text);
|
|
129
|
-
});
|
|
207
|
+
},
|
|
208
|
+
onMousedown: function ($item, _super, event) {
|
|
209
|
+
if($(event.target).is("i")) {
|
|
210
|
+
let elem = $(event.target);
|
|
211
|
+
//console.log(elem.attr("class"))
|
|
212
|
+
if(elem.hasClass("modal_setting")) {
|
|
213
|
+
click_setting(elem);
|
|
214
|
+
}
|
|
215
|
+
return false;
|
|
130
216
|
}
|
|
131
|
-
|
|
132
|
-
|
|
217
|
+
return true;
|
|
218
|
+
},
|
|
219
|
+
onDrop: function ($item, container, _super) {
|
|
220
|
+
//class container-nav
|
|
221
|
+
let time = new Date().getTime();
|
|
222
|
+
let $itemclass = $item.attr("class");
|
|
223
|
+
let getidname = $item.parents().attr('id') || "";
|
|
224
|
+
let iname = $item.find('input[type=text]').attr('data-name');
|
|
225
|
+
let containertype = $item.parents().data('name');
|
|
226
|
+
let newname = getidname ? iname + "___" + getidname : iname;
|
|
227
|
+
let leftright = $item.find('input[type=hidden]').attr('name');
|
|
228
|
+
//container-box
|
|
229
|
+
if($itemclass.indexOf('container-nav') > -1) {
|
|
230
|
+
let parentId = $item.parents().parents();
|
|
231
|
+
$item.find('input[type=text]').attr('name', newname);
|
|
232
|
+
$item.find('input[type=hidden]').attr('name', containertype);
|
|
233
|
+
} else {
|
|
234
|
+
$item.find('input[type=text]').attr('name', newname);
|
|
235
|
+
$item.find('input[type=hidden]').attr('name', containertype);
|
|
133
236
|
}
|
|
237
|
+
_super($item, container);
|
|
238
|
+
}
|
|
134
239
|
});
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
function dropdownRelations(elemTable, elemField, elemConcat, value, fieldValue, concatValue) {
|
|
139
|
-
elemTable = elemTable || "relationtable";
|
|
140
|
-
elemField = elemField || "relationfield";
|
|
141
|
-
elemConcat = elemConcat || "relationconcat";
|
|
142
|
-
value = value || "";
|
|
143
|
-
fieldValue = fieldValue || "";
|
|
144
|
-
concatValue = concatValue || "id";
|
|
145
|
-
|
|
146
|
-
let html = '';
|
|
147
|
-
let elementTable = $("body").find("#"+elemTable);
|
|
148
|
-
if(!elementTable.length){
|
|
149
|
-
return;
|
|
150
|
-
}
|
|
151
|
-
let tableHtml = '';
|
|
152
|
-
for(let key in ZFIELDS) {
|
|
153
|
-
let selected = value == key ? " selected " : "";
|
|
154
|
-
tableHtml += `<option value="${key}" ${selected}>${ZFIELDS[key].name}</option>`;
|
|
155
|
-
}
|
|
156
|
-
elementTable.html(tableHtml);
|
|
157
|
-
let currentRelation = elementTable.val();
|
|
158
|
-
let elementField = $("body").find("#"+elemField);
|
|
159
|
-
//var concatValue = "id";
|
|
160
|
-
for(let key in ZFIELDS[currentRelation].labels) {
|
|
161
|
-
let selected = fieldValue == key ? " selected " : "";
|
|
162
|
-
//concatValue = fieldValue == key ? key : "id";
|
|
163
|
-
html += `<option value="${key}" ${selected}>${ZFIELDS[currentRelation].labels[key]}</option>`;
|
|
164
|
-
}
|
|
165
|
-
elementField.html(html);
|
|
166
|
-
$("#"+elemConcat).val(concatValue);
|
|
167
|
-
$("#"+elemConcat).attr("value",concatValue);
|
|
240
|
+
loadForm();
|
|
241
|
+
});
|
|
168
242
|
}
|
|
169
243
|
|
|
170
|
-
function
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
|
|
244
|
+
function buildOneRow(columncount) {
|
|
245
|
+
let html = ``;
|
|
246
|
+
let time = new Date().getTime();
|
|
247
|
+
let col_md = `col-md-${(12 / columncount)}`;
|
|
248
|
+
container_time = `container_${time}`;
|
|
249
|
+
html += `<li class="container-nav"><i class="fa fa-arrows icon-float"></i><div class="row mt-1 mb-1">`;
|
|
250
|
+
for(let i =1; i <= columncount; i++) {
|
|
251
|
+
html += `<div class="${col_md}" style="background-color: rgba(0,0,0,.03)" ><ol class="divboxlittle container-box"><li><i data-container="${container_time}" data-id="${i}" data-split="${columncount}" data-column="ONE_COLUMN" class="fa fa-plus-circle fa-2x add-container text-success"></i></li></ol> </div>`;
|
|
252
|
+
}
|
|
253
|
+
html += `</div></li>`;
|
|
254
|
+
return html;
|
|
180
255
|
}
|
|
181
256
|
|
|
257
|
+
$("#modal-container-save").on("click", function () {
|
|
258
|
+
let columncount = $("#column-count").val();
|
|
259
|
+
let html = buildOneRow(columncount);
|
|
260
|
+
let length = $("ol").length;
|
|
261
|
+
$("ol").eq(length - 1).append(html);
|
|
262
|
+
$(".btn-modal-container-close").click();
|
|
263
|
+
})
|
|
182
264
|
|
|
183
|
-
$(function () {
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
$("#divtablist").html(json.tabBox)
|
|
194
|
-
counter = json.count;
|
|
195
|
-
$("ol.mydragable").sortable({
|
|
196
|
-
group: 'mydragable',
|
|
197
|
-
nested: false,
|
|
198
|
-
//pullPlaceholder: false,
|
|
199
|
-
isValidTarget: function ($item, container) {
|
|
200
|
-
if($item.hasClass("add-container")) {
|
|
201
|
-
return false;
|
|
202
|
-
} else if($item.hasClass("icon-trash")) {
|
|
203
|
-
return false;
|
|
204
|
-
} else {
|
|
205
|
-
return true;
|
|
206
|
-
}
|
|
207
|
-
},
|
|
208
|
-
onMousedown: function ($item, _super, event) {
|
|
209
|
-
if($(event.target).is("i")) {
|
|
210
|
-
let elem = $(event.target);
|
|
211
|
-
//console.log(elem.attr("class"))
|
|
212
|
-
if(elem.hasClass("modal_setting")) {
|
|
213
|
-
click_setting(elem);
|
|
214
|
-
}
|
|
215
|
-
return false;
|
|
216
|
-
}
|
|
217
|
-
return true;
|
|
218
|
-
},
|
|
219
|
-
onDrop: function ($item, container, _super) {
|
|
220
|
-
//class container-nav
|
|
221
|
-
let time = new Date().getTime();
|
|
222
|
-
let $itemclass = $item.attr("class");
|
|
223
|
-
let getidname = $item.parents().attr('id') || "";
|
|
224
|
-
let iname = $item.find('input[type=text]').attr('data-name');
|
|
225
|
-
let containertype = $item.parents().data('name');
|
|
226
|
-
let newname = getidname ? iname + "___" + getidname : iname;
|
|
227
|
-
let leftright = $item.find('input[type=hidden]').attr('name');
|
|
228
|
-
//container-box
|
|
229
|
-
if($itemclass.indexOf('container-nav') > -1) {
|
|
230
|
-
let parentId = $item.parents().parents();
|
|
231
|
-
$item.find('input[type=text]').attr('name', newname);
|
|
232
|
-
$item.find('input[type=hidden]').attr('name', containertype);
|
|
233
|
-
} else {
|
|
234
|
-
$item.find('input[type=text]').attr('name', newname);
|
|
235
|
-
$item.find('input[type=hidden]').attr('name', containertype);
|
|
236
|
-
}
|
|
237
|
-
_super($item, container);
|
|
238
|
-
}
|
|
239
|
-
});
|
|
240
|
-
loadForm();
|
|
241
|
-
});
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
function buildOneRow(columncount) {
|
|
245
|
-
let html = ``;
|
|
246
|
-
let time = new Date().getTime();
|
|
247
|
-
let col_md = `col-md-${(12 / columncount)}`;
|
|
248
|
-
container_time = `container_${time}`;
|
|
249
|
-
html += `<li class="container-nav"><i class="fa fa-arrows icon-float"></i><div class="row mt-1 mb-1">`;
|
|
250
|
-
for(let i =1; i <= columncount; i++) {
|
|
251
|
-
html += `<div class="${col_md}" style="background-color: rgba(0,0,0,.03)" ><ol class="divboxlittle container-box"><li><i data-container="${container_time}" data-id="${i}" data-split="${columncount}" data-column="ONE_COLUMN" class="fa fa-plus-circle fa-2x add-container text-success"></i></li></ol> </div>`;
|
|
252
|
-
}
|
|
253
|
-
html += `</div></li>`;
|
|
254
|
-
return html;
|
|
265
|
+
$("body").on("click",".add-container",function () {
|
|
266
|
+
parentContainer = $(this).closest("ol");
|
|
267
|
+
let options = '';
|
|
268
|
+
let ols = $("ol.mydragable > li");
|
|
269
|
+
let myObj = {}
|
|
270
|
+
ols.each(function () {
|
|
271
|
+
let span = $(this).find("div").find("div").find("span");
|
|
272
|
+
let name = span.data("name");
|
|
273
|
+
if(name) {
|
|
274
|
+
myObj[name] = $(this);
|
|
255
275
|
}
|
|
276
|
+
})
|
|
277
|
+
for(let key in myObj) {
|
|
278
|
+
options += `<option value="${key}">${key}</option>`
|
|
279
|
+
}
|
|
280
|
+
fieldsObjectInput = myObj;
|
|
281
|
+
$("#container-select").html(options);
|
|
282
|
+
$('#modal_container_into').modal('show');
|
|
283
|
+
})
|
|
256
284
|
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
let myObj = {}
|
|
270
|
-
ols.each(function () {
|
|
271
|
-
let span = $(this).find("div").find("div").find("span");
|
|
272
|
-
let name = span.data("name");
|
|
273
|
-
if(name) {
|
|
274
|
-
myObj[name] = $(this);
|
|
275
|
-
}
|
|
276
|
-
})
|
|
277
|
-
for(let key in myObj) {
|
|
278
|
-
options += `<option value="${key}">${key}</option>`
|
|
279
|
-
}
|
|
280
|
-
fieldsObjectInput = myObj;
|
|
281
|
-
$("#container-select").html(options);
|
|
282
|
-
$('#modal_container_into').modal('show');
|
|
283
|
-
})
|
|
284
|
-
|
|
285
|
-
$("#moveintocontainer").on("click", function () {
|
|
286
|
-
let myval = $("#container-select").val();
|
|
287
|
-
if(myval) {
|
|
288
|
-
let myelement = fieldsObjectInput[myval];
|
|
289
|
-
//let myname = `${container_time}___${container_column}___${container_split}___${container_index}`;
|
|
290
|
-
myelement.find('input[type=hidden]').attr('name', 'ONE_COLUMN');
|
|
291
|
-
myelement.appendTo(parentContainer);
|
|
292
|
-
}
|
|
293
|
-
$(".btncontainer-close").click();
|
|
294
|
-
setTimeout(function () {
|
|
295
|
-
saveContainer();
|
|
296
|
-
},2000)
|
|
285
|
+
$("#moveintocontainer").on("click", function () {
|
|
286
|
+
let myval = $("#container-select").val();
|
|
287
|
+
if(myval) {
|
|
288
|
+
let myelement = fieldsObjectInput[myval];
|
|
289
|
+
//let myname = `${container_time}___${container_column}___${container_split}___${container_index}`;
|
|
290
|
+
myelement.find('input[type=hidden]').attr('name', 'ONE_COLUMN');
|
|
291
|
+
myelement.appendTo(parentContainer);
|
|
292
|
+
}
|
|
293
|
+
$(".btncontainer-close").click();
|
|
294
|
+
setTimeout(function () {
|
|
295
|
+
saveContainer();
|
|
296
|
+
},2000)
|
|
297
297
|
|
|
298
|
-
|
|
298
|
+
})
|
|
299
299
|
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
300
|
+
$("#table").on("change", function () {
|
|
301
|
+
location.href = '/<%- routeName%>?table=' + $(this).val();
|
|
302
|
+
loadForm();
|
|
303
|
+
});
|
|
304
304
|
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
305
|
+
$("#generate").on("click", function () {
|
|
306
|
+
ajaxPost('/<%- routeName%>', {
|
|
307
|
+
table: $("#table").val(),
|
|
308
|
+
route: $("#route").val()
|
|
309
|
+
}, function (data) {
|
|
310
|
+
if (data.status == 0) {
|
|
311
|
+
$("#results").hide();
|
|
312
|
+
toastr.error(data.message, data.title);
|
|
313
|
+
} else {
|
|
314
|
+
$("#results").show();
|
|
315
|
+
toastr.success(data.title, data.message);
|
|
316
|
+
$("#resultsbody").html(data.datas);
|
|
317
|
+
}
|
|
318
|
+
$("#divfields").hide();
|
|
319
|
+
});
|
|
320
|
+
});
|
|
321
321
|
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
322
|
+
$("#add").on("click", function () {
|
|
323
|
+
var tabname = $("#tabname");
|
|
324
|
+
var tabsvalue = $("#tabsvalue");
|
|
325
|
+
if (tabname.val() == "") {
|
|
326
|
+
alert("tab name is empty!");
|
|
327
|
+
return false;
|
|
328
|
+
}
|
|
329
|
+
$("#tabs").append("<div class='divtabs'> " + counter + ". " + tabname.val() + " <input type='hidden' name='tabs[]' value='" + tabname.val() + "' /> <button type='button' onclick='$(this).parent().remove();' class='trashtab'><i class='fas fa-trash'></i> </button></div><br>");
|
|
330
|
+
tabname.val("");
|
|
331
|
+
counter++;
|
|
332
|
+
});
|
|
333
333
|
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
334
|
+
$("#savetab").on("click", function () {
|
|
335
|
+
ajaxPost('/<%- routeName%>/tabs',$("#formgenerator").serializeArray(), function (data) {
|
|
336
|
+
if (data.status == 1)
|
|
337
|
+
location.href = ''
|
|
338
|
+
else
|
|
339
|
+
alert(data.title);
|
|
340
|
+
});
|
|
341
|
+
});
|
|
342
342
|
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
}
|
|
376
|
-
});
|
|
343
|
+
function saveFields() {
|
|
344
|
+
let approvers = $("input[name='zapprovals[approvers][]']").map(function(){return $(this).val();}).get();
|
|
345
|
+
let knowings= $("input[name='zapprovals[knowings][]']").map(function(){return $(this).val();}).get();
|
|
346
|
+
others = fixContainer();
|
|
347
|
+
ajaxPost("/<%- routeName%>/save_and_generate",{
|
|
348
|
+
details: $("#formfields").serializeArray(),
|
|
349
|
+
table: $("#table").val(),
|
|
350
|
+
hardcode_grid : editor_hardcode_grid.getValue(),
|
|
351
|
+
router : editor_router.getValue(),
|
|
352
|
+
index_ejs : editor_index_ejs.getValue(),
|
|
353
|
+
indexcss_ejs : editor_indexcss_ejs.getValue(),
|
|
354
|
+
indexjs_ejs : editor_indexjs_ejs.getValue(),
|
|
355
|
+
form_ejs : editor_form_ejs.getValue(),
|
|
356
|
+
create_ejs : editor_create_ejs.getValue(),
|
|
357
|
+
createjs_ejs : editor_createjs_ejs.getValue(),
|
|
358
|
+
update_ejs : editor_update_ejs.getValue(),
|
|
359
|
+
updatejs_ejs : editor_updatejs_ejs.getValue(),
|
|
360
|
+
import_ejs : editor_import_ejs.getValue(),
|
|
361
|
+
importjs_ejs : editor_importjs_ejs.getValue(),
|
|
362
|
+
view_ejs : editor_view_ejs.getValue(),
|
|
363
|
+
is_approval : is_approval,
|
|
364
|
+
template : $("#template").val(),
|
|
365
|
+
approval_title : $("#approval_title").val(),
|
|
366
|
+
type : $("#type").val(),
|
|
367
|
+
approvers : approvers,
|
|
368
|
+
knowings : knowings,
|
|
369
|
+
others: JSON.stringify(others)
|
|
370
|
+
}, function (data) {
|
|
371
|
+
if (data.status == 0) {
|
|
372
|
+
toastr.error(data.message, data.title);
|
|
373
|
+
} else {
|
|
374
|
+
toastr.success(data.title, data.message);
|
|
377
375
|
}
|
|
376
|
+
});
|
|
377
|
+
}
|
|
378
378
|
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
379
|
+
$("#save").on("click", function () {
|
|
380
|
+
saveFields();
|
|
381
|
+
});
|
|
382
|
+
$("#save_script").on("click", function () {
|
|
383
|
+
saveFields();
|
|
384
|
+
});
|
|
385
385
|
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
386
|
+
$(".btn-reset").on("click", function () {
|
|
387
|
+
if(window.confirm("Reset to factory settings ?")) {
|
|
388
|
+
ajaxPost("/<%- routeName%>/reset", {
|
|
389
|
+
table: $("#table").val(),
|
|
390
|
+
}, function (data) {
|
|
391
|
+
if (data.status == 0) {
|
|
392
|
+
toastr.error(data.message, data.title);
|
|
393
|
+
} else {
|
|
394
|
+
toastr.success(data.title, data.message);
|
|
395
|
+
location.href = '';
|
|
396
|
+
}
|
|
397
|
+
});
|
|
398
|
+
}
|
|
399
|
+
})
|
|
400
400
|
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
401
|
+
$(".btn-minify").on("click", function () {
|
|
402
|
+
if(window.confirm("Minify all views in one line make your website faster ?")) {
|
|
403
|
+
ajaxPost("/<%- routeName%>/minify", {
|
|
404
|
+
}, function (data) {
|
|
405
|
+
if (data.status == 0) {
|
|
406
|
+
toastr.error(data.message, data.title);
|
|
407
|
+
} else {
|
|
408
|
+
toastr.success(data.title, data.message);
|
|
409
|
+
}
|
|
410
|
+
});
|
|
411
|
+
}
|
|
412
|
+
});
|
|
413
413
|
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
414
|
+
$(".btn-generate-assets").on("click", function () {
|
|
415
|
+
if(window.confirm("Replace javascript assets with this one ?")) {
|
|
416
|
+
ajaxPost("/<%- routeName%>/generate-assets", {
|
|
417
|
+
}, function (data) {
|
|
418
|
+
if (data.status == 0) {
|
|
419
|
+
toastr.error(data.message, data.title);
|
|
420
|
+
} else {
|
|
421
|
+
toastr.success(data.title, data.message);
|
|
422
|
+
}
|
|
423
|
+
});
|
|
424
|
+
}
|
|
425
|
+
});
|
|
426
426
|
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
427
|
+
selectTable($("#table").val());
|
|
428
|
+
function changeUrl(title, url) {
|
|
429
|
+
var origin = window.location.origin;
|
|
430
|
+
if (typeof (history.pushState) != "undefined") {
|
|
431
|
+
var obj = {Title: title, Url: origin + '/<%- routeName%>?table=' + url};
|
|
432
|
+
window.history.pushState(obj, obj.Title, obj.Url);
|
|
433
|
+
} else {
|
|
434
|
+
alert("Browser does not support HTML5.");
|
|
435
|
+
}
|
|
436
|
+
}
|
|
437
437
|
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
438
|
+
$("#modal-table").on("change", function () {
|
|
439
|
+
$("#modal-route").val(toName($(this).val()));
|
|
440
|
+
});
|
|
441
|
+
$('#modal-table').on('input', function() {
|
|
442
|
+
$("#modal-route").val(toName($(this).val()));
|
|
443
|
+
});
|
|
444
|
+
$("#delete_module").on("click", function () {
|
|
445
|
+
if(window.confirm("sure to delete ?")) {
|
|
446
|
+
ajaxDelete("/<%- routeName%>/delete-table",{table:$("#table").val()}, function (data) {
|
|
447
|
+
toastrForm(data);
|
|
448
|
+
if(data.status == 1) {
|
|
449
|
+
location.href = '/<%- routeName%>';
|
|
450
|
+
}
|
|
451
|
+
});
|
|
452
|
+
}
|
|
453
|
+
});
|
|
454
454
|
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
455
|
+
$("#modal-save").on("click", function () {
|
|
456
|
+
let reservedWord = ['order','left','right','by','zrole','role','zuser','zcompany_access'];
|
|
457
|
+
let moduleName = $("#modal-table").val();
|
|
458
|
+
moduleName = moduleName.toLowerCase();
|
|
459
|
+
let arrModules = reservedWord.filter((item) => item == moduleName);
|
|
460
|
+
if(arrModules.length) {
|
|
461
|
+
toastrForm({
|
|
462
|
+
status : 0,
|
|
463
|
+
title: "Error Module Name reserved",
|
|
464
|
+
message: "Please change your module name"
|
|
465
|
+
})
|
|
466
|
+
return false;
|
|
467
|
+
}
|
|
468
|
+
ajaxPost("/<%- routeName%>",{name:$("#modal-table").val(),route:$("#modal-route").val()}, function (data) {
|
|
469
|
+
toastrForm(data);
|
|
470
|
+
if(data.status == 1) {
|
|
471
|
+
location.href = '/<%- routeName%>?table=' + $("#modal-route").val();
|
|
472
|
+
}
|
|
473
|
+
});
|
|
474
|
+
});
|
|
475
475
|
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
476
|
+
$("#modal-add").on("click", function () {
|
|
477
|
+
let others = fixContainer();
|
|
478
|
+
ajaxPost("/<%- routeName%>/add_field",{
|
|
479
|
+
table:$("#table").val(),
|
|
480
|
+
name:$("#modal_name").val(),
|
|
481
|
+
type:$("#modal_type").val(),
|
|
482
|
+
position:$("#modal_position").val(),
|
|
483
|
+
relationtable:$("#relationtable").val(),
|
|
484
|
+
relationfield:$("#relationfield").val(),
|
|
485
|
+
relationconcat:$("#relationconcat").val(),
|
|
486
|
+
relationfields:$("#relationfields").val(),
|
|
487
|
+
others:JSON.stringify(others)
|
|
488
|
+
}, function (data) {
|
|
489
|
+
$(this).show();
|
|
490
|
+
toastrForm(data);
|
|
491
|
+
if(data.status == 1) {
|
|
492
|
+
var type = $("#modal_type").val();
|
|
493
|
+
location.href = '';
|
|
494
|
+
}
|
|
495
|
+
});
|
|
496
|
+
});
|
|
497
497
|
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
498
|
+
$("body").on("click",".modal_setting", function () {
|
|
499
|
+
click_setting($(this));
|
|
500
|
+
});
|
|
501
501
|
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
502
|
+
$("body").on("click",".select-plus", function () {
|
|
503
|
+
let name = $(this).data("name");
|
|
504
|
+
let item = $(this).data("item");
|
|
505
|
+
let num = $(".group-select").length || 0;
|
|
506
|
+
html = `<div class="input-group group-select"><div class="input-group-prepend">
|
|
507
507
|
<input type="number" class="form-control cvalue" placeholder="Value" name="${name}[${item}][${num}][value]">
|
|
508
508
|
<input type="text" class="form-control clabel" placeholder="Label" name="${name}[${item}][${num}][label]">
|
|
509
509
|
<span class="input-group-text trash-select" data-name="${name}" data-item="${item}"><i class="fa fa-trash text-danger"></i> </span>
|
|
510
510
|
</div></div>`;
|
|
511
511
|
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
$("body").on("click",".trash-select", function () {
|
|
516
|
-
let name = $(this).data("name");
|
|
517
|
-
let item = $(this).data("item");
|
|
518
|
-
$(this).closest(".group-select").remove();
|
|
519
|
-
$(".group-select").each(function (index, value) {
|
|
520
|
-
$(this).closest("div").find("input.cvalue").attr("name",name+"["+item+"]["+index+"][value]");
|
|
521
|
-
$(this).closest("div").find("input.clabel").attr("name",name+"["+item+"]["+index+"][label]");
|
|
522
|
-
});
|
|
523
|
-
});
|
|
524
|
-
|
|
525
|
-
$("body").on("click","#modal-setting-save", function () {
|
|
526
|
-
let datas = $('#modal-setting-form').serializeArray();
|
|
527
|
-
ajaxPost("/<%- routeName%>/save_setting?table="+$("#table").val(), datas, function (data) {
|
|
528
|
-
toastrForm(data);
|
|
529
|
-
if(data.status == 1) {
|
|
530
|
-
$('#modal_setting').modal('hide');
|
|
531
|
-
}
|
|
532
|
-
});
|
|
533
|
-
});
|
|
512
|
+
$(".divselect").append(html);
|
|
513
|
+
});
|
|
534
514
|
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
$(".divrelationfield").hide();
|
|
545
|
-
$(".divconcat").hide();
|
|
546
|
-
$(".divfield").hide();
|
|
547
|
-
dropdownRelations();
|
|
548
|
-
} else if($(this).val() == "multi_line_editor"){
|
|
549
|
-
$(".divrelation").show();
|
|
550
|
-
$(".divrelationfield").hide();
|
|
551
|
-
$(".divconcat").hide();
|
|
552
|
-
$(".divfield").hide();
|
|
553
|
-
dropdownRelations();
|
|
554
|
-
} else if($(this).val() == "dropdown_multi"){
|
|
555
|
-
$(".divrelation").show();
|
|
556
|
-
$(".divrelationfield").show();
|
|
557
|
-
$(".divconcat").show();
|
|
558
|
-
$(".divfield").hide();
|
|
559
|
-
dropdownRelations();
|
|
560
|
-
} else if($(this).val() == "dropdown_chain"){
|
|
561
|
-
$(".divrelation").show();
|
|
562
|
-
$(".divrelationfield").show();
|
|
563
|
-
$(".divconcat").show();
|
|
564
|
-
$(".divfield").show();
|
|
565
|
-
dropdownRelations();
|
|
566
|
-
} else if($(this).val() == "typeahead"){
|
|
567
|
-
$(".divrelation").show();
|
|
568
|
-
$(".divrelationfield").show();
|
|
569
|
-
$(".divconcat").show();
|
|
570
|
-
$(".divfield").hide();
|
|
571
|
-
dropdownRelations();
|
|
572
|
-
} else {
|
|
573
|
-
$(".divrelation").hide();
|
|
574
|
-
$(".divconcat").hide();
|
|
575
|
-
$(".divfield").hide();
|
|
576
|
-
}
|
|
577
|
-
});
|
|
515
|
+
$("body").on("click",".trash-select", function () {
|
|
516
|
+
let name = $(this).data("name");
|
|
517
|
+
let item = $(this).data("item");
|
|
518
|
+
$(this).closest(".group-select").remove();
|
|
519
|
+
$(".group-select").each(function (index, value) {
|
|
520
|
+
$(this).closest("div").find("input.cvalue").attr("name",name+"["+item+"]["+index+"][value]");
|
|
521
|
+
$(this).closest("div").find("input.clabel").attr("name",name+"["+item+"]["+index+"][label]");
|
|
522
|
+
});
|
|
523
|
+
});
|
|
578
524
|
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
}
|
|
589
|
-
});
|
|
525
|
+
$("body").on("click","#modal-setting-save", function () {
|
|
526
|
+
let datas = $('#modal-setting-form').serializeArray();
|
|
527
|
+
ajaxPost("/<%- routeName%>/save_setting?table="+$("#table").val(), datas, function (data) {
|
|
528
|
+
toastrForm(data);
|
|
529
|
+
if(data.status == 1) {
|
|
530
|
+
$('#modal_setting').modal('hide');
|
|
531
|
+
}
|
|
532
|
+
});
|
|
533
|
+
});
|
|
590
534
|
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
535
|
+
$("body").on("change","#modal_type", function () {
|
|
536
|
+
if($(this).val() == "relation") {
|
|
537
|
+
$(".divrelation").show();
|
|
538
|
+
$(".divrelationfield").show();
|
|
539
|
+
$(".divconcat").show();
|
|
540
|
+
$(".divfield").hide();
|
|
541
|
+
dropdownRelations();
|
|
542
|
+
} else if($(this).val() == "table"){
|
|
543
|
+
$(".divrelation").show();
|
|
544
|
+
$(".divrelationfield").hide();
|
|
545
|
+
$(".divconcat").hide();
|
|
546
|
+
$(".divfield").hide();
|
|
547
|
+
dropdownRelations();
|
|
548
|
+
} else if($(this).val() == "multi_line_editor"){
|
|
549
|
+
$(".divrelation").show();
|
|
550
|
+
$(".divrelationfield").hide();
|
|
551
|
+
$(".divconcat").hide();
|
|
552
|
+
$(".divfield").hide();
|
|
553
|
+
dropdownRelations();
|
|
554
|
+
} else if($(this).val() == "dropdown_multi"){
|
|
555
|
+
$(".divrelation").show();
|
|
556
|
+
$(".divrelationfield").show();
|
|
557
|
+
$(".divconcat").show();
|
|
558
|
+
$(".divfield").hide();
|
|
559
|
+
dropdownRelations();
|
|
560
|
+
} else if($(this).val() == "dropdown_chain"){
|
|
561
|
+
$(".divrelation").show();
|
|
562
|
+
$(".divrelationfield").show();
|
|
563
|
+
$(".divconcat").show();
|
|
564
|
+
$(".divfield").show();
|
|
565
|
+
dropdownRelations();
|
|
566
|
+
} else if($(this).val() == "typeahead"){
|
|
567
|
+
$(".divrelation").show();
|
|
568
|
+
$(".divrelationfield").show();
|
|
569
|
+
$(".divconcat").show();
|
|
570
|
+
$(".divfield").hide();
|
|
571
|
+
dropdownRelations();
|
|
572
|
+
} else {
|
|
573
|
+
$(".divrelation").hide();
|
|
574
|
+
$(".divconcat").hide();
|
|
575
|
+
$(".divfield").hide();
|
|
576
|
+
}
|
|
577
|
+
});
|
|
595
578
|
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
location.href = '';
|
|
605
|
-
}
|
|
606
|
-
});
|
|
579
|
+
$("body").on("click","#delete_field", function () {
|
|
580
|
+
let name = $(this).data("name");
|
|
581
|
+
if(window.confirm("sure delete ? ")) {
|
|
582
|
+
ajaxDelete("/<%- routeName%>/delete_field", {name:name, table:$("#table").val()}, function (data) {
|
|
583
|
+
toastrForm(data);
|
|
584
|
+
if(data.status ==1){
|
|
585
|
+
location.href = '';
|
|
586
|
+
}
|
|
607
587
|
});
|
|
588
|
+
}
|
|
589
|
+
});
|
|
608
590
|
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
591
|
+
$("body").on("click",".edittab", function () {
|
|
592
|
+
$("body").find("#edittab").val($(this).data("name"));
|
|
593
|
+
$("body").find("#modal-tab-save").attr("data-id", $(this).data("id"));
|
|
594
|
+
});
|
|
612
595
|
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
596
|
+
$("body").on("click", "#modal-tab-save", function () {
|
|
597
|
+
ajaxPost("/<%- routeName%>/tab_rename",{
|
|
598
|
+
id:$(this).data("id"),
|
|
599
|
+
name:$("body").find("#edittab").val(),
|
|
600
|
+
table : $("#table").val()
|
|
601
|
+
} , function (data) {
|
|
602
|
+
toastrForm(data);
|
|
603
|
+
if(data.status == 1) {
|
|
604
|
+
location.href = '';
|
|
605
|
+
}
|
|
606
|
+
});
|
|
607
|
+
});
|
|
616
608
|
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
609
|
+
$("body").on("change","#relationtable", function () {
|
|
610
|
+
dropdownRelations("relationtable","relationfield","relationconcat",$(this).val(),"", "CONCAT("+$("body").find("#relationfield").val()+")");
|
|
611
|
+
});
|
|
620
612
|
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
$("body").on("change","#dropdown_multi_table", function () {
|
|
625
|
-
dropdownRelations("dropdown_multi_table","dropdown_multi_name","dropdown_multi_concat",$(this).val());
|
|
626
|
-
});
|
|
627
|
-
$("body").on("change","#multi_line_editor_table", function () {
|
|
628
|
-
dropdownRelations("multi_line_editor_table","multi_line_editor_name","multi_line_editor_concat",$(this).val());
|
|
629
|
-
});
|
|
630
|
-
$("body").on("change","#dropdown_chain_table", function () {
|
|
631
|
-
dropdownRelations("dropdown_chain_table","dropdown_chain_name","dropdown_chain_concat",$(this).val());
|
|
632
|
-
});
|
|
613
|
+
$("body").on("change","#relation_table", function () {
|
|
614
|
+
dropdownRelations("relation_table","relation_name","relation_concat",$(this).val(),"", "CONCAT("+$("body").find("#relation_field").val()+")");
|
|
615
|
+
});
|
|
633
616
|
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
$("body").on("change","#relationname", function(){
|
|
638
|
-
$("#relation_concat").val("CONCAT("+$(this).val()+")");
|
|
639
|
-
});
|
|
640
|
-
$("body").on("change","#typeahead_name", function(){
|
|
641
|
-
$("#typeahead_concat").val("CONCAT("+$(this).val()+")");
|
|
642
|
-
});
|
|
643
|
-
$("body").on("change","#dropdown_multi_name", function(){
|
|
644
|
-
$("#dropdown_multi_concat").val("CONCAT("+$(this).val()+")");
|
|
645
|
-
});
|
|
646
|
-
$("body").on("change","#dropdown_chain_name", function(){
|
|
647
|
-
$("#dropdown_chain_concat").val("CONCAT("+$(this).val()+")");
|
|
648
|
-
});
|
|
649
|
-
$("#is_approval").on('switchChange.bootstrapSwitch', function(event,state) {
|
|
650
|
-
if(state===true) {
|
|
651
|
-
$(".divzapprovals").show();
|
|
652
|
-
is_approval = 1;
|
|
653
|
-
} else {
|
|
654
|
-
$(".divzapprovals").hide();
|
|
655
|
-
is_approval = 0;
|
|
656
|
-
}});
|
|
657
|
-
|
|
658
|
-
$(".export-file").on("click", function (e) {
|
|
659
|
-
e.preventDefault();
|
|
660
|
-
let table = $("#route").val();
|
|
661
|
-
ajaxPost("/zgenerator/export",{
|
|
662
|
-
table : table
|
|
663
|
-
},function (data) {
|
|
664
|
-
toastrForm(data);
|
|
665
|
-
if(data.status == 1) {
|
|
666
|
-
location.href = `/zdownload/zgenerator/${table}`;
|
|
667
|
-
}
|
|
668
|
-
})
|
|
669
|
-
});
|
|
617
|
+
$("body").on("change","#relation_name", function () {
|
|
618
|
+
$("#relation_concat").val("CONCAT("+$(this).val()+")");
|
|
619
|
+
});
|
|
670
620
|
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
621
|
+
$("body").on("change","#typeahead_table", function () {
|
|
622
|
+
dropdownRelations("typeahead_table","typeahead_name","typeahead_concat",$(this).val());
|
|
623
|
+
});
|
|
624
|
+
$("body").on("change","#dropdown_multi_table", function () {
|
|
625
|
+
dropdownRelations("dropdown_multi_table","dropdown_multi_name","dropdown_multi_concat",$(this).val());
|
|
626
|
+
});
|
|
627
|
+
$("body").on("change","#multi_line_editor_table", function () {
|
|
628
|
+
dropdownRelations("multi_line_editor_table","multi_line_editor_name","multi_line_editor_concat",$(this).val());
|
|
629
|
+
});
|
|
630
|
+
$("body").on("change","#dropdown_chain_table", function () {
|
|
631
|
+
dropdownRelations("dropdown_chain_table","dropdown_chain_name","dropdown_chain_concat",$(this).val());
|
|
682
632
|
});
|
|
683
633
|
|
|
634
|
+
$("body").on("change","#relationfield", function(){
|
|
635
|
+
$("#relationconcat").val("CONCAT("+$(this).val()+")");
|
|
636
|
+
});
|
|
637
|
+
$("body").on("change","#relationname", function(){
|
|
638
|
+
$("#relation_concat").val("CONCAT("+$(this).val()+")");
|
|
639
|
+
});
|
|
640
|
+
$("body").on("change","#typeahead_name", function(){
|
|
641
|
+
$("#typeahead_concat").val("CONCAT("+$(this).val()+")");
|
|
642
|
+
});
|
|
643
|
+
$("body").on("change","#dropdown_multi_name", function(){
|
|
644
|
+
$("#dropdown_multi_concat").val("CONCAT("+$(this).val()+")");
|
|
645
|
+
});
|
|
646
|
+
$("body").on("change","#dropdown_chain_name", function(){
|
|
647
|
+
$("#dropdown_chain_concat").val("CONCAT("+$(this).val()+")");
|
|
648
|
+
});
|
|
649
|
+
$("#is_approval").on('switchChange.bootstrapSwitch', function(event,state) {
|
|
650
|
+
if(state===true) {
|
|
651
|
+
$(".divzapprovals").show();
|
|
652
|
+
is_approval = 1;
|
|
653
|
+
} else {
|
|
654
|
+
$(".divzapprovals").hide();
|
|
655
|
+
is_approval = 0;
|
|
656
|
+
}});
|
|
657
|
+
|
|
658
|
+
$(".export-file").on("click", function (e) {
|
|
659
|
+
e.preventDefault();
|
|
660
|
+
let table = $("#route").val();
|
|
661
|
+
ajaxPost("/zgenerator/export",{
|
|
662
|
+
table : table
|
|
663
|
+
},function (data) {
|
|
664
|
+
toastrForm(data);
|
|
665
|
+
if(data.status == 1) {
|
|
666
|
+
location.href = `/zdownload/zgenerator/${table}`;
|
|
667
|
+
}
|
|
668
|
+
})
|
|
669
|
+
});
|
|
684
670
|
|
|
685
|
-
$("
|
|
686
|
-
|
|
671
|
+
$("#submit-import").on("click", function () {
|
|
672
|
+
$("#modal-form-file").submit();
|
|
687
673
|
})
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
for(let i =0 ; i < $containerboxsLength; i++){
|
|
715
|
-
//console.log(`$containerboxsLength ${i}`)
|
|
716
|
-
let item = [];
|
|
717
|
-
let $lis = $containerboxs.eq(i).find('li');
|
|
718
|
-
let $lisLength = $lis.length;
|
|
719
|
-
for(let x =1; x < $lisLength;x++) {
|
|
720
|
-
let $name = "";
|
|
721
|
-
if(parent_container_id) {
|
|
722
|
-
let getname= $lis.eq(x).find('input[type=hidden]').val();
|
|
723
|
-
$name = `${getname}___${parent_container_id}`;
|
|
724
|
-
//fixed in tab
|
|
725
|
-
$lis.eq(x).find('input[type=text]').attr('name',$name);
|
|
726
|
-
$lis.eq(x).find('input[type=hidden]').attr('name',name);
|
|
727
|
-
} else {
|
|
728
|
-
$name = $lis.eq(x).find('input[type=text]').attr('data-name');
|
|
729
|
-
$lis.eq(x).find('input[type=text]').attr('name',$name);
|
|
730
|
-
$lis.eq(x).find('input[type=hidden]').attr('name',name);
|
|
731
|
-
}
|
|
732
|
-
item.push($name);
|
|
733
|
-
}
|
|
734
|
-
arr.push(item)
|
|
735
|
-
}
|
|
736
|
-
obj[name].push(arr)
|
|
737
|
-
} else {
|
|
738
|
-
obj[name].push($(this).find("input[type=text]").attr("name"));
|
|
739
|
-
}
|
|
740
|
-
})
|
|
741
|
-
})
|
|
674
|
+
submitForm("modal-form-file", "", "", function (data) {
|
|
675
|
+
toastrForm(data);
|
|
676
|
+
if(data.status == 1) {
|
|
677
|
+
setTimeout(function () {
|
|
678
|
+
location.href = `?table=${data.table}`;
|
|
679
|
+
},1000)
|
|
680
|
+
}
|
|
681
|
+
});
|
|
682
|
+
});
|
|
683
|
+
|
|
684
|
+
|
|
685
|
+
$(".btn-test").on("click", function () {
|
|
686
|
+
fixContainer();
|
|
687
|
+
})
|
|
688
|
+
|
|
689
|
+
function fixContainer() {
|
|
690
|
+
let length = $(".container-nav").length;
|
|
691
|
+
let obj = {}
|
|
692
|
+
let getId = "";
|
|
693
|
+
if(length) {
|
|
694
|
+
$ols = $("ol.mydragable");
|
|
695
|
+
$ols.each(function () {
|
|
696
|
+
getId = $ols.attr("id") ? $ols.attr("id") : "";
|
|
697
|
+
let name = $(this).data("name");
|
|
698
|
+
if(!Object.prototype.hasOwnProperty.call(obj,name)) {
|
|
699
|
+
obj[name] = [];
|
|
742
700
|
}
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
701
|
+
let lis = $(this).children("li");
|
|
702
|
+
lis.each(function () {
|
|
703
|
+
let className = $(this).attr('class') ? $(this).attr('class') : "";
|
|
704
|
+
//console.log(`className ${className}`)
|
|
705
|
+
if(className == "container-nav") {
|
|
706
|
+
let parent_container = $(this).parent("ol.mydragable");
|
|
707
|
+
let parent_container_id = parent_container.attr('id') || "";
|
|
708
|
+
let parent_container_name = parent_container.data('name') || "";
|
|
709
|
+
let child_container = $(this);
|
|
710
|
+
child_container.attr('data-name', parent_container.data('name')).attr('id', parent_container.attr('id'));
|
|
711
|
+
let arr = [];
|
|
712
|
+
let $containerboxs = $(this).find('.container-box');
|
|
713
|
+
let $containerboxsLength = $containerboxs.length;
|
|
714
|
+
for(let i =0 ; i < $containerboxsLength; i++){
|
|
715
|
+
//console.log(`$containerboxsLength ${i}`)
|
|
716
|
+
let item = [];
|
|
717
|
+
let $lis = $containerboxs.eq(i).find('li');
|
|
718
|
+
let $lisLength = $lis.length;
|
|
719
|
+
for(let x =1; x < $lisLength;x++) {
|
|
720
|
+
let $name = "";
|
|
721
|
+
if(parent_container_id) {
|
|
722
|
+
let getname= $lis.eq(x).find('input[type=hidden]').val();
|
|
723
|
+
$name = `${getname}___${parent_container_id}`;
|
|
724
|
+
//fixed in tab
|
|
725
|
+
$lis.eq(x).find('input[type=text]').attr('name',$name);
|
|
726
|
+
$lis.eq(x).find('input[type=hidden]').attr('name',name);
|
|
727
|
+
} else {
|
|
728
|
+
$name = $lis.eq(x).find('input[type=text]').attr('data-name');
|
|
729
|
+
$lis.eq(x).find('input[type=text]').attr('name',$name);
|
|
730
|
+
$lis.eq(x).find('input[type=hidden]').attr('name',name);
|
|
759
731
|
}
|
|
732
|
+
item.push($name);
|
|
733
|
+
}
|
|
734
|
+
arr.push(item)
|
|
760
735
|
}
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
736
|
+
obj[name].push(arr)
|
|
737
|
+
} else {
|
|
738
|
+
obj[name].push($(this).find("input[type=text]").attr("name"));
|
|
739
|
+
}
|
|
740
|
+
})
|
|
741
|
+
})
|
|
766
742
|
}
|
|
743
|
+
console.log(JSON.stringify(obj))
|
|
744
|
+
/* let myobj = {}
|
|
745
|
+
let isContainer = Object.keys(obj).length ? true : false;
|
|
746
|
+
if(isContainer) {
|
|
747
|
+
for(let key in obj) {
|
|
748
|
+
let arr = obj[key] || [];
|
|
749
|
+
if(arr.length) {
|
|
750
|
+
arr.forEach(function (item) {
|
|
751
|
+
if(Array.isArray(item)) {
|
|
752
|
+
let length = item.length;
|
|
753
|
+
if(isEmpty(item)) {
|
|
754
|
+
obj[key].splice(0,1);
|
|
755
|
+
}
|
|
756
|
+
console.log(length)
|
|
757
|
+
}
|
|
758
|
+
})
|
|
759
|
+
}
|
|
760
|
+
}
|
|
761
|
+
}
|
|
762
|
+
console.log(JSON.stringify(obj))*/
|
|
763
|
+
|
|
764
|
+
others = obj;
|
|
765
|
+
return obj;
|
|
766
|
+
}
|
|
767
767
|
|
|
768
768
|
</script>
|
|
769
769
|
|
|
770
770
|
<script>
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
})
|
|
784
|
-
}
|
|
771
|
+
$(function () {
|
|
772
|
+
$(".layout21").on("click",function (e) {
|
|
773
|
+
e.preventDefault();
|
|
774
|
+
if(sorting == "[2,1]"){
|
|
775
|
+
|
|
776
|
+
} else {
|
|
777
|
+
let table = $("#table").val();
|
|
778
|
+
ajaxPost('/<%- routeName%>/sorting',{
|
|
779
|
+
table: table,
|
|
780
|
+
sorting: "[2,1]",
|
|
781
|
+
}, function (dt) {
|
|
782
|
+
location.href = '';
|
|
785
783
|
})
|
|
784
|
+
}
|
|
785
|
+
})
|
|
786
786
|
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
})
|
|
798
|
-
}
|
|
787
|
+
$(".layout12").on("click",function (e) {
|
|
788
|
+
e.preventDefault();
|
|
789
|
+
if(sorting == "[1,2]"){
|
|
790
|
+
} else {
|
|
791
|
+
let table = $("#table").val();
|
|
792
|
+
ajaxPost('/<%- routeName%>/sorting',{
|
|
793
|
+
table: table,
|
|
794
|
+
sorting: "[1,2]",
|
|
795
|
+
}, function (dt) {
|
|
796
|
+
location.href = '';
|
|
799
797
|
})
|
|
800
|
-
|
|
798
|
+
}
|
|
799
|
+
})
|
|
800
|
+
});
|
|
801
801
|
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
802
|
+
function saveContainer() {
|
|
803
|
+
others = fixContainer();
|
|
804
|
+
ajaxPost('/<%- routeName%>/add_container',{
|
|
805
|
+
table: $("#table").val(),
|
|
806
|
+
others: JSON.stringify(others),
|
|
807
|
+
}, function (dt) {
|
|
808
808
|
|
|
809
|
-
|
|
810
|
-
|
|
809
|
+
})
|
|
810
|
+
}
|
|
811
811
|
</script>
|