mirror of
https://github.com/espocrm/espocrm.git
synced 2026-06-28 06:56:05 +00:00
Icon only actions
This commit is contained in:
@@ -236,13 +236,13 @@ function prepareItemContent(
|
||||
props.innerHTML = options.iconHtml + props.innerHTML;
|
||||
}
|
||||
} else {
|
||||
const label = options.label ?? options.name;
|
||||
const label = options.label;
|
||||
|
||||
let text = options.text ??
|
||||
(
|
||||
options.labelTranslation ?
|
||||
language.translatePath(options.labelTranslation) :
|
||||
language.translate(label ?? '?', 'labels', options.scope)
|
||||
language.translate(label ?? '', 'labels', options.scope)
|
||||
);
|
||||
|
||||
let icon = null;
|
||||
@@ -258,8 +258,10 @@ function prepareItemContent(
|
||||
|
||||
if (isDropdownItem) {
|
||||
text = h('span', {props: {className: 'item-text'}}, text);
|
||||
} else if (icon) {
|
||||
text = h('span', text);
|
||||
} else {
|
||||
if (icon && text) {
|
||||
text = h('span', text);
|
||||
}
|
||||
}
|
||||
|
||||
content = icon ?
|
||||
|
||||
@@ -129,7 +129,7 @@ class ActionItemSetupHelper {
|
||||
actionDefsList.forEach(item => {
|
||||
const name = item.name;
|
||||
|
||||
if (!item.label && !item.labelTranslation) {
|
||||
if (!item.label && !item.labelTranslation && !item.iconClass) {
|
||||
item.text = this.language.translate(name, 'actions', scope);
|
||||
}
|
||||
|
||||
|
||||
@@ -496,8 +496,6 @@ class ModalView<S extends ViewSchema = ViewSchema> extends View<S> {
|
||||
o.text = this.getLanguage().translatePath(o.labelTranslation);
|
||||
} else if ('label' in o) {
|
||||
o.text = this.translate(o.label, 'labels', this.scope);
|
||||
} else {
|
||||
o.text = this.translate(o.name, 'modalActions', this.scope);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -508,8 +506,14 @@ class ModalView<S extends ViewSchema = ViewSchema> extends View<S> {
|
||||
if (o.iconHtml && !o.html) {
|
||||
o.html = o.iconHtml + '<span>' + this.getHelper().escapeString(o.text as string) + '</span>';
|
||||
} else if (o.iconClass && !o.html) {
|
||||
o.html = `<span class="${o.iconClass}"></span>` +
|
||||
'<span>' + this.getHelper().escapeString(o.text as string) + '</span>';
|
||||
if (o.text) {
|
||||
o.html = `<span class="${o.iconClass}"></span>` +
|
||||
'<span>' + this.getHelper().escapeString(o.text as string) + '</span>';
|
||||
} else {
|
||||
o.html = `<span class="${o.iconClass}"></span>`;
|
||||
|
||||
o.className = 'btn-icon';
|
||||
}
|
||||
}
|
||||
|
||||
o.onClick = o.onClick ?? ((_d, event) => {
|
||||
@@ -550,8 +554,6 @@ class ModalView<S extends ViewSchema = ViewSchema> extends View<S> {
|
||||
o.text = this.getLanguage().translatePath(o.labelTranslation);
|
||||
} else if ('label' in o) {
|
||||
o.text = this.translate(o.label, 'labels', this.scope)
|
||||
} else {
|
||||
o.text = this.translate(o.name, 'modalActions', this.scope);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -51,6 +51,14 @@ export default class DetailRecordButtonsView extends View<{
|
||||
const buttons: any[] = [];
|
||||
|
||||
data.buttonList.forEach(it => {
|
||||
let className = this.options.actionClassName;
|
||||
|
||||
if (it.iconClass && !(it.label || it.labelTranslation || it.text || it.html)) {
|
||||
className += ' btn-icon';
|
||||
} else {
|
||||
className += ' btn-xs-wide';
|
||||
}
|
||||
|
||||
buttons.push(
|
||||
new ButtonComponent({
|
||||
name: it.name,
|
||||
@@ -62,7 +70,7 @@ export default class DetailRecordButtonsView extends View<{
|
||||
title: it.title,
|
||||
titleTranslation: it.titleTranslation,
|
||||
text: it.text,
|
||||
className: data.buttonClassName,
|
||||
className: className,
|
||||
hidden: it.hidden,
|
||||
disabled: it.disabled || data.allDisabled,
|
||||
iconClass: it.iconClass,
|
||||
@@ -150,7 +158,6 @@ export default class DetailRecordButtonsView extends View<{
|
||||
buttonList: data.buttonList.filter(it => !it.hidden),
|
||||
dropdownItemList: dropdownItemList,
|
||||
entityType: this.options.entityType,
|
||||
buttonClassName: 'btn-xs-wide ' + this.options.actionClassName,
|
||||
actionClassName: this.options.actionClassName,
|
||||
dropdownEmpty: dropdownEmpty,
|
||||
allDisabled: data.allDisabled,
|
||||
|
||||
Reference in New Issue
Block a user