|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace hipanel\widgets; |
|
4
|
|
|
|
|
5
|
|
|
use kartik\date\DatePickerAsset; |
|
6
|
|
|
use omnilight\assets\MomentAsset; |
|
7
|
|
|
use Yii; |
|
8
|
|
|
use yii\base\Widget; |
|
9
|
|
|
use yii\bootstrap\Modal; |
|
10
|
|
|
use yii\helpers\Html; |
|
11
|
|
|
use yii\helpers\Url; |
|
12
|
|
|
|
|
13
|
|
|
class ReminderButton extends Widget |
|
14
|
|
|
{ |
|
15
|
|
|
public $object_id; |
|
16
|
|
|
|
|
17
|
|
|
public $toggleButton = []; |
|
18
|
|
|
|
|
19
|
|
|
public function init() |
|
20
|
|
|
{ |
|
21
|
|
|
$this->registerCLientScript(); |
|
22
|
|
|
} |
|
23
|
|
|
|
|
24
|
|
|
public function run() |
|
25
|
|
|
{ |
|
26
|
|
|
$modalId = 'reminder-modal-' . $this->object_id; |
|
27
|
|
|
$this->getView()->registerCss("button[data-target='#{$modalId}'] {margin-top: -3px;}"); |
|
28
|
|
|
return AjaxModal::widget([ |
|
29
|
|
|
'bulkPage' => false, |
|
30
|
|
|
'id' => $modalId, |
|
31
|
|
|
'modalFormId' => 'reminder-form-' . $this->object_id, |
|
32
|
|
|
'scenario' => 'create', |
|
33
|
|
|
'actionUrl' => ['@reminder/create-modal', 'object_id' => $this->object_id], |
|
34
|
|
|
'handleSubmit' => Url::toRoute('@reminder/create'), |
|
35
|
|
|
'size' => Modal::SIZE_DEFAULT, |
|
36
|
|
|
'header' => Html::tag('h4', Yii::t('hipanel/reminder', 'Create new reminder'), ['class' => 'modal-title']), |
|
37
|
|
|
'toggleButton' => $this->getToggleButton(), |
|
38
|
|
|
]); |
|
39
|
|
|
} |
|
40
|
|
|
|
|
41
|
|
|
/** |
|
42
|
|
|
* @return mixed |
|
43
|
|
|
*/ |
|
44
|
|
|
public function getToggleButton() |
|
45
|
|
|
{ |
|
46
|
|
|
return (!empty($this->toggleButton)) ? |
|
47
|
|
|
$this->toggleButton : |
|
48
|
|
|
[ |
|
49
|
|
|
'label' => '<i class="fa fa-bell-o"></i> ' . Yii::t('hipanel/reminder', 'Create reminder'), |
|
50
|
|
|
'class' => 'btn margin-bottom btn-info pull-right' |
|
51
|
|
|
]; |
|
52
|
|
|
} |
|
53
|
|
|
|
|
54
|
|
|
/** |
|
55
|
|
|
* @param mixed $toggleButton |
|
56
|
|
|
*/ |
|
57
|
|
|
public function setToggleButton($toggleButton) |
|
58
|
|
|
{ |
|
59
|
|
|
$this->toggleButton = $toggleButton; |
|
|
|
|
|
|
60
|
|
|
} |
|
61
|
|
|
|
|
62
|
|
|
public function registerClientScript() |
|
63
|
|
|
{ |
|
64
|
|
|
$view = $this->getView(); |
|
65
|
|
|
MomentAsset::register($view); |
|
66
|
|
|
DatePickerAsset::register($view); |
|
67
|
|
|
} |
|
68
|
|
|
} |
|
69
|
|
|
|
|
70
|
|
|
|
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..