1<?php
2/**
3 * Render the selector for question massive actions.
4 * @var $model      The question model
5 * @var $oSurvey    The survey object
6 */
7?>
8
9<!-- Rendering massive action widget -->
10
11<?php
12
13    /**
14     * Here are defined the different massive actions for question grid.
15     * To add a new massive action, just create a new entry in the aActions array, and write its related method in questions controller.
16     * If the action need a form inside the modal so the user can set some values, please, use a subview (e.g: _set_question_group_position.php)
17     *
18     * @see documentation: https://github.com/LimeSurvey/LimeSurvey/tree/master/application/extensions/admin/grid/MassiveActionsWidget/README.md
19     */
20
21    $aActions = [];
22    // Download header
23    $aActions[] = array(
24
25        // li element
26        'type' => 'dropdown-header',
27        'text' => gT("General"),
28    );
29    if(!$oSurvey->isActive) {
30        // Delete
31        $aActions[] = array(
32            // li element
33            'type' => 'action',
34            'action' => 'delete',
35            'url' => App()->createUrl('/admin/questions/sa/deleteMultiple/'),
36            'iconClasses' => 'text-danger fa fa-trash',
37            'text' => gT('Delete'),
38            'grid-reload' => 'yes',
39
40            // modal
41            'actionType' => 'modal',
42            'modalType' => 'yes-no',
43            'keepopen' => 'yes',
44            'sModalTitle' => gT('Delete question(s)'),
45            'htmlModalBody' => gT('Deleting these questions will also delete their corresponding answer options and subquestions. Are you sure you want to continue??'),
46        );
47    }
48    if(!$oSurvey->isActive) {
49        // Set question and group
50        $aActions[] = array(
51            // li element
52            'type' => 'action',
53            'action' => 'set-group-position',
54            'url' => App()->createUrl('/admin/questions/sa/setMultipleQuestionGroup/'),
55            'iconClasses' => 'fa fa-folder-open',
56            'text' => gT('Set question group and position'),
57            'grid-reload' => 'yes',
58
59            // modal
60            'actionType' => 'modal',
61            'modalType' => 'yes-no',
62            'keepopen' => 'no',
63            'yes' => gT('Apply'),
64            'no' => gT('Cancel'),
65            'sModalTitle' => gT('Set question group'),
66            'htmlModalBody' => $this->renderPartial('./survey/Question/massive_actions/_set_question_group_position', array('model' => $model, 'oSurvey' => $oSurvey), true),
67        );
68    }
69
70    // Set mandatory
71    $aActions[] = array(
72        // li element
73        'type' => 'action',
74        'action' => 'set-mandatory',
75        'url' => App()->createUrl('/admin/questions/sa/setMultipleMandatory/'),
76        'iconClasses' => 'fa fa-asterisk text-danger',
77        'text' => gT('Set "Mandatory" state'),
78        'grid-reload' => 'yes',
79
80        // modal
81        'actionType' => 'modal',
82        'modalType' => 'yes-no',
83        'yes' => gT('Apply'),
84        'no' => gT('Cancel'),
85        'keepopen' => 'no',
86        'sModalTitle' => gT('Set "Mandatory" state'),
87        'htmlModalBody' => $this->renderPartial('./survey/Question/massive_actions/_set_questions_mandatory', array(), true),
88    );
89
90    // Set CSS Class
91    $aActions[] = array(
92        // li element
93        'type' => 'action',
94        'action' => 'set-css',
95        'url' => App()->createUrl('/admin/questions/sa/setMultipleAttributes/'),
96        'iconClasses' => 'fa fa-css3',
97        'text' => gT('Set CSS class'),
98        'grid-reload' => 'yes',
99
100        // modal
101        'actionType' => 'modal',
102        'modalType' => 'yes-no',
103        'yes' => gT('Apply'),
104        'no' => gT('Cancel'),
105        'keepopen' => 'no',
106        'sModalTitle' => gT('Set CSS class'),
107        'htmlModalBody' => $this->renderPartial('./survey/Question/massive_actions/_set_css_class', array(), true),
108    );
109
110    // Set Statistics
111    $aActions[] = array(
112        // li element
113        'type' => 'action',
114        'action' => 'set-statistics',
115        'url' => App()->createUrl('/admin/questions/sa/setMultipleAttributes/'),
116        'iconClasses' => 'fa fa-bar-chart',
117        'text' => gT('Set statistics options'),
118        'grid-reload' => 'yes',
119
120        // modal
121        'actionType' => 'modal',
122        'modalType' => 'yes-no',
123        'yes' => gT('Apply'),
124        'no' => gT('Cancel'),
125        'keepopen' => 'no',
126        'sModalTitle' => gT('Set statistics options'),
127        'htmlModalBody' => $this->renderPartial('./survey/Question/massive_actions/_set_statistics_options', array(), true),
128    );
129
130    // Separator
131    $aActions[] = array(
132        // li element
133        'type' => 'separator',
134    );
135
136    // Download header
137    $aActions[] = array(
138        // li element
139        'type' => 'dropdown-header',
140        'text' => gT("Advanced") . ' ' . '(' . gT("only apply to certain question types") . ')',
141    );
142
143    if(!$oSurvey->isActive) {
144        // Set other
145        // DEPEND IF SURVEY IS ACTIVE !!!! (checked by /admin/questions/sa/setMultipleOther/ )
146        // TODO: don't show that action if survey is active
147        $aActions[] = array(
148            // li element
149            'type' => 'action',
150            'action' => 'set-other',
151            'url' => App()->createUrl('/admin/questions/sa/setMultipleOther/'),
152            'iconClasses' => 'fa fa-dot-circle-o',
153            'text' => gT('Set "Other" state'),
154            'grid-reload' => 'yes',
155
156            // modal
157            'actionType' => 'modal',
158            'modalType' => 'yes-no',
159            'yes' => gT('Apply'),
160            'no' => gT('Cancel'),
161            'keepopen' => 'no',
162            'sModalTitle' => gT('Set "Other" state'),
163            'htmlModalBody' => $this->renderPartial('./survey/Question/massive_actions/_set_questions_other', array(), true),
164        );
165    }
166
167    // Set subquestions/answers sort options
168    $aActions[] = array(
169        // li element
170        'type' => 'action',
171        'action' => 'set-subquestions-answers-sort',
172        'url' => App()->createUrl('/admin/questions/sa/setMultipleAttributes/'),
173        'iconClasses' => 'fa fa-sort',
174        'text' => gT('Present subquestions/answer options in random order'),
175        'grid-reload' => 'yes',
176
177        // modal
178        'actionType' => 'modal',
179        'modalType' => 'yes-no',
180        'yes' => gT('Apply'),
181        'no' => gT('Cancel'),
182        'keepopen' => 'false',
183        'sModalTitle' => gT('Present subquestions/answer options in random order'),
184        'htmlModalBody' => $this->renderPartial('./survey/Question/massive_actions/_set_subquestansw_order', array(), true),
185    );
186
187
188
189    $this->widget('ext.admin.grid.MassiveActionsWidget.MassiveActionsWidget', array(
190            'pk'          => 'id',
191            'gridid'      => 'question-grid',
192            'dropupId'    => 'questionListActions',
193            'dropUpText'  => gT('Selected question(s)...'),
194            'aActions'    => $aActions,
195    ));
196?>
197
198
199<!--
200    Some widgets in the modals need to be reloaded after grid update
201-->
202<?php App()->getClientScript()->registerScript("ListQuestions-massiveAction-1", "
203    $(function(){
204        $('#question-grid').on('actions-updated', function(){
205            loadPositionWidget();
206        });
207    });
208 ", LSYii_ClientScript::POS_END); ?>
209
210