mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-24 02:58:43 +02:00
Activity form can now have extra inputs
This commit is contained in:
@@ -787,6 +787,22 @@ $(function()
|
||||
|
||||
return oEntries;
|
||||
},
|
||||
/**
|
||||
* @returns {Object} The case logs having a new entry and their values, format is {<ATT_CODE_1>: <HTML_VALUE_1>, <ATT_CODE_2>: <HTML_VALUE_2>}
|
||||
* @private
|
||||
*/
|
||||
_GetExtraInputsFromAllForms: function () {
|
||||
const me = this;
|
||||
|
||||
let oExtraInputs = {};
|
||||
this.element.find(this.js_selectors.caselog_entry_form).each(function () {
|
||||
const oEntryFormElem = $(this);
|
||||
oExtraInputs = $.extend(oExtraInputs, oEntryFormElem.triggerHandler('get_extra_inputs.caselog_entry_form.itop'));
|
||||
});
|
||||
|
||||
return oExtraInputs;
|
||||
},
|
||||
|
||||
/**
|
||||
* @return {boolean} True if at least 1 of the entry form is draft (has some text in it)
|
||||
* @private
|
||||
@@ -863,6 +879,7 @@ $(function()
|
||||
_SendEntriesToServer: function (sStimulusCode = null) {
|
||||
const me = this;
|
||||
const oEntries = this._GetEntriesFromAllForms();
|
||||
const oExtraInputs = this._GetExtraInputsFromAllForms();
|
||||
|
||||
// Proceed only if entries to send
|
||||
if (Object.keys(oEntries).length === 0) {
|
||||
@@ -870,13 +887,13 @@ $(function()
|
||||
}
|
||||
|
||||
// Prepare parameters
|
||||
let oParams = {
|
||||
let oParams = $.extend(oExtraInputs, {
|
||||
operation: 'activity_panel_add_caselog_entries',
|
||||
object_class: this._GetHostObjectClass(),
|
||||
object_id: this._GetHostObjectID(),
|
||||
transaction_id: this.options.transaction_id,
|
||||
entries: oEntries,
|
||||
};
|
||||
});
|
||||
|
||||
// Freeze case logs
|
||||
this._FreezeCaseLogsEntryForms();
|
||||
|
||||
@@ -157,6 +157,9 @@ $(function() {
|
||||
this.element.on('get_entry.caselog_entry_form.itop', function () {
|
||||
return me._GetInputData();
|
||||
});
|
||||
this.element.on('get_extra_inputs.caselog_entry_form.itop', function () {
|
||||
return me._GetExtraInputs();
|
||||
});
|
||||
// Clear the entry value
|
||||
this.element.on('clear_entry.caselog_entry_form.itop', function () {
|
||||
me._EmptyInput();
|
||||
@@ -281,6 +284,27 @@ $(function() {
|
||||
_GetInputData: function() {
|
||||
return (this._GetCKEditorInstance() === undefined) ? '' : this._GetCKEditorInstance().getData();
|
||||
},
|
||||
_GetExtraInputs: function() {
|
||||
let aExtraInputs = {};
|
||||
const aFormInputs = this.element.serializeArray();
|
||||
// Iterate across all values that would be sent if we submit current form
|
||||
for (const aExtraInput of aFormInputs) {
|
||||
// If we don't already have a value with the same name, add it
|
||||
// Otherwise we'll consider that we need to return this value as an array of values
|
||||
if(aExtraInputs[aExtraInput.name] === undefined) {
|
||||
aExtraInputs[aExtraInput.name] = aExtraInput.value;
|
||||
}
|
||||
else {
|
||||
if(Array.isArray(aExtraInputs[aExtraInput.name])){
|
||||
aExtraInputs[aExtraInput.name].push(aExtraInput.value);
|
||||
}
|
||||
else{
|
||||
aExtraInputs[aExtraInput.name] = [aExtraInputs[aExtraInput.name], aExtraInput.value];
|
||||
}
|
||||
}
|
||||
};
|
||||
return aExtraInputs;
|
||||
},
|
||||
// - Main actions
|
||||
_ShowMainActions: function() {
|
||||
this.element.find(this.js_selectors.main_actions).removeClass(this.css_classes.is_hidden);
|
||||
|
||||
@@ -24,6 +24,8 @@
|
||||
<div class="ibo-caselog-entry-form--text-input" data-role="ibo-caselog-entry-form--text-input">
|
||||
{{ render_block(oUIBlock.GetTextInput(), {aPage: aPage}) }}
|
||||
</div>
|
||||
<div class="ibo-caselog-entry-form--extra-inputs" data-role="ibo-caselog-entry-form--extra-inputs">
|
||||
</div>
|
||||
<div class="ibo-caselog-entry-form--lock-indicator ibo-is-hidden" data-role="ibo-caselog-entry-form--lock-indicator">
|
||||
<span class="ibo-caselog-entry-form--lock-icon" data-role="ibo-caselog-entry-form--lock-icon">
|
||||
<span class="fas fa-lock"></span>
|
||||
|
||||
Reference in New Issue
Block a user