Allow custom image url for et2_dialog buttons

This commit is contained in:
Hadi Nategh 2021-03-11 12:09:53 +01:00
parent a97416ff5d
commit 72c334be02
2 changed files with 15 additions and 8 deletions

View File

@ -23,6 +23,7 @@ var __extends = (this && this.__extends) || (function () {
}; };
})(); })();
Object.defineProperty(exports, "__esModule", { value: true }); Object.defineProperty(exports, "__esModule", { value: true });
exports.et2_dialog = void 0;
/*egw:uses /*egw:uses
et2_core_widget; et2_core_widget;
/vendor/bower-asset/jquery-ui/jquery-ui.js; /vendor/bower-asset/jquery-ui/jquery-ui.js;
@ -281,7 +282,10 @@ var et2_dialog = /** @class */ (function (_super) {
} }
} }
if (button.image) { if (button.image) {
button.style = 'background-image: url(' + this.egw().image(button.image, 'api') + ')'; button.style = 'background-image: url(' +
(button.image.match('^http|\/') ?
button.image : this.egw().image(button.image, 'api'))
+ ')';
delete button.image; delete button.image;
} }
} }
@ -449,7 +453,7 @@ var et2_dialog = /** @class */ (function (_super) {
et2_dialog.show_dialog = function (_callback, _message, _title, _value, _buttons, _type, _icon, _egw_or_appname) { et2_dialog.show_dialog = function (_callback, _message, _title, _value, _buttons, _type, _icon, _egw_or_appname) {
var parent = et2_dialog._create_parent(_egw_or_appname); var parent = et2_dialog._create_parent(_egw_or_appname);
// Just pass them along, widget handles defaults & missing // Just pass them along, widget handles defaults & missing
return et2_createWidget("dialog", { return et2_core_widget_1.et2_createWidget("dialog", {
callback: _callback || function () { callback: _callback || function () {
}, },
message: _message, message: _message,
@ -471,7 +475,7 @@ var et2_dialog = /** @class */ (function (_super) {
*/ */
et2_dialog.alert = function (_message, _title, _type) { et2_dialog.alert = function (_message, _title, _type) {
var parent = et2_dialog._create_parent(et2_dialog._create_parent().egw()); var parent = et2_dialog._create_parent(et2_dialog._create_parent().egw());
et2_createWidget("dialog", { et2_core_widget_1.et2_createWidget("dialog", {
callback: function () { callback: function () {
}, },
message: _message, message: _message,
@ -493,7 +497,7 @@ var et2_dialog = /** @class */ (function (_super) {
et2_dialog.show_prompt = function (_callback, _message, _title, _value, _buttons, _egw_or_appname) { et2_dialog.show_prompt = function (_callback, _message, _title, _value, _buttons, _egw_or_appname) {
var callback = _callback; var callback = _callback;
// Just pass them along, widget handles defaults & missing // Just pass them along, widget handles defaults & missing
return et2_createWidget("dialog", { return et2_core_widget_1.et2_createWidget("dialog", {
callback: function (_button_id, _value) { callback: function (_button_id, _value) {
if (typeof callback == "function") { if (typeof callback == "function") {
callback.call(this, _button_id, _value.value); callback.call(this, _button_id, _value.value);
@ -583,7 +587,7 @@ var et2_dialog = /** @class */ (function (_super) {
} }
} }
]; ];
var dialog = et2_createWidget("dialog", { var dialog = et2_core_widget_1.et2_createWidget("dialog", {
template: egw.webserverUrl + '/api/templates/default/long_task.xet', template: egw.webserverUrl + '/api/templates/default/long_task.xet',
value: { value: {
content: { content: {
@ -626,7 +630,7 @@ var et2_dialog = /** @class */ (function (_super) {
.appendTo(log); .appendTo(log);
totals.failed++; totals.failed++;
// Ask to retry / ignore / abort // Ask to retry / ignore / abort
et2_createWidget("dialog", { et2_core_widget_1.et2_createWidget("dialog", {
callback: function (button) { callback: function (button) {
switch (button) { switch (button) {
case 'dialog[cancel]': case 'dialog[cancel]':

View File

@ -14,7 +14,7 @@
/vendor/bower-asset/jquery-ui/jquery-ui.js; /vendor/bower-asset/jquery-ui/jquery-ui.js;
*/ */
import {et2_register_widget, WidgetConfig} from "./et2_core_widget"; import {et2_createWidget, et2_register_widget, WidgetConfig} from "./et2_core_widget";
import {et2_widget} from "./et2_core_widget"; import {et2_widget} from "./et2_core_widget";
import {et2_button} from "./et2_widget_button"; import {et2_button} from "./et2_widget_button";
import {ClassWithAttributes} from "./et2_core_inheritance"; import {ClassWithAttributes} from "./et2_core_inheritance";
@ -431,7 +431,10 @@ export class et2_dialog extends et2_widget {
} }
} }
if (button.image) { if (button.image) {
button.style = 'background-image: url(' + this.egw().image(button.image, 'api') + ')'; button.style = 'background-image: url(' +
(button.image.match('^http|\/') ?
button.image : this.egw().image(button.image, 'api'))
+ ')';
delete button.image; delete button.image;
} }
} }