zet-lib 1.0.51 → 1.0.53

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