Skip to content

EspoCRM – Open Source CRM Application

Use Virtual DOM for header buttons

Yuriib4de4a4ebd10
diff --git a/client/res/templates/header.tpl b/client/res/templates/header.tpl
index e972c71748..244f75b5f9 100644
--- a/client/res/templates/header.tpl
+++ b/client/res/templates/header.tpl
@@ -2,90 +2,5 @@
<div class="{{#if noBreakWords}} no-break-words{{/if}} page-header-column-1">
<h3 class="header-title">{{{header}}}</h3>
</div>
- <div class="page-header-column-2">
- <div class="header-buttons btn-group pull-right{{#if menuItemsHidden}} hidden{{/if}}">
- {{#each items.buttons}}
- <a
- {{#if link}}href="{{link}}"{{else}}role="button"{{/if}}
- tabindex="0"
- class="btn btn-{{#if style}}{{style}}{{else}}default{{/if}} btn-xs-wide main-header-manu-action action{{#if disabled}} disabled{{/if}}{{#if hidden}} hidden{{/if}}{{#if className}} {{className}}{{/if}}"
- data-name="{{name}}"
- data-action="{{action}}"
- {{#each data}} data-{{hyphen @key}}="{{./this}}"{{/each}}
- {{#if title}}title="{{title}}"{{/if}}
- >
- {{#if iconHtml~}}
- {{{iconHtml}}}
- {{~else~}}
- {{#if iconClass}}<span class="{{iconClass}}"></span>{{/if~}}
- {{~/if~}}
- <span>{{#if html}}{{{html}}}{{else}}{{#if text}}{{text}}{{else}}{{translate label scope=../scope}}{{/if}}{{/if}}</span>
- </a>
- {{/each}}
-
- {{#if items.actions}}
- <div class="btn-group" role="group">
- <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">
- {{translate 'Actions'}} <span class="caret"></span>
- </button>
- <ul class="dropdown-menu pull-right">
- {{#each items.actions}}
- <li class="{{#if hidden}}hidden{{/if}}">
- <a
- {{#if link}}href="{{link}}"{{else}}role="button"{{/if}}
- tabindex="0"
- class="action main-header-manu-action{{#if disabled}} disabled{{/if}}"
- data-name="{{name}}"
- data-action="{{action}}"
- {{#each data}} data-{{@key}}="{{./this}}"{{/each}}
- {{#if title}}title="{{title}}"{{/if}}
- >{{#if iconHtml}}{{{iconHtml}}}{{/if}}
- {{#if html}}{{{html}}}{{else}}{{#if text}}{{text}}{{else}}{{translate label scope=../scope}}{{/if}}{{/if}}</a></li>
- {{/each}}
- </ul>
- </div>
- {{/if}}
-
- {{#if items.dropdown}}
- <div class="btn-group dropdown-group{{#unless hasVisibleDropdownItems}} hidden{{/unless}}" role="group">
- <button
- type="button"
- class="btn btn-default dropdown-toggle{{#unless hasVisibleDropdownItems}} hidden{{/unless}}"
- data-toggle="dropdown"
- >
- <span class="fas fa-ellipsis-h"></span>
- </button>
- <ul class="dropdown-menu pull-right">
- {{#each items.dropdown}}
- {{#if this}}
- <li class="{{#if hidden}}hidden{{/if}}">
- <a
- {{#if link}}href="{{link}}"{{else}}role="button"{{/if}}
- tabindex="0"
- class="action main-header-manu-action{{#if disabled}} disabled{{/if}}"
- data-name="{{name}}"
- data-action="{{action}}"
- {{#each data}} data-{{@key}}="{{./this}}"{{/each}}
- >
- {{#if iconHtml}}
- {{{iconHtml}}}
- {{else}}
- {{#if iconClass}}
- <span class="{{iconClass}}"></span>
- {{/if}}
- {{/if}}
- {{#if html}}{{{html}}}{{else}}{{#if text}}{{text}}{{else}}{{translate label scope=../scope}}{{/if}}{{/if}}</a></li>
- {{else}}
- {{#unless @first}}
- {{#unless @last}}
- <li class="divider"></li>
- {{/unless}}
- {{/unless}}
- {{/if}}
- {{/each}}
- </ul>
- </div>
- {{/if}}
- </div>
- </div>
+ <div class="page-header-column-2">{{{buttons}}}</div>
</div>
diff --git a/client/src/components/controls.ts b/client/src/components/controls.ts
index 6df9c398a1..a8a1cfe060 100644
--- a/client/src/components/controls.ts
+++ b/client/src/components/controls.ts
@@ -28,10 +28,11 @@
import Language from 'language';
import {inject} from 'di';
-import {h, VNode} from 'bullbone';
+import {h, VNode, toVNode} from 'bullbone';
interface ButtonOptions {
- name: string;
+ name: string | null;
+ action?: string | null;
style?: 'default' | 'success' | 'danger'| 'warning' | 'info' | 'primary' | 'text' | null;
className?: string | null;
scope?: string | null;
@@ -45,11 +46,12 @@ interface ButtonOptions {
hidden?: boolean;
html?: string | null;
iconHtml?: string | null;
- dataset?: Record<string, unknown>;
+ data?: Record<string, unknown>;
}
interface DropdownItemOptions {
- name: string;
+ name: string | null;
+ action?: string | null;
className?: string | null;
scope?: string | null;
title?: string | null;
@@ -62,7 +64,7 @@ interface DropdownItemOptions {
hidden?: boolean;
html?: string | null;
iconHtml?: string | null;
- dataset?: Record<string, unknown>;
+ data?: Record<string, unknown>;
}
/**
@@ -113,13 +115,13 @@ export class ButtonComponent {
const {content, props} = prepareItemContent(this.options, this.language);
return h(tag, {
- key: this.options.name ?? null,
+ key: this.options.name ?? undefined,
class: classes,
attrs: attrs,
dataset: {
- ...this.options.dataset,
- name: this.options.name,
- action: this.options.name,
+ ...this.options.data,
+ name: this.options.name!,
+ action: this.options.action ?? this.options.name!,
},
props,
}, content);
@@ -175,15 +177,15 @@ export class DropdownItemComponent {
class: classes,
attrs: attrs,
dataset: {
- ...this.options.dataset,
- name: this.options.name,
- action: this.options.name,
+ ...this.options.data,
+ name: this.options.name!,
+ action: this.options.action ?? this.options.name!,
},
props: props,
}, content);
return h('li', {
- key: this.options.name ?? null,
+ key: this.options.name ?? undefined,
class: {
'disabled': this.options.disabled === true,
'hidden': this.options.hidden === true,
@@ -214,13 +216,16 @@ function prepareItemContent(
(
options.labelTranslation ?
language.translatePath(options.labelTranslation) :
- language.translate(label, 'labels', options.scope)
+ language.translate(label ?? '?', 'labels', options.scope)
);
let icon = null;
if (options.iconHtml) {
- icon = h('span', {props: {innerHTML: options.iconHtml}});
+ const div = document.createElement('div');
+ div.innerHTML = options.iconHtml;
+
+ icon = div.firstElementChild ? toVNode(div.firstElementChild) : null;
} else if (options.iconClass) {
icon = h('span', {props: {className: options.iconClass}});
}
diff --git a/client/src/views/detail.ts b/client/src/views/detail.ts
index 343f7412f6..ad52a0f631 100644
--- a/client/src/views/detail.ts
+++ b/client/src/views/detail.ts
@@ -221,7 +221,7 @@ class DetailView<S extends DetailViewSchema = DetailViewSchema> extends MainView
this.listenTo(this.model, 'sync', model => {
if (model && model.hasChanged(this.nameAttribute)) {
- this.getHeaderView()?.reRender();
+ this.getHeaderView()?.reRender({buffer: true});
}
});
}
@@ -632,19 +632,11 @@ class DetailView<S extends DetailViewSchema = DetailViewSchema> extends MainView
}
protected hideAllHeaderActionItems() {
- if (!this.getHeaderView()) {
- return;
- }
-
- this.getHeaderView().hideAllMenuItems();
+ this.getHeaderView()?.hideAllMenuItems();
}
protected showAllHeaderActionItems() {
- if (!this.getHeaderView()) {
- return;
- }
-
- this.getHeaderView().showAllActionItems();
+ this.getHeaderView()?.showAllActionItems();
}
// noinspection JSUnusedGlobalSymbols
diff --git a/client/src/views/header.js b/client/src/views/header.js
index 0e2c6711a6..bc051f30d7 100644
--- a/client/src/views/header.js
+++ b/client/src/views/header.js
@@ -29,11 +29,18 @@
/** @module views/header */
import View from 'view';
+import HeaderButtonsView from 'views/main/header-buttons';
class HeaderView extends View {
template = 'header'
+ /**
+ * @type {string}
+ * @private
+ */
+ scope
+
data() {
const data = {};
@@ -68,6 +75,8 @@ class HeaderView extends View {
setup() {
this.scope = this.options.scope;
+ this.setupButtons();
+
if (this.model) {
this.listenTo(this.model, 'after:save', () => {
if (this.isRendered()) {
@@ -92,10 +101,12 @@ class HeaderView extends View {
*
* @return {Promise}
*/
- hideAllMenuItems() {
+ async hideAllMenuItems() {
this.menuItemsHidden = true;
- return this.reRender({buffer: true});
+ await this.reRenderButtons();
+
+ this.adjustFontSize();
}
/**
@@ -103,10 +114,12 @@ class HeaderView extends View {
*
* @return {Promise}
*/
- showAllActionItems() {
+ async showAllActionItems() {
this.menuItemsHidden = false;
- return this.reRender({buffer: true});
+ await this.reRenderButtons();
+
+ this.adjustFontSize();
}
afterRender() {
@@ -215,6 +228,48 @@ class HeaderView extends View {
getParentMainView() {
return /** @type {import('views/main').default} */this.getParentView();
}
+
+ /**
+ * @private
+ */
+ setupButtons() {
+ const view = new HeaderButtonsView({
+ scope: this.scope ?? this.getParentMainView().scope,
+ dataProvider: () => {
+ const items = this.getItems();
+
+ return {
+ buttons: items.buttons ?? [],
+ actions: items.actions ?? [],
+ dropdown: items.dropdown ?? [],
+ hidden: this.menuItemsHidden,
+ };
+ },
+ });
+
+ this.assignView('buttons', view);
+ }
+
+ /**
+ * @private
+ * @return {HeaderButtonsView}
+ */
+ getButtonsView() {
+ return this.getView('buttons');
+ }
+
+ /**
+ * Re-render buttons.
+ *
+ * @since 10.0.0
+ */
+ async reRenderButtons() {
+ if (!this.isReady) {
+ return;
+ }
+
+ await this.getButtonsView()?.reRender({buffer: true});
+ }
}
export default HeaderView;
diff --git a/client/src/views/main.ts b/client/src/views/main.ts
index e3c86cf6c7..9f8c4243bb 100644
--- a/client/src/views/main.ts
+++ b/client/src/views/main.ts
@@ -33,6 +33,7 @@ import type Model from 'model';
import type Collection from 'collection';
import type {AccessDefs} from 'utils';
import Utils from 'utils';
+import type HeaderView from 'views/header';
/**
* A top-right menu item (button or dropdown action).
@@ -192,7 +193,7 @@ class MainView<S extends MainViewSchema = MainViewSchema> extends View<S> {
actions: (MenuItem | false)[];
}
- private $headerActionsContainer: JQuery
+ //private $headerActionsContainer: JQuery
/**
* A shortcut-key => action map.
@@ -317,18 +318,6 @@ class MainView<S extends MainViewSchema = MainViewSchema> extends View<S> {
this.updateLastUrl();
- this.on('after:render-internal', () => {
- this.$headerActionsContainer = this.$el.find('.page-header .header-buttons');
- });
-
- this.on('header-rendered', () => {
- this.$headerActionsContainer = this.$el.find('.page-header .header-buttons');
-
- this.adjustButtons();
- });
-
- this.on('after:render', () => this.adjustButtons());
-
if (this.shortcutKeys) {
this.shortcutKeys = Utils.cloneDeep(this.shortcutKeys);
} else {
@@ -528,11 +517,10 @@ class MainView<S extends MainViewSchema = MainViewSchema> extends View<S> {
*
* @param name An item name.
* @param item New item definitions to write.
- * @param doNotReRender Skip re-render.
*
* @since 8.2.0
*/
- updateMenuItem(name: string, item: Partial<MenuItem>, doNotReRender: boolean = false) {
+ updateMenuItem(name: string, item: Partial<MenuItem>) {
const actionItem = this._getHeaderActionItem(name);
if (!actionItem) {
@@ -543,11 +531,7 @@ class MainView<S extends MainViewSchema = MainViewSchema> extends View<S> {
(actionItem as any)[key] = (item as any)[key];
}
- if (doNotReRender) {
- return;
- }
-
- this.reRenderHeader();
+ this.getHeaderView()?.reRenderButtons();
}
/**
@@ -556,13 +540,11 @@ class MainView<S extends MainViewSchema = MainViewSchema> extends View<S> {
* @param type A type.
* @param item Item definitions.
* @param toBeginning To beginning.
- * @param doNotReRender Skip re-render.
*/
addMenuItem(
type: 'buttons' | 'dropdown',
item: MenuItem | false,
toBeginning: boolean = false,
- doNotReRender: boolean = false,
) {
const list = this.menu[type];
@@ -612,20 +594,15 @@ class MainView<S extends MainViewSchema = MainViewSchema> extends View<S> {
list.push(item);
}
- if (doNotReRender) {
- return;
- }
-
- this.reRenderHeader();
+ this.getHeaderView()?.reRenderButtons();
}
/**
* Remove a menu item.
*
* @param name An item name.
- * @param doNotReRender Skip re-render.
*/
- removeMenuItem(name: string, doNotReRender: boolean) {
+ removeMenuItem(name: string) {
let index = -1;
let type: 'buttons' | 'dropdown' | 'actions' | false = false;
@@ -646,15 +623,7 @@ class MainView<S extends MainViewSchema = MainViewSchema> extends View<S> {
items.splice(index, 1);
}
- if (!doNotReRender) {
- this.reRenderHeader();
-
- return;
- }
-
- if (doNotReRender && this.isRendered()) {
- this.$headerActionsContainer.find('[data-name="' + name + '"]').remove();
- }
+ this.getHeaderView()?.reRenderButtons();
}
/**
@@ -669,24 +638,7 @@ class MainView<S extends MainViewSchema = MainViewSchema> extends View<S> {
item.disabled = true;
}
- const process = () => {
- this.$headerActionsContainer
- .find(`[data-name="${name}"]`)
- .addClass('disabled')
- .attr('disabled');
- };
-
- if (this.isBeingRendered()) {
- this.whenRendered().then(() => process());
-
- return;
- }
-
- if (!this.isRendered()) {
- return;
- }
-
- process();
+ this.getHeaderView()?.reRenderButtons();
}
/**
@@ -701,24 +653,7 @@ class MainView<S extends MainViewSchema = MainViewSchema> extends View<S> {
item.disabled = false;
}
- const process = () => {
- this.$headerActionsContainer
- .find(`[data-name="${name}"]`)
- .removeClass('disabled')
- .removeAttr('disabled');
- };
-
- if (this.isBeingRendered()) {
- this.whenRendered().then(() => process());
-
- return;
- }
-
- if (!this.isRendered()) {
- return;
- }
-
- process();
+ this.getHeaderView()?.reRenderButtons();
}
// noinspection JSUnusedGlobalSymbols
@@ -772,17 +707,7 @@ class MainView<S extends MainViewSchema = MainViewSchema> extends View<S> {
item.hidden = true;
}
- if (!this.isRendered()) {
- return;
- }
-
- this.$headerActionsContainer.find(`li > .action[data-name="${name}"]`).parent().addClass('hidden');
- this.$headerActionsContainer.find(`a.action[data-name="${name}"]`).addClass('hidden');
-
- this.controlMenuDropdownVisibility();
- this.adjustButtons();
-
- this.getHeaderView()?.trigger('action-item-update');
+ this.getHeaderView()?.reRenderButtons();
}
/**
@@ -790,109 +715,22 @@ class MainView<S extends MainViewSchema = MainViewSchema> extends View<S> {
*
* @param name A name.
*/
- showHeaderActionItem(name: string) {
+ async showHeaderActionItem(name: string) {
const item = this._getHeaderActionItem(name);
if (item) {
item.hidden = false;
}
- const processUi = () => {
- const $dropdownItem = this.$headerActionsContainer.find(`li > .action[data-name="${name}"]`).parent();
- const $button = this.$headerActionsContainer.find(`a.action[data-name="${name}"]`);
-
- // Item can be available but not rendered as it was skipped by access check in getMenu.
- if (item && !$dropdownItem.length && !$button.length) {
- this.reRenderHeader();
-
- return;
- }
+ await this.getHeaderView()?.reRenderButtons();
- $dropdownItem.removeClass('hidden');
- $button.removeClass('hidden');
-
- this.controlMenuDropdownVisibility();
- this.adjustButtons();
-
- this.getHeaderView()?.trigger('action-item-update');
- };
-
- if (!this.isRendered()) {
- if (this.isBeingRendered()) {
- this.whenRendered().then(() => processUi());
- }
-
- return;
- }
-
- processUi();
- }
-
- /**
- * Whether a menu has any non-hidden dropdown items.
- */
- private hasMenuVisibleDropdownItems(): boolean {
- let hasItems = false;
-
- (this.menu.dropdown || []).forEach(item => {
- if (item && !item.hidden) {
- hasItems = true;
- }
- });
-
- return hasItems;
- }
-
- private controlMenuDropdownVisibility() {
- const $group = this.$headerActionsContainer.find('.dropdown-group');
-
- if (this.hasMenuVisibleDropdownItems()) {
- $group.removeClass('hidden');
- $group.find('> button').removeClass('hidden');
-
- return;
- }
-
- $group.addClass('hidden');
- $group.find('> button').addClass('hidden');
- }
-
- protected getHeaderView(): import('views/header').default {
- return this.getView('header') as import('views/header').default;
+ this.getHeaderView()?.trigger('action-item-update');
}
- private adjustButtons() {
- const container = this.$headerActionsContainer.get(0);
-
- const nodes = container?.querySelectorAll<HTMLElement>('.btn');
- if (!nodes) {
- return;
- }
-
- let buttons = [...nodes];
-
- if (!buttons) {
- return;
- }
-
- for (const it of buttons) {
- it.classList.remove('radius-left', 'radius-right');
- }
-
- buttons = buttons.filter(it => !it.classList.contains('hidden'));
-
- for (const [i, it] of buttons.entries()) {
- if (i === 0 || buttons[i - 1].classList.contains('btn-text')) {
- it.classList.add('radius-left');
- }
-
- if (i === buttons.length - 1 || buttons[i + 1].classList.contains('btn-text')) {
- it.classList.add('radius-right');
- }
- }
+ protected getHeaderView(): HeaderView | null {
+ return this.getView('header') as HeaderView | null;
}
-
/**
* Called when a stored view is reused (by the controller).
*
diff --git a/client/src/views/main/header-buttons.ts b/client/src/views/main/header-buttons.ts
new file mode 100644
index 0000000000..b3349fd073
--- /dev/null
+++ b/client/src/views/main/header-buttons.ts
@@ -0,0 +1,245 @@
+/************************************************************************
+ * This file is part of EspoCRM.
+ *
+ * EspoCRM – Open Source CRM application.
+ * Copyright (C) 2014-2026 EspoCRM, Inc.
+ * Website: https://www.espocrm.com
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
+ *
+ * The interactive user interfaces in modified source and object code versions
+ * of this program must display Appropriate Legal Notices, as required under
+ * Section 5 of the GNU Affero General Public License version 3.
+ *
+ * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
+ * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
+ ************************************************************************/
+
+import View from 'view';
+import {MenuItem} from 'views/main';
+import {h, VNode} from 'bullbone';
+import {ButtonComponent, DropdownItemComponent} from 'components/controls';
+import Language from 'language';
+import {inject} from 'di';
+
+export default class HeaderButtonsView extends View<{
+ options: {
+ dataProvider: () => {
+ buttons: MenuItem[],
+ actions: MenuItem[],
+ dropdown: (MenuItem | false)[],
+ hidden: boolean,
+ },
+ scope: string | null,
+ },
+}> {
+
+ readonly useVirtualDom = true
+
+ @inject(Language)
+ private language: Language
+
+ protected data() {
+ return this.options.dataProvider();
+ }
+
+ protected content(): VNode {
+ const data = this.options.dataProvider();
+
+ const actions = data.actions.filter(it => !it.hidden);
+
+ const dropdown = data.dropdown
+ .filter(it => it === false || !it.hidden)
+ .filter((it, i, list) => {
+ if (i === 0) {
+ return true;
+ }
+
+ if (it === false && list[i - 1] === false) {
+ return false;
+ }
+
+ return true;
+ });
+
+ const elements: any[] = [];
+
+ data.buttons.forEach(it => {
+ const className = ('btn-xs-wide main-header-manu-action ' + (it.className ?? '')).trim();
+
+ elements.push(
+ new ButtonComponent({
+ scope: this.options.scope,
+ name: it.name ?? null,
+ action: it.action,
+ link: it.link,
+ text: it.text,
+ label: it.label,
+ labelTranslation: it.labelTranslation,
+ style: it.style,
+ hidden: it.hidden,
+ disabled: it.disabled,
+ data: it.data,
+ title: it.title,
+ iconClass: it.iconClass,
+ iconHtml: it.iconHtml,
+ html: it.html,
+ className: className,
+ }).node()
+ );
+ });
+
+ if (actions.length) {
+ const button = h(
+ 'button',
+ {
+ key: '_actions-dropdown-button',
+ attrs: {type: 'button'},
+ props: {
+ className: 'btn btn-default dropdown-toggle',
+ },
+ dataset: {toggle: 'dropdown'},
+ },
+ [
+ this.language.translate('Actions'),
+ ' ',
+ h('span', {props: {className: 'caret'}})
+ ]
+ );
+
+ const dropdownItems: any[] = [];
+
+ actions.forEach(it => {
+ dropdownItems.push(
+ new DropdownItemComponent({
+ name: it.name ?? null,
+ action: it.action,
+ scope: this.options.scope,
+ label: it.label,
+ labelTranslation: it.labelTranslation,
+ title: it.title,
+ text: it.text,
+ className: 'main-header-manu-action',
+ hidden: it.hidden,
+ disabled: it.disabled,
+ }).node()
+ );
+ });
+
+ const ul = h('ul', {props: {className: 'dropdown-menu pull-right'}}, dropdownItems);
+
+ elements.push(
+ h('div', {props: {className: 'btn-group', role: 'group'}}, [button, ul]),
+ );
+ }
+
+ if (dropdown.length) {
+ const button = h(
+ 'button',
+ {
+ key: '_menu-dropdown-button',
+ attrs: {type: 'button'},
+ props: {
+ className: 'btn btn-default dropdown-toggle',
+ },
+ dataset: {toggle: 'dropdown'},
+ },
+ h('span', {props: {className: 'fas fa-ellipsis-h'}})
+ );
+
+ const dropdownItems: any[] = [];
+
+ dropdown.forEach((it, i) => {
+ if (it === false) {
+ if (i === 0 || i === data.dropdown.length - 1) {
+ return;
+ }
+
+ dropdownItems.push(
+ h('li', {class: {'divider': true}})
+ );
+
+ return;
+ }
+
+ dropdownItems.push(
+ new DropdownItemComponent({
+ name: it.name ?? null,
+ action: it.action,
+ scope: this.options.scope,
+ label: it.label,
+ labelTranslation: it.labelTranslation,
+ title: it.title,
+ text: it.text,
+ className: 'main-header-manu-action',
+ hidden: it.hidden,
+ disabled: it.disabled,
+ }).node()
+ );
+ });
+
+ const ul = h('ul', {props: {className: 'dropdown-menu pull-right'}}, dropdownItems);
+
+ elements.push(
+ h('div', {props: {className: 'btn-group', role: 'group'}}, [button, ul]),
+ );
+ }
+
+ return h('div', {
+ props: {
+ className: 'header-buttons btn-group pull-right',
+ },
+ class: {
+ 'hidden': data.hidden,
+ },
+ }, elements)
+ }
+
+ protected afterRender() {
+ this.adjustButtons();
+ }
+
+ /**
+ * @todo Move to data.
+ */
+ private adjustButtons() {
+ const nodes = this.element.querySelectorAll<HTMLElement>('.btn');
+
+ if (!nodes) {
+ return;
+ }
+
+ let buttons = [...nodes];
+
+ if (!buttons.length) {
+ return;
+ }
+
+ for (const it of buttons) {
+ it.classList.remove('radius-left', 'radius-right');
+ }
+
+ buttons = buttons.filter(it => !it.classList.contains('hidden'));
+
+ for (const [i, it] of buttons.entries()) {
+ if (i === 0 || buttons[i - 1].classList.contains('btn-text')) {
+ it.classList.add('radius-left');
+ }
+
+ if (i === buttons.length - 1 || buttons[i + 1].classList.contains('btn-text')) {
+ it.classList.add('radius-right');
+ }
+ }
+ }
+}
diff --git a/package-lock.json b/package-lock.json
index 299afbdb7b..b116a5a0cd 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -22,7 +22,7 @@
"bootstrap": "github:yurikuzn/espo-bootstrap#0.1.2",
"bootstrap-colorpicker": "^2.5.2",
"bootstrap-datepicker": "^1.9.0",
- "bullbone": "github:espocrm/bullbone#1.5.1",
+ "bullbone": "github:espocrm/bullbone#1.5.2",
"cronstrue": "^1.114.0",
"cropper": "^0.7.9",
"devbridge-autocomplete": "^1.4.11",
@@ -3453,8 +3453,8 @@
}
},
"node_modules/bullbone": {
- "version": "1.5.1",
- "resolved": "git+ssh://[email protected]/espocrm/bullbone.git#86fe3beb41dd9fb752a46091c45a2ee7f6db3eec",
+ "version": "1.5.2",
+ "resolved": "git+ssh://[email protected]/espocrm/bullbone.git#f47f88b1c5bd08d6d2246b00a4d35148c20a802d",
"license": "AGPL",
"dependencies": {
"snabbdom": "^3.6.3"
@@ -11019,8 +11019,8 @@
"dev": true
},
"bullbone": {
- "version": "git+ssh://[email protected]/espocrm/bullbone.git#86fe3beb41dd9fb752a46091c45a2ee7f6db3eec",
- "from": "bullbone@github:espocrm/bullbone#1.5.1",
+ "version": "git+ssh://[email protected]/espocrm/bullbone.git#f47f88b1c5bd08d6d2246b00a4d35148c20a802d",
+ "from": "bullbone@github:espocrm/bullbone#1.5.2",
"requires": {
"snabbdom": "^3.6.3"
}
diff --git a/package.json b/package.json
index b6c87c2203..fd438f99d9 100644
--- a/package.json
+++ b/package.json
@@ -71,7 +71,7 @@
"bootstrap": "github:yurikuzn/espo-bootstrap#0.1.2",
"bootstrap-colorpicker": "^2.5.2",
"bootstrap-datepicker": "^1.9.0",
- "bullbone": "github:espocrm/bullbone#1.5.1",
+ "bullbone": "github:espocrm/bullbone#1.5.2",
"cronstrue": "^1.114.0",
"cropper": "^0.7.9",
"devbridge-autocomplete": "^1.4.11",