Skip to content

Commit

Permalink
Dev: Reodered Buttons and add borders
Browse files Browse the repository at this point in the history
  • Loading branch information
thedirtypanda committed Jul 14, 2021
1 parent 9257a4f commit db43e16
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 38 deletions.
81 changes: 46 additions & 35 deletions application/models/Participant.php
Original file line number Diff line number Diff line change
Expand Up @@ -131,44 +131,63 @@ public function getButtons()
if ($this->userHasPermissionToEdit()) {
// Edit button
$editData = array(
'action_participant_editModal',
'green-border action_participant_editModal',
'',
gT("Edit this participant"),
'edit'
'pencil'
);
$buttons .= vsprintf($raw_button_template, $editData);

// Add participant to survey
$addParticipantData = array(
'action_participant_addToSurvey',
'',
gT("Add participant to survey"),
'user-plus'
);

$buttons .= vsprintf($raw_button_template, $addParticipantData);

// Survey information
$listActiveSurveysData = array(
'action_participant_infoModal',
'',
gT("List active surveys"),
'search'
);
$buttons .= vsprintf($raw_button_template, $listActiveSurveysData);

// Share this participant
$shareParticipantData = array(
'action_participant_shareParticipant',
'',
gT("Share this participant"),
'share'
);
$buttons .= vsprintf($raw_button_template, $shareParticipantData);

// Only owner or superadmin can delete
$userId = Yii::app()->user->id;
$isSuperAdmin = Permission::model()->hasGlobalPermission('superadmin', 'read');
$deletePermission = Permission::model()->hasGlobalPermission('participantpanel', 'delete');
if ($this->owner_uid == $userId || $isSuperAdmin || $deletePermission) {
// Delete button
$deleteData = array(
'action_participant_deleteModal',
'red-border action_participant_deleteModal',
'text-danger',
gT("Delete this participant"),
'trash text-danger'
'trash'
);
$buttons .= vsprintf($raw_button_template, $deleteData);
} else {
// Invisible button
$deleteData = array(
'action_participant_deleteModal invisible',
'red-border action_participant_deleteModal invisible',
'text-danger',
gT("Delete this participant"),
'trash text-danger'
'trash'
);
$buttons .= vsprintf($raw_button_template, $deleteData);
}
// Share this participant
$infoData = array(
'action_participant_shareParticipant',
'',
gT("Share this participant"),
'share'
);
$buttons .= vsprintf($raw_button_template, $infoData);
$buttons .= vsprintf($raw_button_template, $deleteData);
} else {
// Three empty buttons for correct alignment
// TODO: For some reason, the delete button is smaller than the others
Expand All @@ -195,7 +214,17 @@ public function getButtons()
'trash text-danger'
);
}
$buttons .= vsprintf($raw_button_template, $deleteData);

// Share this participant
$infoData = array(
'action_participant_shareParticipant',
'',
gT("Share this participant"),
'share'
);
$buttons .= vsprintf($raw_button_template, $infoData);


$infoData = array(
'action_participant_shareParticipant invisible',
'',
Expand All @@ -205,24 +234,6 @@ public function getButtons()
$buttons .= vsprintf($raw_button_template, $infoData);
}

// Survey information
$infoData = array(
'action_participant_infoModal',
'',
gT("List active surveys"),
'search'
);
$buttons .= vsprintf($raw_button_template, $infoData);

// Add participant to survey
$infoData = array(
'action_participant_addToSurvey',
'',
gT("Add participant to survey"),
'user-plus'
);
$buttons .= vsprintf($raw_button_template, $infoData);

$buttons .= "</div>";
return $buttons;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,12 @@
$this->widget('bootstrap.widgets.TbGridView', array(
'id' => 'list_central_participants',
'emptyText'=>gT('No participants found.'),
'itemsCssClass' => 'table table-striped items',
'itemsCssClass' => 'table table-hover items',
'dataProvider' => $model->search(),
'columns' => $model->columns,
'rowHtmlOptionsExpression' => '["data-participant_id" => $data->id]',
'htmlOptions' => array('style'=>'cursor: pointer;', 'class'=>'hoverAction table-responsive'),
'itemsCssClass' => 'table table-responsive table-striped',
'htmlOptions' => array('style'=>'cursor: pointer;', 'class'=>'table-responsive'),
'itemsCssClass' => 'table table-responsive table-hover',
'filter'=>$model,
'afterAjaxUpdate' => 'function(id, data){LS.CPDB.bindButtons;LS.CPDB.participantPanel();bindListItemclick();}',
'ajaxType' => 'POST',
Expand Down

0 comments on commit db43e16

Please sign in to comment.