Browse Source

Fixed minor form behavior with MViews and Custom Tables

Stephen Ficklin 7 years ago
parent
commit
a0b7db4da4

+ 7 - 0
tripal_chado/api/tripal_chado.custom_tables.api.inc

@@ -215,6 +215,13 @@ function chado_create_custom_table($table, $schema, $skip_if_exists = TRUE, $mvi
   else {
     drupal_set_message("Custom table, '" . $table . "' , already exists. Table structure not changed, but definition array has been saved.", 'status');
   }
+
+  if ($mview_id) {
+    drupal_goto('admin/tripal/storage/chado/mviews/');
+  }
+  else {
+    drupal_goto('admin/tripal/storage/chado/custom_tables');
+  }
   return TRUE;
 }
 

+ 13 - 8
tripal_chado/includes/tripal_chado.custom_tables.inc

@@ -111,6 +111,15 @@ function tripal_custom_table_view($table_id) {
  */
 function tripal_custom_tables_form($form, &$form_state = NULL, $table_id = NULL) {
 
+  // set the breadcrumb
+  $breadcrumb = array();
+  $breadcrumb[] = l('Home', '<front>');
+  $breadcrumb[] = l('Administration', 'admin');
+  $breadcrumb[] = l('Tripal', 'admin/tripal');
+  $breadcrumb[] = l('Chado Schema', 'admin/tripal/storage/chado');
+  $breadcrumb[] = l('Custom Tables', 'admin/tripal/storage/chado/custom_tables');
+  drupal_set_breadcrumb($breadcrumb);
+
   if (!$table_id) {
     $action = 'Add';
   }
@@ -147,11 +156,6 @@ function tripal_custom_tables_form($form, &$form_state = NULL, $table_id = NULL)
     }
   }
 
-  $form['return'] = array(
-    '#type' => 'markup',
-    '#markup' => "<p>" . l("Return to list of custom tables", "admin/tripal/storage/chado/custom_tables") . "</p>",
-  );
-
   // Build the form
   $form['action'] = array(
     '#type' => 'value',
@@ -259,9 +263,10 @@ array (
     '#value'        => t($value),
     '#executes_submit_callback' => TRUE,
   );
-
-
-
+  $form['cancel'] = array(
+    '#type'   => 'markup',
+    '#markup' => l('Cancel', 'admin/tripal/storage/chado/custom_tables'),
+  );
 
   return $form;
 }

+ 24 - 7
tripal_chado/includes/tripal_chado.mviews.inc

@@ -45,6 +45,14 @@ function tripal_mview_admin_view() {
  *  The unique ID of the materialized view to render
  */
 function tripal_mview_report($mview_id) {
+  // set the breadcrumb
+  $breadcrumb = array();
+  $breadcrumb[] = l('Home', '<front>');
+  $breadcrumb[] = l('Administration', 'admin');
+  $breadcrumb[] = l('Tripal', 'admin/tripal');
+  $breadcrumb[] = l('Chado Schema', 'admin/tripal/storage/chado');
+  $breadcrumb[] = l('Materialied Views', 'admin/tripal/storage/chado/mviews');
+  drupal_set_breadcrumb($breadcrumb);
 
   // get this mview details
   $sql = "SELECT * FROM {tripal_mviews} WHERE mview_id = :mview_id";
@@ -55,8 +63,7 @@ function tripal_mview_report($mview_id) {
 
   // create a table with each row containig stats for
   // an individual job in the results set.
-  $output  = "<p>" . l("Return to table of materialized views", "admin/tripal/storage/chado/mviews/") . "</p>";
-  $output .= "<p>Details for <b>$mview->name</b>:</p>";
+  $output = "<p>Details for <b>$mview->name</b>:</p>";
 
   // build the URLs using the url function so we can handle installations where
   // clean URLs are or are not used
@@ -126,6 +133,17 @@ function tripal_mview_report($mview_id) {
  *   A form array (Form API)
  */
 function tripal_mviews_form($form, &$form_state = NULL, $mview_id = NULL) {
+
+  // set the breadcrumb
+  $breadcrumb = array();
+  $breadcrumb[] = l('Home', '<front>');
+  $breadcrumb[] = l('Administration', 'admin');
+  $breadcrumb[] = l('Tripal', 'admin/tripal');
+  $breadcrumb[] = l('Chado Schema', 'admin/tripal/storage/chado');
+  $breadcrumb[] = l('Materialied Views', 'admin/tripal/storage/chado/mviews');
+  drupal_set_breadcrumb($breadcrumb);
+
+
   if (!$mview_id) {
     $action = 'Add';
   }
@@ -239,11 +257,6 @@ function tripal_mviews_form($form, &$form_state = NULL, $mview_id = NULL) {
     '#value' => $default_modulename,
   );
 
-  $form['return_link'] = array(
-    '#type' => 'item',
-    '#description' => l("Return to table of materialized views", "admin/tripal/storage/chado/mviews/"),
-  );
-
   $form['instructions'] = array(
     '#type' => 'fieldset',
     '#title' => 'Instructions',
@@ -439,6 +452,10 @@ SELECT
     '#value'        => t($value),
     '#executes_submit_callback' => TRUE,
   );
+  $form['cancel'] = array(
+    '#type'         => 'markup',
+    '#markup'        => l('Cancel', 'admin/tripal/storage/chado/mviews'),
+  );
 
 
   return $form;

+ 3 - 0
tripal_chado/includes/tripal_chado.vocab_storage.inc

@@ -95,6 +95,9 @@ function tripal_chado_vocab_get_vocabulary($vocabulary) {
   ";
   $result = chado_query($sql, array(':name' => $vocabulary));
   $result = $result->fetchAssoc();
+  if (!$result) {
+    return FALSE;
+  }
 
   if (!$result['name']) {
     $result['name'] = $result['short_name'];