diff --git a/CHANGE.md b/CHANGE.md index 9f54f46..ff4b266 100755 --- a/CHANGE.md +++ b/CHANGE.md @@ -1,6 +1,14 @@ Change Log: `yii2-detail-view` ============================== +## Version 1.8.4 + +**Date:** 01-Sep-2021 + +- (enh #183): Enhancements to support Bootstrap v5.x +- (enh #179): Update Hungarian Translations. +- (enh #176): Correct container identifier. + ## Version 1.8.3 **Date:** 15-May-2020 diff --git a/LICENSE.md b/LICENSE.md index ce741c1..d745e18 100755 --- a/LICENSE.md +++ b/LICENSE.md @@ -1,4 +1,4 @@ -Copyright (c) 2014 - 2020, Kartik Visweswaran +Copyright (c) 2014 - 2021, Kartik Visweswaran Krajee.com All rights reserved. diff --git a/composer.json b/composer.json index 3e1994d..798e9f2 100755 --- a/composer.json +++ b/composer.json @@ -22,7 +22,7 @@ ], "require": { "kartik-v/yii2-dialog": "~1.0", - "kartik-v/yii2-widget-activeform": ">=1.5.7" + "kartik-v/yii2-widget-activeform": ">=1.6.0" }, "autoload": { "psr-4": { diff --git a/src/DetailView.php b/src/DetailView.php index 4343d8b..5bb1e65 100644 --- a/src/DetailView.php +++ b/src/DetailView.php @@ -3,19 +3,21 @@ /** * @package yii2-detail-view * @author Kartik Visweswaran - * @copyright Copyright © Kartik Visweswaran, Krajee.com, 2014 - 2020 + * @copyright Copyright © Kartik Visweswaran, Krajee.com, 2014 - 2021 * @version 1.8.3 */ namespace kartik\detail; use Closure; +use Exception; use kartik\base\BootstrapInterface; use kartik\base\Config; use kartik\base\TranslationTrait; use kartik\base\WidgetTrait; use kartik\base\PluginAssetBundle; use kartik\dialog\Dialog; +use ReflectionException; use Yii; use yii\base\Arrayable; use yii\base\InvalidConfigException; @@ -778,7 +780,7 @@ public function init() /** * @inheritdoc - * @throws \ReflectionException + * @throws ReflectionException */ public function run() { @@ -795,17 +797,17 @@ protected function initWidget() $this->_msgCat = 'kvdetail'; $this->pluginName = 'kvDetailView'; $this->initBsVersion(); - $isBs4 = $this->isBs4(); - if ($isBs4) { + $notBs3 = !$this->isBs(3); + if ($notBs3) { Html::addCssClass($this->container, 'kv-container-bs4'); } if ($this->enableEditMode) { /** - * @var ActiveForm $formClass + * @var string|ActiveForm $formClass */ $formClass = $this->formClass; $activeForm = ActiveForm::class; - if (!is_subclass_of($formClass, $activeForm) && $formClass !== $activeForm) { + if (!is_subclass_of($formClass, $activeForm) && $formClass != $activeForm) { throw new InvalidConfigException("Form class '{$formClass}' must exist and extend from '{$activeForm}'."); } $this->validateDisplay(); @@ -837,8 +839,8 @@ protected function initWidget() /** * Prepares and runs the detail view widget - * @throws \ReflectionException - * @throws \Exception + * @throws ReflectionException + * @throws Exception */ protected function runWidget() { @@ -860,12 +862,12 @@ protected function runWidget() $this->registerAssets(); $output = $this->renderDetailView(); - if (is_array($this->panel) && !empty($this->panel) && $this->panel !== false) { + if (is_array($this->panel) && !empty($this->panel)) { $output = $this->renderPanel($output); } $output = strtr(Html::tag('div', $this->mainTemplate, $this->container), ['{detail}' => $output]); Html::addCssClass($this->viewButtonsContainer, 'kv-buttons-1'); - $buttons = Html::tag('span', $this->renderButtons(1), $this->viewButtonsContainer); + $buttons = Html::tag('span', $this->renderButtons(), $this->viewButtonsContainer); if ($this->enableEditMode) { Html::addCssClass($this->editButtonsContainer, 'kv-buttons-2'); $buttons .= Html::tag('span', $this->renderButtons(2), $this->editButtonsContainer); @@ -883,7 +885,7 @@ protected function runWidget() /** * Initializes and renders alert container block - * @throws \Exception + * @throws Exception */ protected function renderAlertBlock() { @@ -901,7 +903,7 @@ protected function renderAlertBlock() Html::addCssStyle($this->alertContainerOptions, 'display:none;'); } $out = Html::beginTag('div', $this->alertContainerOptions); - $alertWidgetClass = $this->isBs4() ? 'yii\bootstrap4\Alert' : 'yii\bootstrap\Alert'; + $alertWidgetClass = !$this->isBs(3) ? 'yii\bootstrap4\Alert' : 'yii\bootstrap\Alert'; foreach ($flashes as $type => $message) { if (!isset($this->alertMessageSettings[$type])) { continue; @@ -1059,9 +1061,10 @@ protected function renderAttributeItem($attribute) /** * Checks if a bootstrap grid column class has been added to the container * - * @param array $container + * @param array $container * * @return boolean + * @throws Exception */ protected static function hasGridCol($container = []) { @@ -1088,7 +1091,7 @@ protected static function hasGridCol($container = []) * @param array $config the attribute config * * @return mixed - * @throws \yii\base\InvalidConfigException + * @throws InvalidConfigException */ protected function renderFormAttribute($config) { @@ -1173,7 +1176,7 @@ protected function getPanelType() * Sets the grid panel layout based on the [[template]] and [[panel]] settings. * @param string $items * @return string - * @throws InvalidConfigException + * @throws InvalidConfigException|Exception */ protected function renderPanel($items) { @@ -1195,20 +1198,20 @@ protected function renderPanel($items) $panelBefore = ''; $panelAfter = ''; $panelFooter = ''; - $isBs4 = $this->isBs4(); + $notBs3 = !$this->isBs(3); if (isset($this->panelCssPrefix)) { static::initCss($options, $this->panelCssPrefix . $type); } else { $this->addCssClass($options, self::BS_PANEL); - Html::addCssClass($options, $isBs4 ? "border-{$type}" : "panel-{$type}"); + Html::addCssClass($options, $notBs3 ? "border-{$type}" : "panel-{$type}"); } if ($after === false && $footer === false) { Html::addCssClass($this->container, 'kv-flat-b'); } - $titleTag = ArrayHelper::remove($titleOptions, 'tag', ($isBs4 ? 'h5' : 'h3')); - static::initCss($titleOptions, $isBs4 ? 'm-0' : $this->getCssClass(self::BS_PANEL_TITLE)); + $titleTag = ArrayHelper::remove($titleOptions, 'tag', ($notBs3 ? 'h5' : 'h3')); + static::initCss($titleOptions, $notBs3 ? 'm-0' : $this->getCssClass(self::BS_PANEL_TITLE)); if ($heading !== false) { - $color = $isBs4 ? ($type === 'default' ? ' bg-light' : " text-white bg-{$type}") : ''; + $color = $notBs3 ? ($type === 'default' ? ' bg-light' : " text-white bg-{$type}") : ''; static::initCss($headingOptions, $this->getCssClass(self::BS_PANEL_HEADING) . $color); $panelHeading = Html::tag('div', $this->panelHeadingTemplate, $headingOptions); } @@ -1296,17 +1299,17 @@ protected function renderButton($type) * * @param string $type the button type * @param string $iconBs3 the bootstrap 3 icon suffix name - * @param string $iconBs4 the bootstrap 4 icon suffix name + * @param string $iconNotBs3 the non bootstrap 3 icon suffix name * @param string $title the title to display on hover * * @return string - * @throws InvalidConfigException + * @throws InvalidConfigException|Exception */ - protected function getDefaultButton($type, $iconBs3, $iconBs4, $title) + protected function getDefaultButton($type, $iconBs3, $iconNotBs3, $title) { $buttonOptions = $type . 'Options'; $options = $this->$buttonOptions; - $css = $this->getDefaultIconPrefix() . ($this->isBs4() ? $iconBs4 : $iconBs3); + $css = $this->getDefaultIconPrefix() . (!$this->isBs(3) ? $iconNotBs3 : $iconBs3); $label = ArrayHelper::remove($options, 'label', ''); if (empty($options['class'])) { $options['class'] = 'kv-action-btn'; @@ -1332,7 +1335,7 @@ protected function getDefaultButton($type, $iconBs3, $iconBs4, $title) /** * Register assets - * @throws \Exception + * @throws Exception */ protected function registerAssets() { @@ -1369,9 +1372,6 @@ protected function registerAssets() 'dialogLib' => ArrayHelper::getValue($this->krajeeDialogSettings, 'libName', 'krajeeDialog'), ]; $id = 'jQuery("#' . $this->container['id'] . '")'; - if ($this->enableEditMode) { - $options['mode'] = $this->mode; - } $this->registerPlugin($this->pluginName, $id); if ($this->tooltips) { PluginAssetBundle::registerBundle($view, $this->bsVersion); @@ -1426,8 +1426,8 @@ protected function parseAttributeItem($attribute) } $attribute = [ 'attribute' => $matches[1], - 'format' => isset($matches[3]) ? $matches[3] : 'text', - 'label' => isset($matches[5]) ? $matches[5] : null, + 'format' => $matches[3] ?? 'text', + 'label' => $matches[5] ?? null, ]; } if (!is_array($attribute)) { diff --git a/src/DetailViewAsset.php b/src/DetailViewAsset.php index b353797..9ed9ce4 100644 --- a/src/DetailViewAsset.php +++ b/src/DetailViewAsset.php @@ -3,7 +3,7 @@ /** * @package yii2-detail-view * @author Kartik Visweswaran - * @copyright Copyright © Kartik Visweswaran, Krajee.com, 2014 - 2020 + * @copyright Copyright © Kartik Visweswaran, Krajee.com, 2014 - 2021 * @version 1.8.3 */ diff --git a/src/assets/css/kv-detail-view.css b/src/assets/css/kv-detail-view.css index 57b0080..a161c5a 100644 --- a/src/assets/css/kv-detail-view.css +++ b/src/assets/css/kv-detail-view.css @@ -1,13 +1,13 @@ /*! * @package yii2-detail-view * @author Kartik Visweswaran - * @copyright Copyright © Kartik Visweswaran, Krajee.com, 2014 - 2020 + * @copyright Copyright © Kartik Visweswaran, Krajee.com, 2014 - 2021 * @version 1.8.3 * * Styles for yii2-detail-view extension * * Author: Kartik Visweswaran - * Copyright: 2014 - 2020, Kartik Visweswaran, Krajee.com + * Copyright: 2014 - 2021, Kartik Visweswaran, Krajee.com * For more JQuery plugins visit http://plugins.krajee.com * For more Yii related demos visit http://demos.krajee.com */ diff --git a/src/assets/css/kv-detail-view.min.css b/src/assets/css/kv-detail-view.min.css index 5a1fbfa..9e3b939 100644 --- a/src/assets/css/kv-detail-view.min.css +++ b/src/assets/css/kv-detail-view.min.css @@ -1,13 +1,13 @@ /*! * @package yii2-detail-view * @author Kartik Visweswaran - * @copyright Copyright © Kartik Visweswaran, Krajee.com, 2014 - 2020 + * @copyright Copyright © Kartik Visweswaran, Krajee.com, 2014 - 2021 * @version 1.8.3 * * Styles for yii2-detail-view extension * * Author: Kartik Visweswaran - * Copyright: 2014 - 2020, Kartik Visweswaran, Krajee.com + * Copyright: 2014 - 2021, Kartik Visweswaran, Krajee.com * For more JQuery plugins visit http://plugins.krajee.com * For more Yii related demos visit http://demos.krajee.com */.kv-container-bs4 .form-group:not(.has-error),.kv-container-bs4 .table{margin:0}.kv-container-bs4 .table-bordered .kv-child-table-cell td,.kv-container-bs4 .table-bordered .kv-child-table-cell th{border-top:none;border-bottom:none}.kv-container-bs4 .card>.kv-detail-view>.table-bordered>tbody>tr>td:first-child,.panel>.kv-detail-view>.table-bordered>tbody>tr>td:first-child{border-left:0}.kv-container-bs4 .card>.kv-detail-view>.table-bordered>tbody>tr>td:last-child,.panel>.kv-detail-view>.table-bordered>tbody>tr>td:last-child{border-right:0}.kv-flat-b .card>.kv-detail-view:last-child,.kv-flat-b .panel>.kv-detail-view:last-child{border-bottom-right-radius:.25rem;border-bottom-left-radius:.25rem}.kv-form-attribute .help-block{margin-bottom:-15px}.kv-edit-mode .kv-edit-hidden,.kv-view-mode .kv-view-hidden{display:none}.kv-edit-mode .kv-view-hidden,.kv-view-mode .kv-edit-hidden{display:table-row}.kv-edit-hidden.kv-view-hidden{display:none}.kv-detail-loading{opacity:.3;background:url(../img/loading.gif) top 15px right 15px no-repeat #fff}.kv-detail-loading *{background:0 0!important}.kv-detail-loading td{border-color:#efefef!important}.kv-edit-mode .kv-detail-view{overflow-y:hidden}.kv-form-attribute .row{margin-bottom:-5px}.kv-edit-mode table{overflow:hidden}.kv-child-table{width:100%}.kv-child-table-row,.kv-child-table-row>td{vertical-align:middle;padding:0!important;margin:0!important}.kv-child-table-cell{margin:0;padding:0;width:100%;overflow:hidden}.kv-child-table-row th{border-left:1px #ddd solid;border-right:1px #ddd solid}.kv-child-table td,.kv-child-table th{margin:0;background:0 0}.table .kv-child-table>tbody>tr>td,.table .kv-child-table>tbody>tr>th{padding:8px}.table-condensed .kv-child-table>tbody>tr>td,.table-condensed .kv-child-table>tbody>tr>th{padding:5px}.kv-action-btn{margin:0 2px;padding:0 5px;background:0 0;border:none;font-size:16px;cursor:pointer}.kv-action-btn:focus{outline:0}.kv-action-btn.disabled,.kv-action-btn[disabled]{cursor:not-allowed}.card .kv-action-btn{color:#fff}.card .kv-action-btn:focus,.card .kv-action-btn:hover{color:#fff;outline:0;opacity:.8}.card.border-default .kv-action-btn,.card.border-default .kv-action-btn:focus,.card.border-default .kv-action-btn:hover,.panel-default .kv-action-btn{color:#333}.panel-primary .kv-action-btn:hover{color:#c4e3f3}.panel-info .kv-action-btn{color:#31708f}.panel-info .kv-action-btn:hover{color:#245269}.panel-warning .kv-action-btn{color:#8a6d3b}.panel-warning .kv-action-btn:hover{color:#66512c}.panel-danger .kv-action-btn{color:#a94442}.panel-danger .kv-action-btn:hover{color:#843534}.panel-success .kv-action-btn{color:#3c763d}.panel-success .kv-action-btn:hover{color:#2b542c} \ No newline at end of file diff --git a/src/assets/js/kv-detail-view.js b/src/assets/js/kv-detail-view.js index 83d5f05..b84da50 100644 --- a/src/assets/js/kv-detail-view.js +++ b/src/assets/js/kv-detail-view.js @@ -1,13 +1,13 @@ /*! * @package yii2-detail-view * @author Kartik Visweswaran - * @copyright Copyright © Kartik Visweswaran, Krajee.com, 2014 - 2020 + * @copyright Copyright © Kartik Visweswaran, Krajee.com, 2014 - 2021 * @version 1.8.3 * * Client extension for the yii2-detail-view extension * * Author: Kartik Visweswaran - * Copyright: 2014 - 2020, Kartik Visweswaran, Krajee.com + * Copyright: 2014 - 2021, Kartik Visweswaran, Krajee.com * For more JQuery plugins visit http://plugins.krajee.com * For more Yii related demos visit http://demos.krajee.com */ diff --git a/src/assets/js/kv-detail-view.min.js b/src/assets/js/kv-detail-view.min.js index 019d579..db8f957 100644 --- a/src/assets/js/kv-detail-view.min.js +++ b/src/assets/js/kv-detail-view.min.js @@ -1,13 +1,13 @@ /*! * @package yii2-detail-view * @author Kartik Visweswaran - * @copyright Copyright © Kartik Visweswaran, Krajee.com, 2014 - 2020 + * @copyright Copyright © Kartik Visweswaran, Krajee.com, 2014 - 2021 * @version 1.8.3 * * Client extension for the yii2-detail-view extension * * Author: Kartik Visweswaran - * Copyright: 2014 - 2020, Kartik Visweswaran, Krajee.com + * Copyright: 2014 - 2021, Kartik Visweswaran, Krajee.com * For more JQuery plugins visit http://plugins.krajee.com * For more Yii related demos visit http://demos.krajee.com */