Clicking a record in readOnly mode will open the manage form in preview mode

Use "recordOnClick: null" to retain the original behavior
This commit is contained in:
Samuel Georges 2014-12-06 15:46:02 +11:00
parent 906d97dce4
commit ea34622840
3 changed files with 38 additions and 26 deletions

View File

@ -695,18 +695,13 @@ class RelationController extends ControllerBehavior
$config->showSorting = $this->getConfig('view[showSorting]', true);
$config->defaultSort = $this->getConfig('view[defaultSort]');
$config->recordsPerPage = $this->getConfig('view[recordsPerPage]');
$config->showCheckboxes = $this->getConfig('view[showCheckboxes]', false);
$config->showCheckboxes = $this->getConfig('view[showCheckboxes]', !$this->readOnly);
$defaultOnClick = null;
if (!$this->readOnly) {
$defaultOnClick = sprintf(
"$.oc.relationBehavior.clickManageListRecord(:id, '%s', '%s')",
$this->field,
$this->relationGetSessionKey()
);
$config->showCheckboxes = $this->getConfig('view[showCheckboxes]', true);
}
$defaultOnClick = sprintf(
"$.oc.relationBehavior.clickManageListRecord(:id, '%s', '%s')",
$this->field,
$this->relationGetSessionKey()
);
$config->recordOnClick = $this->getConfig('view[recordOnClick]', $defaultOnClick);
$config->recordUrl = $this->getConfig('view[recordUrl]', null);

View File

@ -10,27 +10,41 @@
<div class="modal-header">
<button type="button" class="close" data-dismiss="popup">&times;</button>
<h4 class="modal-title">
<?= e(trans('backend::lang.relation.update_name', ['name'=>$relationLabel])) ?>
<?php if ($this->readOnly): ?>
<?= e(trans('backend::lang.relation.preview_name', ['name'=>$relationLabel])) ?>
<?php else: ?>
<?= e(trans('backend::lang.relation.update_name', ['name'=>$relationLabel])) ?>
<?php endif ?>
</h4>
</div>
<div class="modal-body">
<?= $relationManageWidget->render() ?>
<?= $relationManageWidget->render(['preview' => $this->readOnly]) ?>
</div>
<div class="modal-footer">
<button
type="submit"
class="btn btn-primary">
<?= e(trans('backend::lang.relation.update')) ?>
</button>
<button
type="button"
class="btn btn-default"
data-dismiss="popup">
<?= e(trans('backend::lang.relation.cancel')) ?>
</button>
<?php if ($this->readOnly): ?>
<button
type="button"
class="btn btn-default"
data-dismiss="popup">
<?= e(trans('backend::lang.relation.close')) ?>
</button>
<?php else: ?>
<button
type="submit"
class="btn btn-primary">
<?= e(trans('backend::lang.relation.update')) ?>
</button>
<button
type="button"
class="btn btn-default"
data-dismiss="popup">
<?= e(trans('backend::lang.relation.cancel')) ?>
</button>
<?php endif ?>
</div>
<?= Form::close() ?>
<?php else: ?>

View File

@ -192,11 +192,14 @@ return [
'add_selected' => "Add selected",
'add_a_new' => "Add a new :name",
'cancel' => "Cancel",
'close' => "Close",
'add_name' => "Add :name",
'create' => "Create",
'create_name' => "Create :name",
'update' => "Update",
'update_name' => "Update :name",
'preview' => "Preview",
'preview_name' => "Preview :name",
'remove' => "Remove",
'remove_name' => "Remove :name",
'delete' => "Delete",