zet-lib 3.0.6 → 3.0.8

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.
@@ -177,12 +177,12 @@ router.post("/fields", async (req, res) => {
177
177
  let othersArr = Object.keys(others) || [];
178
178
  let json = {}
179
179
  if(othersArr.length) {
180
- console.log('masuk ke container')
181
- json = await Api.modalWithContainer(objData);
180
+ console.log('masuk ke container')
181
+ json = await Api.modalWithContainer(objData);
182
182
  } else {
183
- json = await Api.modalClassic(objData);
183
+ json = await Api.modalClassic(objData);
184
184
  }
185
-
185
+
186
186
  res.json(json);
187
187
  } catch (e) {
188
188
  console.log(e);
@@ -1132,6 +1132,28 @@ router.post("/save_setting", async (req, res) => {
1132
1132
  return res.json(Util.flashError("Table is locked"));
1133
1133
  }
1134
1134
  const post = req.body;
1135
+ for(let key in post) {
1136
+ for(let q in post[key]){
1137
+ if(q == "select"){
1138
+ let selects = post[key][q] || []
1139
+ if(selects.length){
1140
+ // Validasi setiap item harus memiliki value dan label yang terisi
1141
+ for(let i = 0; i < selects.length; i++){
1142
+ const item = selects[i];
1143
+ if(!item || typeof item !== 'object'){
1144
+ return res.json(Util.flashError(`Select item at index ${i} must be an object`));
1145
+ }
1146
+ if(!item.hasOwnProperty('value') || item.value === null || item.value === undefined || item.value === ''){
1147
+ return res.json(Util.flashError(`Select item at index ${i} must have a non-empty value`));
1148
+ }
1149
+ if(!item.hasOwnProperty('label') || item.label === null || item.label === undefined || item.label === ''){
1150
+ return res.json(Util.flashError(`Select item at index ${i} must have a non-empty label`));
1151
+ }
1152
+ }
1153
+ }
1154
+ }
1155
+ }
1156
+ }
1135
1157
  let data = await connection.result({
1136
1158
  table: "zfields",
1137
1159
  where: { table: table },
package/lib/zRoute.js CHANGED
@@ -400,6 +400,9 @@ zRoute.attributeData = async (res, MYMODEL, obj) => {
400
400
  if (MYMODEL.widgets[key].name == "custom") {
401
401
  customs.push(key);
402
402
  }
403
+ if (MYMODEL.widgets[key].name == "html") {
404
+ customs.push(key);
405
+ }
403
406
  }
404
407
  if (customs.length) {
405
408
  visibles = visibles.filter((item) => !customs.includes(item));
@@ -3103,6 +3106,10 @@ zRoute.forms = (
3103
3106
  case "tags":
3104
3107
  obj.type = "tags";
3105
3108
  break;
3109
+ case "html":
3110
+ obj.type = "html";
3111
+ obj.code = widgets[key].code || ""
3112
+ break;
3106
3113
  case "checkbox":
3107
3114
  obj.type = "checkbox";
3108
3115
  break;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zet-lib",
3
- "version": "3.0.6",
3
+ "version": "3.0.8",
4
4
  "description": "zet is a library that part of zet generator.",
5
5
  "engines": {
6
6
  "node": ">=18"