mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-23 02:28:44 +02:00
N°4481 - Fix n:n link addition when there are more than 3+ ext. keys on the link class
This commit is contained in:
@@ -375,6 +375,7 @@ JS
|
||||
|
||||
$oValue->Rewind();
|
||||
$aForm = array();
|
||||
$iMaxAddedId = 0;
|
||||
$iAddedId = -1; // Unique id for new links
|
||||
while ($oCurrentLink = $oValue->Fetch())
|
||||
{
|
||||
@@ -395,8 +396,12 @@ JS
|
||||
} else {
|
||||
$key = $oCurrentLink->GetKey();
|
||||
}
|
||||
|
||||
$iMaxAddedId = max($iMaxAddedId, $key);
|
||||
$aForm[$key] = $this->GetFormRow($oPage, $oLinkedObj, $oCurrentLink, $aArgs, $oCurrentObj, $key, $bReadOnly);
|
||||
}
|
||||
$oBlock->iMaxAddedId = (int) $iMaxAddedId;
|
||||
|
||||
$oDataTable = DataTableUIBlockFactory::MakeForForm("{$this->m_sAttCode}{$this->m_sNameSuffix}", $this->m_aTableConfig, $aForm);
|
||||
$oDataTable->SetOptions(['select_mode' => 'custom']);
|
||||
$oBlock->AddSubBlock($oDataTable);
|
||||
|
||||
@@ -3,8 +3,23 @@
|
||||
* @license http://opensource.org/licenses/AGPL-3.0
|
||||
*/
|
||||
|
||||
|
||||
function LinksWidget(id, sClass, sAttCode, iInputId, sSuffix, bDuplicates, oWizHelper, sExtKeyToRemote, bDoSearch) {
|
||||
/**
|
||||
*
|
||||
* @param id
|
||||
* @param sClass
|
||||
* @param sAttCode
|
||||
* @param iInputId
|
||||
* @param sSuffix
|
||||
* @param bDuplicates
|
||||
* @param oWizHelper
|
||||
* @param sExtKeyToRemote
|
||||
* @param bDoSearch
|
||||
* @param iMaxAddedId
|
||||
* @constructor
|
||||
*
|
||||
* @since 3.0.0 Add iMaxAddedId parameter
|
||||
*/
|
||||
function LinksWidget(id, sClass, sAttCode, iInputId, sSuffix, bDuplicates, oWizHelper, sExtKeyToRemote, bDoSearch, iMaxAddedId = 0) {
|
||||
this.id = id;
|
||||
this.iInputId = iInputId;
|
||||
this.sClass = sClass;
|
||||
@@ -13,7 +28,7 @@ function LinksWidget(id, sClass, sAttCode, iInputId, sSuffix, bDuplicates, oWizH
|
||||
this.bDuplicates = bDuplicates;
|
||||
this.oWizardHelper = oWizHelper;
|
||||
this.sExtKeyToRemote = sExtKeyToRemote;
|
||||
this.iMaxAddedId = 0;
|
||||
this.iMaxAddedId = iMaxAddedId;
|
||||
this.aAdded = [];
|
||||
this.aRemoved = [];
|
||||
this.aModified = {};
|
||||
@@ -418,4 +433,13 @@ function LinksWidget(id, sClass, sAttCode, iInputId, sSuffix, bDuplicates, oWizH
|
||||
// Remove unused inputs
|
||||
$('#linkedset_'+me.id+' :input[name^="attr_'+me.sAttCode+'["]').prop("disabled", true);
|
||||
};
|
||||
|
||||
this.UpdateMaxAddedId = function () {
|
||||
const iCurrentMaxAddedId = this.iMaxAddedId;
|
||||
this.iMaxAddedId = Math.max(iCurrentMaxAddedId, this.GetMaxAddedId());
|
||||
};
|
||||
|
||||
this.GetMaxAddedId = function () {
|
||||
this.oWizardHelper;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -43,6 +43,8 @@ class BlockIndirectLinksEdit extends UIContentBlock
|
||||
public $sExtKeyToRemote;
|
||||
/** @var bool */
|
||||
public $bJSDoSearch;
|
||||
/** @var int */
|
||||
public $iMaxAddedId = 0;
|
||||
|
||||
/** @var string */
|
||||
public $sFormPrefix;
|
||||
|
||||
@@ -10,7 +10,8 @@ oWidget{{ oUIBlock.iInputId }} = new LinksWidget(
|
||||
{{ oUIBlock.bDuplicates }},
|
||||
{{ oUIBlock.oWizHelper }},
|
||||
'{{ oUIBlock.sExtKeyToRemote }}',
|
||||
{{ oUIBlock.bJSDoSearch }}
|
||||
{{ oUIBlock.bJSDoSearch }},
|
||||
{{ oUIBlock.iMaxAddedId }}
|
||||
);
|
||||
oWidget{{ oUIBlock.iInputId }}.Init();
|
||||
{% endapply %}
|
||||
Reference in New Issue
Block a user