Browse Source

Fixed ajax form elements after adding vertical tabs for migrating content

ccheng 9 years ago
parent
commit
45ae18eacc
1 changed files with 22 additions and 18 deletions
  1. 22 18
      tripal_chado/includes/tripal_chado.migrate.inc

+ 22 - 18
tripal_chado/includes/tripal_chado.migrate.inc

@@ -33,6 +33,12 @@ function tripal_chado_migrate_form($form, &$form_state) {
     '#collapsed' => TRUE,
     '#collapsed' => TRUE,
     '#group' => 'overview_vert_tabs'
     '#group' => 'overview_vert_tabs'
   );
   );
+  $form['step2']['step2_content'] = array(
+    '#type' => 'fieldset',
+    '#collapsible' => FALSE,
+    '#prefix' => '<div id="tripal-chado-migrate-form-step2">',
+    '#suffix' => '</div>'
+  );
   
   
   $tv2_content_type = 'all';
   $tv2_content_type = 'all';
   if (array_key_exists('values', $form_state)) {
   if (array_key_exists('values', $form_state)) {
@@ -40,15 +46,15 @@ function tripal_chado_migrate_form($form, &$form_state) {
   }
   }
 
 
   $options = tripal_chado_get_tripal_v2_content_type_options(TRUE);
   $options = tripal_chado_get_tripal_v2_content_type_options(TRUE);
-  $form['step2']['tv2_content_type'] = array(
+  $form['step2']['step2_content']['tv2_content_type'] = array(
     '#type' => 'select',
     '#type' => 'select',
     '#title' => 'Tripal v2 Content Type',
     '#title' => 'Tripal v2 Content Type',
     '#description' => t('Select the Tripal v2 content type to migrate.'),
     '#description' => t('Select the Tripal v2 content type to migrate.'),
     '#options' => $options,
     '#options' => $options,
     '#default_value' => $tv2_content_type,
     '#default_value' => $tv2_content_type,
     '#ajax' => array(
     '#ajax' => array(
-      'callback' => "tripal_chado_migrate_form_ajax_callback",
-      'wrapper' => "tripal-chado-migrate-form",
+      'callback' => "tripal_chado_migrate_form_step2_ajax_callback",
+      'wrapper' => "tripal-chado-migrate-form-step2",
       'effect' => 'fade',
       'effect' => 'fade',
       'method' => 'replace'
       'method' => 'replace'
     ),
     ),
@@ -56,13 +62,12 @@ function tripal_chado_migrate_form($form, &$form_state) {
 
 
   // Add a review button that allows reviewing migratable content types
   // Add a review button that allows reviewing migratable content types
   if ($tv2_content_type != 'all') {
   if ($tv2_content_type != 'all') {
-
     $table = str_replace('chado_', '', $tv2_content_type);
     $table = str_replace('chado_', '', $tv2_content_type);
     $schema = chado_get_schema($table);
     $schema = chado_get_schema($table);
     $pkey = $schema['primary key'][0];
     $pkey = $schema['primary key'][0];
     $fkeys = $schema['foreign keys'];
     $fkeys = $schema['foreign keys'];
 
 
-    $form['step2']['tv3_content_type'] = array(
+    $form['step2']['step2_content']['tv3_content_type'] = array(
       '#type' => 'fieldset',
       '#type' => 'fieldset',
       '#title' => 'Tripal v3 Content Type',
       '#title' => 'Tripal v3 Content Type',
       '#description' => "Click the 'Get Tripal v3 Types' button to retrieve a list of Tripal v3
       '#description' => "Click the 'Get Tripal v3 Types' button to retrieve a list of Tripal v3
@@ -70,13 +75,13 @@ function tripal_chado_migrate_form($form, &$form_state) {
         depending on the size of your database.  The number of items to be converted is
         depending on the size of your database.  The number of items to be converted is
         shown beside the type."
         shown beside the type."
     );
     );
-    $form['step2']['tv3_content_type']['get_v3_type_btn'] = array(
+    $form['step2']['step2_content']['tv3_content_type']['get_v3_type_btn'] = array(
       '#type' => 'button',
       '#type' => 'button',
       '#name' => 'get_v3_type_btn',
       '#name' => 'get_v3_type_btn',
       '#value' => "Get Tripal v3 Types",
       '#value' => "Get Tripal v3 Types",
       '#ajax' => array(
       '#ajax' => array(
-        'callback' => "tripal_chado_migrate_form_ajax_callback",
-        'wrapper' => "tripal-chado-migrate-form",
+        'callback' => "tripal_chado_migrate_form_step2_ajax_callback",
+        'wrapper' => "tripal-chado-migrate-form-step2",
         'effect' => 'fade',
         'effect' => 'fade',
         'method' => 'replace'
         'method' => 'replace'
       ),
       ),
@@ -86,7 +91,7 @@ function tripal_chado_migrate_form($form, &$form_state) {
     if ($form_state['clicked_button']['#name'] == 'get_v3_type_btn') {
     if ($form_state['clicked_button']['#name'] == 'get_v3_type_btn') {
 
 
       // Migrate all      
       // Migrate all      
-      $form['step2']['tv3_content_type']['tv3_migrate_all'] = array(
+      $form['step2']['step2_content']['tv3_content_type']['tv3_migrate_all'] = array(
         '#type' => 'checkbox',
         '#type' => 'checkbox',
         '#title' => 'Migrate All'
         '#title' => 'Migrate All'
       );
       );
@@ -113,7 +118,7 @@ function tripal_chado_migrate_form($form, &$form_state) {
             $tv3_content_type->namespace . '--' . 
             $tv3_content_type->namespace . '--' . 
             $tv3_content_type->accession . '--' . 
             $tv3_content_type->accession . '--' . 
             $tv3_content_type->type);
             $tv3_content_type->type);
-          $form['step2']['tv3_content_type'][$key] = array(
+          $form['step2']['step2_content']['tv3_content_type'][$key] = array(
             '#type' => 'checkbox',
             '#type' => 'checkbox',
             '#title' => $tv3_content_type->type . ' (' . $tv3_content_type->num . ')',
             '#title' => $tv3_content_type->type . ' (' . $tv3_content_type->num . ')',
           );
           );
@@ -131,7 +136,7 @@ function tripal_chado_migrate_form($form, &$form_state) {
         $org_count = chado_query($sql)->fetchField();
         $org_count = chado_query($sql)->fetchField();
         if ($org_count > 0) {
         if ($org_count > 0) {
           $key = urldecode('tv3_content_type--local--organism--organism');
           $key = urldecode('tv3_content_type--local--organism--organism');
-          $form['step2']['tv3_content_type'][$key] = array(
+          $form['step2']['step2_content']['tv3_content_type'][$key] = array(
             '#type' => 'checkbox',
             '#type' => 'checkbox',
             '#title' => 'Organism (' . $org_count . ')',
             '#title' => 'Organism (' . $org_count . ')',
           );
           );
@@ -149,7 +154,7 @@ function tripal_chado_migrate_form($form, &$form_state) {
         $ana_count = chado_query($sql)->fetchField();
         $ana_count = chado_query($sql)->fetchField();
         if ($ana_count > 0) {
         if ($ana_count > 0) {
           $key = urlencode('tv3_content_type--local--analysis--analysis');
           $key = urlencode('tv3_content_type--local--analysis--analysis');
-          $form['step2']['tv3_content_type'][$key] = array(
+          $form['step2']['step2_content']['tv3_content_type'][$key] = array(
             '#type' => 'checkbox',
             '#type' => 'checkbox',
             '#title' => 'Analysis (' . $ana_count . ')',
             '#title' => 'Analysis (' . $ana_count . ')',
           );
           );
@@ -157,15 +162,15 @@ function tripal_chado_migrate_form($form, &$form_state) {
         }
         }
       }
       }
       if ($no_data) {
       if ($no_data) {
-        unset($form['step2']['tv3_content_type']['tv3_migrate_all']);
+        unset($form['step2']['step2_content']['tv3_content_type']['tv3_migrate_all']);
         drupal_set_message('No data for migration or all have been migrated.', 'warning');
         drupal_set_message('No data for migration or all have been migrated.', 'warning');
       }
       }
     }
     }
   }
   }
 
 
   // Submit button
   // Submit button
-  if ($tv2_content_type == 'all' || key_exists('tv3_migrate_all', $form['step2']['tv3_content_type'])) {
-    $form['step2']['migrate_btn'] = array(
+  if ($tv2_content_type == 'all' || key_exists('tv3_migrate_all', $form['step2']['step2_content']['tv3_content_type'])) {
+    $form['step2']['step2_content']['migrate_btn'] = array(
       '#type' => 'submit',
       '#type' => 'submit',
       '#name' => 'migrate_btn',
       '#name' => 'migrate_btn',
       '#value' => "Migrate $options[$tv2_content_type]",
       '#value' => "Migrate $options[$tv2_content_type]",
@@ -249,9 +254,8 @@ function tripal_chado_migrate_form_submit($form, &$form_state) {
  * @param $form_state
  * @param $form_state
  * @return $form
  * @return $form
  */
  */
-function tripal_chado_migrate_form_ajax_callback(&$form, &$form_state) {
-  $active_tab = $form_state['values']['overview_vert_tabs__active_tab'];
-  return $form;
+function tripal_chado_migrate_form_step2_ajax_callback(&$form, &$form_state) {
+  return $form['step2']['step2_content'];
 }
 }
 
 
 /**
 /**