Add new options to RelationController (view mode): recordUrl, recordOnClick, toolbarButtons
This commit is contained in:
parent
3e5d6452fb
commit
906d97dce4
|
|
@ -8865,6 +8865,9 @@ label {
|
|||
.form-preview > .form-group:last-child {
|
||||
padding-bottom: 0;
|
||||
}
|
||||
.form-preview.form-flush {
|
||||
border-top: none;
|
||||
}
|
||||
.form-elements:before,
|
||||
.form-tabless-fields:before,
|
||||
.form-elements:after,
|
||||
|
|
|
|||
|
|
@ -36,8 +36,14 @@ label {
|
|||
>.form-group:last-child {
|
||||
padding-bottom: 0;
|
||||
}
|
||||
|
||||
// Form to sit flush to the element above
|
||||
&.form-flush {
|
||||
border-top: none;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Nice forms
|
||||
//
|
||||
|
|
|
|||
|
|
@ -641,25 +641,42 @@ class RelationController extends ControllerBehavior
|
|||
|
||||
protected function makeToolbarWidget()
|
||||
{
|
||||
if ($this->readOnly) {
|
||||
return;
|
||||
$defaultConfig = [];
|
||||
|
||||
/*
|
||||
* Add buttons to toolbar
|
||||
*/
|
||||
$defaultButtons = null;
|
||||
|
||||
if (!$this->readOnly) {
|
||||
$defaultButtons = '~/modules/backend/behaviors/relationcontroller/partials/_toolbar.htm';
|
||||
}
|
||||
|
||||
$defaultConfig = [
|
||||
'buttons' => '@/modules/backend/behaviors/relationcontroller/partials/_toolbar.htm',
|
||||
];
|
||||
$defaultConfig['buttons'] = $this->getConfig('view[toolbarButtons]', $defaultButtons);
|
||||
|
||||
/*
|
||||
* Make config
|
||||
*/
|
||||
$toolbarConfig = $this->makeConfig($this->getConfig('toolbar', $defaultConfig));
|
||||
$toolbarConfig->alias = $this->alias . 'Toolbar';
|
||||
|
||||
/*
|
||||
* Add search to toolbar
|
||||
*/
|
||||
if ($this->viewMode == 'multi' && $this->getConfig('view[showSearch]')) {
|
||||
$useSearch = $this->viewMode == 'multi' && $this->getConfig('view[showSearch]');
|
||||
|
||||
if ($useSearch) {
|
||||
$toolbarConfig->search = [
|
||||
'prompt' => 'backend::lang.list.search_prompt'
|
||||
];
|
||||
}
|
||||
|
||||
/*
|
||||
* No buttons, no search should mean no toolbar
|
||||
*/
|
||||
if (empty($toolbarConfig->search) && empty($toolbarConfig->buttons))
|
||||
return;
|
||||
|
||||
$toolbarWidget = $this->makeWidget('Backend\Widgets\Toolbar', $toolbarConfig);
|
||||
$toolbarWidget->cssClasses[] = 'list-header';
|
||||
|
||||
|
|
@ -680,15 +697,20 @@ class RelationController extends ControllerBehavior
|
|||
$config->recordsPerPage = $this->getConfig('view[recordsPerPage]');
|
||||
$config->showCheckboxes = $this->getConfig('view[showCheckboxes]', false);
|
||||
|
||||
$defaultOnClick = null;
|
||||
|
||||
if (!$this->readOnly) {
|
||||
$config->recordOnClick = sprintf(
|
||||
$defaultOnClick = sprintf(
|
||||
"$.oc.relationBehavior.clickManageListRecord(:id, '%s', '%s')",
|
||||
$this->field,
|
||||
$this->relationGetSessionKey()
|
||||
);
|
||||
$config->showCheckboxes = true;
|
||||
$config->showCheckboxes = $this->getConfig('view[showCheckboxes]', true);
|
||||
}
|
||||
|
||||
$config->recordOnClick = $this->getConfig('view[recordOnClick]', $defaultOnClick);
|
||||
$config->recordUrl = $this->getConfig('view[recordUrl]', null);
|
||||
|
||||
if ($emptyMessage = $this->getConfig('emptyMessage')) {
|
||||
$config->noRecordsMessage = $emptyMessage;
|
||||
}
|
||||
|
|
@ -699,7 +721,7 @@ class RelationController extends ControllerBehavior
|
|||
$widget = $this->makeWidget('Backend\Widgets\Lists', $config);
|
||||
$widget->bindEvent('list.extendQuery', function ($query) {
|
||||
$this->controller->relationExtendQuery($query, $this->field, $this->manageMode);
|
||||
|
||||
|
||||
$this->relationObject->setQuery($query);
|
||||
if ($this->model->exists) {
|
||||
$this->relationObject->addConstraints();
|
||||
|
|
|
|||
Loading…
Reference in New Issue