diff --git a/CHANGE.md b/CHANGE.md index f5149d1..1c75c5d 100755 --- a/CHANGE.md +++ b/CHANGE.md @@ -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 diff --git a/README.md b/README.md index 413fffa..54e58b5 100755 --- a/README.md +++ b/README.md @@ -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. diff --git a/composer.json b/composer.json index 2a08efd..0503bfd 100755 --- a/composer.json +++ b/composer.json @@ -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" }, diff --git a/src/ExportColumnAsset.php b/src/ExportColumnAsset.php index 2fbed63..5c87ef0 100644 --- a/src/ExportColumnAsset.php +++ b/src/ExportColumnAsset.php @@ -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; diff --git a/src/ExportMenu.php b/src/ExportMenu.php index a14c52a..15adf3f 100644 --- a/src/ExportMenu.php +++ b/src/ExportMenu.php @@ -4,7 +4,7 @@ * @package yii2-export * @author Kartik Visweswaran * @copyright Copyright © Kartik Visweswaran, Krajee.com, 2015 - 2018 - * @version 1.3.2 + * @version 1.3.3 */ namespace kartik\export; @@ -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. @@ -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'; @@ -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`. @@ -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) { @@ -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', ''); @@ -936,10 +926,10 @@ 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; } } @@ -947,6 +937,7 @@ public function renderExportMenu() * Renders the columns selector * * @return string the column selector markup + * @throws InvalidConfigException */ public function renderColumnSelector() { @@ -956,6 +947,7 @@ public function renderColumnSelector() return $this->render( $this->exportColumnsView, [ + 'isBs4' => $this->isBs4(), 'options' => $this->columnSelectorOptions, 'menuOptions' => $this->columnSelectorMenuOptions, 'columnSelector' => $this->columnSelector, @@ -1056,9 +1048,6 @@ public function generateHeader() $this->_endCol = 0; foreach ($this->getVisibleColumns() as $column) { - if (!empty($column->hiddenFromExport)) { - continue; - } $opts = $styleOpts; $this->_endCol++; /** @@ -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; } @@ -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; } /** @@ -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) { @@ -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) { @@ -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]); } /** @@ -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 = ''; @@ -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) { diff --git a/src/ExportMenuAsset.php b/src/ExportMenuAsset.php index 369fb16..ce32df4 100644 --- a/src/ExportMenuAsset.php +++ b/src/ExportMenuAsset.php @@ -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; diff --git a/src/assets/css/kv-export-columns.css b/src/assets/css/kv-export-columns.css index fe6be13..54accec 100644 --- a/src/assets/css/kv-export-columns.css +++ b/src/assets/css/kv-export-columns.css @@ -2,7 +2,7 @@ * @package yii2-export * @author Kartik Visweswaran * @copyright Copyright © Kartik Visweswaran, Krajee.com, 2015 - 2018 - * @version 1.3.2 + * @version 1.3.3 * * Export Columns Selector Style Sheet * diff --git a/src/assets/css/kv-export-columns.min.css b/src/assets/css/kv-export-columns.min.css index 0a83c60..d998f02 100644 --- a/src/assets/css/kv-export-columns.min.css +++ b/src/assets/css/kv-export-columns.min.css @@ -2,7 +2,7 @@ * @package yii2-export * @author Kartik Visweswaran * @copyright Copyright © Kartik Visweswaran, Krajee.com, 2015 - 2018 - * @version 1.3.2 + * @version 1.3.3 * * Export Columns Selector Style Sheet * diff --git a/src/assets/css/kv-export-data.css b/src/assets/css/kv-export-data.css index 1c91909..bdc722c 100644 --- a/src/assets/css/kv-export-data.css +++ b/src/assets/css/kv-export-data.css @@ -2,7 +2,7 @@ * @package yii2-export * @author Kartik Visweswaran * @copyright Copyright © Kartik Visweswaran, Krajee.com, 2015 - 2018 - * @version 1.3.2 + * @version 1.3.3 * * Export Menu Style Sheet * diff --git a/src/assets/css/kv-export-data.min.css b/src/assets/css/kv-export-data.min.css index 16fccb4..9e91fac 100644 --- a/src/assets/css/kv-export-data.min.css +++ b/src/assets/css/kv-export-data.min.css @@ -2,7 +2,7 @@ * @package yii2-export * @author Kartik Visweswaran * @copyright Copyright © Kartik Visweswaran, Krajee.com, 2015 - 2018 - * @version 1.3.2 + * @version 1.3.3 * * Export Menu Style Sheet * diff --git a/src/assets/js/kv-export-columns.js b/src/assets/js/kv-export-columns.js index 08fc9b9..25432fc 100644 --- a/src/assets/js/kv-export-columns.js +++ b/src/assets/js/kv-export-columns.js @@ -2,7 +2,7 @@ * @package yii2-export * @author Kartik Visweswaran * @copyright Copyright © Kartik Visweswaran, Krajee.com, 2015 - 2018 - * @version 1.3.2 + * @version 1.3.3 * * Export Columns Selector Validation Module. * diff --git a/src/assets/js/kv-export-columns.min.js b/src/assets/js/kv-export-columns.min.js index 10c4870..3efff45 100644 --- a/src/assets/js/kv-export-columns.min.js +++ b/src/assets/js/kv-export-columns.min.js @@ -2,7 +2,7 @@ * @package yii2-export * @author Kartik Visweswaran * @copyright Copyright © Kartik Visweswaran, Krajee.com, 2015 - 2018 - * @version 1.3.2 + * @version 1.3.3 * * Export Columns Selector Validation Module. * diff --git a/src/assets/js/kv-export-data.js b/src/assets/js/kv-export-data.js index df75e51..c0e3fef 100644 --- a/src/assets/js/kv-export-data.js +++ b/src/assets/js/kv-export-data.js @@ -2,7 +2,7 @@ * @package yii2-export * @author Kartik Visweswaran * @copyright Copyright © Kartik Visweswaran, Krajee.com, 2015 - 2018 - * @version 1.3.2 + * @version 1.3.3 * * Export Data Validation Module. * @@ -38,9 +38,6 @@ $.each(options, function (key, val) { self[key] = val; }); - var settings = options.settings; - self.$form = $("#" + settings.formId); - self.messages = settings.messages; self.popup = ''; self.listen(); }; @@ -56,7 +53,7 @@ var el = self.popup.document.getElementsByTagName('body'); setTimeout(function () { el[0].innerHTML = msg; - }, 4000); + }, 1800); } else { var newmsg = $h.popupTemplate.replace('{msg}', msg); self.popup.document.write(newmsg); @@ -64,49 +61,64 @@ }, listen: function () { var self = this; - self.$form.attr('action', window.location.href).appendTo('body'); self.listenClick(); - if (self.target === '_popup') { - self.$form.off('submit.exportmenu').on('submit.exportmenu', function () { - setTimeout(function () { - self.setPopupAlert(self.messages.downloadComplete, true); - }, 1000); - }); - } }, processExport: function (fmt) { - var self = this, $selected, cols = []; - self.$form.attr('action', window.location.href).appendTo('body'); - self.$form.find('[name="export_type"]').val(fmt); - if (self.target === '_popup') { + var self = this, $selected, cols = [], $csrf, yiiLib = window.yii, isPopup, cfg = self.settings, + frmConfig, expCols, $form, getInput = function (name, value) { + return $('', {'type': 'hidden', 'name': name, 'value': value}); + }; + isPopup = cfg.target === '_popup'; + if (isPopup) { self.popup = $h.popupDialog('', 'kvExportFullDialog', 350, 120); self.popup.focus(); - self.setPopupAlert(self.messages.downloadProgress); + self.setPopupAlert(self.settings.messages.downloadProgress); } - if (!$h.isEmpty(self.columnSelectorId)) { - $selected = $('#' + self.columnSelectorId).parent().find('input[name="export_columns_selector[]"]'); + $csrf = yiiLib ? getInput(yiiLib.getCsrfParam() || '_csrf', yiiLib.getCsrfToken() || null) : null; + expCols = ''; + if (!$h.isEmpty(cfg.colSelId)) { + $selected = $('#' + cfg.colSelId).parent().find('input[name="export_columns_selector[]"]'); $selected.each(function () { var $el = $(this); if ($el.is(':checked')) { cols.push($el.attr('data-key')); } }); - self.$form.find('input[name="export_columns"]').val(JSON.stringify(cols)); + expCols = JSON.stringify(cols); + } + frmConfig = $.extend(true, {}, cfg.formOptions, { + action: window.location.href, + method: 'post', + css: {display: 'none'} + }); + $form = $('
', frmConfig).append($csrf) + .append(getInput(cfg.exportTypeParam, fmt), getInput(cfg.exportRequestParam, 1)) + .append(getInput(cfg.exportColsParam, expCols), getInput(cfg.colSelFlagParam, cfg.colSelEnabled)) + .appendTo('body'); + if (!$h.isEmpty(cfg.exportFormHiddenInputs)) { + $.each(cfg.exportFormHiddenInputs, function (key, setting) { + var opts = {'name': key, 'value': setting.value || null, 'type': 'hidden'}; + opts = $.extend({}, opts, setting.options || {}); + $form.append($('', opts)); + }); + } + $form.submit().remove(); + if (isPopup) { + self.setPopupAlert(self.settings.messages.downloadComplete, true); } - self.$form.trigger('submit'); }, listenClick: function () { var self = this; self.$element.off('click.exportmenu').on('click.exportmenu', function (e) { - var fmt, msgs, msg = '', msg1, msg2, msg3, lib = window[self.dialogLib]; + var fmt, msgs, msg = '', msg1, msg2, msg3, lib = window[self.settings.dialogLib]; fmt = $(this).data('format'); e.preventDefault(); e.stopPropagation(); - if (!self.showConfirmAlert) { + if (!self.settings.showConfirmAlert) { self.processExport(fmt); return; } - msgs = self.messages; + msgs = self.settings.messages; msg1 = $h.isEmpty(self.alertMsg) ? '' : self.alertMsg; msg2 = $h.isEmpty(msgs.allowPopups) ? '' : msgs.allowPopups; msg3 = $h.isEmpty(msgs.confirmDownload) ? '' : msgs.confirmDownload; @@ -156,14 +168,19 @@ }; $.fn.exportdata.defaults = { - filename: 'export', - target: '_popup', - showConfirmAlert: true, - columnSelectorId: null, alertMsg: '', - dialogLib: 'krajeeDialog', settings: { - formId: '', + formOptions: {}, + exportType: '', + colSelEnabled: '', + exportRequestParam: '', + exportTypeParam: '', + exportColsParam: '', + exportFormHiddenInputs: {}, + colSelId: null, + target: '_popup', + showConfirmAlert: true, + dialogLib: 'krajeeDialog', messages: { allowPopups: '', confirmDownload: '', diff --git a/src/assets/js/kv-export-data.min.js b/src/assets/js/kv-export-data.min.js index 7c14f1f..0ccc5b7 100644 --- a/src/assets/js/kv-export-data.min.js +++ b/src/assets/js/kv-export-data.min.js @@ -2,7 +2,7 @@ * @package yii2-export * @author Kartik Visweswaran * @copyright Copyright © Kartik Visweswaran, Krajee.com, 2015 - 2018 - * @version 1.3.2 + * @version 1.3.3 * * Export Data Validation Module. * @@ -10,4 +10,5 @@ * Copyright: 2015, Kartik Visweswaran, Krajee.com * For more JQuery plugins visit http://plugins.krajee.com * For more Yii related demos visit http://demos.krajee.com - */!function(t){"use strict";var o={isEmpty:function(o,e){return null===o||void 0===o||o===[]||""===o||e&&""===t.trim(o)},popupDialog:function(t,o,e,n){var i=screen.width/2-e/2;return window.open("",o,"",!0).close(),window.open(t,o,"toolbar=no, location=no, directories=no, status=yes, menubar=no, scrollbars=no, resizable=no, copyhistory=no, width="+e+", height="+n+", top=60, left="+i)},popupTemplate:'Export Data - © Krajee{msg}'},e=function(o,e){var n=this;n.$element=t(o),t.each(e,function(t,o){n[t]=o});var i=e.settings;n.$form=t("#"+i.formId),n.messages=i.messages,n.popup="",n.listen()};e.prototype={constructor:e,setPopupAlert:function(t){var e=this;if(e.popup.document)if(arguments.length&&arguments[1]){var n=e.popup.document.getElementsByTagName("body");setTimeout(function(){n[0].innerHTML=t},4e3)}else{var i=o.popupTemplate.replace("{msg}",t);e.popup.document.write(i)}},listen:function(){var t=this;t.$form.attr("action",window.location.href).appendTo("body"),t.listenClick(),"_popup"===t.target&&t.$form.off("submit.exportmenu").on("submit.exportmenu",function(){setTimeout(function(){t.setPopupAlert(t.messages.downloadComplete,!0)},1e3)})},processExport:function(e){var n=this,i=[];n.$form.attr("action",window.location.href).appendTo("body"),n.$form.find('[name="export_type"]').val(e),"_popup"===n.target&&(n.popup=o.popupDialog("","kvExportFullDialog",350,120),n.popup.focus(),n.setPopupAlert(n.messages.downloadProgress)),o.isEmpty(n.columnSelectorId)||(t("#"+n.columnSelectorId).parent().find('input[name="export_columns_selector[]"]').each(function(){var o=t(this);o.is(":checked")&&i.push(o.attr("data-key"))}),n.$form.find('input[name="export_columns"]').val(JSON.stringify(i))),n.$form.trigger("submit")},listenClick:function(){var e=this;e.$element.off("click.exportmenu").on("click.exportmenu",function(n){var i,a,r,p,l,s="",u=window[e.dialogLib];i=t(this).data("format"),n.preventDefault(),n.stopPropagation(),e.showConfirmAlert?(a=e.messages,r=o.isEmpty(e.alertMsg)?"":e.alertMsg,p=o.isEmpty(a.allowPopups)?"":a.allowPopups,l=o.isEmpty(a.confirmDownload)?"":a.confirmDownload,s=r.length&&p.length?r+"\n\n"+p:!r.length&&p.length?p:r.length&&!p.length?r:"",l.length&&(s=s+"\n\n"+l),o.isEmpty(s)?e.processExport(i):u.confirm(s,function(t){t&&e.processExport(i)})):e.processExport(i)})}},t.fn.exportdata=function(o){var n=Array.apply(null,arguments);return n.shift(),this.each(function(){var i=t(this),a=i.data("exportdata"),r="object"==typeof o&&o;a||i.data("exportdata",a=new e(this,t.extend({},t.fn.exportdata.defaults,r,t(this).data()))),"string"==typeof o&&a[o].apply(a,n)})},t.fn.exportdata.defaults={filename:"export",target:"_popup",showConfirmAlert:!0,columnSelectorId:null,alertMsg:"",dialogLib:"krajeeDialog",settings:{formId:"",messages:{allowPopups:"",confirmDownload:"",downloadProgress:"",downloadComplete:""}}}}(window.jQuery); \ No newline at end of file + */ +!function(t){"use strict";var e={isEmpty:function(e,o){return null===e||void 0===e||e===[]||""===e||o&&""===t.trim(e)},popupDialog:function(t,e,o,n){var p=screen.width/2-o/2,a=60,i=window.open("",e,"",!0);return i.close(),window.open(t,e,"toolbar=no, location=no, directories=no, status=yes, menubar=no, scrollbars=no, resizable=no, copyhistory=no, width="+o+", height="+n+", top="+a+", left="+p)},popupTemplate:'Export Data - © Krajee{msg}'},o=function(e,o){var n=this;n.$element=t(e),t.each(o,function(t,e){n[t]=e}),n.popup="",n.listen()};o.prototype={constructor:o,setPopupAlert:function(t){var o=this;if(o.popup.document)if(arguments.length&&arguments[1]){var n=o.popup.document.getElementsByTagName("body");setTimeout(function(){n[0].innerHTML=t},1800)}else{var p=e.popupTemplate.replace("{msg}",t);o.popup.document.write(p)}},listen:function(){var t=this;t.listenClick()},processExport:function(o){var n,p,a,i,r,s,l=this,d=[],u=window.yii,c=l.settings,m=function(e,o){return t("",{type:"hidden",name:e,value:o})};a="_popup"===c.target,a&&(l.popup=e.popupDialog("","kvExportFullDialog",350,120),l.popup.focus(),l.setPopupAlert(l.settings.messages.downloadProgress)),p=u?m(u.getCsrfParam()||"_csrf",u.getCsrfToken()||null):null,r="",e.isEmpty(c.colSelId)||(n=t("#"+c.colSelId).parent().find('input[name="export_columns_selector[]"]'),n.each(function(){var e=t(this);e.is(":checked")&&d.push(e.attr("data-key"))}),r=JSON.stringify(d)),i=t.extend(!0,{},c.formOptions,{action:window.location.href,method:"post",css:{display:"none"}}),s=t("",i).append(p).append(m(c.exportTypeParam,o),m(c.exportRequestParam,1)).append(m(c.exportColsParam,r),m(c.colSelFlagParam,c.colSelEnabled)).appendTo("body"),e.isEmpty(c.exportFormHiddenInputs)||t.each(c.exportFormHiddenInputs,function(e,o){var n={name:e,value:o.value||null,type:"hidden"};n=t.extend({},n,o.options||{}),s.append(t("",n))}),s.submit().remove(),a&&l.setPopupAlert(l.settings.messages.downloadComplete,!0)},listenClick:function(){var o=this;o.$element.off("click.exportmenu").on("click.exportmenu",function(n){var p,a,i,r,s,l="",d=window[o.settings.dialogLib];return p=t(this).data("format"),n.preventDefault(),n.stopPropagation(),o.settings.showConfirmAlert?(a=o.settings.messages,i=e.isEmpty(o.alertMsg)?"":o.alertMsg,r=e.isEmpty(a.allowPopups)?"":a.allowPopups,s=e.isEmpty(a.confirmDownload)?"":a.confirmDownload,l=i.length&&r.length?i+"\n\n"+r:!i.length&&r.length?r:i.length&&!r.length?i:"",s.length&&(l=l+"\n\n"+s),e.isEmpty(l)?void o.processExport(p):void d.confirm(l,function(t){t&&o.processExport(p)})):void o.processExport(p)})}},t.fn.exportdata=function(e){var n=Array.apply(null,arguments);return n.shift(),this.each(function(){var p=t(this),a=p.data("exportdata"),i="object"==typeof e&&e;a||p.data("exportdata",a=new o(this,t.extend({},t.fn.exportdata.defaults,i,t(this).data()))),"string"==typeof e&&a[e].apply(a,n)})},t.fn.exportdata.defaults={alertMsg:"",settings:{formOptions:{},exportType:"",colSelEnabled:"",exportRequestParam:"",exportTypeParam:"",exportColsParam:"",exportFormHiddenInputs:{},colSelId:null,target:"_popup",showConfirmAlert:!0,dialogLib:"krajeeDialog",messages:{allowPopups:"",confirmDownload:"",downloadProgress:"",downloadComplete:""}}}}(window.jQuery); \ No newline at end of file diff --git a/src/views/_columns.php b/src/views/_columns.php index a684fde..02ca8b6 100644 --- a/src/views/_columns.php +++ b/src/views/_columns.php @@ -3,7 +3,7 @@ * @package yii2-export * @author Kartik Visweswaran * @copyright Copyright © Kartik Visweswaran, Krajee.com, 2015 - 2018 - * @version 1.3.2 + * @version 1.3.3 * * Column Selector View * @@ -13,6 +13,7 @@ use yii\helpers\ArrayHelper; /** + * @var bool $isBs4 * @var array $options * @var array $batchToggle * @var array $columnSelector @@ -58,7 +59,7 @@ -
  • +
  • - * @copyright Copyright © Kartik Visweswaran, Krajee.com, 2015 - 2018 - * @version 1.3.2 - * - * Export Submission Form - * - */ -use yii\helpers\ArrayHelper; -use yii\helpers\Html; - -/** - * @var array $options - * @var string $exportTypeParam - * @var string $exportType - * @var string $exportRequestParam - * @var string $exportColsParam - * @var string $colselFlagParam - * @var string $columnSelectorEnabled - */ -echo Html::beginForm('', 'post', $options); -echo Html::hiddenInput($exportTypeParam, $exportType); -echo Html::hiddenInput($exportRequestParam, 1); -echo Html::hiddenInput($exportColsParam, ''); -echo Html::hiddenInput($colselFlagParam, $columnSelectorEnabled); -if (!empty($exportFormHiddenInputs)) { - foreach ($exportFormHiddenInputs as $name => $setting) { - echo Html::hiddenInput( - $name, - ArrayHelper::getValue($setting, 'value', null), - ArrayHelper::getValue($setting, 'options', []) - ); - } -} -echo Html::endForm(); diff --git a/src/views/_view.php b/src/views/_view.php index ed52536..a3ba984 100644 --- a/src/views/_view.php +++ b/src/views/_view.php @@ -3,7 +3,7 @@ * @package yii2-export * @author Kartik Visweswaran * @copyright Copyright © Kartik Visweswaran, Krajee.com, 2015 - 2018 - * @version 1.3.2 + * @version 1.3.3 * * Export Submission View * @@ -12,6 +12,7 @@ use yii\helpers\Html; /** + * @var bool $isBs4 * @var string $icon * @var string $file * @var string $href