mirror of
https://github.com/Combodo/iTop.git
synced 2026-02-13 07:24:13 +01:00
#1000 Implemented the behavior for the flag OPT_ATT_MUSTCHANGE, and took the opportunity to add a feedback when a field is mandatory OR when the format is wrong
SVN:trunk[3394]
This commit is contained in:
@@ -1854,7 +1854,8 @@ abstract class cmdbAbstractObject extends CMDBObject implements iDisplay
|
||||
{
|
||||
$sNullValue = "'$sNullValue'"; // Add quotes to turn this into a JS string if it's not a number
|
||||
}
|
||||
$oPage->add_ready_script("$('#$iId').bind('".implode(' ', $aEventsList)."', function(evt, sFormId) { return ValidateField('$iId', '$sPattern', $bMandatory, sFormId, $sNullValue) } );\n"); // Bind to a custom event: validate
|
||||
$sOriginalValue = ($iFlags & OPT_ATT_MUSTCHANGE) ? "'".addslashes($value)."'" : 'undefined';
|
||||
$oPage->add_ready_script("$('#$iId').bind('".implode(' ', $aEventsList)."', function(evt, sFormId) { return ValidateField('$iId', '$sPattern', $bMandatory, sFormId, $sNullValue, $sOriginalValue) } );\n"); // Bind to a custom event: validate
|
||||
}
|
||||
$aDependencies = MetaModel::GetDependentAttributes($sClass, $sAttCode); // List of attributes that depend on the current one
|
||||
if (count($aDependencies) > 0)
|
||||
@@ -1863,6 +1864,9 @@ abstract class cmdbAbstractObject extends CMDBObject implements iDisplay
|
||||
$oPage->add_ready_script("$('#$iId').unbind('change.dependencies').bind('change.dependencies', function(evt, sFormId) { return oWizardHelper{$sFormPrefix}.UpdateDependentFields(['".implode("','", $aDependencies)."']) } );\n"); // Bind to a custom event: validate
|
||||
}
|
||||
}
|
||||
$oPage->add_dict_entry('UI:ValueMustBeSet');
|
||||
$oPage->add_dict_entry('UI:ValueMustBeChanged');
|
||||
$oPage->add_dict_entry('UI:ValueInvalidFormat');
|
||||
return "<div>{$sHTMLValue}</div>";
|
||||
}
|
||||
|
||||
|
||||
@@ -1416,3 +1416,7 @@ div.ui-dialog-header {
|
||||
padding-bottom: 10px;
|
||||
padding-top: 7px;
|
||||
}
|
||||
.form_field_error {
|
||||
border: 1px solid #933;
|
||||
background: #fcc;
|
||||
}
|
||||
@@ -457,7 +457,7 @@
|
||||
<hidden/>
|
||||
</attribute>
|
||||
<attribute id="agent_id">
|
||||
<must_change/>
|
||||
<must_prompt/>
|
||||
</attribute>
|
||||
<attribute id="agent_email">
|
||||
<hidden/>
|
||||
@@ -466,13 +466,13 @@
|
||||
<mandatory/>
|
||||
</attribute>
|
||||
<attribute id="supervisor_id">
|
||||
<must_change/>
|
||||
<must_prompt/>
|
||||
</attribute>
|
||||
<attribute id="manager_group_id">
|
||||
<mandatory/>
|
||||
</attribute>
|
||||
<attribute id="manager_id">
|
||||
<must_change/>
|
||||
<must_prompt/>
|
||||
</attribute>
|
||||
<attribute id="outage">
|
||||
<hidden/>
|
||||
@@ -1488,7 +1488,7 @@
|
||||
<hidden/>
|
||||
</attribute>
|
||||
<attribute id="agent_id">
|
||||
<must_change/>
|
||||
<must_prompt/>
|
||||
</attribute>
|
||||
<attribute id="agent_email">
|
||||
<hidden/>
|
||||
@@ -1497,13 +1497,13 @@
|
||||
<mandatory/>
|
||||
</attribute>
|
||||
<attribute id="supervisor_id">
|
||||
<must_change/>
|
||||
<must_prompt/>
|
||||
</attribute>
|
||||
<attribute id="manager_group_id">
|
||||
<mandatory/>
|
||||
</attribute>
|
||||
<attribute id="manager_id">
|
||||
<must_change/>
|
||||
<must_prompt/>
|
||||
</attribute>
|
||||
<attribute id="outage">
|
||||
<hidden/>
|
||||
@@ -2465,7 +2465,7 @@
|
||||
<hidden/>
|
||||
</attribute>
|
||||
<attribute id="agent_id">
|
||||
<must_change/>
|
||||
<must_prompt/>
|
||||
</attribute>
|
||||
<attribute id="agent_email">
|
||||
<hidden/>
|
||||
@@ -2474,13 +2474,13 @@
|
||||
<mandatory/>
|
||||
</attribute>
|
||||
<attribute id="supervisor_id">
|
||||
<must_change/>
|
||||
<must_prompt/>
|
||||
</attribute>
|
||||
<attribute id="manager_group_id">
|
||||
<mandatory/>
|
||||
</attribute>
|
||||
<attribute id="manager_id">
|
||||
<must_change/>
|
||||
<must_prompt/>
|
||||
</attribute>
|
||||
<attribute id="outage">
|
||||
<hidden/>
|
||||
@@ -3471,7 +3471,7 @@
|
||||
<hidden/>
|
||||
</attribute>
|
||||
<attribute id="agent_id">
|
||||
<must_change/>
|
||||
<must_prompt/>
|
||||
</attribute>
|
||||
<attribute id="agent_email">
|
||||
<hidden/>
|
||||
@@ -3480,13 +3480,13 @@
|
||||
<mandatory/>
|
||||
</attribute>
|
||||
<attribute id="supervisor_id">
|
||||
<must_change/>
|
||||
<must_prompt/>
|
||||
</attribute>
|
||||
<attribute id="manager_group_id">
|
||||
<mandatory/>
|
||||
</attribute>
|
||||
<attribute id="manager_id">
|
||||
<must_change/>
|
||||
<must_prompt/>
|
||||
</attribute>
|
||||
<attribute id="outage">
|
||||
<hidden/>
|
||||
@@ -4547,7 +4547,7 @@
|
||||
<hidden/>
|
||||
</attribute>
|
||||
<attribute id="agent_id">
|
||||
<must_change/>
|
||||
<must_prompt/>
|
||||
</attribute>
|
||||
<attribute id="agent_email">
|
||||
<hidden/>
|
||||
@@ -4556,13 +4556,13 @@
|
||||
<mandatory/>
|
||||
</attribute>
|
||||
<attribute id="supervisor_id">
|
||||
<must_change/>
|
||||
<must_prompt/>
|
||||
</attribute>
|
||||
<attribute id="manager_group_id">
|
||||
<mandatory/>
|
||||
</attribute>
|
||||
<attribute id="manager_id">
|
||||
<must_change/>
|
||||
<must_prompt/>
|
||||
</attribute>
|
||||
<attribute id="outage">
|
||||
<hidden/>
|
||||
|
||||
@@ -54,7 +54,7 @@
|
||||
<read_only/>
|
||||
</attribute>
|
||||
<attribute id="description">
|
||||
<must_change/>
|
||||
<must_prompt/>
|
||||
</attribute>
|
||||
<attribute id="start_date">
|
||||
<read_only/>
|
||||
@@ -63,28 +63,28 @@
|
||||
<mandatory/>
|
||||
</attribute>
|
||||
<attribute id="org_id">
|
||||
<must_change/>
|
||||
<must_prompt/>
|
||||
</attribute>
|
||||
<attribute id="service_id">
|
||||
<must_change/>
|
||||
<must_prompt/>
|
||||
</attribute>
|
||||
<attribute id="servicesubcategory_id">
|
||||
<must_change/>
|
||||
<must_prompt/>
|
||||
</attribute>
|
||||
<attribute id="product">
|
||||
<must_prompt/>
|
||||
</attribute>
|
||||
<attribute id="impact">
|
||||
<must_change/>
|
||||
<must_prompt/>
|
||||
</attribute>
|
||||
<attribute id="urgency">
|
||||
<must_change/>
|
||||
<must_prompt/>
|
||||
</attribute>
|
||||
<attribute id="priority">
|
||||
<read_only/>
|
||||
</attribute>
|
||||
<attribute id="workgroup_id">
|
||||
<must_change/>
|
||||
<must_prompt/>
|
||||
</attribute>
|
||||
<attribute id="agent_email">
|
||||
<hidden/>
|
||||
|
||||
@@ -213,7 +213,7 @@
|
||||
<read_only/>
|
||||
</attribute>
|
||||
<attribute id="description">
|
||||
<must_change/>
|
||||
<must_prompt/>
|
||||
</attribute>
|
||||
<attribute id="ticket_log">
|
||||
<hidden/>
|
||||
@@ -222,28 +222,28 @@
|
||||
<read_only/>
|
||||
</attribute>
|
||||
<attribute id="org_id">
|
||||
<must_change/>
|
||||
<must_prompt/>
|
||||
</attribute>
|
||||
<attribute id="service_id">
|
||||
<must_change/>
|
||||
<must_prompt/>
|
||||
</attribute>
|
||||
<attribute id="servicesubcategory_id">
|
||||
<must_change/>
|
||||
<must_prompt/>
|
||||
</attribute>
|
||||
<attribute id="product">
|
||||
<must_prompt/>
|
||||
</attribute>
|
||||
<attribute id="impact">
|
||||
<must_change/>
|
||||
<must_prompt/>
|
||||
</attribute>
|
||||
<attribute id="urgency">
|
||||
<must_change/>
|
||||
<must_prompt/>
|
||||
</attribute>
|
||||
<attribute id="priority">
|
||||
<read_only/>
|
||||
</attribute>
|
||||
<attribute id="workgroup_id">
|
||||
<must_change/>
|
||||
<must_prompt/>
|
||||
</attribute>
|
||||
<attribute id="agent_id">
|
||||
<hidden/>
|
||||
|
||||
@@ -91,7 +91,7 @@
|
||||
<read_only/>
|
||||
</attribute>
|
||||
<attribute id="description">
|
||||
<must_change/>
|
||||
<must_prompt/>
|
||||
</attribute>
|
||||
<attribute id="start_date">
|
||||
<read_only/>
|
||||
@@ -100,28 +100,28 @@
|
||||
<mandatory/>
|
||||
</attribute>
|
||||
<attribute id="org_id">
|
||||
<must_change/>
|
||||
<must_prompt/>
|
||||
</attribute>
|
||||
<attribute id="service_id">
|
||||
<must_change/>
|
||||
<must_prompt/>
|
||||
</attribute>
|
||||
<attribute id="servicesubcategory_id">
|
||||
<must_change/>
|
||||
<must_prompt/>
|
||||
</attribute>
|
||||
<attribute id="product">
|
||||
<must_prompt/>
|
||||
</attribute>
|
||||
<attribute id="impact">
|
||||
<must_change/>
|
||||
<must_prompt/>
|
||||
</attribute>
|
||||
<attribute id="urgency">
|
||||
<must_change/>
|
||||
<must_prompt/>
|
||||
</attribute>
|
||||
<attribute id="priority">
|
||||
<read_only/>
|
||||
</attribute>
|
||||
<attribute id="workgroup_id">
|
||||
<must_change/>
|
||||
<must_prompt/>
|
||||
</attribute>
|
||||
<attribute id="agent_email">
|
||||
<hidden/>
|
||||
|
||||
@@ -422,7 +422,7 @@
|
||||
<read_only/>
|
||||
</attribute>
|
||||
<attribute id="description">
|
||||
<must_change/>
|
||||
<must_prompt/>
|
||||
</attribute>
|
||||
<attribute id="start_date">
|
||||
<read_only/>
|
||||
@@ -431,28 +431,28 @@
|
||||
<mandatory/>
|
||||
</attribute>
|
||||
<attribute id="org_id">
|
||||
<must_change/>
|
||||
<must_prompt/>
|
||||
</attribute>
|
||||
<attribute id="service_id">
|
||||
<must_change/>
|
||||
<must_prompt/>
|
||||
</attribute>
|
||||
<attribute id="servicesubcategory_id">
|
||||
<must_change/>
|
||||
<must_prompt/>
|
||||
</attribute>
|
||||
<attribute id="product">
|
||||
<must_prompt/>
|
||||
</attribute>
|
||||
<attribute id="impact">
|
||||
<must_change/>
|
||||
<must_prompt/>
|
||||
</attribute>
|
||||
<attribute id="urgency">
|
||||
<must_change/>
|
||||
<must_prompt/>
|
||||
</attribute>
|
||||
<attribute id="priority">
|
||||
<read_only/>
|
||||
</attribute>
|
||||
<attribute id="workgroup_id">
|
||||
<must_change/>
|
||||
<must_prompt/>
|
||||
</attribute>
|
||||
<attribute id="agent_email">
|
||||
<hidden/>
|
||||
|
||||
@@ -169,7 +169,7 @@
|
||||
<read_only/>
|
||||
</attribute>
|
||||
<attribute id="org_id">
|
||||
<must_change/>
|
||||
<must_prompt/>
|
||||
</attribute>
|
||||
<attribute id="team_id">
|
||||
<hidden/>
|
||||
@@ -178,7 +178,7 @@
|
||||
<hidden/>
|
||||
</attribute>
|
||||
<attribute id="description">
|
||||
<must_change/>
|
||||
<must_prompt/>
|
||||
</attribute>
|
||||
<attribute id="start_date">
|
||||
<read_only/>
|
||||
@@ -199,10 +199,10 @@
|
||||
<normal/>
|
||||
</attribute>
|
||||
<attribute id="impact">
|
||||
<must_change/>
|
||||
<must_prompt/>
|
||||
</attribute>
|
||||
<attribute id="urgency">
|
||||
<must_change/>
|
||||
<must_prompt/>
|
||||
</attribute>
|
||||
<attribute id="priority">
|
||||
<read_only/>
|
||||
|
||||
@@ -1196,7 +1196,10 @@ When associated with a trigger, each action is given an "order" number, specifyi
|
||||
'Class:ShortcutOQL/Attribute:auto_reload_sec+' => 'The minimum allowed is 5 seconds',
|
||||
|
||||
'UI:FillAllMandatoryFields' => 'Please fill all mandatory fields.',
|
||||
|
||||
'UI:ValueMustBeSet' => 'Please specify a value',
|
||||
'UI:ValueMustBeChanged' => 'Please change the value',
|
||||
'UI:ValueInvalidFormat' => 'Invalid format',
|
||||
|
||||
'UI:CSVImportConfirmTitle' => 'Please confirm the operation',
|
||||
'UI:CSVImportConfirmMessage' => 'Are you sure you want to do this?',
|
||||
'UI:CSVImportError_items' => 'Errors: %1$d',
|
||||
|
||||
@@ -1036,6 +1036,9 @@ Lors de l\'association à un déclencheur, on attribue à chaque action un numé
|
||||
'Class:ShortcutOQL/Attribute:auto_reload_sec+' => 'Le minimum permis est de 5 secondes',
|
||||
|
||||
'UI:FillAllMandatoryFields' => 'Veuillez remplir tous les champs obligatoires.',
|
||||
'UI:ValueMustBeSet' => 'Veuillez spécifier une valeur pour ce champ',
|
||||
'UI:ValueMustBeChanged' => 'Veuillez modifier la valeur de ce champ',
|
||||
'UI:ValueInvalidFormat' => 'Format invalide',
|
||||
|
||||
'UI:CSVImportConfirmTitle' => 'Veuillez confirmer cette opération',
|
||||
'UI:CSVImportConfirmMessage' => 'Etes-vous sûr(e) de vouloir faire cela ?',
|
||||
|
||||
@@ -146,7 +146,7 @@ function CheckFields(sFormId, bDisplayAlert)
|
||||
return (oFormErrors['err_'+sFormId] == 0); // If no error, submit the form
|
||||
}
|
||||
|
||||
function ReportFieldValidationStatus(sFieldId, sFormId, bValid)
|
||||
function ReportFieldValidationStatus(sFieldId, sFormId, bValid, sExplain)
|
||||
{
|
||||
if (bValid)
|
||||
{
|
||||
@@ -163,13 +163,21 @@ function ReportFieldValidationStatus(sFieldId, sFormId, bValid)
|
||||
oFormErrors['input_'+sFormId] = sFieldId;
|
||||
}
|
||||
// Visual feedback
|
||||
$('#v_'+sFieldId).html('<img src="../images/validation_error.png" style="vertical-align:middle"/>');
|
||||
$('#v_'+sFieldId).html('<img src="../images/validation_error.png" style="vertical-align:middle" data-tooltip="'+sExplain+'"/>');
|
||||
$('#v_'+sFieldId).tooltip({
|
||||
items: 'span',
|
||||
tooltipClass: 'form_field_error',
|
||||
content: function() {
|
||||
return $(this).find('img').attr('data-tooltip'); // As opposed to the default 'content' handler, do not escape the contents of 'title'
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function ValidateField(sFieldId, sPattern, bMandatory, sFormId, nullValue)
|
||||
function ValidateField(sFieldId, sPattern, bMandatory, sFormId, nullValue, originalValue)
|
||||
{
|
||||
var bValid = true;
|
||||
var sExplain = '';
|
||||
if ($('#'+sFieldId).attr('disabled'))
|
||||
{
|
||||
bValid = true; // disabled fields are not checked
|
||||
@@ -185,6 +193,19 @@ function ValidateField(sFieldId, sPattern, bMandatory, sFormId, nullValue)
|
||||
else if (bMandatory && (currentVal == nullValue))
|
||||
{
|
||||
bValid = false;
|
||||
sExplain = Dict.S('UI:ValueMustBeSet');
|
||||
}
|
||||
else if ((originalValue != undefined) && (currentVal == originalValue))
|
||||
{
|
||||
bValid = false;
|
||||
if (originalValue == nullValue)
|
||||
{
|
||||
sExplain = Dict.S('UI:ValueMustBeSet');
|
||||
}
|
||||
else
|
||||
{
|
||||
sExplain = Dict.S('UI:ValueMustBeChanged');
|
||||
}
|
||||
}
|
||||
else if (currentVal == nullValue)
|
||||
{
|
||||
@@ -196,9 +217,10 @@ function ValidateField(sFieldId, sPattern, bMandatory, sFormId, nullValue)
|
||||
re = new RegExp(sPattern);
|
||||
//console.log('Validating field: '+sFieldId + ' current value: '+currentVal + ' pattern: '+sPattern );
|
||||
bValid = re.test(currentVal);
|
||||
sExplain = Dict.S('UI:ValueInvalidFormat');
|
||||
}
|
||||
}
|
||||
ReportFieldValidationStatus(sFieldId, sFormId, bValid);
|
||||
ReportFieldValidationStatus(sFieldId, sFormId, bValid, sExplain);
|
||||
//console.log('Form: '+sFormId+' Validating field: '+sFieldId + ' current value: '+currentVal+' pattern: '+sPattern+' result: '+bValid );
|
||||
return true; // Do not stop propagation ??
|
||||
}
|
||||
@@ -229,7 +251,7 @@ function ValidateCKEditField(sFieldId, sPattern, bMandatory, sFormId, nullValue)
|
||||
bValid = true;
|
||||
}
|
||||
|
||||
ReportFieldValidationStatus(sFieldId, sFormId, bValid);
|
||||
ReportFieldValidationStatus(sFieldId, sFormId, bValid, '');
|
||||
|
||||
setTimeout(function(){ValidateCKEditField(sFieldId, sPattern, bMandatory, sFormId, nullValue);}, 500);
|
||||
}
|
||||
@@ -321,7 +343,7 @@ function ValidateCaseLogField(sFieldId, bMandatory, sFormId)
|
||||
}
|
||||
}
|
||||
}
|
||||
ReportFieldValidationStatus(sFieldId, sFormId, bValid);
|
||||
ReportFieldValidationStatus(sFieldId, sFormId, bValid, '');
|
||||
return bValid;
|
||||
}
|
||||
// Manage a 'duration' field
|
||||
|
||||
Reference in New Issue
Block a user