Make sure that we attach ONLY the elements that are visible in the form when using the "select all" mode for managing 1:n links.

SVN:trunk[2984]
This commit is contained in:
Denis Flaven
2013-11-26 11:16:11 +00:00
parent ebe89b0af7
commit 0aa0de9f1c
2 changed files with 25 additions and 4 deletions

View File

@@ -232,7 +232,8 @@ $(function()
iKey = parseInt(this.value, 10); // Numbers are in base 10 iKey = parseInt(this.value, 10); // Numbers are in base 10
oParams.aAlreadyLinked.push(iKey); oParams.aAlreadyLinked.push(iKey);
} }
); oParams.operation = 'searchObjectsToAdd2'; );
oParams.operation = 'searchObjectsToAdd2';
oParams['class'] = this.options.class_name; oParams['class'] = this.options.class_name;
oParams.real_class = ''; oParams.real_class = '';
oParams.att_code = this.options.att_code; oParams.att_code = this.options.att_code;
@@ -325,11 +326,18 @@ $(function()
_onDoAdd:function() _onDoAdd:function()
{ {
var oParams = this._getSelection('selectObject'); var oParams = this._getSelection('selectObject');
this.oDlg.dialog('close');
oParams.operation = 'doAddObjects2'; oParams.operation = 'doAddObjects2';
oParams['class'] = this.options.class_name; oParams['class'] = this.options.class_name;
oParams.att_code = this.options.att_code; oParams.att_code = this.options.att_code;
oParams.iInputId = this.id; oParams.iInputId = this.id;
// Retrieve the 'filter' definition, BEFORE closing the dialog and destroying its contents
var table = $('#ResultsToAdd_'+this.id).find('table.listResults')[0];
oParams.filter = table.config.filter;
oParams.extra_params = table.config.extra_params;
this.oDlg.dialog('close');
var me = this; var me = this;
$.post(this.options.submit_to, oParams, function(data) { $.post(this.options.submit_to, oParams, function(data) {
var oInserted = $(data); var oInserted = $(data);

View File

@@ -336,14 +336,27 @@ try
$sAttCode = utils::ReadParam('att_code', ''); $sAttCode = utils::ReadParam('att_code', '');
$iInputId = utils::ReadParam('iInputId', ''); $iInputId = utils::ReadParam('iInputId', '');
$iCurrObjectId = utils::ReadParam('iObjId', 0); $iCurrObjectId = utils::ReadParam('iObjId', 0);
$sFilter = utils::ReadParam('filter', ''); $sFilter = utils::ReadParam('filter', '', false, 'raw_data');
if ($sFilter != '') if ($sFilter != '')
{ {
$oFullSetFilter = DBObjectSearch::unserialize($sFilter); $oFullSetFilter = DBObjectSearch::unserialize($sFilter);
} }
else else
{ {
$oFullSetFilter = new DBObjectSearch($sRemoteClass); $oLinksetDef = MetaModel::GetAttributeDef($sClass, $sAttCode);
$valuesDef = $oLinksetDef->GetValuesDef();
if ($valuesDef === null)
{
$oFullSetFilter = new DBObjectSearch($oLinksetDef->GetLinkedClass());
}
else
{
if (!$valuesDef instanceof ValueSetObjects)
{
throw new Exception('Error: only ValueSetObjects are supported for "allowed_values" in AttributeLinkedSet ('.$this->sClass.'/'.$this->sAttCode.').');
}
$oFullSetFilter = DBObjectSearch::FromOQL($valuesDef->GetFilterExpression());
}
} }
$oWidget = new UILinksWidgetDirect($sClass, $sAttCode, $iInputId); $oWidget = new UILinksWidgetDirect($sClass, $sAttCode, $iInputId);
$oWidget->DoAddObjects($oPage, $oFullSetFilter); $oWidget->DoAddObjects($oPage, $oFullSetFilter);