Pārlūkot izejas kodu

- Creation of n-n links with no attributes no longer prompts since it's not needed !

git-svn-id: http://svn.code.sf.net/p/itop/code/trunk@519 a333f486-631f-4898-b8df-5754b55c2be0
dflaven 15 gadi atpakaļ
vecāks
revīzija
36eb838c26
2 mainītis faili ar 26 papildinājumiem un 5 dzēšanām
  1. 5 1
      application/ui.linkswidget.class.inc.php
  2. 21 4
      js/linkswidget.js

+ 5 - 1
application/ui.linkswidget.class.inc.php

@@ -70,7 +70,11 @@ class UILinksWidget
 				}
 			}
 		}
-		$sAttributes = "['".implode("','", $aAttributes)."']";
+		$sAttributes = '[]';
+		if (count($aAttributes) > 0)
+		{
+			$sAttributes = "['".implode("','", $aAttributes)."']";
+		}
 		if ($oCurrentValuesSet != null)
 		{
 			// Serialize the link set into a JSon object

+ 21 - 4
js/linkswidget.js

@@ -54,14 +54,31 @@ function LinksWidget(id, sLinkedClass, sExtKeyToMe, sExtKeyToRemote, aAttributes
 		}
 		this.aPreviousLinks = this.aLinks; // Save the list in case of cancellation
 		this.aLinks = new Array(); // rebuild the list of links from scratch
-		if (oSelected.length > 0)
+		if (this.aAttributes.length == 0)
 		{
-			$('#LinkDlg_'+this.id).dialog('open');
+			// No attributes on the link, no need for the extra dialog box
+			// Process the results directly
+			for(i=0; i<this.aObjectBeingLinked.length; i++)
+			{
+				oLink = {};
+				oLink[this.sExtKeyToRemote] = this.aObjectBeingLinked[i];
+				this.aLinks.push(oLink);
+			}
+			this.Refresh();
+			// Grey out the 'Add...' button
+			$('#ac_add_'+this.id).attr('disabled', 'disabled');
 		}
 		else
 		{
-			this.Refresh();
-			$('#ac_add_'+this.id).attr('disabled', 'disabled');
+			if (oSelected.length > 0)
+			{
+				$('#LinkDlg_'+this.id).dialog('open');
+			}
+			else
+			{
+				this.Refresh();
+				$('#ac_add_'+this.id).attr('disabled', 'disabled');
+			}
 		}
 	}