Skip to content

Commit

Permalink
Fixed issue #08798: Editing a dropdown attribute value deletes everyt…
Browse files Browse the repository at this point in the history
…hing but the first word

Dev: Clean up JavaScript and styles for editing attributes
  • Loading branch information
tpartner committed Mar 3, 2014
1 parent b5b0065 commit 66368b9
Show file tree
Hide file tree
Showing 8 changed files with 140 additions and 29 deletions.
15 changes: 11 additions & 4 deletions application/views/admin/participants/viewAttribute_view.php
Expand Up @@ -31,7 +31,7 @@
</ul>

<div id='ddtable' style='display: none'>
<table width='400' class='hovertable' style='margin:0 auto'>
<table class='hovertable'>
<tr>
<th colspan='2'><?php $clang->eT('Values:'); ?></th>
</tr>
Expand All @@ -40,7 +40,7 @@
{
?>
<tr>
<td class='data'>
<td class='data' data-text='<?php echo $value['value']; ?>' data-id='<?php echo $value['value_id']; ?>'>
<div class=editable id="<?php echo $value['value_id']; ?>">
<?php
echo $value['value'];
Expand All @@ -49,6 +49,13 @@
</td>
<td class='actions'>
<?php
$edit = array('src' => Yii::app()->getConfig('adminimageurl') . 'cancel_16.png',
'alt' => $clang->gT("Cancel editing"),
'width' => '16',
'class' => 'cancel',
'height' => '16',
'title' => $clang->gT("Cancel editing"));
echo CHtml::image($edit['src'], $edit['alt'], array_slice($edit, 2));
$edit = array('src' => Yii::app()->getConfig('adminimageurl') . 'edit_16.png',
'alt' => $clang->gT("Edit value"),
'width' => '15',
Expand All @@ -61,7 +68,7 @@
'alt' => $clang->gT("Delete value"),
'width' => '15',
'height' => '15',
'class'=> 'edit',
'class'=> 'delete',
'title' => $clang->gT("Delete value"));
echo CHtml::link(CHtml::image($del['src'], $del['alt'], array_slice($del, 2)), $this->createUrl('admin/participants/sa/delAttributeValues/aid/' . $attributes['attribute_id'] . '/vid/' . $value['value_id']));
?></td>
Expand All @@ -70,7 +77,7 @@
}
?>
</table>
<table width='400' style='margin:0 auto'>
<table>
<tr>
<td></td>
<td class='actions'>
Expand Down
26 changes: 19 additions & 7 deletions scripts/admin/viewAttribute.js
Expand Up @@ -60,19 +60,31 @@ $(document).ready(function() {
var id = 1;
$('.add').click(function(){
html = "<tr>"+
"<td><input type='text' name='attribute_value_name_"+id+"' id='attribute_value_name_"+id+"' size='8' style='50%;'></td></tr>";
"<td colspan='2'><input type='text' name='attribute_value_name_"+id+"' id='attribute_value_name_"+id+"' size='8' style='50%;'></td></tr>";
$('.dd').fadeIn('slow');
$('#ddtable tr:last').after(html);
id++;
});
$(".editable").click(function () {
var value_id = this.id;
$(this).replaceWith( "<div><input type='text' size='20' name='editbox' id='editbox' value="+$(this).text()+"><input type='hidden' id='value_id' name='value_id' value='"+value_id+"' /></div>" );
$(document.body).on('dblclick', '.editable', function() {
editAttrValue(this.id);
});
$('.edit').click(function(){
var value_id = this.name;
$("#"+value_id).replaceWith( "<div><input type='text' size='20' name='editbox' id='editbox' value="+$("#"+value_id).text()+"><input type='hidden' id='value_id' name='value_id' value='"+value_id+"' /></div>" );
$('.actions .edit').click(function(){
editAttrValue(this.name);
});
$('.actions .cancel').click(function(){
var thisRow = $(this).closest('tr');
var valueText = $('td.data', thisRow).html('<div id="'+$('td.data', thisRow).attr('data-id')+'" class="editable">'+$('td.data', thisRow).attr('data-text')+'</div>');
$('.actions .cancel', thisRow).hide();
$('.actions .edit, .actions .delete', thisRow).show();
});
function editAttrValue(valueId) {
var valueText = $.trim($("#"+valueId).text());
var thisRow = $("#"+valueId).closest('tr');
$("#"+valueId).replaceWith( "<div><input type='text' size='20' name='editbox' id='editbox"+valueId+"' /><input type='hidden' id='value_id' name='value_id' value='"+valueId+"' /></div>" );
$('#editbox'+valueId).val(valueText);
$('.actions .edit, .actions .delete', thisRow).hide();
$('.actions .cancel', thisRow).show();
}
$('.languagesetting').click(function(){
$(".languagesetting").css('border', '1px solid black');
$(".languagesetting").css('background-color', 'white');
Expand Down
Binary file added styles/blobblueish/images/cancel_16.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
42 changes: 36 additions & 6 deletions styles/blobblueish/viewAttribute.css
@@ -1,9 +1,4 @@
#addlang
{
width: 30%;
margin-left: auto ;
margin-right: auto ;
}

#comsettingdrop
{
width: 15%;
Expand All @@ -25,4 +20,39 @@
width: 20%;
margin-left: auto ;
margin-right: auto ;
}

#addlang {
margin: 1em 0;
}

#ddtable table,
#addlang table {
margin: 0 auto;
width: 30%;
min-width: 400px;
}

#ddtable th,
#addlang th {
padding: 1px 3px;
}

#ddtable td,
#addlang td {
padding: 3px;
}

#ddtable td.actions,
#addlang td.actions {
text-align: right;
}

#ddtable td.actions img,
#addlang td.actions img {
margin-left: 3px;
}

#ddtable td.actions img.cancel {
display: none;
}
Binary file added styles/darkblue/images/cancel_16.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
43 changes: 37 additions & 6 deletions styles/darkblue/viewAttribute.css
@@ -1,9 +1,4 @@
#addlang
{
width: 400px;
margin-left: auto ;
margin-right: auto ;
}

.commonsettings {
width: 400px;
margin-left: auto;
Expand Down Expand Up @@ -41,4 +36,40 @@ td.data {
}
input {
background-color: white;
}

#addlang {
margin: 1em 0;
}

#ddtable table,
#addlang table {
margin: 0 auto;
width: 30%;
min-width: 400px;
}

