Stephen Ficklin před 9 roky
rodič
revize
4528ddb61a

+ 23 - 1
tripal_entities/includes/TripalEntityUIController.inc

@@ -81,12 +81,25 @@ class TripalEntityUIController extends EntityDefaultUIController {
     $items['data/' . $wildcard . '/edit'] = array(
       'title' => 'Edit',
       'page callback' => 'drupal_get_form',
-      'page arguments' => array('tripal_entities_entity_form', 1),
+      'page arguments' => array('tripal_entities_entity_form', NULL, 1),
       'access callback' => 'tripal_entities_entity_access',
       'access arguments' => array('edit', 1),
       'file' =>  'includes/tripal_entities.entity_form.inc',
       'file path' => drupal_get_path('module', 'tripal_entities'),
       'type' => MENU_LOCAL_TASK,
+      'weight' => -8,
+    );
+
+    $items['data/' . $wildcard . '/manage'] = array(
+      'title' => 'Manage',
+      'page callback' => 'tripal_entity_manage_fields',
+      'page arguments' => array(1),
+      'access callback' => 'tripal_entities_entity_access',
+      'access arguments' => array('manage', 1),
+      'file' =>  'includes/TripalEntityUIController.inc',
+      'file path' => drupal_get_path('module', 'tripal_entities'),
+      'type' => MENU_LOCAL_TASK,
+      'weight' => -6,
     );
 
     // Menu item for deleting tripal data entities.
@@ -104,3 +117,12 @@ class TripalEntityUIController extends EntityDefaultUIController {
     return $items;
   }
 }
+
+/**
+ *
+ * @param unknown $entity
+ */
+function tripal_entity_manage_fields($entity) {
+  drupal_goto('admin/structure/bio_data/' . $entity->type . '/manage/' . $entity->bundle . '/fields');
+  return '';
+}

+ 7 - 2
tripal_entities/includes/tripal_entities.chado_entity.inc

