zet-lib 3.0.8 → 3.0.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/Form.js +4 -0
- package/lib/Model.js +142 -1
- package/lib/Util.js +5 -3
- package/lib/generatorApi.js +1328 -1328
- package/lib/generatorModel.js +13 -5
- package/lib/moduleLib.js +57 -57
- package/lib/views/generatorjs.ejs +2 -2
- package/lib/views/zgenerator/routerApp.ejs +359 -359
- package/lib/zRoute.js +66 -1
- package/package.json +1 -1
package/lib/zRoute.js
CHANGED
|
@@ -329,6 +329,42 @@ zRoute.post = (req, res, MYMODEL, routeName, body) => {
|
|
|
329
329
|
post[routeName][key] = val ? val : val === 0 ? 0 : null;
|
|
330
330
|
break;
|
|
331
331
|
|
|
332
|
+
case "money":
|
|
333
|
+
if (typeof val == "string" && val.trim() !== "") {
|
|
334
|
+
// Get widget configuration
|
|
335
|
+
const widgetConfig = widgets[key] || {};
|
|
336
|
+
const symbol = widgetConfig.symbol || "";
|
|
337
|
+
const thousandSeparator = widgetConfig.thousandSeparator || ",";
|
|
338
|
+
const decimalPlaces = widgetConfig.decimalPlaces || ".";
|
|
339
|
+
|
|
340
|
+
// Remove symbol if present
|
|
341
|
+
let cleanedVal = val.trim();
|
|
342
|
+
if (symbol && cleanedVal.startsWith(symbol)) {
|
|
343
|
+
cleanedVal = cleanedVal.substring(symbol.length).trim();
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
// Remove thousand separators
|
|
347
|
+
if (thousandSeparator) {
|
|
348
|
+
// Escape special regex characters
|
|
349
|
+
const escapedThousandSep = thousandSeparator.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
350
|
+
cleanedVal = cleanedVal.replace(new RegExp(escapedThousandSep, 'g'), '');
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
// Replace decimal separator with standard dot
|
|
354
|
+
if (decimalPlaces && decimalPlaces !== ".") {
|
|
355
|
+
// Escape special regex characters
|
|
356
|
+
const escapedDecimalSep = decimalPlaces.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
357
|
+
cleanedVal = cleanedVal.replace(escapedDecimalSep, '.');
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
// Convert to number
|
|
361
|
+
const numVal = parseFloat(cleanedVal);
|
|
362
|
+
post[routeName][key] = isNaN(numVal) ? null : numVal;
|
|
363
|
+
} else {
|
|
364
|
+
post[routeName][key] = val ? val : val === 0 ? 0 : null;
|
|
365
|
+
}
|
|
366
|
+
break;
|
|
367
|
+
|
|
332
368
|
case "json_array":
|
|
333
369
|
myval = null;
|
|
334
370
|
if (val) {
|
|
@@ -1272,6 +1308,10 @@ zRoute.dataTableData = (
|
|
|
1272
1308
|
myvalue = Util.formatNumber(value);
|
|
1273
1309
|
break;
|
|
1274
1310
|
|
|
1311
|
+
case "money":
|
|
1312
|
+
myvalue = `${MYMODEL.widgets[key].symbol} ${Util.formatNumber(value, MYMODEL.widgets[key].thousandSeparator)}`;
|
|
1313
|
+
break;
|
|
1314
|
+
|
|
1275
1315
|
case "integer":
|
|
1276
1316
|
myvalue = value + "";
|
|
1277
1317
|
break;
|
|
@@ -3723,7 +3763,10 @@ zRoute.viewForm = (
|
|
|
3723
3763
|
obj[key].value = data[key] || "";
|
|
3724
3764
|
break;
|
|
3725
3765
|
case "number":
|
|
3726
|
-
obj[key].value = data[key] ? Util.formatNumber(data[key], "
|
|
3766
|
+
obj[key].value = data[key] ? Util.formatNumber(data[key], ".") : "";
|
|
3767
|
+
break;
|
|
3768
|
+
case "money":
|
|
3769
|
+
obj[key].value = data[key] ? `${widgets[key].symbol} ${Util.formatNumber(data[key], ".")}` : "";
|
|
3727
3770
|
break;
|
|
3728
3771
|
case "typeahead":
|
|
3729
3772
|
obj[key].type = "text";
|
|
@@ -4127,6 +4170,7 @@ zRoute.generateJS = (req, res, MYMODEL, relations, zForms = "", data = {}) => {
|
|
|
4127
4170
|
let hasAttributes = [];
|
|
4128
4171
|
let joinsFields = [];
|
|
4129
4172
|
let selectize = [];
|
|
4173
|
+
let moneys = [];
|
|
4130
4174
|
if (MYMODEL.joins) {
|
|
4131
4175
|
joinsFields = MYMODEL.joins.list;
|
|
4132
4176
|
}
|
|
@@ -4136,6 +4180,9 @@ zRoute.generateJS = (req, res, MYMODEL, relations, zForms = "", data = {}) => {
|
|
|
4136
4180
|
hasDatePicker = true;
|
|
4137
4181
|
} else if (widgets[key].name == "number") {
|
|
4138
4182
|
hasNumber = true;
|
|
4183
|
+
} else if (widgets[key].name == "money") {
|
|
4184
|
+
hasNumber = true;
|
|
4185
|
+
moneys.push(key);
|
|
4139
4186
|
} else if (widgets[key].name == "clockpicker") {
|
|
4140
4187
|
hasClockPicker = true;
|
|
4141
4188
|
} else if (widgets[key].name == "editor") {
|
|
@@ -4227,6 +4274,24 @@ zRoute.generateJS = (req, res, MYMODEL, relations, zForms = "", data = {}) => {
|
|
|
4227
4274
|
scriptForm += numberObj.script;
|
|
4228
4275
|
headObj.number = numberObj.head;
|
|
4229
4276
|
endObj.number = numberObj.end;
|
|
4277
|
+
if(moneys.length > 0) {
|
|
4278
|
+
let moneyScript = ``
|
|
4279
|
+
moneys.map((money) => {
|
|
4280
|
+
moneyScript += `$('#${money}').formatCurrency({
|
|
4281
|
+
symbol: '${widgets[money].symbol || "" }',
|
|
4282
|
+
decimalSymbol: '${widgets[money].decimalPlaces || "," }',
|
|
4283
|
+
digitGroupSymbol: '${widgets[money].thousandSeparator || "." }',
|
|
4284
|
+
roundToDecimalPlace: ${widgets[money].digitDecimal || 0}
|
|
4285
|
+
});`
|
|
4286
|
+
moneyScript += `$('#${money}').formatCurrencyLive({
|
|
4287
|
+
symbol: '${widgets[money].symbol || "" }',
|
|
4288
|
+
decimalSymbol: '${widgets[money].decimalPlaces || "," }',
|
|
4289
|
+
digitGroupSymbol: '${widgets[money].thousandSeparator || "." }',
|
|
4290
|
+
roundToDecimalPlace: ${widgets[money].digitDecimal || 0}
|
|
4291
|
+
});`
|
|
4292
|
+
})
|
|
4293
|
+
scriptForm += ` $(function() {${moneyScript}});`;
|
|
4294
|
+
}
|
|
4230
4295
|
}
|
|
4231
4296
|
if (hasClockPicker) {
|
|
4232
4297
|
let clockpickerObj = moduleLib.clockpicker(req, res);
|