Various minor fixes and improvements

This commit is contained in:
Samuel Georges 2015-03-18 19:28:14 +11:00
parent 0916c7a650
commit a1ac5edbf7
9 changed files with 88 additions and 11 deletions

View File

@ -291,6 +291,8 @@ table.table.data tr.list-tree-level-25 td.list-cell-index-1{padding-left:275px}
.control-simplelist.is-selectable li:hover,.control-simplelist.is-selectable li:hover a{color:white}
.control-simplelist.is-selectable li:hover a{text-decoration:none}
.control-simplelist.is-selectable li:last-child{border-bottom:none}
.control-simplelist.is-selectable li.active a{background:#f0f0f0}
.control-simplelist.is-selectable li.active a:hover{background:#4da7e8}
.list-preview .control-simplelist.is-selectable ul{margin-bottom:0}
.control-filter{padding:0 10px;font-size:13px;color:#949ea6;background-color:#f3f3f3;border-top:1px solid #949ea6;border-bottom:1px solid #949ea6}
.control-filter a{text-decoration:none;color:#949ea6}

View File

@ -2225,6 +2225,7 @@ body{webkit-font-smoothing:antialiased;background:#f9f9f9}
.layout > .layout-row > .layout-cell.width-200{width:200px}
.layout > .layout-row > .layout-cell.width-300{width:300px}
.layout > .layout-row > .layout-cell.layout-container,.layout > .layout-row > .layout-cell .layout-container,.layout > .layout-row > .layout-cell.padded-container,.layout > .layout-row > .layout-cell .padded-container{padding:20px 20px 0 20px}
.layout > .layout-row > .layout-cell.layout-container .container-flush,.layout > .layout-row > .layout-cell .layout-container .container-flush,.layout > .layout-row > .layout-cell.padded-container .container-flush,.layout > .layout-row > .layout-cell .padded-container .container-flush{padding-top:0}
.layout > .layout-row > .layout-cell .layout-relative{position:relative;height:100%}
.layout > .layout-row > .layout-cell .layout-absolute{position:absolute;height:100%;width:100%}
.layout > .layout-row > .layout-cell.min-size{width:0}
@ -2237,6 +2238,7 @@ body{webkit-font-smoothing:antialiased;background:#f9f9f9}
.layout > .layout-row > .layout-cell.width-200{width:200px}
.layout > .layout-row > .layout-cell.width-300{width:300px}
.layout > .layout-row > .layout-cell.layout-container,.layout > .layout-row > .layout-cell .layout-container,.layout > .layout-row > .layout-cell.padded-container,.layout > .layout-row > .layout-cell .padded-container{padding:20px 20px 0 20px}
.layout > .layout-row > .layout-cell.layout-container .container-flush,.layout > .layout-row > .layout-cell .layout-container .container-flush,.layout > .layout-row > .layout-cell.padded-container .container-flush,.layout > .layout-row > .layout-cell .padded-container .container-flush{padding-top:0}
.layout > .layout-row > .layout-cell .layout-relative{position:relative;height:100%}
.layout > .layout-row > .layout-cell .layout-absolute{position:absolute;height:100%;width:100%}
.layout > .layout-row > .layout-cell.min-size{width:0}
@ -2251,6 +2253,7 @@ body{webkit-font-smoothing:antialiased;background:#f9f9f9}
.layout > .layout-cell.width-200{width:200px}
.layout > .layout-cell.width-300{width:300px}
.layout > .layout-cell.layout-container,.layout > .layout-cell .layout-container,.layout > .layout-cell.padded-container,.layout > .layout-cell .padded-container{padding:20px 20px 0 20px}
.layout > .layout-cell.layout-container .container-flush,.layout > .layout-cell .layout-container .container-flush,.layout > .layout-cell.padded-container .container-flush,.layout > .layout-cell .padded-container .container-flush{padding-top:0}
.layout > .layout-cell .layout-relative{position:relative;height:100%}
.layout > .layout-cell .layout-absolute{position:absolute;height:100%;width:100%}
.layout > .layout-cell.min-size{width:0}

View File

@ -107,6 +107,15 @@
&:last-child {
border-bottom: none;
}
&.active {
a {
background: #f0f0f0;
&:hover {
background: @color-list-hover-bg;
}
}
}
}
}

View File

@ -54,6 +54,11 @@ body {
&.layout-container, .layout-container, &.padded-container, .padded-container {
padding: 20px 20px 0 20px;
// Container to sit flush to the element above
.container-flush {
padding-top: 0;
}
}
.layout-relative {

View File

@ -132,6 +132,16 @@ class RelationController extends ControllerBehavior
*/
protected $manageMode;
/**
* @var string Force a certain view mode.
*/
protected $forceViewMode;
/**
* @var string Force a certain manage mode.
*/
protected $forceManageMode;
/**
* @var string The target that triggered an AJAX event (button, list)
*/
@ -227,8 +237,8 @@ class RelationController extends ControllerBehavior
$this->readOnly = $this->getConfig('readOnly');
$this->deferredBinding = $this->getConfig('deferredBinding') || !$this->model->exists;
$this->toolbarButtons = $this->evalToolbarButtons();
$this->viewMode = $this->viewMode ?: $this->evalViewMode();
$this->manageMode = $this->manageMode ?: $this->evalManageMode();
$this->viewMode = $this->evalViewMode();
$this->manageMode = $this->evalManageMode();
$this->manageId = post('manage_id');
/*
@ -291,6 +301,10 @@ class RelationController extends ControllerBehavior
*/
protected function evalViewMode()
{
if ($this->forceViewMode) {
return $this->forceViewMode;
}
switch ($this->relationType) {
case 'hasMany':
case 'belongsToMany':
@ -312,6 +326,10 @@ class RelationController extends ControllerBehavior
return $mode;
}
if ($this->forceManageMode) {
return $this->forceManageMode;
}
switch ($this->eventTarget) {
case 'button-create':
case 'button-update':
@ -385,11 +403,15 @@ class RelationController extends ControllerBehavior
{
$field = $this->validateField($field);
$result = ['#'.$this->relationGetId('view') => $this->relationRenderView()];
if ($toolbar = $this->relationRenderToolbar()) {
$result = ['#'.$this->relationGetId('view') => $this->relationRenderView($field)];
if ($toolbar = $this->relationRenderToolbar($field)) {
$result['#'.$this->relationGetId('toolbar')] = $toolbar;
}
if ($eventResult = $this->controller->relationExtendRefreshResults($field)) {
$result = $eventResult + $result;
}
return $result;
}
@ -539,6 +561,10 @@ class RelationController extends ControllerBehavior
{
}
public function relationExtendRefreshResults($field)
{
}
//
// AJAX (Buttons)
//
@ -626,7 +652,7 @@ class RelationController extends ControllerBehavior
*/
public function onRelationManageCreate()
{
$this->manageMode = 'form';
$this->forceManageMode = 'form';
$this->beforeAjax();
$saveData = $this->manageWidget->getSaveData();
@ -664,7 +690,7 @@ class RelationController extends ControllerBehavior
*/
public function onRelationManageUpdate()
{
$this->manageMode = 'form';
$this->forceManageMode = 'form';
$this->beforeAjax();
$saveData = $this->manageWidget->getSaveData();
@ -1025,12 +1051,29 @@ class RelationController extends ControllerBehavior
$config->model = $this->relationModel;
$config->alias = $this->alias . 'ManagePivotList';
$config->showSetup = false;
$config->defaultSort = $this->getConfig('pivot[defaultSort]');
$config->recordsPerPage = $this->getConfig('pivot[recordsPerPage]');
$config->recordOnClick = sprintf(
"$.oc.relationBehavior.clickManagePivotListRecord(:id, '%s', '%s')",
$this->field,
$this->relationGetSessionKey()
);
$widget = $this->makeWidget('Backend\Widgets\Lists', $config);
/*
* Link the Search Widget to the List Widget
*/
if ($this->getConfig('pivot[showSearch]')) {
$this->searchWidget = $this->makeSearchWidget();
$this->searchWidget->bindToController();
$this->searchWidget->bindEvent('search.submit', function () use ($widget) {
$widget->setSearchTerm($this->searchWidget->getActiveTerm());
return $widget->onRefresh();
});
$this->searchWidget->setActiveTerm(null);
}
}
/*
* List

View File

@ -4,12 +4,18 @@
<button type="button" class="close" data-dismiss="popup">&times;</button>
<h4 class="modal-title"><?= e(trans('backend::lang.relation.add_a_new', ['name'=>$relationLabel])) ?></h4>
</div>
<div class="modal-body">
<p><?= e(trans('backend::lang.relation.help')) ?></p>
<?php if (!$relationSearchWidget): ?>
<div class="modal-body">
<p><?= e(trans('backend::lang.relation.help')) ?></p>
</div>
<?php endif ?>
<div class="list-flush">
<?php if ($relationSearchWidget): ?>
<?= $relationSearchWidget->render() ?>
<?php endif ?>
<?= $relationManageWidget->render() ?>
</div>
<?= $relationManageWidget->render() ?>
<div class="modal-footer">
<button
type="button"

View File

@ -17,6 +17,7 @@
<button
class="btn btn-default"
data-control="popup"
data-size="huge"
data-handler="<?= $this->getEventHandler('onFindRecord') ?>"
data-request-data="recordfinder_flag: 1"
type="button">

View File

@ -203,6 +203,14 @@ class Form extends WidgetBase
}
$this->prepareVars();
/*
* Apply preview mode to widgets
*/
foreach ($this->formWidgets as $widget) {
$widget->previewMode = $this->previewMode;
}
return $this->makePartial($targetPartial, $extraVars);
}

View File

@ -12,7 +12,7 @@
value="0"
<?= $this->previewMode ? 'disabled="disabled"' : '' ?>>
<label class="custom-switch">
<label class="custom-switch" <?= $this->previewMode ? 'onclick="return false"' : '' ?>>
<input
type="checkbox"
id="<?= $field->getId() ?>"