@@ -75,6 +75,7 @@ function tripal_entities_field_widget_form_alter(&$element, &$form_state, $conte
   if (array_key_exists('#field_name', $element)) {
     $field_name = $element['#field_name'];
     $matches = array();
+
     if (preg_match('/(.+?)__(.+?)$/', $field_name, $matches)) {
       $tablename = $matches[1];
       $colname = $matches[2];
@@ -91,7 +92,7 @@ function tripal_entities_field_widget_form_alter(&$element, &$form_state, $conte
       // We want the date combo fieldset to be collaspible so we will
       // add our own theme_wrapper to replace the one added by the date
       // module.
-      if ($schema['fields'][$colname]['type'] == 'datetime') {
+      if (array_key_exists($colname, $schema['fields']) and $schema['fields'][$colname]['type'] == 'datetime') {
         $element['#theme_wrappers'] = array('tripal_entities_date_combo');
       }
     }
@@ -140,7 +141,11 @@ function tripal_entities_chado_field_alter(&$field) {
     $field['field_type'] = 'dbxref_id';
     $field['widget_type'] = 'tripal_fields_primary_dbxref_widget';
     $field['label'] = 'Primary Cross Reference';;
-    $field['description'] = 'This record can be cross-referenced with a record in another online database. This field is intended for the most prominent reference.  At a minimum, the database and accession must be provided.';
+    $field['description'] = 'This record can be cross-referenced with a
+        record in another online database. The primary reference is for the
+        most prominent reference.  At a minimum, the database and accession
+        must be provided.  To remove a set reference, change the database
+        field to "Select a Database".';
   }
   else if ($field['chado_table'] == 'feature' and
     $field['chado_column'] == 'md5checksum') {

+ 13 - 0
tripal_entities/theme/css/tripal_entities.css

@@ -4,8 +4,21 @@
    float: left;
    margin-right: 10px;
 }
+.primary-dbxref-widget-links {
+   clear: both;
+}
 
 .kvproperty-adder-widget-item {
    float: left;
    margin-right: 10px;
+}
+
+.residues-formatter {
+   border: 1px solid #dddddd;
+   color: #000000;
+   height: 300px;
+   max-width: 500px;
+   overflow: scroll;
+   white-space: normal;
+   background-color: white;
 }

+ 6 - 1
tripal_fields/includes/fields/kvproperty.inc

@@ -13,8 +13,13 @@
 function tripal_fields_kvproperty_formatter(&$element, $entity_type, $entity, $field,
   $instance, $langcode, $items, $display) {
 
+  $content = '';
   foreach ($items as $delta => $item) {
-    // Do nothing, this field is only meant for the form.
+    $content =  key_exists('value', $item) ? $item['value'] : '';
+    $element[$delta] = array(
+      '#type' => 'markup',
+      '#markup' => $content,
+    );
   }
 }
 /**

+ 16 - 2
tripal_fields/includes/fields/primary_dbxref.inc

@@ -19,7 +19,7 @@ function tripal_fields_primary_dbxref_formatter(&$element, $entity_type, $entity
       $dbxref = chado_generate_var('dbxref', array('dbxref_id' => $item['value']));
       $accession = $dbxref->db_id->name . ':' . $dbxref->accession;
       if ($dbxref->db_id->urlprefix) {
-        $accession = l($accession, $dbxref->db_id->urlprefix . '/' . $dbxref->accession);
+        $accession = l($accession, $dbxref->db_id->urlprefix . '/' . $dbxref->accession, array('attributes' => array('target' => '_blank')));
       }
     }
     $element[$delta] = array(
@@ -64,6 +64,14 @@ function tripal_fields_primary_dbxref_widget($form, $form_state, $field, $instan
   if (count($temp) > 0) {
     $db_id = $temp[0];
   }
+  // If we are here because our parent was triggered in a form submit
+  // then that means an ajax call was made and we don't want the fieldset to
+  // be closed when it returns from the ajax call.
+  $collapsed = TRUE;
+  if (array_key_exists('triggering_element', $form_state) and
+      $form_state['triggering_element']['#parents'][0] == $field_name) {
+    $collapsed = FALSE;
+  }
 
   $schema = chado_get_schema('dbxref');
   $options = tripal_get_db_select_options();
@@ -77,7 +85,7 @@ function tripal_fields_primary_dbxref_widget($form, $form_state, $field, $instan
     '#theme' => 'tripal_fields_primary_dbxref_widget',
     '#group' => 'entity_vetical_tabs',
     '#collapsible' => TRUE,
-    '#collapsed' => TRUE,
+    '#collapsed' => $collapsed,
     array(
       $element['#field_name'] => array(
         '#type' => 'hidden',
@@ -124,6 +132,10 @@ function tripal_fields_primary_dbxref_widget($form, $form_state, $field, $instan
         '#default_value' => $description,
         '#size' => 20,
       ),
+      'links' => array(
+        '#type' => 'item',
+        '#markup' => l('Add a new database', 'admin/tripal/chado/tripal_db/add', array('attrbutes', array('target' => '_blank')))
+      )
     ),
     '#prefix' => "<span id='$field_name-dbxref--db-id'>",
     '#suffix' => "</span>"
@@ -148,6 +160,7 @@ function tripal_fields_primary_dbxref_widget_form_ajax_callback($form, $form_sta
       drupal_set_message('The selected cross reference is new and will be added for future auto completions.');
     }
   }
+
   return $form[$field_name];
 }
 
@@ -211,6 +224,7 @@ function theme_tripal_fields_primary_dbxref_widget($variables) {
       <div class=\"primary-dbxref-widget-item\">" .
       drupal_render($element[0]['dbxref__description']) . "
       </div>
+      <div class=\"primary-dbxref-widget-links\">" . drupal_render($element[0]['links']) . "</div>
     </div>
   ";
       return $layout;

+ 1 - 1
tripal_fields/includes/fields/residues.inc

@@ -15,7 +15,7 @@ function tripal_fields_residues_textarea_formatter(&$element, $entity_type, $ent
 
   foreach ($items as $delta => $item) {
     $residues = key_exists('value', $item) ? $item['value'] : '';
-    $content = '<pre>' . $residues . '</pre>';
+    $content = '<pre class="residues-formatter">' . $residues . '</pre>';
     $element[$delta] = array(
       // We create a render array to produce the desired markup,
       '#type' => 'markup',