diff --git a/application/itopwebpage.class.inc.php b/application/itopwebpage.class.inc.php
index 9d933fbc5..2f666bc76 100644
--- a/application/itopwebpage.class.inc.php
+++ b/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 = "\n
\n";
+ $sTabs = "\n
\n";
$sTabs .= "
\n";
// Display the unordered list that will be rendered as the tabs
$i = 0;
@@ -374,6 +375,7 @@ EOF
$sTabs .= "
\n\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));
diff --git a/pages/csvimport.php b/pages/csvimport.php
index e77793edf..26f5a7073 100644
--- a/pages/csvimport.php
+++ b/pages/csvimport.php
@@ -964,21 +964,25 @@ function Welcome(iTopWebPage $oPage)
$oPage->add("
".Dict::S('UI:Title:BulkImport+')."
\n");
$oPage->AddTabContainer('tabs1');
- $sFileLoadHtml = '
';
-
- $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);
+
+ $sFileLoadHtml = '
';
+
+ $oPage->AddToTab('tabs1', Dict::S('UI:CSVImport:Tab:LoadFromFile'), $sFileLoadHtml);
$sCSVData = utils::ReadParam('csvdata', '');
$sPasteDataHtml = '
';
$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 = '
'.Dict::S('UI:CSVImport:PickClassForTemplate').' ';
$sTemplateHtml .= GetClassesSelect('template_class', '', 300, UR_ACTION_BULK_MODIFY);
$sTemplateHtml .= '
';