Skip to content

Commit

Permalink
Add translations in Card.js (#222)
Browse files Browse the repository at this point in the history
* Add translations in Card.js

* Make foreach calls more consistent

---------

Co-authored-by: Tobias Oetiker <[email protected]>
  • Loading branch information
zaucker and oetiker authored Feb 15, 2024
1 parent bc5f5e8 commit 178aa75
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 18 deletions.
4 changes: 3 additions & 1 deletion CHANGES
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
- Translate tooltip and placeholder in Card.js
- Make foreach function calls consistent in Card.js and Auto.js

0.49.0 2024-01-09 09:45:14 +0100 Tobias Oetiker <[email protected]>

- add new action: openLink
Expand All @@ -9,7 +12,6 @@
features => 'noopener,noreferrer'
}


0.48.1 2023-12-01 17:32:03 +0100 Tobias Oetiker <[email protected]>

- use CB_CFG_ as prefix ... this makes more sense than CM_CB
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down Expand Up @@ -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;

Expand All @@ -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);
}
Expand All @@ -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;
Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 -)
Expand All @@ -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]) ?
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}

Expand Down Expand Up @@ -263,7 +263,7 @@ qx.Class.define("callbackery.ui.form.Auto", {
}
});
}
},this);
});

var model = this._model = formCtrl.createModel(true);

Expand Down Expand Up @@ -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 = {};
Expand Down

0 comments on commit 178aa75

Please sign in to comment.