From a1ac5edbf728577ffae4e46639366b943ee657c4 Mon Sep 17 00:00:00 2001 From: Samuel Georges Date: Wed, 18 Mar 2015 19:28:14 +1100 Subject: [PATCH] Various minor fixes and improvements --- modules/backend/assets/css/controls.css | 2 + modules/backend/assets/css/october.css | 3 + .../assets/less/controls/simplelist.less | 9 +++ .../backend/assets/less/layout/layout.less | 5 ++ .../backend/behaviors/RelationController.php | 55 +++++++++++++++++-- .../partials/_manage_pivot.htm | 14 +++-- .../recordfinder/partials/_recordfinder.htm | 1 + modules/backend/widgets/Form.php | 8 +++ .../widgets/form/partials/_field_switch.htm | 2 +- 9 files changed, 88 insertions(+), 11 deletions(-) diff --git a/modules/backend/assets/css/controls.css b/modules/backend/assets/css/controls.css index 7b9b8d62e..fb80373c0 100644 --- a/modules/backend/assets/css/controls.css +++ b/modules/backend/assets/css/controls.css @@ -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} diff --git a/modules/backend/assets/css/october.css b/modules/backend/assets/css/october.css index fa72ef73c..3ba0d1f28 100644 --- a/modules/backend/assets/css/october.css +++ b/modules/backend/assets/css/october.css @@ -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} diff --git a/modules/backend/assets/less/controls/simplelist.less b/modules/backend/assets/less/controls/simplelist.less index b7a9280b0..2063175aa 100644 --- a/modules/backend/assets/less/controls/simplelist.less +++ b/modules/backend/assets/less/controls/simplelist.less @@ -107,6 +107,15 @@ &:last-child { border-bottom: none; } + + &.active { + a { + background: #f0f0f0; + &:hover { + background: @color-list-hover-bg; + } + } + } } } diff --git a/modules/backend/assets/less/layout/layout.less b/modules/backend/assets/less/layout/layout.less index a2fe5abaf..2fa327cbc 100644 --- a/modules/backend/assets/less/layout/layout.less +++ b/modules/backend/assets/less/layout/layout.less @@ -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 { diff --git a/modules/backend/behaviors/RelationController.php b/modules/backend/behaviors/RelationController.php index 92a1bc9dd..3c50db8c6 100644 --- a/modules/backend/behaviors/RelationController.php +++ b/modules/backend/behaviors/RelationController.php @@ -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 diff --git a/modules/backend/behaviors/relationcontroller/partials/_manage_pivot.htm b/modules/backend/behaviors/relationcontroller/partials/_manage_pivot.htm index db8b55db8..02f0ca616 100644 --- a/modules/backend/behaviors/relationcontroller/partials/_manage_pivot.htm +++ b/modules/backend/behaviors/relationcontroller/partials/_manage_pivot.htm @@ -4,12 +4,18 @@ -