Completed
Pull Request — master (#126)
by
unknown
22:33 queued 07:02
created

ApplyToAllWidget::run()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 13

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 13
c 0
b 0
f 0
rs 9.8333
cc 1
nc 1
nop 0
1
<?php
2
3
4
namespace hipanel\widgets;
5
6
7
use hipanel\assets\ApplyToAllAsset;
8
use yii\base\Widget;
9
10
/**
11
 * Class AssignAttributesWidget
12
 * @package hipanel\widgets
13
 */
14
class ApplyToAllWidget extends Widget
15
{
16
    /**
17
     * @var \hipanel\base\Model[]
18
     */
19
    public $models;
20
21
    /**
22
     * @var string[]
23
     */
24
    public $attributes;
25
26
    /**
27
     * @inheritDoc
28
     */
29
    public function run()
30
    {
31
        ApplyToAllAsset::register($this->view);
32
        $options = \yii\helpers\Json::htmlEncode([
33
            'countModels' => count($this->models),
34
            'formName' => strtolower(reset($this->models)->formName()),
35
            'attributes' => $this->attributes,
36
            'linkText' => \Yii::t('hipanel', 'Apply to all'),
37
        ]);
38
        $this->view->registerJs("\$('#assign-hubs-form').applyToAll($options);");
39
40
        return parent::run();
41
    }
42
}
43