1C-Bitrix
25.700.0
Загрузка...
Поиск...
Не найдено
Toolbar.php
См. документацию.
1
<?php
2
3
namespace
Bitrix\Calendar\OpenEvents\Component
;
4
5
use
Bitrix\Calendar\Core\Event\Tools\Dictionary
;
6
use
Bitrix\Calendar\Core\Property\ColorHelper
;
7
use
Bitrix\Calendar\OpenEvents\Filter\Filter
;
8
use
Bitrix\Main\Engine\CurrentUser
;
9
use
Bitrix\Main\Localization\Loc
;
10
use
Bitrix\Main\UI\Filter\Options
;
11
use
Bitrix\UI
;
12
13
class
Toolbar
14
{
15
public
function
build
(): void
16
{
17
$this->
addCreateButton
();
18
$this->
addFilter
();
19
}
20
21
protected
function
addCreateButton
(): void
22
{
23
$calendarType = Dictionary::CALENDAR_TYPE[
'open_event'
];
24
$userId
= CurrentUser::get()->getId();
25
26
$colors =
\Bitrix\Main\Web\Json::encode
(
ColorHelper::OUR_COLORS
);
27
28
$addButton =
new
UI\Buttons\Button
([
29
'color'
=>
UI
\
Buttons
\Color::SUCCESS,
30
'text'
=> Loc::getMessage(
'CALENDAR_OPEN_EVENTS_TOOLBAR_BUTTON_CREATE'
),
31
'click'
=>
new
UI
\
Buttons
\JsCode(
"
32
BX.Runtime.loadExtension('calendar.entry').then(({ EntryManager }) => {
33
const colors = $colors;
34
EntryManager.openEditSlider({
35
type: '$calendarType',
36
userId: $userId,
37
formDataValue: {
38
color: colors[Math.floor(Math.random()*colors.length)],
39
},
40
});
41
});
42
"
),
43
'events'
=> [
44
'mouseover'
=>
new
UI
\
Buttons
\JsCode(
"BX.Runtime.loadExtension('calendar.entry');"
),
45
],
46
]);
47
48
UI\Toolbar\Facade\Toolbar::addButton($addButton,
UI
\
Toolbar
\
ButtonLocation::AFTER_TITLE
);
49
}
50
51
protected
function
addFilter
(): void
52
{
53
$filter
=
new
Filter
();
54
55
(
new
Options
($filter::getId()))->reset();
56
57
UI\Toolbar\Facade\Toolbar::addFilter(
$filter
->getOptions());
58
}
59
}
$userId
if(!is_object($USER)||! $USER->IsAuthorized()) $userId
Определения
check_mail.php:18
Bitrix\Calendar\Core\Event\Tools\Dictionary
Определения
dictionary.php:8
Bitrix\Calendar\Core\Property\ColorHelper
Определения
colorhelper.php:6
Bitrix\Calendar\Core\Property\ColorHelper\OUR_COLORS
const OUR_COLORS
Определения
colorhelper.php:7
Bitrix\Calendar\OpenEvents\Component\Toolbar\build
build()
Определения
Toolbar.php:15
Bitrix\Calendar\OpenEvents\Component\Toolbar\addCreateButton
addCreateButton()
Определения
Toolbar.php:21
Bitrix\Calendar\OpenEvents\Component\Toolbar\addFilter
addFilter()
Определения
Toolbar.php:51
Bitrix\Calendar\OpenEvents\Filter\Filter
Определения
Filter.php:10
Bitrix\Main\Engine\CurrentUser
Определения
currentuser.php:8
Bitrix\Main\Localization\Loc
Определения
loc.php:12
Bitrix\Main\UI\Filter\Options
Определения
options.php:16
Bitrix\Main\Web\Json\encode
static encode($data, $options=null)
Определения
json.php:22
Bitrix\UI\Buttons\Button
Определения
button.php:6
Bitrix\UI\Toolbar\ButtonLocation\AFTER_TITLE
const AFTER_TITLE
Определения
buttonlocation.php:7
$filter
$filter
Определения
iblock_catalog_list.php:54
Bitrix\Calendar\OpenEvents\Component
Определения
Toolbar.php:3
Bitrix\UI\Buttons
Определения
addbutton.php:3
Bitrix\UI\Toolbar
Определения
buttonlocation.php:3
Bitrix\UI
bitrix
modules
calendar
lib
OpenEvents
Component
Toolbar.php
Создано системой
1.14.0