Skip to content

Commit

Permalink
Fixed issue #17846: Expression manager on file upload question type d…
Browse files Browse the repository at this point in the history
…on't work on same page (#2269)

* Fixed issue #17846: Expression manager on file upload question type don't work on same page

* Revert "Fixed issue #17846: Expression manager on file upload question type don't work on same page"

This reverts commit a7c090f.

* Fixed issue #17846: Expression manager on file upload question type don't work on same page

* Fixed issue #17846: Expression manager on file upload question type don't work on same page

Co-authored-by: encuestabizdevgit <devgit@encuesta.biz>
  • Loading branch information
gabrieljenik and encuestabizdevgit committed Mar 14, 2022
1 parent f6ad186 commit cc70269
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 7 deletions.
2 changes: 1 addition & 1 deletion application/helpers/expressions/em_manager_helper.php
Expand Up @@ -4087,7 +4087,7 @@ public function setVariableAndTokenMappingsForExpressionManager($surveyid,$force
$jsVarName_on = 'answer' . $sgqa;;
break;
case '|': //File Upload
$jsVarName = $sgqa;
$jsVarName = 'java' . $sgqa;
$jsVarName_on = $jsVarName;
break;
case 'P': //Multiple choice with comments checkbox + text
Expand Down
Expand Up @@ -21,8 +21,8 @@
<span class='fa fa-upload'></span>&nbsp;{{ gT('Upload files') }}
</a>
</div>
<input type='hidden' id='{{ fileid }}' name='{{ fileid }}' value='{{ value }}' />
<input type='hidden' id='{{ fileid }}_filecount' name='{{ fileid }}_filecount' value="{{ filecountvalue }}" />
<input type='hidden' id='java{{ fileid }}' name='{{ fileid }}' value='{{ value }}' />
<input type='hidden' id='java{{ fileid }}_filecount' name='{{ fileid }}_filecount' value="{{ filecountvalue }}" />
<div id='{{ fileid }}_uploadedfiles'>

</div>
Expand Down
4 changes: 4 additions & 0 deletions assets/scripts/expressions/em_javascript.js
Expand Up @@ -46,6 +46,10 @@ $(document).on("change",".radio-item :radio:not([onclick]), .button-item :radio:
$(document).on("change",".checkbox-item :checkbox:not([onclick]),.button-item :checkbox:not([onclick])",function(event){
checkconditions($(this).val(), $(this).attr('name'), 'checkbox', 'click')
});
/* hidden item */
$(document).on("updated",".answer-item :hidden, .upload-item :hidden",function(event){
checkconditions($(this).val(), $(this).attr('name'), 'equation', 'updated')
});

/**
* For number
Expand Down
4 changes: 2 additions & 2 deletions assets/scripts/modaldialog.js
Expand Up @@ -135,8 +135,8 @@ function displayUploadedFiles(jsonstring, filecount, fieldname, show_title, show
}

function copyJSON(jsonstring, filecount, fieldname, show_title, show_comment, pos) {
$('#'+fieldname).val(jsonstring);
$('#'+fieldname+'_filecount').val(filecount);
$('#java'+fieldname).val(jsonstring).trigger('updated');
$('#java'+fieldname+'_filecount').val(filecount).trigger('updated');
displayUploadedFiles(jsonstring, filecount, fieldname, show_title, show_comment, pos);
}

Expand Down
4 changes: 2 additions & 2 deletions assets/scripts/uploader.js
Expand Up @@ -30,14 +30,14 @@ function doFileUpload()
{
var fieldname = $('#ia').val();
/* Load the previously uploaded files */
var filecount = window.parent.window.$('#' + fieldname + '_filecount').val();
var filecount = window.parent.window.$('#java' + fieldname + '_filecount').val();
$('#' + fieldname + '_filecount').val(filecount);

var image_extensions = new Array("gif", "jpeg", "jpg", "png", "swf", "psd", "bmp", "tiff", "jp2", "iff", "bmp", "xbm", "ico");

if (filecount > 0)
{
var jsontext = window.parent.window.$('#' + fieldname).val();
var jsontext = window.parent.window.$('#java' + fieldname).val();
var json = '';
try{
json = JSON.parse(jsontext);
Expand Down

1 comment on commit cc70269

@Shnoulle
Copy link
Collaborator

@Shnoulle Shnoulle commented on cc70269 Dec 19, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This commit broke usage of Upload Question type.
Please revert before a better fix :)

https://bugs.limesurvey.org/view.php?id=18562

Please sign in to comment.