Browse Source

change to additional type widget to allow for publications to be added manually

Shawna 7 years ago
parent
commit
c7870a6f4c

+ 3 - 0
tripal_chado/includes/TripalFields/schema__additional_type/schema__additional_type_widget.inc

@@ -40,6 +40,9 @@ class schema__additional_type_widget extends ChadoFieldWidget {
       '#value' => $value,
     );
 
+    If ($field_table == 'pub' && empty($vocabulary)){
+      $vocabulary = 'tripal_pub';
+    };
     // If a parent_term is provided then use that to get the options
     $options = array();
     $options[] = 'Select a type';

+ 11 - 6
tripal_ds/includes/tripal_ds.ds.inc

@@ -143,7 +143,6 @@ function _ds_layout_settings_info($bundle_name, $instances) {
         $right_fields[$key] = $field_name;
       }
       usort($right_fields, sort_object('label'));
-      watchdog('debug', '<pre>$right_fields: '. print_r($right_fields, TRUE) .'</pre>');
 
     }
 
@@ -181,8 +180,6 @@ function _ds_layout_settings_info($bundle_name, $instances) {
     _ds_fields_info_write($bundle_name);
     $region_left = [ 'toc' ];
     $fields_with_regions += [ 'toc' => 'left' ];
-    watchdog('debug', '<pre>$fields_with_regions: '. print_r($fields_with_regions, TRUE) .'</pre>');
-    watchdog('debug', '<pre>$region_right: '. print_r($region_right, TRUE) .'</pre>');
 
     // Build the ds layout.
     $record = new stdClass;
@@ -257,10 +254,10 @@ function _ds_layout_pub_settings_info($bundle_name, $instances) {
         field_update_instance($instance);
       }
       elseif($instance_name == 'tpub__publication_type' || $instance_name == 'tpub__doi' || $instance_name == 'tpub__publication_date') {
-        array_push($properties, $instance);
+        array_push($properties, $instance_name);
       }
       else {
-        array_push($disabled_instances, $instance);
+        array_push($disabled_instances, $instance_name);
       }
 
     }
@@ -274,7 +271,7 @@ function _ds_layout_pub_settings_info($bundle_name, $instances) {
       // updating fields here to ensure name consistency.
       $group_field_name = substr($group_field_name, 0, 27);
 
-      // Add randomm numbers to ensure the field name is unique within the 32
+      // Add random numbers to ensure the field name is unique within the 32
       // character limit of the field.
       $group_field_name = $group_field_name.rand(0, 99999);
 
@@ -294,6 +291,11 @@ function _ds_layout_pub_settings_info($bundle_name, $instances) {
       $region_right = array_merge($region_right, $properties);
       $all_fields+= [ 'group_prop_tripalpane' => 'right', 'group_prop_table' => 'right' ];
     }
+    if(!empty($all_fields)){
+      foreach ($disabled_instances as $disabled_field) {
+        $all_fields += [$disabled_field => 'disabled'];
+      }
+    }
 
     // Add blocks to $region_left and build the toc field that is placed within.
     _ds_fields_info_write($bundle_name);
@@ -329,6 +331,9 @@ function _ds_layout_pub_settings_info($bundle_name, $instances) {
     );
     $record->settings = $settings;
     drupal_write_record('ds_layout_settings', $record);
+    // Clear the Drpual chace
+    cache_clear_all();
+    watchdog('debug', '<pre>$record: '. print_r($record, TRUE) .'</pre>');
   }
   catch (Exception $e) {
     watchdog_exception('tripal_ds', $e);