Skip to content

Commit

Permalink
Updates to release v1.3.3 fix #266 fix #267 fix #268 fix #269
Browse files Browse the repository at this point in the history
  • Loading branch information
kartik-v committed Oct 11, 2018
1 parent a38d993 commit 6e2e1dd
Show file tree
Hide file tree
Showing 17 changed files with 129 additions and 153 deletions.
9 changes: 9 additions & 0 deletions CHANGE.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
Change Log: `yii2-export`
=========================

## version 1.3.3

**Date:** _under development_

- (enh #269): Correct styles for BS4.
- (enh #268): Enhance export columns visibility.
- (enh #267): Configurable export menu form parameters.
- (enh #266): Enhancements to export form functionality.

## version 1.3.2

**Date:** 04-Oct-2018
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ In addition, with release v1.2.0, the extension also displays a handy grid colum

The extension offers configurable user interfaces for advanced cases using view templates.

- `exportFormView` allows you to setup your own custom view file for rendering the export form.
- `exportColumnsView` allows you to setup your own custom view file for rendering the column selector dropdown.
- `afterSaveView` allows you to setup your own after save view file if you are configuring to save exported file on server .

## Demo
You can see detailed [documentation](http://demos.krajee.com/export) and [demonstration](http://demos.krajee.com/export-demo) on usage of the extension.
Expand Down
1 change: 0 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
],
"require": {
"kartik-v/yii2-dynagrid": ">=1.4.5",
"kartik-v/yii2-dialog": "~1.0",
"kartik-v/yii2-mpdf": "~1.0",
"phpoffice/phpspreadsheet": "~1.0"
},
Expand Down
2 changes: 1 addition & 1 deletion src/ExportColumnAsset.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/**
* @copyright Copyright © Kartik Visweswaran, Krajee.com, 2015 - 2018
* @package yii2-export
* @version 1.3.2
* @version 1.3.3
*/

namespace kartik\export;
Expand Down
125 changes: 55 additions & 70 deletions src/ExportMenu.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* @package yii2-export
* @author Kartik Visweswaran <[email protected]>
* @copyright Copyright &copy; Kartik Visweswaran, Krajee.com, 2015 - 2018
* @version 1.3.2
* @version 1.3.3
*/

namespace kartik\export;
Expand Down Expand Up @@ -92,18 +92,6 @@ class ExportMenu extends GridView
* Set download target for grid export to a new window that auto closes after download
*/
const TARGET_BLANK = '_blank';
/**
* Export type input parameter for export form
*/
const PARAM_EXPORT_TYPE = 'export_type';
/**
* Export columns input parameter for export form
*/
const PARAM_EXPORT_COLS = 'export_columns';
/**
* Column selector flag parameter for export form
*/
const PARAM_COLSEL_FLAG = 'column_selector_enabled';

/**
* @var string the target for submitting the export form, which will trigger the download of the exported file.
Expand Down Expand Up @@ -278,7 +266,7 @@ class ExportMenu extends GridView
public $noExportColumns = [];

/**
* @var string the view file for rendering the export form
* @var string the view file for rendering the export form. DEPRECATED since v1.3.3 (this is not used any more).
*/
public $exportFormView = '_form';

Expand Down Expand Up @@ -325,6 +313,21 @@ class ExportMenu extends GridView
*/
public $exportRequestParam;

/**
* @var string the export type input parameter for export form
*/
public $exportTypeParam = 'export_type';

/**
* @var string the export columns input parameter for export form
*/
public $exportColsParam = 'export_columns';

/**
* @var string the column selector flag parameter for export form
*/
public $colSelFlagParam = 'column_selector_enabled';

/**
* @var array the output style configuration options for each data cell. It must be the style configuration
* array as required by `\PhpOffice\PhpSpreadsheet\Spreadsheet`.
Expand Down Expand Up @@ -703,8 +706,8 @@ public function init()
if ($this->stream) {
Yii::$app->controller->layout = false;
}
$this->_exportType = $_POST[self::PARAM_EXPORT_TYPE];
$this->_columnSelectorEnabled = $_POST[self::PARAM_COLSEL_FLAG];
$this->_exportType = $_POST[$this->exportTypeParam];
$this->_columnSelectorEnabled = $_POST[$this->colSelFlagParam];
$this->initSelectedColumns();
}
if ($this->dynagrid) {
Expand Down Expand Up @@ -885,19 +888,6 @@ public function renderExportMenu()
}
}
}
$form = $this->render(
$this->exportFormView,
[
'options' => $this->exportFormOptions,
'exportType' => $this->_exportType,
'columnSelectorEnabled' => $this->_columnSelectorEnabled,
'exportRequestParam' => $this->exportRequestParam,
'exportTypeParam' => self::PARAM_EXPORT_TYPE,
'exportColsParam' => self::PARAM_EXPORT_COLS,
'colselFlagParam' => self::PARAM_COLSEL_FLAG,
'exportFormHiddenInputs' => $this->exportFormHiddenInputs,
]
);
$iconCss = $isBs4 ? 'fas fa-external-link-alt' : 'glyphicon glyphicon-export';
if ($this->asDropdown) {
$icon = ArrayHelper::remove($this->dropdownOptions, 'icon', '<i class="' . $iconCss . '"></i>');
Expand Down Expand Up @@ -936,17 +926,18 @@ public function renderExportMenu()
$out = $class::widget($opts);
}
$replacePairs = ['{menu}' => $out, '{columns}' => $this->renderColumnSelector()];
$content = strtr($this->template, $replacePairs) . "\n" . $form;
$content = strtr($this->template, $replacePairs);
return Html::tag('div', $content, $this->container);
} else {
return $items . "\n" . $form;
return $items;
}
}

/**
* Renders the columns selector
*
* @return string the column selector markup
* @throws InvalidConfigException
*/
public function renderColumnSelector()
{
Expand All @@ -956,6 +947,7 @@ public function renderColumnSelector()
return $this->render(
$this->exportColumnsView,
[
'isBs4' => $this->isBs4(),
'options' => $this->columnSelectorOptions,
'menuOptions' => $this->columnSelectorMenuOptions,
'columnSelector' => $this->columnSelector,
Expand Down Expand Up @@ -1056,9 +1048,6 @@ public function generateHeader()

$this->_endCol = 0;
foreach ($this->getVisibleColumns() as $column) {
if (!empty($column->hiddenFromExport)) {
continue;
}
$opts = $styleOpts;
$this->_endCol++;
/**
Expand Down Expand Up @@ -1092,8 +1081,8 @@ public function generateHeader()
*/
public function getVisibleColumns()
{
if (!$this->_columnSelectorEnabled) {
return $this->columns;
if (!isset($this->_visibleColumns)) {
$this->setVisibleColumns();
}
return $this->_visibleColumns;
}
Expand All @@ -1103,17 +1092,15 @@ public function getVisibleColumns()
*/
public function setVisibleColumns()
{
if (!$this->_columnSelectorEnabled) {
$this->_visibleColumns = $this->columns;
return;
}
$cols = [];
$columns = [];
foreach ($this->columns as $key => $column) {
if (!in_array($key, $this->noExportColumns) && in_array($key, $this->selectedColumns)) {
$cols[] = $column;
if (!empty($column->hiddenFromExport) || $column instanceof ActionColumn || ($this->_columnSelectorEnabled
&& (in_array($key, $this->noExportColumns) || !in_array($key, $this->selectedColumns)))) {
continue;
}
$columns[] = $column;
}
$this->_visibleColumns = $cols;
$this->_visibleColumns = $columns;
}

/**
Expand Down Expand Up @@ -1218,14 +1205,9 @@ public function generateRow($model, $key, $index)
*/
$this->_endCol = 0;
foreach ($this->getVisibleColumns() as $column) {
if (!empty($column->hiddenFromExport)) {
continue;
}
$format = $this->enableFormatter && isset($column->format) ? $column->format : 'raw';
$value = null;
if ($column instanceof ActionColumn) {
$value = null;
} elseif ($column instanceof SerialColumn) {
if ($column instanceof SerialColumn) {
$value = $index + 1;
$pagination = $column->grid->dataProvider->getPagination();
if ($pagination !== false) {
Expand Down Expand Up @@ -1547,6 +1529,7 @@ protected function getSetting($key, $default = null)
*
* @param string $file the output filename on server with path
* @throws \PhpOffice\PhpSpreadsheet\Writer\Exception
* @throws InvalidConfigException
*/
protected function renderPDF($file)
{
Expand Down Expand Up @@ -1600,10 +1583,10 @@ protected function initSelectedColumns()
return;
}
$this->selectedColumns = array_keys($this->columnSelector);
if (!isset($_POST[self::PARAM_EXPORT_COLS]) or $_POST[self::PARAM_EXPORT_COLS] === '') {
if (!isset($_POST[$this->exportColsParam]) or $_POST[$this->exportColsParam] === '') {
return;
}
$this->selectedColumns = Json::decode($_POST[self::PARAM_EXPORT_COLS]);
$this->selectedColumns = Json::decode($_POST[$this->exportColsParam]);
}

/**
Expand Down Expand Up @@ -1818,16 +1801,24 @@ protected function registerAssets()
'Request submitted! You may safely close this dialog after saving your downloaded file.'
),
];
$formId = $this->exportFormOptions['id'];
$options = Json::encode(
[
'formId' => $formId,
'messages' => $this->messages,
'dialogLib' => new JsExpression(
ArrayHelper::getValue($this->krajeeDialogSettings, 'libName', 'krajeeDialog')
),
]
);
$options = [
'target' => $this->target,
'formOptions' => $this->exportFormOptions,
'messages' => $this->messages,
'exportType' => $this->_exportType,
'colSelFlagParam' => $this->colSelFlagParam,
'colSelEnabled' => $this->_columnSelectorEnabled ? 1 : 0,
'exportRequestParam' => $this->exportRequestParam,
'exportTypeParam' => $this->exportTypeParam,
'exportColsParam' => $this->exportColsParam,
'exportFormHiddenInputs' => $this->exportFormHiddenInputs,
'showConfirmAlert' => $this->showConfirmAlert,
'dialogLib' => ArrayHelper::getValue($this->krajeeDialogSettings, 'libName', 'krajeeDialog'),
];
if ($this->_columnSelectorEnabled) {
$options['colSelId'] = $this->columnSelectorOptions['id'];
}
$options = Json::encode($options);
$menu = 'kvexpmenu_' . hash('crc32', $options);
$view->registerJs("var {$menu} = {$options};\n", View::POS_HEAD);
$script = '';
Expand All @@ -1836,16 +1827,10 @@ protected function registerAssets()
continue;
}
$id = $this->options['id'] . '-' . strtolower($format);
$options = [
$options = Json::encode([
'settings' => new JsExpression($menu),
'alertMsg' => $setting['alertMsg'],
'target' => $this->target,
'showConfirmAlert' => $this->showConfirmAlert,
];
if ($this->_columnSelectorEnabled) {
$options['columnSelectorId'] = $this->columnSelectorOptions['id'];
}
$options = Json::encode($options);
]);
$script .= "jQuery('#{$id}').exportdata({$options});\n";
}
if ($this->_columnSelectorEnabled) {
Expand Down
2 changes: 1 addition & 1 deletion src/ExportMenuAsset.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/**
* @copyright Copyright &copy; Kartik Visweswaran, Krajee.com, 2015 - 2018
* @package yii2-export
* @version 1.3.2
* @version 1.3.3
*/

namespace kartik\export;
Expand Down
2 changes: 1 addition & 1 deletion src/assets/css/kv-export-columns.css
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* @package yii2-export
* @author Kartik Visweswaran <[email protected]>
* @copyright Copyright &copy; Kartik Visweswaran, Krajee.com, 2015 - 2018
* @version 1.3.2
* @version 1.3.3
*
* Export Columns Selector Style Sheet
*
Expand Down
2 changes: 1 addition & 1 deletion src/assets/css/kv-export-columns.min.css
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* @package yii2-export
* @author Kartik Visweswaran <[email protected]>
* @copyright Copyright &copy; Kartik Visweswaran, Krajee.com, 2015 - 2018
* @version 1.3.2
* @version 1.3.3
*
* Export Columns Selector Style Sheet
*
Expand Down
2 changes: 1 addition & 1 deletion src/assets/css/kv-export-data.css
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* @package yii2-export
* @author Kartik Visweswaran <[email protected]>
* @copyright Copyright &copy; Kartik Visweswaran, Krajee.com, 2015 - 2018
* @version 1.3.2
* @version 1.3.3
*
* Export Menu Style Sheet
*
Expand Down
2 changes: 1 addition & 1 deletion src/assets/css/kv-export-data.min.css
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* @package yii2-export
* @author Kartik Visweswaran <[email protected]>
* @copyright Copyright &copy; Kartik Visweswaran, Krajee.com, 2015 - 2018
* @version 1.3.2
* @version 1.3.3
*
* Export Menu Style Sheet
*
Expand Down
2 changes: 1 addition & 1 deletion src/assets/js/kv-export-columns.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* @package yii2-export
* @author Kartik Visweswaran <[email protected]>
* @copyright Copyright &copy; Kartik Visweswaran, Krajee.com, 2015 - 2018
* @version 1.3.2
* @version 1.3.3
*
* Export Columns Selector Validation Module.
*
Expand Down
2 changes: 1 addition & 1 deletion src/assets/js/kv-export-columns.min.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* @package yii2-export
* @author Kartik Visweswaran <[email protected]>
* @copyright Copyright &copy; Kartik Visweswaran, Krajee.com, 2015 - 2018
* @version 1.3.2
* @version 1.3.3
*
* Export Columns Selector Validation Module.
*
Expand Down
Loading

0 comments on commit 6e2e1dd

Please sign in to comment.