Bläddra i källkod

- Fized bug Trac#107: "select first line as header" is now checked when uploading data from a file.

git-svn-id: http://svn.code.sf.net/p/itop/code/trunk@425 a333f486-631f-4898-b8df-5754b55c2be0
dflaven 15 år sedan
förälder
incheckning
79e3306b36
2 ändrade filer med 50 tillägg och 9 borttagningar
  1. 34 2
      application/itopwebpage.class.inc.php
  2. 16 7
      pages/csvimport.php

+ 34 - 2
application/itopwebpage.class.inc.php

@@ -113,7 +113,7 @@ class iTopWebPage extends NiceWebPage
 		$("#RightPane").trigger("resize");
 	}
 	
-	$("#tabbedContent > ul").tabs( 1, { fxFade: true, fxSpeed: 'fast' } ); // tabs
+	$("div[id^=tabbedContent] > ul").tabs( 1, { fxFade: true, fxSpeed: 'fast' } ); // tabs
 	$("table.listResults").tableHover(); // hover tables
 	$(".listResults").tablesorter( { headers: { 0:{sorter: false }}, widgets: ['zebra']} ); // sortable and zebra tables
 	$(".date-pick").datePicker( {clickInput: false, createButton: true, startDate: '2000-01-01'} ); // Date picker
@@ -352,9 +352,10 @@ EOF
 		foreach($this->m_aTabs as $sTabContainerName => $m_aTabs)
 		{
 			$sTabs = '';
+			$container_index = 0;
 			if (count($m_aTabs) > 0)
 			{
-			  $sTabs = "<!-- tabs -->\n<div id=\"tabbedContent\" class=\"light\">\n";
+			  $sTabs = "<!-- tabs -->\n<div id=\"tabbedContent_{$container_index}\" class=\"light\">\n";
 			  $sTabs .= "<ul>\n";
 			  // Display the unordered list that will be rendered as the tabs
 	          $i = 0;
@@ -374,6 +375,7 @@ EOF
 			  $sTabs .= "</div>\n<!-- end of tabs-->\n";
 	        }
 			$this->s_content = str_replace("\$Tabs:$sTabContainerName\$", $sTabs, $this->s_content);
+			$container_index++;
 		}
         
 		// Display the page's content
@@ -427,6 +429,36 @@ EOF
 		return $sPreviousTab;
 	}
 	
+	/**
+	 * Make the given tab the active one, as if it were clicked
+	 * DOES NOT WORK: apparently in the *old* version of jquery
+	 * that we are using this is not supported... TO DO upgrade
+	 * the whole jquery bundle...
+	 */
+	public function SelectTab($sTabContainer, $sTabLabel)
+	{
+		$container_index = 0;
+		$tab_index = 0;
+		foreach($this->m_aTabs as $sCurrentTabContainerName => $aTabs)
+		{
+			if ($sTabContainer == $sCurrentTabContainerName)
+			{
+				foreach($aTabs as $sCurrentTabLabel => $void)
+				{
+					if ($sCurrentTabLabel == $sTabLabel)
+					{
+						break;
+					}
+					$tab_index++;
+				}	
+				break;
+			}
+			$container_index++;
+		}
+		$sSelector = '#tabbedContent_'.$container_index.' > ul';
+		$this->add_ready_script("$('$sSelector').tabs('select', $tab_index);");
+	}
+	
 	public function StartCollapsibleSection($sSectionLabel, $bOpen = false)
 	{
 		$this->add($this->GetStartCollapsibleSection($sSectionLabel, $bOpen));

+ 16 - 7
pages/csvimport.php

@@ -964,22 +964,26 @@ function Welcome(iTopWebPage $oPage)
 	$oPage->add("<div><p><h1>".Dict::S('UI:Title:BulkImport+')."</h1></p></div>\n");
 	$oPage->AddTabContainer('tabs1');	
 
+	$sSeparator = utils::ReadParam('separator', '');
+	$sTextQualifier = utils::ReadParam('text_qualifier', '');
+	$bHeaderLine = utils::ReadParam('header_line', true);
+	$iSkippedLines = utils::ReadParam('nb_skipped_lines', '');
+	$sClassName = utils::ReadParam('class_name', '');
+	$bAdvanced = utils::ReadParam('advanced', 0);
+
 	$sFileLoadHtml = '<div><form enctype="multipart/form-data" method="post"><p>'.Dict::S('UI:CSVImport:SelectFile').'</p>'.
 			'<p><input type="file" name="csvdata"/></p>'.
 			'<p><input type="submit" value="'.Dict::S('UI:Button:Next').'"/></p>'.
 			'<p><input type="hidden" name="step" value="2"/></p>'.
 			'<p><input type="hidden" name="operation" value="file_upload"/></p>'.
+			'<input type="hidden" name="header_line" value="'.$bHeaderLine.'"/>'.
+			'<input type="hidden" name="nb_skipped_lines" value="'.$iSkippedLines.'"/>'.
+			'<input type="hidden" name="class_name" value="'.$sClassName.'"/>'.
+			'<input type="hidden" name="advanced" value="'.$bAdvanced.'"/>'.
 			'</form></div>';
 	
 	$oPage->AddToTab('tabs1', Dict::S('UI:CSVImport:Tab:LoadFromFile'), $sFileLoadHtml);	
 	$sCSVData = utils::ReadParam('csvdata', '');
-	$sSeparator = utils::ReadParam('separator', '');
-	$sTextQualifier = utils::ReadParam('text_qualifier', '');
-	$bHeaderLine = utils::ReadParam('header_line', true);
-	$iSkippedLines = utils::ReadParam('nb_skipped_lines', '');
-	$sClassName = utils::ReadParam('class_name', '');
-	$bAdvanced = utils::ReadParam('advanced', 0);
-	$sCSVData = utils::ReadParam('csvdata', '');
 	$sPasteDataHtml = '<div><form enctype="multipart/form-data" method="post"><p>'.Dict::S('UI:CSVImport:PasteData').'</p>'.
 			'<p><textarea cols="100" rows="30" name="csvdata">'.htmlentities($sCSVData, ENT_QUOTES, 'UTF-8').'</textarea></p>'.
 			'<p><input type="submit" value="'.Dict::S('UI:Button:Next').'"/></p>'.
@@ -994,6 +998,11 @@ function Welcome(iTopWebPage $oPage)
 			'</form></div>';
 			
 	$oPage->AddToTab('tabs1', Dict::S('UI:CSVImport:Tab:CopyPaste'), $sPasteDataHtml);		
+	if (!empty($sCSVData))
+	{
+		// When there are some data, activate the 'copy & paste' tab by default
+		$oPage->SelectTab('tabs1', Dict::S('UI:CSVImport:Tab:CopyPaste'));
+	}
 	$sTemplateHtml = '<div><p>'.Dict::S('UI:CSVImport:PickClassForTemplate').' ';
 	$sTemplateHtml .= GetClassesSelect('template_class', '', 300, UR_ACTION_BULK_MODIFY);
 	$sTemplateHtml .= '</div>';