From f535443a1b7a54bbe12baa8fdf0b144d35803fed Mon Sep 17 00:00:00 2001 From: Fritz Zaucker Date: Thu, 15 Feb 2024 16:08:34 +0100 Subject: [PATCH 1/2] Make foreach function calls consistent --- CHANGES | 3 +++ .../source/class/callbackery/ui/Card.js | 21 ++++++++++++------- .../source/class/callbackery/ui/form/Auto.js | 18 ++++++++-------- 3 files changed, 25 insertions(+), 17 deletions(-) diff --git a/CHANGES b/CHANGES index 4384fd38..10e79620 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,6 @@ + - Translate tooltip and placeholder in Card.js + - Make foreach function calls consistent in Card.js and Auto.js + 0.48.1 2023-12-01 17:32:03 +0100 Tobias Oetiker - use CB_CFG_ as prefix ... this makes more sense than CM_CB diff --git a/lib/CallBackery/qooxdoo/callbackery/source/class/callbackery/ui/Card.js b/lib/CallBackery/qooxdoo/callbackery/source/class/callbackery/ui/Card.js index 54ca1443..fefaa3a8 100644 --- a/lib/CallBackery/qooxdoo/callbackery/source/class/callbackery/ui/Card.js +++ b/lib/CallBackery/qooxdoo/callbackery/source/class/callbackery/ui/Card.js @@ -26,7 +26,7 @@ qx.Class.define("callbackery.ui.Card", { this.__dataCache = {}; this.__actions = []; - cfg.action.forEach(function(action) { + cfg.action.forEach(action => { if (action.addToContextMenu) { this.__actions.push(action); } @@ -111,7 +111,7 @@ qx.Class.define("callbackery.ui.Card", { this._setLayout(layout); // add form elements - formCfg.forEach(function(cfg) { + formCfg.forEach(cfg => { var labelCfg = cfg.label; var fieldCfg = cfg.field; @@ -124,12 +124,12 @@ qx.Class.define("callbackery.ui.Card", { font : 'cardLabel' }); if (labelCfg.set) { + ['value','tooltip'].forEach(key => { + if (key in labelCfg.set){ + labelCfg.set[key] = this.xtr(labelCfg.set[key]); + } + }); label.set(labelCfg.set); - // canot use set({}) with xtr(). - // TODO: fix xtr() return - if (labelCfg.set.value) { - label.setValue(this.xtr(labelCfg.set.value)); - } } this._add(label, labelCfg.addSet); } @@ -145,6 +145,11 @@ qx.Class.define("callbackery.ui.Card", { var fieldClass = qx.Bootstrap.getByName(className); var field = new fieldClass; if (fieldCfg.set) { + ['placeholder','tooltip'].forEach(key => { + if (key in fieldCfg.set){ + fieldCfg.set[key] = this.xtr(fieldCfg.set[key]); + } + }); field.set(fieldCfg.set); } var event; @@ -216,7 +221,7 @@ qx.Class.define("callbackery.ui.Card", { }, this); // add action buttons - this.__actions.forEach(function(action) { + this.__actions.forEach(action => { var btn = this.__createButton(this.xtr(action.label), action.buttonSet.icon); btn.addListener('execute', function() { this.__parentForm.setSelection(this.__dataCache); diff --git a/lib/CallBackery/qooxdoo/callbackery/source/class/callbackery/ui/form/Auto.js b/lib/CallBackery/qooxdoo/callbackery/source/class/callbackery/ui/form/Auto.js index e8f18c18..2fa45510 100644 --- a/lib/CallBackery/qooxdoo/callbackery/source/class/callbackery/ui/form/Auto.js +++ b/lib/CallBackery/qooxdoo/callbackery/source/class/callbackery/ui/form/Auto.js @@ -59,7 +59,7 @@ qx.Class.define("callbackery.ui.form.Auto", { var tm = this._typeMap = {}; var that = this; var formKeyIdx = 0; - structure.forEach(function(s){ + structure.forEach(s => { var options = {}; // value binding in qooxdoo does not like keys // with strange characters ... (like -) @@ -72,7 +72,7 @@ qx.Class.define("callbackery.ui.form.Auto", { this._keyToFormKey[s.key] = formKey; this._formKeyToKey[formKey] = s.key; } - ['note','copyOnTap','copyFailMsg','copySuccessMsg'].forEach(function(prop){ + ['note','copyOnTap','copyFailMsg','copySuccessMsg'].forEach(prop => { if (s[prop]){ options[prop] = qx.lang.Type.isString(s[prop]) || qx.lang.Type.isArray(s[prop]) ? @@ -167,9 +167,9 @@ qx.Class.define("callbackery.ui.form.Auto", { case 'comboBox': control = new qx.ui.form.ComboBox(); var ctrl = this._boxCtrl[s.key] = new qx.data.controller.List(null, control); - cfg.structure.forEach(function(item){ + cfg.structure.forEach(item => { item = item != null ? this.xtr(item) : null; - },this); + }); var sbModel = qx.data.marshal.Json.createModel(cfg.structure || []); ctrl.setModel(sbModel); break; @@ -203,11 +203,11 @@ qx.Class.define("callbackery.ui.form.Auto", { if (s.set.filter){ s.set.filter = RegExp(s.filter); } - ['placeholder','tooltip','label'].forEach(function(key){ + ['placeholder','tooltip','label'].forEach(key => { if (key in s.set){ s.set[key] = this.xtr(s.set[key]); } - }, this); + }); control.set(s.set); } @@ -263,7 +263,7 @@ qx.Class.define("callbackery.ui.form.Auto", { } }); } - },this); + }); var model = this._model = formCtrl.createModel(true); @@ -364,11 +364,11 @@ qx.Class.define("callbackery.ui.form.Auto", { }]); } else { - data.forEach(function(item,i){ + data.forEach((item,i) => { item.title = item.title != null ? this.xtr(item.title) : null; - },this); + }); model = qx.data.marshal.Json.createModel(data); } let lookup = {}; From 6e3caec9e50d607e9e0f85a5fea770e2cefd4766 Mon Sep 17 00:00:00 2001 From: Fritz Zaucker Date: Tue, 27 Feb 2024 09:30:00 +0100 Subject: [PATCH 2/2] Update required flag in form labels on attribute change --- CHANGES | 2 ++ .../class/callbackery/ui/form/renderer/NoteForm.js | 11 +++++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/CHANGES b/CHANGES index e4f4e2ba..098176d0 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,5 @@ + - Update required flag on change of required property + 0.49.2 2024-02-20 09:57:55 +0100 Tobias Oetiker - Add command `showconfig` to show config documentation form Config.pm diff --git a/lib/CallBackery/qooxdoo/callbackery/source/class/callbackery/ui/form/renderer/NoteForm.js b/lib/CallBackery/qooxdoo/callbackery/source/class/callbackery/ui/form/renderer/NoteForm.js index 0858cf7c..5e8db8fa 100644 --- a/lib/CallBackery/qooxdoo/callbackery/source/class/callbackery/ui/form/renderer/NoteForm.js +++ b/lib/CallBackery/qooxdoo/callbackery/source/class/callbackery/ui/form/renderer/NoteForm.js @@ -139,7 +139,7 @@ qx.Class.define("callbackery.ui.form.renderer.NoteForm", { // add the items var msg = callbackery.ui.MsgBox.getInstance(); var that = this; - for (var i = 0; i < items.length; i++) { + for (let i = 0; i < items.length; i++) { (function () { // context let label = that._createLabel(names[i], items[i]); let item = items[i]; @@ -147,7 +147,13 @@ qx.Class.define("callbackery.ui.form.renderer.NoteForm", { marginTop: 2, marginBottom: 2 }); - var labelName = names[i]; + let labelName = names[i]; + + // rerender form to update required flag + item.addListener("changeRequired", (e) => { + that._onChangeLocale(e); + }, that); + // allow form items without label if (label) { @@ -183,6 +189,7 @@ qx.Class.define("callbackery.ui.form.renderer.NoteForm", { }); } that._add(item, { row: that._row + 1, column: 1 }); + if (itemOptions != null && itemOptions[i] != null) { if (itemOptions[i].note) { that._gotNote = true;