N°2844 - Document file: Fix object details not displaying correctly

This commit is contained in:
Molkobain
2021-03-12 18:32:56 +01:00
parent 0902f2c32b
commit ebada5e866
2 changed files with 23 additions and 18 deletions

View File

@@ -2099,28 +2099,33 @@ EOF
$aEventsList[] = 'validate';
$aEventsList[] = 'change';
$oDocument = $value; // Value is an ormDocument object
$sFileName = '';
if (is_object($oDocument)) {
$sFileName = $oDocument->GetFileName();
}
$iMaxFileSize = utils::ConvertToBytes(ini_get('upload_max_filesize'));
$sHTMLValue = "<div class=\"field_input_zone field_input_document\">\n";
$sHTMLValue .= "<input type=\"hidden\" name=\"MAX_FILE_SIZE\" value=\"$iMaxFileSize\" />\n";
$sHTMLValue .= "<input type=\"hidden\" id=\"do_remove_{$iId}\" name=\"attr_{$sFieldPrefix}{$sAttCode}{$sNameSuffix}[remove]\" value=\"0\"/>\n";
$sFileNameForHtml = utils::EscapeHtml($sFileName);
$iMaxFileSize = utils::ConvertToBytes(ini_get('upload_max_filesize'));
$sRemoveBtnLabelForHtml = utils::EscapeHtml(Dict::S('UI:Button:RemoveDocument'));
$sHTMLValue = <<<HTML
<div class="field_input_zone field_input_document">
<input type="hidden" name="MAX_FILE_SIZE" value="{$iMaxFileSize}" />
<input type="hidden" id="do_remove_{$iId}" name="attr_{$sFieldPrefix}{$sAttCode}{$sNameSuffix}[remove]" value="0"/>
<input name="attr_{$sFieldPrefix}{$sAttCode}{$sNameSuffix}[filename]" type="hidden" id="{$iId}" value="{$sFileNameForHtml}"/>
<span id="name_{$iInputId}" >{$sFileNameForHtml}</span>&#160;&#160;
<button id="remove_attr_{$iId}" class="ibo-button ibo-is-alternative ibo-is-danger ibo-is-hidden" data-role="ibo-button" type="button" data-tooltip-content="{$sRemoveBtnLabelForHtml}" onClick="$('#file_{$iId}').val(''); UpdateFileName('{$iId}', '');">
<span class="fas fa-trash"></span>
</button>
</div>
<br/>
<input title="{$sHelpText}" name="attr_{$sFieldPrefix}{$sAttCode}{$sNameSuffix}[fcontents]" type="file" id="file_{$iId}" onChange="UpdateFileName('{$iId}', this.value)"/>
{$sValidationSpan}{$sReloadSpan}
HTML;
$sHTMLValue .= "<input name=\"attr_{$sFieldPrefix}{$sAttCode}{$sNameSuffix}[filename]\" type=\"hidden\" id=\"$iId\" \" value=\"".htmlentities($sFileName,
ENT_QUOTES, 'UTF-8')."\"/>\n";
$sHTMLValue .= "<span id=\"name_$iInputId\"' >".htmlentities($sFileName, ENT_QUOTES,
'UTF-8')."</span>&#160;&#160;";
$sHTMLValue .= "<div title=\"".htmlentities(Dict::S('UI:Button:RemoveDocument'), ENT_QUOTES, 'UTF-8')."\" id=\"remove_attr_$iId\" class=\"button\" onClick=\"$('#file_$iId').val('');UpdateFileName('$iId', '');\" style=\"display: contents;\">";
$sHTMLValue .= "<div class=\"ui-icon ui-icon-trash\"></div></div>";
$sHTMLValue .= "</div>";
$sHTMLValue .= "<br/>\n";
$sHTMLValue .= "<input title=\"$sHelpText\" name=\"attr_{$sFieldPrefix}{$sAttCode}{$sNameSuffix}[fcontents]\" type=\"file\" id=\"file_$iId\" onChange=\"UpdateFileName('$iId', this.value)\"/>\n";
$sHTMLValue .= "</div>\n";
$sHTMLValue .= "{$sValidationSpan}{$sReloadSpan}\n";
if ($sFileName == '') {
$oPage->add_ready_script("$('#remove_attr_{$iId}').hide();");
$oPage->add_ready_script("$('#remove_attr_{$iId}').addClass('ibo-is-hidden');");
}
break;

View File

@@ -134,10 +134,10 @@ function UpdateFileName(id, sNewFileName) {
$('#name_'+id).text(sNewFileName);
if(sNewFileName=='') {
$('#do_remove_'+id).val('1');
$('#remove_attr_' + id).hide();
$('#remove_attr_'+id).addClass('ibo-is-hidden');
} else {
$('#do_remove_'+id).val('0');
$('#remove_attr_' + id).show();
$('#remove_attr_'+id).removeClass('ibo-is-hidden');
}
return true;