Switch the manage popup title according to the button pressed
Fixes #1755
This commit is contained in:
parent
4fe6cc6509
commit
762c5e754b
|
|
@ -130,6 +130,11 @@ class RelationController extends ControllerBehavior
|
|||
*/
|
||||
protected $viewMode;
|
||||
|
||||
/**
|
||||
* @var string The title used for the manage popup.
|
||||
*/
|
||||
protected $manageTitle;
|
||||
|
||||
/**
|
||||
* @var string Management of relation as list, form, or pivot.
|
||||
*/
|
||||
|
|
@ -220,6 +225,7 @@ class RelationController extends ControllerBehavior
|
|||
{
|
||||
$this->vars['relationManageId'] = $this->manageId;
|
||||
$this->vars['relationLabel'] = $this->config->label ?: $this->field;
|
||||
$this->vars['relationManageTitle'] = $this->manageTitle;
|
||||
$this->vars['relationField'] = $this->field;
|
||||
$this->vars['relationType'] = $this->relationType;
|
||||
$this->vars['relationSearchWidget'] = $this->searchWidget;
|
||||
|
|
@ -309,6 +315,7 @@ class RelationController extends ControllerBehavior
|
|||
$this->toolbarButtons = $this->evalToolbarButtons();
|
||||
$this->viewMode = $this->evalViewMode();
|
||||
$this->manageMode = $this->evalManageMode();
|
||||
$this->manageTitle = $this->evalManageTitle();
|
||||
$this->manageId = post('manage_id');
|
||||
$this->foreignId = post('foreign_id');
|
||||
|
||||
|
|
@ -1315,6 +1322,39 @@ class RelationController extends ControllerBehavior
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine the management mode popup title.
|
||||
* @return string
|
||||
*/
|
||||
protected function evalManageTitle()
|
||||
{
|
||||
if ($customTitle = $this->getConfig('manage[title]')) {
|
||||
return $customTitle;
|
||||
}
|
||||
|
||||
switch ($this->manageMode) {
|
||||
case 'list':
|
||||
if ($this->eventTarget == 'button-link') {
|
||||
return 'backend::lang.relation.add_a_link';
|
||||
}
|
||||
else {
|
||||
return 'backend::lang.relation.add_a_new';
|
||||
}
|
||||
break;
|
||||
case 'form':
|
||||
if ($this->readOnly) {
|
||||
return 'backend::lang.relation.preview_name';
|
||||
}
|
||||
else {
|
||||
return 'backend::lang.relation.update_name';
|
||||
}
|
||||
break;
|
||||
case 'pivot':
|
||||
return 'backend::lang.relation.add_a_new';
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine the management mode based on the relation type and settings.
|
||||
* @return string
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ use Backend\Models\UserPreferences;
|
|||
*/
|
||||
class UserPreferencesModel extends SettingsModel
|
||||
{
|
||||
private static $instances = [];
|
||||
protected static $instances = [];
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
|
|
|
|||
|
|
@ -12,11 +12,7 @@
|
|||
<div class="modal-header">
|
||||
<button type="button" class="close" data-dismiss="popup">×</button>
|
||||
<h4 class="modal-title">
|
||||
<?php if ($this->readOnly): ?>
|
||||
<?= e(trans('backend::lang.relation.preview_name', ['name' => trans($relationLabel)])) ?>
|
||||
<?php else: ?>
|
||||
<?= e(trans('backend::lang.relation.update_name', ['name' => trans($relationLabel)])) ?>
|
||||
<?php endif ?>
|
||||
<?= e(trans($relationManageTitle, ['name' => trans($relationLabel)])) ?>
|
||||
</h4>
|
||||
</div>
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
<?= Form::open() ?>
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close" data-dismiss="popup">×</button>
|
||||
<h4 class="modal-title"><?= e(trans('backend::lang.relation.add_a_new', [
|
||||
<h4 class="modal-title"><?= e(trans($relationManageTitle, [
|
||||
'name' => trans($relationLabel)
|
||||
])) ?></h4>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
<?= Form::open() ?>
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close" data-dismiss="popup">×</button>
|
||||
<h4 class="modal-title"><?= e(trans('backend::lang.relation.add_a_new', ['name'=>trans($relationLabel)])) ?></h4>
|
||||
<h4 class="modal-title"><?= e(trans($relationManageTitle, ['name'=>trans($relationLabel)])) ?></h4>
|
||||
</div>
|
||||
<?php if (!$relationSearchWidget): ?>
|
||||
<div class="modal-body">
|
||||
|
|
|
|||
|
|
@ -228,6 +228,7 @@ return [
|
|||
'add' => 'Add',
|
||||
'add_selected' => 'Add selected',
|
||||
'add_a_new' => 'Add a new :name',
|
||||
'add_a_link' => 'Link a new :name',
|
||||
'link_selected' => 'Link selected',
|
||||
'link_a_new' => 'Link a new :name',
|
||||
'cancel' => 'Cancel',
|
||||
|
|
|
|||
Loading…
Reference in New Issue