zet-lib 3.0.5 → 3.0.7

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/zAppRouter.js CHANGED
@@ -622,7 +622,7 @@ router.get("/layout_changes/:layout", access, async (req, res) => {
622
622
  req.session.user.layout = selectedLayout;
623
623
  }
624
624
  res.locals.layout = selectedLayout;
625
- ///global.layout = selectedLayout;
625
+ global.layout = selectedLayout;
626
626
  } catch (err) {
627
627
  debug(req, res, err);
628
628
  }
@@ -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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zet-lib",
3
- "version": "3.0.5",
3
+ "version": "3.0.7",
4
4
  "description": "zet is a library that part of zet generator.",
5
5
  "engines": {
6
6
  "node": ">=18"