Skip to content

Commit

Permalink
Fixed issue #CT-480: CPDB attribute issues (#3620)
Browse files Browse the repository at this point in the history
* Attributes were not considered when adding CPDB participant to survey

* Export participants: Select all attributes was broken

* Import Participants to CPDB: page design fixes

* Fix redirect button in modal

* Fixed empty warning alert on suucessful import of participants
  • Loading branch information
twilligls committed Nov 16, 2023
1 parent 5d97f49 commit 5c210ea
Show file tree
Hide file tree
Showing 16 changed files with 81 additions and 57 deletions.
28 changes: 17 additions & 11 deletions application/views/admin/participants/attributeMapCSV_view.php
@@ -1,4 +1,4 @@
<div class='header'>
<div class='header pt-2'>
<h3 class='pagetitle'><?php neT("Select which fields to import as attributes with your {n} participant.|Select which fields to import as attributes with your {n} participants.", $linecount); ?></h3>
</div>

Expand All @@ -15,12 +15,15 @@
<p class='help-block'><?php eT("The following additional fields were found in your CSV file."); ?></p>
<div class="csvatt droppable-csv">
<?php
foreach ($firstline as $value)
{
foreach ($firstline as $value) {
echo CHtml::tag(
"div",
array('id'=>"cs_{$value}",'data-name'=>$value,'class'=>"draggable well well-sm csv-attribute-item"),
$value
array(
'id' => "cs_{$value}",
'data-name' => $value,
'class' => "draggable card csv-attribute-item"
),
'<div class="card-body">' . $value . '</div>'
);
}
?>
Expand All @@ -46,11 +49,14 @@
<div class='card-body'>
<p class='help-block'><?php eT("Drop a CSV field into an existing participant attribute listed below to import your data into it."); ?></p>
<div class="centralatt">
<?php foreach ($attributes as $key => $value): ?>
<div class='col-12 droppable-map'>
<div class='col-md-6'>
<div id='c_<?php echo $value['attribute_id']; ?>' data-name='c_<?php echo $key; ?>' class='well well-sm csv-attribute-item'>
<?php echo $value['attribute_name']; ?>
<?php foreach ($attributes as $key => $value) : ?>
<div class='col-12 row droppable-map'>
<div class='col-6'>
<div id='c_<?php echo $value['attribute_id']; ?>' data-name='c_<?php echo $key; ?>' class='card csv-attribute-item'>
<div class='card-body'>
<?php echo $value['attribute_name']; ?>
<span class='ri-arrow-left-right-fill tokenatt-arrow'></span>
</div>
</div>
</div>
</div>
Expand All @@ -62,7 +68,7 @@
<label for='overwrite'><?php eT("Overwrite existing participant attribute values if a duplicate participant is found?") ?>
<br />
<?php
if($participant_id_exists) {
if ($participant_id_exists) {
eT("Duplicates will be detected using the participant_id field in this CSV file.");
} else {
eT("Duplicates will be detected by a combination of firstname, lastname and email addresses.");
Expand Down
18 changes: 9 additions & 9 deletions application/views/admin/participants/attributeMap_view.php
Expand Up @@ -2,7 +2,7 @@
var redUrl = "<?php echo $this->createUrl("/admin/participants/sa/displayParticipants"); ?>";
var surveyId = "<?php echo $survey_id ?>";
var redirect = "<?php echo $redirect ?>";
if(redirect)
if(redirect == "1")
{
redUrl = "<?php echo $this->createUrl("/admin/tokens/sa/browse/surveyid/{$survey_id}"); ?>";
}
Expand All @@ -19,7 +19,7 @@

</script>

<div class='header ui-widget-header'>
<div class='header pt-2'>
<div class='pagetitle h3'>
<?php eT("Map your central participant attributes to existing survey participant attributes or create new ones"); ?>
</div>
Expand Down Expand Up @@ -75,16 +75,16 @@
<?php foreach ($selectedtokenattribute as $id => $name): ?>
<?php if (isset($automaticallyMappedAttributes[$id])): ?>
<?php $autoAttr = $automaticallyMappedAttributes[$id]; // Short-hand... ?>
<div class='tokenatt-container col-12'>
<div class='col-sm-6'>
<div class='tokenatt-container row col-12'>
<div class='col-6'>
<div class='card ui-state-disabled token-attribute' id='t_<?php echo $id; ?>'>
<div class='card-body'>
<?php echo CHtml::encode($name); ?>
<span class='ri-arrow-left-right-fill tokenatt-arrow'></span>
</div>
</div>
</div>
<div class='col-md-6'>
<div class='col-6'>
<div class='card ui-state-disabled cpdb-attribute' id='c_<?php echo $autoAttr['cpdbAttribute']['attribute_id']; ?>'>
<div class='card-body'>
<?php echo $autoAttr['cpdbAttribute']['attribute_name']; ?>
Expand All @@ -93,8 +93,8 @@
</div>
</div>
<?php else: ?>
<div class='tokenatt-container col-12'>
<div class='col-md-6'>
<div class='tokenatt-container row col-12'>
<div class='col-6'>
<div class='card ui-state-disabled token-attribute' id='t_<?php echo $id; ?>'>
<div class='card-body'>
<?php echo CHtml::encode($name); ?>
Expand Down Expand Up @@ -154,8 +154,8 @@
<div class='card-header '><?php eT("Standard participant fields") ?></div>
<div class='card-body'>
<div class="standardfields">
<div class='tokenatt-container col-12'>
<div class='col-md-6'>
<div class='tokenatt-container row col-12'>
<div class='col-6'>
<div class='card ui-state-disabled token-attribute' id='t_token'>
<div class='card-body'>
<?php eT("Participant") ?>
Expand Down
Expand Up @@ -8,8 +8,14 @@
<div class="modal-body">
<div class="form">
<div class='mb-3 row'>
<label class='form-label col-md-4' for='attributes'><?php eT('Attributes to export:');?></label>
<div class='col-md-8'>
<div class="col-4">
<label class='form-label' for='attributes'><?php eT('Attributes to export:');?></label>
<input type="checkbox" value="" id="select-all">
<label class="form-check-label" for="select-all">
<?= gT('Select all'); ?>
</label>
</div>
<div class='col-8'>
<?php $this->widget('yiiwheels.widgets.select2.WhSelect2',
array(
'asDropDownList' => true,
Expand Down
Expand Up @@ -20,9 +20,6 @@
var error = "<?php eT("Error", 'js') ?>";
var exportBtn = "<?php eT("Export", 'js') ?>";
var cancelBtn = "<?php eT("Cancel", 'js') ?>";
var sSelectAllText = "<?php eT("Select all", 'js') ?>";
var sNonSelectedText = "<?php eT("None selected", 'js') ?>";
var sNSelectedText = "<?php eT("selected", 'js') ?>";
var exportToCSVURL = "<?php echo Yii::app()->getController()->createUrl("admin/participants/sa/exporttocsv"); ?>";
var openModalParticipantPanel = "<?php echo ls\ajax\AjaxHelper::createUrl("/admin/participants/sa/openModalParticipantPanel"); ?>";
var editValueParticipantPanel = "<?php echo Yii::app()->getController()->createUrl("/admin/participants/sa/editValueParticipantPanel"); ?>";
Expand Down
13 changes: 7 additions & 6 deletions application/views/admin/participants/uploadSummary_view.php
Expand Up @@ -35,7 +35,6 @@
if ($overwritten > 0) {
$infoSummary .= "<li>" . sprintf(gT("%s records were duplicate but had attributes updated"), $overwritten) . "</li>";
}
$warningSummary .= "</ul>";
if (count($duplicatelist) || count($invalidemaillist) || count($invalidattribute) || count($aInvalidFormatlist)) {
$warningSummary .= "<div class='warningheader'>" . gT('Warnings') . "</div><ul>";
if (count($duplicatelist) > 0) {
Expand Down Expand Up @@ -82,11 +81,13 @@
'htmlOptions' => ['class' => 'successheader']
], true);

$alerts .= $this->widget('ext.AlertWidget.AlertWidget', [
'text' => $warningSummary,
'type' => 'warning',
'htmlOptions' => ['class' => 'warningheader']
], true);
if ($warningSummary !== '') {
$alerts .= $this->widget('ext.AlertWidget.AlertWidget', [
'text' => $warningSummary,
'type' => 'warning',
'htmlOptions' => ['class' => 'warningheader']
], true);
}
} else {
$alerts .= $this->widget('ext.AlertWidget.AlertWidget', [
'header' => gT('Error'),
Expand Down
Expand Up @@ -1691,7 +1691,7 @@ iframe#dialog {
/** Arrow between mapped attributes in CPDB */
.tokenatt-arrow {
position: absolute;
right: -0.5em;
right: -1.5em;
}

/** Arrow between mapped attributes in CPDB when doing CSV import */
Expand Down
Expand Up @@ -11,6 +11,10 @@
margin-bottom: 20px;
}

#csvattribute {
z-index: 1;
}

#tokenattribute {
margin-left: 1.5%;
}
Expand Down
2 changes: 1 addition & 1 deletion assets/packages/adminbasics/build/adminbasics.css
Expand Up @@ -2427,7 +2427,7 @@ iframe#dialog {
/** Arrow between mapped attributes in CPDB */
.tokenatt-arrow {
position: absolute;
right: -0.5em;
right: -1.5em;
}

/** Arrow between mapped attributes in CPDB when doing CSV import */
Expand Down
2 changes: 1 addition & 1 deletion assets/packages/adminbasics/build/adminbasics.rtl.css
Expand Up @@ -2427,7 +2427,7 @@ iframe#dialog {
/** Arrow between mapped attributes in CPDB */
.tokenatt-arrow {
position: absolute;
left: -0.5em;
left: -1.5em;
}

/** Arrow between mapped attributes in CPDB when doing CSV import */
Expand Down
2 changes: 1 addition & 1 deletion assets/scripts/admin/attributeMap.js
Expand Up @@ -153,7 +153,7 @@ $(document).on('ready pjax:scriptcomplete', function(){
});

newcurrentarray = {};
$('.newcreate .card-default').each(function(index, value) {
$('.newcreate .card').each(function(index, value) {
var id = $(value).attr('id').substring(2);
newcurrentarray[index] = id;
});
Expand Down
19 changes: 10 additions & 9 deletions assets/scripts/admin/attributeMapCSV.js
Expand Up @@ -69,17 +69,17 @@ $(document).on('ready pjax:scriptcomplete', function() {
// Remove the text input if dropped out of the new attributes column
if(!$(this).hasClass('newcreate') && $('input[type="text"]', newDraggable).length > 0) {
$('input[type="text"]', newDraggable).remove();
$(newDraggable).text($(newDraggable).attr('data-name'));
$(newDraggable).html('<div class="card-body">' + $(newDraggable).attr('data-name') + '</div>');
}

// Dropped in new attributes
if($(this).hasClass('newcreate')) {
newDraggable.html(newDraggable.attr('id').replace('cs_',''));
newDraggable.html('<div class="card-body">' + newDraggable.attr('id').replace('cs_','') + '</div>');
var id = newDraggable.attr('id').replace(/ /g, '');
var name = newDraggable.attr('data-name');
newDraggable.prepend('<input type="text" id="td_' + id + '" value="' + name + '">&nbsp;');
}
newDraggable.find($('.card-body')).prepend('<input class="form-control" type="text" id="td_' + id + '" value="' + name + '">&nbsp;');
}

// Reset the mappable attribute classes
$('.mappable-attribute-wrapper').removeClass('paired');
$('.mappable-attribute-wrapper .csv-attribute').closest('.mappable-attribute-wrapper').addClass('paired');
Expand All @@ -97,7 +97,7 @@ $(document).on('ready pjax:scriptcomplete', function() {
drop: function(event, ui) {

// Insert nice arrow
var col = $(this).find('.col-md-6:first-child');
var col = $(this).find('.col-6:first-child');
col.append('<span class="ri-arrow-left-right-fill csvatt-arrow"></span>');

// Physically move the draggable to the target (the plugin just visually moves it)
Expand Down Expand Up @@ -144,7 +144,7 @@ $(document).on('ready pjax:scriptcomplete', function() {
$(newDraggable).text($(newDraggable).attr('data-name'));
}

newDraggable.wrap("<div class='col-md-6'></div>");
newDraggable.wrap('<div class="col-6"></div>');

adjustHeights();
}
Expand All @@ -171,10 +171,11 @@ $(document).on('ready pjax:scriptcomplete', function() {
$('#move-all').click(function () {
$('.droppable-csv .csv-attribute-item').each(function(i, elem) {
var $elem = $(elem);
$elem.html($elem.attr('id').replace('cs_',''));
$elem.html('<div class="card-body">' + $elem.attr('id').replace('cs_','') + '</div>');
var id = $elem.attr('id').replace(/ /g, '');
var name = $elem.attr('data-name');
$elem.prepend('<input type="text" id="td_' + id + '" value="' + name + '">');
$elem.find($('.card-body'))
.prepend('<input class="form-control" type="text" id="td_' + id + '" value="' + name + '">');
$elem.detach().appendTo('.newcreate');
adjustHeights();
});
Expand Down
19 changes: 10 additions & 9 deletions assets/scripts/admin/participantpanel.js
Expand Up @@ -127,15 +127,16 @@ LS.CPDB = (function() {
dlForm.css('display', 'none').appendTo('body').submit();
$(self).modal("hide");
});
$('#attributes')
.multiselect({
includeSelectAllOption:true,
selectAllValue: '0',
selectAllText: sSelectAllText,
nonSelectedText: sNonSelectedText,
nSelectedText: sNSelectedText,
maxHeight: 140
});

$('#select-all').click(function () {
if ($('#select-all').is(':checked')) {
$('#attributes > option').prop('selected', 'selected');
$('#attributes').trigger('change');
} else {
$('#attributes > option').removeAttr('selected');
$('#attributes').trigger('change');
}
});
});
/* $.download(exporttocsvall,'searchcondition=dummy',$('#exportcsvallprocessing').dialog("close"));*/
}
Expand Down
6 changes: 5 additions & 1 deletion themes/admin/Sea_Green/css/sea_green-rtl.css
Expand Up @@ -12950,7 +12950,7 @@ iframe#dialog {
/** Arrow between mapped attributes in CPDB */
.tokenatt-arrow {
position: absolute;
left: -0.5em;
left: -1.5em;
}

/** Arrow between mapped attributes in CPDB when doing CSV import */
Expand Down Expand Up @@ -14765,6 +14765,10 @@ html[dir=ltr] th {
margin-bottom: 20px;
}

#csvattribute {
z-index: 1;
}

#tokenattribute {
margin-right: 1.5%;
}
Expand Down
2 changes: 1 addition & 1 deletion themes/admin/Sea_Green/css/sea_green-rtl.min.css

Large diffs are not rendered by default.

6 changes: 5 additions & 1 deletion themes/admin/Sea_Green/css/sea_green.css
Expand Up @@ -12973,7 +12973,7 @@ iframe#dialog {
/** Arrow between mapped attributes in CPDB */
.tokenatt-arrow {
position: absolute;
right: -0.5em;
right: -1.5em;
}

/** Arrow between mapped attributes in CPDB when doing CSV import */
Expand Down Expand Up @@ -14788,6 +14788,10 @@ html[dir=rtl] th {
margin-bottom: 20px;
}

#csvattribute {
z-index: 1;
}

#tokenattribute {
margin-left: 1.5%;
}
Expand Down
2 changes: 1 addition & 1 deletion themes/admin/Sea_Green/css/sea_green.min.css

Large diffs are not rendered by default.

0 comments on commit 5c210ea

Please sign in to comment.