Skip to content

Commit

Permalink
Fixed issue: If the cpdb had custom attributes and error would be dis…
Browse files Browse the repository at this point in the history
…played while trying access it / small ui size adjustment
  • Loading branch information
ptelu authored and olleharstedt committed May 21, 2021
1 parent 574db34 commit b1f3fa6
Show file tree
Hide file tree
Showing 3 changed files with 74 additions and 69 deletions.
112 changes: 57 additions & 55 deletions application/models/Participant.php
Expand Up @@ -356,92 +356,94 @@ public function getBlacklistSwitchbutton()
*/
public function getColumns()
{
$cols = array(
array(
"name" => 'checkbox',
"type" => 'raw',
$cols = [
[
"name" => 'checkbox',
"type" => 'raw',
"header" => "<input type='checkbox' id='action_toggleAllParticipant' />",
"filter" => false
),
array(
"name" => 'buttons',
"type" => 'raw',
],
[
"name" => 'buttons',
"type" => 'raw',
"header" => gT("Action"),
"filter" => false
),
array(
],
[
"name" => 'lastname'
),
array(
],
[
"name" => 'firstname'
),
array(
],
[
"name" => 'email'
),
array(
"name" => 'language',
"value" => 'getLanguageNameFromCode($data->language, false)',
],
[
"name" => 'language',
"value" => 'getLanguageNameFromCode($data->language, false)',
'filter' => $this->allUsedLanguagesWithRealName
),
array(
"name" => 'countActiveSurveys',
"value" => '$data->getCountActiveSurveys()',
"header" => gT("Active surveys"),
"htmlOptions" => array('width' => '80px')
),
array(
"name" => 'owner.full_name',
],
[
"name" => 'countActiveSurveys',
"value" => '$data->getCountActiveSurveys()',
"header" => gT("Active surveys"),
"htmlOptions" => ['width' => '80px']
],
[
"name" => 'owner.full_name',
"header" => gT("Owner"),
"filter" => $this->getOwnersList($this->owner_uid)
),
array(
"name" => 'blacklisted',
"value" => '$data->getBlacklistSwitchbutton()',
"type" => "raw",
"filter" => array('N' => gT("No"), 'Y' => gT('Yes'))
),
array(
'name' => 'created',
],
[
"name" => 'blacklisted',
"value" => '$data->getBlacklistSwitchbutton()',
"type" => "raw",
"filter" => ['N' => gT("No"), 'Y' => gT('Yes')]
],
[
'name' => 'created',
'value' => '$data->createdFormatted',
'type' => 'raw',
)
);
'type' => 'raw',
]
];

$extraAttributeParams = Yii::app()->request->getParam('extraAttribute');
foreach ($this->allExtraAttributes as $name => $attribute) {
if ($attribute['visible'] == "FALSE") {
if ($attribute['visible'] === "FALSE") {
continue;
}
$col_array = array(
"value" => '$data->getParticipantAttribute($this->id)',
"id" => $name,
if (!isset($extraAttributeParams[$name])) {
$extraAttributeParams[$name] = '';
}
$col_array = [
"value" => '$data->getParticipantAttribute($this->id)',
"id" => $name,
"header" => $attribute['defaultname'] . $this->setEncryptedAttributeLabel(0, 'Participant', $attribute['defaultname']),
"type" => "html",
);
"type" => "html",
];
//textbox
if ($attribute['attribute_type'] == "TB") {
if ($attribute['attribute_type'] === "TB") {
$col_array["filter"] = TbHtml::textField("extraAttribute[" . $name . "]", $extraAttributeParams[$name]);
}
//dropdown
elseif ($attribute['attribute_type'] == "DD") {
} elseif ($attribute['attribute_type'] === "DD") {
//dropdown
$options_raw = $this->getOptionsForAttribute($attribute['attribute_id']);
$options_array = array(
$options_array = [
'' => ''
);
];
foreach ($options_raw as $option) {
$options_array[$option['value']] = $option['value'];
}

$col_array["filter"] = TbHtml::dropDownList("extraAttribute[" . $name . "]", $extraAttributeParams[$name], $options_array);
}
//date -> still a text field, too many errors with the gridview
elseif ($attribute['attribute_type'] == "DP") {
} elseif ($attribute['attribute_type'] === "DP") {
//date -> still a text field, too many errors with the gridview
$col_array["filter"] = TbHtml::textField("extraAttribute[" . $name . "]", $extraAttributeParams[$name]);
}
$cols[] = $col_array;
}
return $cols;
}

/**
* Retrieves a list of models based on the current search/filter conditions.
* @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
Expand Down Expand Up @@ -521,7 +523,7 @@ public function search()
// See: https://forum.yiiframework.com/t/show-sql-generated-from-cdbcriteria/45021

// Use "LIKE" for text-box, equal for other types
if ($attributeType == 'TB') {
if ($attributeType === 'TB') {
$bindKey = ':attribute_id' . $attributeId;
$callParticipantAttributes->where("attribute_id = " . $bindKey . " AND value LIKE '%" . $value . "%'", array($bindKey => $attributeId));
$criteria->params[$bindKey] = $attributeId;
Expand Down
2 changes: 1 addition & 1 deletion application/views/admin/participants/attributeMap_view.php
Expand Up @@ -71,7 +71,7 @@
<?php eT("Existing survey participant attributes"); ?>
</div>
<div class='panel-body'>
<div class="tokenatt ui-sortable" style="min-height: 200px;">
<div class="tokenatt ui-sortable">
<?php foreach ($selectedtokenattribute as $id => $name): ?>
<?php if (isset($automaticallyMappedAttributes[$id])): ?>
<?php $autoAttr = $automaticallyMappedAttributes[$id]; // Short-hand... ?>
Expand Down
29 changes: 16 additions & 13 deletions assets/scripts/admin/attributeMap.js
Expand Up @@ -4,26 +4,29 @@ var LS = LS || { onDocumentReady: {} };

$(document).on('ready pjax:scriptcomplete', function(){

var height = $(document).height();
var width = $(document).width();
var windowHeight = $(window).height();
var tokencurrentarray = {};
var newcurrentarray = {};


var centralattribute = $('#centralattribute');
var newcreated = $('#newcreated');
var tokenattribute = $('#tokenattribute');

if($("#overwrite").is(':checked')) {var attoverwrite=true;} else {var attoverwrite=false;}
if($("#overwriteman").is(':checked')) {var attoverwriteman=true;} else {var attoverwriteman=false;}
if($("#createautomap").is(':checked')) {var attcreateautomap=true;} else {var attcreateautomap=false;}
if($("#overwritest").is(':checked')) {var attoverwritest=true;} else {var attoverwritest=false;}

$('#tokenattribute').css({'height' : height-200});
$('#centralattribute').css({'height' : height-200});
$('#newcreated').css({'height' : height-200});
var ncHeadingHeight = $('#newcreated .heading').outerHeight();
$('.newcreate').css({
'padding-bottom':0,
'min-height':$('#newcreated').height()-ncHeadingHeight-5
});
$("#overwrite").click(function(){
centralattribute.css({'min-height': windowHeight * 0.5});
newcreated.css({'min-height': windowHeight * 0.5});
tokenattribute.css({'min-height': windowHeight * 0.5});
var ncHeadingHeight = $('#newcreated .heading').outerHeight();
$('.newcreate').css({
'padding-bottom': 0,
'min-height': newcreated.height() - ncHeadingHeight - 5
});

$("#overwrite").click(function (){
if($("#overwrite").is(':checked')) {attoverwrite=true;} else {attoverwrite=false;}
});
$("#overwriteman").click(function(){
Expand Down

0 comments on commit b1f3fa6

Please sign in to comment.