Skip to content

Commit

Permalink
release 0.47.3
Browse files Browse the repository at this point in the history
- sync action menu button properties with normal buttons
- set table column with to work on mobile
  • Loading branch information
oetiker committed Aug 29, 2023
1 parent c82c660 commit 48522b2
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 16 deletions.
8 changes: 8 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
0.47.3 2023-08-29 16:20:30 +0200 Tobias Oetiker <tobi@oetiker.ch>

- make table columns with flex with work on mobile devices

0.47.2 2023-08-29 14:14:54 +0200 Tobias Oetiker <tobi@oetiker.ch>

- connect mmButton properties to button propperties

0.47.1 2023-08-29 12:04:49 +0200 Tobias Oetiker <tobi@oetiker.ch>

- include callbackery.ui.form.FileSelectorMenuButton into distro
Expand Down
2 changes: 1 addition & 1 deletion lib/CallBackery.pm
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ use CallBackery::Plugin::Doc;
use CallBackery::Database;
use CallBackery::User;

our $VERSION = '0.47.1';
our $VERSION = '0.47.3';


=head2 config
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ qx.Class.define("callbackery.ui.plugin.Action", {
this._plugin = plugin;
this._urlActions = [];
this._buttonMap = {};
this._mmButtonMap = {};
this._buttonSetMap = {};
this._cfg = cfg;
this._populate(cfg, buttonClass, getFormData);
Expand Down Expand Up @@ -116,7 +115,6 @@ qx.Class.define("callbackery.ui.plugin.Action", {
_tableMenu: null,
_defaultAction: null,
_buttonMap: null,
_mmButtonMap: null,
_urlActions: null,
_mobileMenu: null,
_print(content, left, top) {
Expand Down Expand Up @@ -174,10 +172,9 @@ qx.Class.define("callbackery.ui.plugin.Action", {
+ (btCfg.testingIdPostfix ? btCfg.testingIdPostfix : '')
+ 'mmButton';
this.addOwnedQxObject(mmButton, mmBtnId);
this._mmButtonMap[btCfg.key] = mmButton;
}
this._bindButtonPropperties(button, mmButton);
return;
break;
case 'save':
case 'submitVerify':
case 'submit':
Expand All @@ -196,7 +193,6 @@ qx.Class.define("callbackery.ui.plugin.Action", {
}
if (btCfg.key) {
this._buttonMap[btCfg.key] = button;
this._mmButtonMap[btCfg.key] = mmButton;
let urlAction = btCfg.urlAction;
if (urlAction) {
this._urlActions.push({
Expand Down Expand Up @@ -278,8 +274,15 @@ qx.Class.define("callbackery.ui.plugin.Action", {
}, this);
break;
case 'upload':
button = this._makeUploadButton(cfg, btCfg, getFormData);
mmButton = this._makeUploadButton(cfg, btCfg, getFormData, callbackery.ui.form.FileSelectorMenuButton);
button = this._makeUploadButton(cfg, btCfg, getFormData,
buttonClass == qx.ui.toolbar.Button
? qx.ui.toolbar.FileSelectorButton
: qx.ui.form.FileSelectorButton);
mmButton = this._makeUploadButton(cfg, btCfg, getFormData,
callbackery.ui.form.FileSelectorMenuButton);
if (btCfg.key) {
this._buttonMap[btCfg.key] = button;
}
break;
case 'separator':
this.add(new qx.ui.core.Spacer(10, 10));
Expand Down Expand Up @@ -488,20 +491,20 @@ qx.Class.define("callbackery.ui.plugin.Action", {
menuButton.addListener('execute', action, this);
tm.add(menuButton);
}
if (button && menuButton) {
this._bindButtonProperties(button, mmButton);
}
}, this);
},
_makeUploadButton(cfg, btCfg, getFormData, buttonClass) {
var button;
var label = btCfg.label ? this.xtr(btCfg.label) : null;
if (buttonClass === qx.ui.toolbar.Button) {
button = new qx.ui.toolbar.FileSelectorButton(label);
if (buttonClass) {
button = new buttonClass(label);
}
else {
button = new qx.ui.form.FileSelectorButton(label);
}
if (btCfg.key) {
this._buttonMap[btCfg.key] = button;
}
if (btCfg.buttonSet) {
var bs = btCfg.buttonSet;
if (bs.label) {
Expand Down Expand Up @@ -595,6 +598,11 @@ qx.Class.define("callbackery.ui.plugin.Action", {
},
getButtonSetMap() {
return this._buttonSetMap;
},
_bindButtonProperties(button, mmButton) {
['visibility', 'enabled', 'label', 'icon'].forEach((prop) => {
button.bind(prop, mmButton, prop);
});
}
},

Expand All @@ -605,5 +613,6 @@ qx.Class.define("callbackery.ui.plugin.Action", {
for (const [key, btn] of Object.entries(this._buttonMap)) {
btn.destroy();
}
}
},

});
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,45 @@ qx.Class.define('callbackery.ui.plugin.Table', {
if ('visible' in col) {
tcm.setColumnVisible(i, col.visible);
}
if (col.width != null) {
resizeBehavior.setWidth(i, String(col.width));
});

let setColumnResizeBehavior = () => {
let flexList = [];
let totalFlex = 0;
cfg.table.forEach((col, i) => {
if (tcm.isColumnVisible(i) && col.width) {
let match = String(col.width).match(/^(\d+)\*/);
if (match) {
let flex = parseInt(match[1]);
totalFlex += flex;
flexList[i] = flex;
}
}
});
let width = this.getBounds().width;
let cols = tcm.getVisibleColumnCount();
if (width / cols < 100) {
let oneFlex = cols * 100 / totalFlex;
cfg.table.forEach((col, i) => {
if (flexList[i]) {
resizeBehavior.setWidth(i, Math.round(oneFlex * flexList[i]));
}
});
}
else {
cfg.table.forEach((col, i) => {
if (col.width) {
resizeBehavior.setWidth(i, col.width);
}
});
}
};
this.addListener('resize', () => {
setColumnResizeBehavior();
});

table.addListener('columnVisibilityChanged', () => {
setColumnResizeBehavior();
});

var selectionModel = table.getSelectionModel();
Expand Down

0 comments on commit 48522b2

Please sign in to comment.