Jelajahi Sumber

worked on cvterm fields to add a pub

Chun-Huai Cheng 8 tahun lalu
induk
melakukan
73f0c5c905

+ 17 - 4
tripal_chado/includes/TripalFields/chado_linker__cvterm.inc

@@ -114,6 +114,7 @@ class chado_linker__cvterm extends TripalField {
     $fkey_value = $element['#entity']->chado_record_id;
     $cvterm_name = '';
     $cvterm_id = '';
+    $pub_id = '';
     $title = '';
     $is_not = '';
     $cvterm = NULL;
@@ -123,7 +124,11 @@ class chado_linker__cvterm extends TripalField {
     if (array_key_exists($delta, $items)) {
       $record_id = $items[$delta]['value'];
       $cvterm_name = $items[$delta]['cvterm__name'];
-      $title =$items[$delta]['pub'];
+      $pub_id =$items[$delta]['chado-' . $table_name . '__pub_id'];
+      if ($pub_id && $pub_id != 1) {
+        $pub = chado_generate_var('pub', array('pub_id' => $pub_id));
+        $title = $pub->title;
+      }
       $is_not = $items[$delta]['chado-' . $table_name . '__is_not'];
       $cvterm_id = $items[$delta]['chado-' . $table_name . '__cvterm_id'];
     }
@@ -185,6 +190,7 @@ class chado_linker__cvterm extends TripalField {
         'effect' => 'fade',
         'method' => 'replace'
       ),
+      '#size' => 30
     );
     
     $widget['pub'] = array(
@@ -199,6 +205,12 @@ class chado_linker__cvterm extends TripalField {
         'method' => 'replace'
       ),
       '#maxlength' => 100000,
+      '#size' => 30
+    );
+    
+    $widget['chado-' . $table_name . '__pub_id'] = array(
+      '#type' => 'value',
+      '#default_value' => $pub_id ? $pub_id : 1,
     );
 
     $widget['chado-' . $table_name . '__is_not'] = array(
@@ -240,9 +252,7 @@ class chado_linker__cvterm extends TripalField {
     if (!$cvterm_name) {
       $form_state['values'][$field_name][$langcode][$delta]['chado-' . $table_name . '__cvterm_id'] = '';
       $form_state['values'][$field_name][$langcode][$delta]['chado-' . $table_name . '__' . $lfkey_field] = '';
-    }
-    else {
-      $form_state['values'][$field_name][$langcode][$delta]['chado-' . $table_name . '__pub_id'] = 1;
+      $form_state['values'][$field_name][$langcode][$delta]['chado-' . $table_name . '__pub_id'] = '';
     }
   }
 
@@ -344,6 +354,9 @@ function theme_chado_linker__cvterm_widget($variables) {
         drupal_render($element['cvterm__name']) . "
         </div>
         <div class=\"annotation-cvterm-widget-item\">" .
+        drupal_render($element['pub']) . "
+        </div>
+        <div class=\"annotation-cvterm-widget-item\">" .
         drupal_render($element['chado-' . $table_name . '__is_not']) . "
         </div>
       </div>

+ 1 - 1
tripal_chado/theme/css/tripal_chado.css

@@ -6,7 +6,7 @@
 .kvproperty-adder-widget-item,
 .chado-linker--relationship-widget-item,
 .chado-linker--relationship-instance-settings-option2-item,
-.annotation-cvterm-widget {
+.annotation-cvterm-widget-item {
    float: left;
    margin-right: 10px;
 }