N°4085 - Polishing : bulk modify

This commit is contained in:
acognet
2021-06-22 17:34:14 +02:00
parent bce1bd8192
commit 457165b2fc
2 changed files with 88 additions and 3 deletions

View File

@@ -2804,7 +2804,7 @@ $('.state_select_{$this->m_iFormId}').change( function() {
}
});
JAVASCRIPT
);
);
}
}
@@ -2847,6 +2847,18 @@ EOF
$oPage->p($sStatesSelection);
$aFieldsMap = $this->DisplayBareProperties($oPage, true, $sPrefix, $aExtraParams);
//if we are in bulk modify : Special case to display the case log, if any...
// WARNING: if you modify the loop below, also check the corresponding code in UpdateObject and DisplayModifyForm
if (isset($aExtraParams['nbBulkObj'])) {
foreach (MetaModel::ListAttributeDefs(get_class($this)) as $sAttCode => $oAttDef) {
if ($oAttDef instanceof AttributeCaseLog) {
$sComment = (isset($aExtraParams['fieldsComments'][$sAttCode])) ? $aExtraParams['fieldsComments'][$sAttCode] : '';
$this->DisplayCaseLogForBulkModify($oPage, $sAttCode, $sComment, $sPrefix);
$aFieldsMap[$sAttCode] = $this->m_iFormId.'_'.$sAttCode;
}
}
}
if (!is_array($aFieldsMap)) {
$aFieldsMap = array();
}
@@ -4507,6 +4519,72 @@ HTML
}
}
/**
* Special display where the case log uses the whole "screen" at the bottom of the "Properties" tab
*
* @param \WebPage $oPage
* @param string $sAttCode
* @param string $sComment
* @param string $sPrefix
*
* @throws \ArchivedObjectException
* @throws \CoreException
* @throws \CoreUnexpectedValue
* @throws \DictExceptionMissingString
* @throws \MySQLException
* @throws \OQLException
* @throws \Exception
*/
public function DisplayCaseLogForBulkModify(WebPage $oPage, $sAttCode, $sComment = '', $sPrefix = '')
{
$sClass = get_class($this);
$iFlags = $this->GetAttributeFlags($sAttCode);
if ($iFlags & (OPT_ATT_HIDDEN | OPT_ATT_READONLY | OPT_ATT_SLAVE)) {
// The case log can not be updated
} else {
$oAttDef = MetaModel::GetAttributeDef(get_class($this), $sAttCode);
$sAttDefClass = get_class($oAttDef);
$sAttLabel = $oAttDef->GetLabel();
$sAttMetaDataLabel = utils::HtmlEntities($sAttLabel);
$sAttMetaDataFlagMandatory = (($iFlags & OPT_ATT_MANDATORY) === OPT_ATT_MANDATORY) ? 'true' : 'false';
$sAttMetaDataFlagMustChange = (($iFlags & OPT_ATT_MUSTCHANGE) === OPT_ATT_MUSTCHANGE) ? 'true' : 'false';
$sAttMetaDataFlagMustPrompt = (($iFlags & OPT_ATT_MUSTPROMPT) === OPT_ATT_MUSTPROMPT) ? 'true' : 'false';
$sInputId = $this->m_iFormId.'_'.$sAttCode;
$sValue = $this->Get($sAttCode);
$sDisplayValue = $this->GetEditValue($sAttCode);
$aArgs = array('this' => $this, 'formPrefix' => $sPrefix);
$sCommentAsHtml = ($sComment != '') ? '<span>'.$sComment.'</span><br/>' : '';
$sFieldAsHtml = self::GetFormElementForField($oPage, $sClass, $sAttCode, $oAttDef, $sValue, $sDisplayValue, $sInputId, '', $iFlags, $aArgs);
$sHTMLValue = <<<HTML
<div class="field_data">
<div class="field_value">
$sCommentAsHtml
$sFieldAsHtml
</div>
</div>
HTML;
$aFieldsMap[$sAttCode] = $sInputId;
$oPage->add(<<<HTML
<fieldset>
<legend>{$sAttLabel}</legend>
<div class="field_container field_large" data-attribute-code="{$sAttCode}" data-attribute-type="{$sAttDefClass}" data-attribute-label="{$sAttMetaDataLabel}"
data-attribute-flag-hidden="false" data-attribute-flag-read-only="false" data-attribute-flag-mandatory="{$sAttMetaDataFlagMandatory}"
data-attribute-flag-must-change="{$sAttMetaDataFlagMustChange}" data-attribute-flag-must-prompt="{$sAttMetaDataFlagMustPrompt}" data-attribute-flag-slave="false">
{$sHTMLValue}
</div>
</fieldset>
HTML
);
}
}
/**
* @param $sCurrentState
* @param $sStimulus

View File

@@ -277,8 +277,15 @@ function CheckAll(sSelector, bValue) {
function ToggleField(value, field_id) {
if (value) {
$('#'+field_id).prop('disabled', false);
// In case the field is rendered as a div containing several inputs (e.g. RedundancySettings)
$('#'+field_id+' :input').prop('disabled', false);
if ($('#'+field_id).hasClass('selectized')) {
$('#'+field_id)[0].selectize.enable();
} else if ($('#'+field_id).parent().find('.ibo-input-select-autocomplete').length > 0) {
$('#'+field_id).parent().find('.ibo-input-select-autocomplete').prop('disabled', false);
$('#'+field_id).parent().find('.ibo-input-select--action-buttons').removeClass('ibo-is-hidden');
} else {
// In case the field is rendered as a div containing several inputs (e.g. RedundancySettings)
$('#'+field_id+' :input').prop('disabled', false);
}
} else {
$('#'+field_id).prop('disabled', true);
if ($('#'+field_id).hasClass('selectized')) {