ソースを参照

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.

git-svn-id: http://svn.code.sf.net/p/itop/code/trunk@2984 a333f486-631f-4898-b8df-5754b55c2be0
dflaven 11 年 前
コミット
e383135533
2 ファイル変更25 行追加4 行削除
  1. 10 2
      js/linksdirectwidget.js
  2. 15 2
      pages/ajax.render.php

+ 10 - 2
js/linksdirectwidget.js

@@ -232,7 +232,8 @@ $(function()
 					iKey = parseInt(this.value, 10); // Numbers are in base 10
 					oParams.aAlreadyLinked.push(iKey);
 				}
-			);			oParams.operation = 'searchObjectsToAdd2';
+			);
+			oParams.operation = 'searchObjectsToAdd2';
 			oParams['class'] = this.options.class_name;
 			oParams.real_class = '';
 			oParams.att_code = this.options.att_code;
@@ -325,11 +326,18 @@ $(function()
 		_onDoAdd:function()
 		{
 			var oParams = this._getSelection('selectObject');
-			this.oDlg.dialog('close');
 			oParams.operation = 'doAddObjects2';
 			oParams['class'] = this.options.class_name;
 			oParams.att_code = this.options.att_code;
 			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;
 			$.post(this.options.submit_to, oParams, function(data) {
 				var oInserted = $(data);

+ 15 - 2
pages/ajax.render.php

@@ -336,14 +336,27 @@ try
 		$sAttCode = utils::ReadParam('att_code', '');
 		$iInputId = utils::ReadParam('iInputId', '');
 		$iCurrObjectId =  utils::ReadParam('iObjId', 0);
-		$sFilter = utils::ReadParam('filter', '');
+		$sFilter = utils::ReadParam('filter', '', false, 'raw_data');
 		if ($sFilter != '')
 		{
 			$oFullSetFilter = DBObjectSearch::unserialize($sFilter);
 		}
 		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->DoAddObjects($oPage, $oFullSetFilter);