- Модуль: crm
- Путь к файлу: ~/bitrix/modules/crm/lib/component/itemlist.php
- Класс: Bitrix\Crm\Component\ItemList
- Вызов: ItemList::getToolbarParameters
protected function getToolbarParameters(): array
{
$buttons = [];
$spotlight = null;
$container = Service\Container::getInstance();
$dynamicTypesLimit = RestrictionManager::getDynamicTypesLimitRestriction();
$isTypeSettingsRestricted = $dynamicTypesLimit->isTypeSettingsRestricted($this->entityTypeId);
$category = $this->category;
if (!$category && $this->factory->isCategoriesSupported())
{
$category = $this->factory->getDefaultCategory();
}
$isEnabled = $container->getUserPermissions()->checkAddPermissions(
$this->entityTypeId,
$category ? $category->getId() : null
);
$addButtonParameters = $this->getAddButtonParameters(!$isEnabled);
if ($isTypeSettingsRestricted)
{
$addButtonParameters['onclick'] = $isEnabled ? $dynamicTypesLimit->getShowFeatureJsHandler() : null;
unset($addButtonParameters['link']);
}
$buttons[Toolbar\ButtonLocation::AFTER_TITLE][] = new Buttons\Button($addButtonParameters);
if ($this->factory->isCategoriesEnabled())
{
$categories = $this->userPermissions->filterAvailableForReadingCategories(
$this->factory->getCategories()
);
if (
count($categories) > 1
|| Container::getInstance()->getUserPermissions()->canWriteConfig()
)
{
$buttonConfig = [
'icon' => defined('Bitrix\UI\Buttons\Icon::FUNNEL') ? Icon::FUNNEL : '',
'color' => Buttons\Color::LIGHT_BORDER,
'className' => 'ui-btn ui-btn-themes ui-btn-light-border ui-btn-dropdown ui-toolbar-btn-dropdown',
'text' => $this->category ? $this->category->getName() : Loc::getMessage('CRM_TYPE_TOOLBAR_ALL_ITEMS'),
'menu' => [
'items' => $this->getToolbarCategories($categories), //Tools\ToolBar::mapItems(),
],
'maxWidth' => '400px',
'dataset' => [
'role' => 'bx-crm-toolbar-categories-button',
'entity-type-id' => $this->factory->getEntityTypeId(),
'category-id' => $this->category ? $this->category->getId() : null,
'toolbar-collapsed-icon' => defined('Bitrix\UI\Buttons\Icon::FUNNEL') ? Icon::FUNNEL : '',
],
];
if ($this->factory->isCountersEnabled())
{
$counterValue = $this->getCounterValue(null);
if ($counterValue > 0)
{
$buttonConfig['counter'] = $counterValue;
}
}
$buttons[Toolbar\ButtonLocation::AFTER_TITLE][] = new Buttons\Button($buttonConfig);
}
}
$settingsItems = $this->getToolbarSettingsItems();
// a bit of hardcode to avoid components copying
if (
$this->entityTypeId === \CCrmOwnerType::SmartInvoice
&& !InvoiceSettings::getCurrent()->isOldInvoicesEnabled()
&& Container::getInstance()->getUserPermissions()->canReadType(\CCrmOwnerType::Invoice)
)
{
$settingsItems[] = [
'text' => \CCrmOwnerType::GetCategoryCaption(\CCrmOwnerType::Invoice),
'href' => Container::getInstance()->getRouter()->getItemListUrlInCurrentView(\CCrmOwnerType::Invoice),
'onclick' => new Buttons\JsHandler('BX.Crm.Router.Instance.closeSettingsMenu'),
];
if (InvoiceSettings::getCurrent()->isShowInvoiceTransitionNotice())
{
$spotlight = [
'ID' => 'crm-old-invoices-transition',
'JS_OPTIONS' => [
'targetElement' => static::TOOLBAR_SETTINGS_BUTTON_ID,
'content' => Loc::getMessage('CRM_COMPONENT_ITEM_LIST_OLD_INVOICES_TRANSITION_SPOTLIGHT'),
'targetVertex' => "middle-center",
'autoSave' => true,
],
];
}
}
if (count($settingsItems) > 0)
{
$settingsButton = new Buttons\SettingsButton([
'menu' => [
'id' => 'crm-toolbar-settings-menu',
'items' => $settingsItems,
'offsetLeft' => 20,
'closeByEsc' => true,
'angle' => true
],
]);
$settingsButton->addAttribute('id', static::TOOLBAR_SETTINGS_BUTTON_ID);
$buttons[Toolbar\ButtonLocation::RIGHT][] = $settingsButton;
}
$parameters = [
'buttons' => $buttons,
'filter' => $this->prepareFilter(),
'views' => $this->getToolbarViews(),
'isWithFavoriteStar' => true,
'spotlight' => $spotlight,
'entityTypeName' => \CCrmOwnerType::ResolveName($this->entityTypeId),
'categoryId' => $this->arResult['categoryId'],
'pathToEntityList' => '/crm/type/' . $this->entityTypeId,
];
return array_merge(parent::getToolbarParameters(), $parameters);
}