#ddtable th,
#addlang th {
padding: 1px 3px;
}

#ddtable td,
#addlang td {
padding: 3px;
}

#ddtable td.actions,
#addlang td.actions {
text-align: right;
}

#ddtable td.actions img,
#addlang td.actions img {
float: none;
margin-left: 3px;
}

#ddtable td.actions img.cancel {
display: none;
}
Binary file added styles/gringegreen/images/cancel_16.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
43 changes: 37 additions & 6 deletions styles/gringegreen/viewAttribute.css
@@ -1,9 +1,4 @@
#addlang
{
width: 400px;
margin-left: auto ;
margin-right: auto ;
}

.commonsettings {
width: 400px;
margin-left: auto;
Expand Down Expand Up @@ -41,4 +36,40 @@ td.data {
}
input {
background-color: white;
}

#addlang {
margin: 1em 0;
}

#ddtable table,
#addlang table {
margin: 0 auto;
width: 30%;
min-width: 400px;
}

#ddtable th,
#addlang th {
padding: 1px 3px;
}

#ddtable td,
#addlang td {
padding: 3px;
}

#ddtable td.actions,
#addlang td.actions {
text-align: right;
}

#ddtable td.actions img,
#addlang td.actions img {
float: none;
margin-left: 3px;
}

#ddtable td.actions img.cancel {
display: none;
}

0 comments on commit 66368b9

Please sign in to comment.