Skip to content

Commit

Permalink
Merge pull request #15 from d3yii2/ActionColumns
Browse files Browse the repository at this point in the history
Added action column
  • Loading branch information
uldisn authored Jul 2, 2019
2 parents 4d20037 + acca18f commit 1869e77
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 4 deletions.
12 changes: 11 additions & 1 deletion views/d3files/files.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
* @var bool $viewByFancyBox
* @var array $viewByFancyBoxExtensions
* @var array $fileList
* @var $actionColumn
*/


Expand Down Expand Up @@ -211,7 +212,7 @@ function handleDragLeave(e) {
'data-fancybox' => true,
'data-type' => 'iframe',
'fancybox' => 'fancybox',
'data-src' => \yii\helpers\Url::to($fbUrl)
'data-src' => Url::to($fbUrl)
];

echo Html::a('<i class="fa fa-external-link"></i>',
Expand All @@ -221,6 +222,15 @@ function handleDragLeave(e) {
</td>
<?php
}
if($actionColumn) {
?>
<td class="col-xs-1">
<?php
echo call_user_func($actionColumn,$row);
?>
</td>
<?php
}
?>
<td class="text-center col-xs-1">
<?=Html::a(
Expand Down
14 changes: 13 additions & 1 deletion views/d3files/files_readonly.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
<?php

use eaBlankonThema\widget\ThFancyBoxLink;
use yii\helpers\Html;

/**
* @var bool $viewByFancyBox
* @var array $viewByFancyBoxExtensions
* @var array $fileList
* @var $actionColumn
*/

if($viewByFancyBox) {
Expand Down Expand Up @@ -49,13 +52,22 @@
) ?>
</td>
<?php
if($actionColumn) {
?>
<td class="col-xs-1">
<?php
echo call_user_func($actionColumn,$row);
?>
</td>
<?php
}
if($viewByFancyBox) {
$ext = strtolower(pathinfo($row['file_name'], PATHINFO_EXTENSION));
?>
<td class="col-xs-1">
<?php
if(in_array($ext,$viewByFancyBoxExtensions, true)){
echo \eaBlankonThema\widget\ThFancyBoxLink::widget([
echo ThFancyBoxLink::widget([
'text' => Yii::t('d3files', 'View'),
'options' => [
//'class' => 'unpaid-invoice-table-actions-col'
Expand Down
8 changes: 6 additions & 2 deletions widgets/D3FilesWidget.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ class D3FilesWidget extends Widget
/** @var array */
public $fileList;

/** @var callable implented only in ea\eablankonthema\d3files_views\d3files\files_readonly.php */
public $actionColumn;

public function init()
{
parent::init();
Expand Down Expand Up @@ -85,7 +88,8 @@ public function run()
'fileList' => $this->fileList,
'url_prefix' => $url_prefix,
'viewByFancyBox' => $this->viewByFancyBox,
'viewByFancyBoxExtensions' => $this->viewByFancyBoxExtensions
'viewByFancyBoxExtensions' => $this->viewByFancyBoxExtensions,
'actionColumn' => $this->actionColumn
]
);
}
Expand Down Expand Up @@ -139,7 +143,7 @@ public static function getModalLoadAttributes(array $attachmentUrl, array $file,

$attrs = [
'data-toggle' => 'modal',
'data-src' => \yii\helpers\Url::to($attachmentUrl),
'data-src' => Url::to($attachmentUrl),
'data-target' => $modalSelector,
'data-content-target' => $modalContentSelector,
];
Expand Down

0 comments on commit 1869e77

Please sign in to comment.