Skip to content

Commit

Permalink
Dev: start review participant panel
Browse files Browse the repository at this point in the history
Dev: … argl …
  • Loading branch information
Shnoulle committed Nov 12, 2018
1 parent ca51587 commit bb3c7ce
Show file tree
Hide file tree
Showing 7 changed files with 57 additions and 5 deletions.
5 changes: 3 additions & 2 deletions application/controllers/admin/participantsaction.php
Expand Up @@ -311,12 +311,13 @@ public function displayParticipants()
$model->setAttributes($participantParam, false);
}
/* @todo : See when/where it's used */
$searchcondition = $request->getPost('searchcondition');
$searchcondition = $request->getParam('searchcondition');
$searchparams = array();
if ($searchcondition) {
$searchparams = explode('||', $searchcondition);
$model->addSurveyFilter($searchparams);
}

// data to be passed to view
$aData = array(
'names' => User::model()->findAll(),
Expand Down Expand Up @@ -406,7 +407,7 @@ public function deleteParticipant()
*/
public function openEditParticipant()
{
$participant_id = Yii::app()->request->getPost('participant_id');
$participant_id = Yii::app()->request->getParam('participant_id');
if ($participant_id) {
$model = Participant::model()->findByPk($participant_id);
$operationType = "edit";
Expand Down
1 change: 1 addition & 0 deletions application/controllers/admin/responses.php
Expand Up @@ -403,6 +403,7 @@ public function browse($iSurveyId)
}

if (Permission::model()->hasSurveyPermission($iSurveyId, 'responses', 'read')) {
App()->getClientScript()->registerScriptFile(App()->getConfig('adminscripts').'gridAction.js', LSYii_ClientScript::POS_BEGIN);
App()->getClientScript()->registerScriptFile(App()->getConfig('adminscripts').'listresponse.js', LSYii_ClientScript::POS_BEGIN);
App()->getClientScript()->registerScriptFile(App()->getConfig('adminscripts').'tokens.js', LSYii_ClientScript::POS_BEGIN);

Expand Down
1 change: 1 addition & 0 deletions application/controllers/admin/tokens.php
Expand Up @@ -32,6 +32,7 @@ class tokens extends Survey_Common_Action
*/
public function index($surveyid)
{
App()->getClientScript()->registerScriptFile(App()->getConfig('adminscripts').'gridAction.js', LSYii_ClientScript::POS_BEGIN);
App()->getClientScript()->registerScriptFile(App()->getConfig('adminscripts').'tokens.js', LSYii_ClientScript::POS_BEGIN);
$iSurveyId = $surveyid;
$iSurveyId = (int) $iSurveyId;
Expand Down
1 change: 1 addition & 0 deletions application/models/Participant.php
Expand Up @@ -478,6 +478,7 @@ public function search()

$criteria = new CDbCriteria;
$criteria->join = 'LEFT JOIN {{participant_shares}} AS shares ON t.participant_id = shares.participant_id AND (shares.share_uid = '.Yii::app()->user->id.' OR shares.share_uid = -1)';
$criteria->compare('t.participant_id', $this->participant_id, true, 'AND', true);
$criteria->compare('t.firstname', $this->firstname, true, 'AND', true);
$criteria->compare('t.lastname', $this->lastname, true, 'AND', true);
$criteria->compare('t.email', $this->email, true, 'AND', true);
Expand Down
27 changes: 25 additions & 2 deletions application/models/TokenDynamic.php
Expand Up @@ -634,7 +634,7 @@ public function getStandardColsForGrid()
array(
'header' => gT('Action'),
'class'=>'bootstrap.widgets.TbButtonColumn',
'template'=>'{viewresponse}{spacerviewresponse}{previewsurvey}{previewsurveyspacer}{mail}{remind}{mailspacer}{edit}{deletetoken}',
'template'=>'{viewresponse}{spacerviewresponse}{previewsurvey}{previewsurveyspacer}{mail}{remind}{mailspacer}{edit}{deletetoken}{viewparticipant}{viewparticipantspacer}',
'buttons'=> $this->getGridButtons(),
),
array(
Expand Down Expand Up @@ -922,7 +922,30 @@ public function getGridButtons()
'click' => 'confirmGridAction'
);
/* CPDB link */
$baseVisible = Permission::model()->hasGlobalPermission('participantpanel', 'read');
$baseVisible = Permission::model()->hasGlobalPermission('participantpanel', 'read') && self::model(self::$sid)->count("participant_id is not null");
$gridButtons['viewparticipant'] = array(
'label'=>'<span class="sr-only">'.gT('View this participant in the central participants database').'</span><span class="icon-cpdb" aria-hidden="true"></span>',
'imageUrl'=>false,
'url' => 'App()->createUrl("admin/participants/sa/displayParticipants",array("searchcondition"=>"participant_id||equal||".$data->participant_id))',
'options' => array(
'class'=>"btn btn-default btn-xs",
'data-toggle'=>"tooltip",
'title'=>gT('View this participant in the central participants database'),
),
'visible' => 'boolval('.$baseVisible.') && $data->participant_id',
);
$gridButtons['viewparticipantspacer'] = array(
'label'=>'<span class="icon-cpdb text-muted" aria-hidden="true"></span>',
'imageUrl'=>false,
'url' => '#',
'options' => array(
'class'=>"btn btn-default btn-xs disabled",
'data-toggle'=>"tooltip",
'title'=>"",
),
'visible' => 'boolval('.$baseVisible.') && empty($data->participant_id)',
'script' => 'noGridAction',
);
return $gridButtons;
}

Expand Down
Expand Up @@ -30,7 +30,7 @@
. "<div class='col-xs-12'>"
. gT("Active filters:")
. "<span class=''>&nbsp;&nbsp;</span>"
. "<button id='removeAllFilters' class='btn btn-warning btn-xs'>".gT("Remove filters")."</button>"
. "<button id='removeAllFilters' class='btn btn-warning btn-xs' data_url='".App()->createUrl("admin/participants/sa/displayParticipants")."'>".gT("Remove filters")."</button>"
. "</div>"
. "</div>";
$i=0;
Expand Down
25 changes: 25 additions & 0 deletions assets/scripts/admin/gridAction.js
@@ -0,0 +1,25 @@
/* Todo : move this function to admin base grig.js */
var noGridAction = function() {
return false;
}
function confirmGridAction() {
var actionUrl = $(this).attr('href');
var text = $(this).data('confirm-text') || $(this).attr('title') || $(this).data('original-title');
var utf8 = $(this).data('confirm-utf8') || LS.lang.confirm;
$.bsconfirm(text,utf8,function onClickOK() {
$('#responses-grid').yiiGridView('update', {
type : 'POST',
url : actionUrl, // No need to add csrfToken, already in ajaxSetup
success: function(data) {
jQuery('#responses-grid').yiiGridView('update');
$('#identity__bsconfirmModal').modal('hide');
// todo : show an success alert box
},
error: function (request, status, error) {
$('#identity__bsconfirmModal').modal('hide');
alert(request.responseText);// Use a better alert box (see todo success)
}
});
});
return false;
}

0 comments on commit bb3c7ce

Please sign in to comment.