Browse Source

cleaning up and removing the display layout and references

Shawna Spoor 8 years ago
parent
commit
f93d08d01b

+ 59 - 45
tripal_ds/includes/tripal_ds.ds.inc

@@ -3,24 +3,26 @@
  * Implements hook_ds_layout_settings_info().
  */
 function _ds_layout_settings_info($bundle_name, $instances) {
-    $region_right = array();
-    $region_left = array();
-    $region_top = array();
-    $region_bottom = array();
-    $prop_fields = array();
-    $data_sequence_fields = array();
+    //$all_fields= array(); //was region_right
+    $prop_fields = array(); // was region_left
+    $summary_fields = array(); // was region_top
+    $data_sequence_fields = array(); //was region_bottom
+
+    //$prop_fields = array();
+    //$data_sequence_fields = array();
     $all_other_fields = array();
-    $fields_with_regions = array();
+    //$fields_with_regions = array();
     $i = 0;
 
     foreach ($instances as $key => $instance){
         $instance_name = $instance['field_name'];
-
         if($instance_name=="rdfs__type"){
-            array_push($region_top, $instance_name);
-            $fields_with_regions[$instance_name]= 'top';
+            array_push($summary_fields, $instance_name);
+            //$fields_with_regions[$instance_name]= 'top';
 
-        } else {
+        } 
+        else {
+            //TODO: How do we handle non-chado dbs, placement of fields within tripal panes might need to be done in a hook. 
             $instance_base_table = $instance['settings']['base_table'];
             $instance_base_chado = $instance['settings']['chado_table'];
             $prop_table = strpos($instance_base_chado, 'prop');
@@ -32,36 +34,43 @@ function _ds_layout_settings_info($bundle_name, $instances) {
                     if ($prop_table !== FALSE){
                         //Properties section instances
                         array_push($prop_fields, $instance_name);
-                        $fields_with_regions[$instance_name]= 'right';
+                        //$fields_with_regions[$instance_name]= 'right';
 
-                    } elseif ($data_sequence !== FALSE) {
+                    } 
+                    elseif ($data_sequence !== FALSE) {
                         //data sequence section instances
                         array_push($data_sequence_fields, $instance_name);
-                        $fields_with_regions[$instance_name] = 'right';
+                       // $fields_with_regions[$instance_name] = 'right';
 
-                    }else {
+                    } 
+                    else {
                         //overview section instances
-                        array_push($region_top, $instance_name);
-                        $fields_with_regions[$instance_name] = 'top';
+                        array_push($summary_fields, $instance_name);
+                       // $fields_with_regions[$instance_name] = 'top';
                     }
 
-                } elseif ($instance_base_chado != $instance_base_table){
+                } 
+                elseif ($instance_base_chado != $instance_base_table){
                     if ($prop_table !== FALSE){
                         //Properties section instances
                         array_push($prop_fields, $instance_name);
-                        $fields_with_regions[$instance_name]= 'right';
+                       // $fields_with_regions[$instance_name]= 'right';
 
-                    } elseif ($data_sequence !== FALSE){
+                    } 
+                    elseif ($data_sequence !== FALSE){
                         //data sequence section instances
                         array_push($data_sequence_fields, $instance_name);
-                        $fields_with_regions[$instance_name]= 'right';
+                       // $fields_with_regions[$instance_name]= 'right';
 
-                    } else {
+                    } 
+                    else {
                         //Linker section instances
-                        //array_push($region_right, $instance_name);
                         array_push($all_other_fields, $instance);
-                        $fields_with_regions[$instance_name]= 'right';
+                       // $fields_with_regions[$instance_name]= 'right';
 
+                        //update the display settings so that the title is hidden
+                        $instance['display']['default']['label'] = 'hidden';
+                        field_update_instance($instance);
                     }
                 }
             }
@@ -69,52 +78,57 @@ function _ds_layout_settings_info($bundle_name, $instances) {
         $i++;
     }
 
-    //add the field sets to the region arrays
-    if(!empty($region_top)){
-        _overview_field_group_info($bundle_name, $region_top);
+    //consolidate the field sets
+    if(!empty($summary_fields)){
+        _summary_field_group_info($bundle_name, $summary_fields);
 
         //add the fields to the regions
-        array_unshift($region_top, 'group_summary_tripalpane', 'group_summary', 'group_summary_table');
-        $fields_with_regions += [ 'group_summary_tripalpane' =>'top', 'group_summary' => 'top', 'group_summary_table' => 'top' ];
+        //array_unshift($summary_fields, 'group_summary_tripalpane', 'group_summary', 'group_summary_table');
+        //$fields_with_regions += [ 'group_summary_tripalpane' =>'top', 'group_summary' => 'top', 'group_summary_table' => 'top' ];
     }
     if (!empty($prop_fields)){
         _prop_field_group_info($bundle_name, $prop_fields);
-        array_unshift($prop_fields, 'group_prop_tripalpane', 'group_prop', 'group_prop_table');
+        //array_unshift($prop_fields, 'group_prop_tripalpane', 'group_prop', 'group_prop_table');
 
         //add the fields to the regions
-        $region_right = array_merge($prop_fields, $region_right);
-        $fields_with_regions += [ 'group_prop_tripalpane' => 'right', 'group_prop' => 'right', 'group_prop_table' => 'right' ];
+        //$region_right = array_merge($prop_fields, $region_right);
+        //$fields_with_regions += [ 'group_prop_tripalpane' => 'right', 'group_prop' => 'right', 'group_prop_table' => 'right' ];
     }
     if (!empty($data_sequence_fields)){
         _data_sequence_field_group_info($bundle_name, $data_sequence_fields);
-        array_unshift($data_sequence_fields, 'group_sequence_tripalpane', 'group_sequence', 'group_sequence_table');
+        //array_unshift($data_sequence_fields, 'group_sequence_tripalpane', 'group_sequence', 'group_sequence_table');
 
         //add the fields to the regions
-        $region_right = array_merge($data_sequence_fields, $region_right);
-        $fields_with_regions += [ 'group_sequence_tripalpane' => 'right', 'group_sequence' => 'right', 'group_sequence_table' => 'right' ];
+        //$region_right = array_merge($data_sequence_fields, $region_right);
+        //$fields_with_regions += [ 'group_sequence_tripalpane' => 'right', 'group_sequence' => 'right', 'group_sequence_table' => 'right' ];
     }
     if (!empty($all_other_fields)){
         foreach ($all_other_fields as $key => $other_field) {
-          //temporary fields
+          //temporary field names
           $temporary_field = array();
-          $group_field_name = 'group_'.$other_field['field_name'];
-          $fieldset_field_name = 'fieldset_'.$other_field['field_name'];
+          $group_field_name = 'gp_'.$other_field['field_name'];
+          $fieldset_field_name = 'ft_'.$other_field['field_name'];
 
           //need to truncate the names because of database field size restrictions, updating fields here to ensure name consistency
-          $group_field_name = substr($group_field_name, 0, 15);
-          $fieldset_field_name = substr($fieldset_field_name, 0, 15);
+          $group_field_name = substr($group_field_name, 0, 27);
+          $fieldset_field_name = substr($fieldset_field_name, 0, 27);
+
+          //add randomm 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);
+          $fieldset_field_name = $fieldset_field_name.rand(0, 99999);
 
           //build the field group
           _additional_fields_field_group_info($bundle_name, $other_field['label'], $group_field_name, $fieldset_field_name, $other_field['field_name']);
           //update arrays
-          array_push($temporary_field, $group_field_name, $fieldset_field_name, $other_field['field_name']);
-          $region_right = array_merge($region_right, $temporary_field);
-          $fields_with_regions+= [ $group_field_name => 'right', $fieldset_field_name => 'right' ];
+          //array_push($temporary_field, $group_field_name, $fieldset_field_name, $other_field['field_name']);
+          //$region_right = array_merge($region_right, $temporary_field);
+          //$fields_with_regions+= [ $group_field_name => 'right', $fieldset_field_name => 'right' ];
+
 
         }
 
     }
-
+    /*
     //build the ds layout
     $record = new stdClass;
     $record->id ='TripalEntity|' . $bundle_name . '|default';
@@ -151,5 +165,5 @@ function _ds_layout_settings_info($bundle_name, $instances) {
     );
     $record->settings = $settings;
     drupal_write_record('ds_layout_settings', $record);
-
+    */
 }

+ 8 - 43
tripal_ds/includes/tripal_ds.field_formatter.inc

@@ -50,48 +50,13 @@ function tripal_ds_field_group_format_settings($group) {
  * @param $element The field group form element.
  * @param $group The Field group object prepared for pre_render.
  * @param $form The root element or form.
-
-function field_group_pre_render_tripalpane(&$element, $group, &$form) {
-
-  $element += array(
-    '#type' => 'tripalpane',
-    '#title' => check_plain(t($group->label)),
-    '#collapsible' => $group->collapsible,
-    '#collapsed' => $group->collapsed,
-    '#pre_render' => array(),
-    '#attributes' => array('class' => explode(' ', $group->classes)),
-    '#description' => $group->description,
-  );
-
-  if ($group->collapsible || $group->collapsed) {
-    $element['#attached']['library'][] = array('system', 'drupal.collapse');
-  }
-}
  */
-/*
- * Implements hook_field_group_build_pre_re2 nder_alter().
- * @param Array $elements by address.
-
-function tripal_ds_field_group_build_pre_render_alter(&$element) {
-  // While custom fields and groups are present at the root level of the form
-  // e.g. $element['field_custom_field'] they will later be moved into
-  // $element['additional_settings']['group']['#groups']['additional_settings']['field_custom_field']
-  // which is where we need to alter them.
-
-  // Use the states API to set the visibility of a fieldset within a vertical
-  // tab based on the value of a custom checkbox field.
-  if (isset($element['group_parent_vertical_tab'])) {
-    $element['additional_settings']['group']['#groups']['additional_settings']['group_parent_vertical_tab']['group_child_fieldset']['#states'] = array(
-      'visible' => array(
-        ':input[name="field_custom_checkbox[' . LANGUAGE_NONE . ']"]' => array('checked' => TRUE),
-      ),
-    );
+function tripal_ds_field_group_pre_render(&$element, $group, &$form) {
+  $group_name = $group->group_name;
+  switch ($group->format_type) {
+    case 'tripalpane':
+      $element['#prefix'] = '<div class="tripal_pane-fieldset-'.$group_name.' '.$group_name.'">';
+      $element['#suffix'] = '</div>';
+      break;
   }
-}
-
-**
- * Implements hook_field_group_format_summary().
-
-function tripal_ds_field_group_format_summary($group) {
-}
- */
+}

+ 52 - 13
tripal_ds/includes/tripal_ds.field_group.inc

@@ -3,7 +3,7 @@
  * Implements hook_field_group_info().
  */
 
-function _overview_field_group_info($bundle_name, $fields){
+function _summary_field_group_info($bundle_name, $fields){
     
     //tripalpane  to nest the fieldset within
     $field_group_tripalpane = new stdClass();
@@ -25,7 +25,7 @@ function _overview_field_group_info($bundle_name, $fields){
         'format_settings' => array(
             'label' => 'Tripal Pane Summary',
             'instance_settings' => array(
-                'id' => '',
+                'id' => 'tripal_ds-fieldset-group_summary_tripalpane',
                 'classes' => 'group-summary-tripalpane field-group-tripalpane',
                 'description' => '',
             ),
@@ -33,6 +33,15 @@ function _overview_field_group_info($bundle_name, $fields){
     );
     drupal_write_record('field_group', $field_group_tripalpane);
 
+    //write to the tripal_ds table to record the new tripal pane
+    $field_for_table = new stdClass();
+    $field_for_table->field_name = 'group_summary_tripalpane';
+    $field_for_table->field_label = 'Summary';
+    $field_for_table->entity_type = 'TripalEntity';
+    $field_for_table->bundle = $bundle_name;
+
+    drupal_write_record('tripal_ds', $field_for_table);
+
     //fieldset field to nest the table within
     $field_group_fieldset = new stdClass();
     $field_group_fieldset->disabled = FALSE; /* Edit this to true to make a default field_group disabled initially*/
@@ -94,6 +103,8 @@ function _overview_field_group_info($bundle_name, $fields){
     );
 
     drupal_write_record('field_group', $field_group);
+
+
 }
 /**
  * Implements hook_field_group_info().
@@ -111,22 +122,31 @@ function _prop_field_group_info($bundle_name, $fields){
     $field_group_tripalpane->mode = 'default';
     $field_group_tripalpane->parent_name = '';
     $field_group_tripalpane->data = array(
-        'label' => 'Tripal Pane Prop',
+        'label' => 'Tripal Pane Properties',
         'weight' => '2',
         'children' => array(
             0 => 'group_prop',
         ),
         'format_type' => 'tripalpane',
         'format_settings' => array(
-            'label' => 'Tripal Pane Prop',
+            'label' => 'Tripal Pane Properties',
             'instance_settings' => array(
-                'id' => '',
+                'id' => 'tripal_ds-fieldset-group_prop_tripalpane',
                 'classes' => 'group-prop-tripalpane field-group-tripalpane',
                 'description' => '',
             ),
         ),
     );
     drupal_write_record('field_group', $field_group_tripalpane);
+    
+    //write to the tripal_ds table to record the new tripal pane
+    $field_for_table = new stdClass();
+    $field_for_table->field_name = 'group_prop_tripalpane';
+    $field_for_table->field_label = 'Properties';
+    $field_for_table->entity_type = 'TripalEntity';
+    $field_for_table->bundle = $bundle_name;
+
+    drupal_write_record('tripal_ds', $field_for_table);
 
 
     //fieldset field to nest the table within
@@ -140,14 +160,14 @@ function _prop_field_group_info($bundle_name, $fields){
     $field_group_fieldset->mode = 'default';
     $field_group_fieldset->parent_name = 'group_prop_tripalpane';
     $field_group_fieldset->data = array(
-        'label' => 'Prop',
+        'label' => 'Properties',
         'weight' => '3',
         'children' => array(
             0 => 'group_prop_table',
         ),
         'format_type' => 'fieldset',
         'format_settings' => array(
-            'label' => 'Prop',
+            'label' => 'Properties',
             'instance_settings' => array(
                 'id' => '',
                 'classes' => 'group-prop field-group-fieldset',
@@ -170,12 +190,12 @@ function _prop_field_group_info($bundle_name, $fields){
     $field_group->mode = 'default';
     $field_group->parent_name = 'group_prop';
     $field_group->data = array(
-        'label' => 'Prop Table',
+        'label' => 'Properties Table',
         'weight' => '30',
         'children' => $fields,
         'format_type' => 'table',
         'format_settings' => array(
-            'label' => 'Prop Table',
+            'label' => 'Properties Table',
             'instance_settings' => array(
                 'label_visibility' => '1',
                 'desc' => '',
@@ -216,7 +236,7 @@ function _data_sequence_field_group_info($bundle_name, $fields){
         'format_settings' => array(
             'label' => 'Tripal Pane Data Sequences',
             'instance_settings' => array(
-                'id' => '',
+                'id' => 'tripal_ds-fieldset-group_sequence_tripalpane',
                 'classes' => 'group-sequence-tripalpane field-group-tripalpane',
                 'description' => '',
             ),
@@ -224,6 +244,15 @@ function _data_sequence_field_group_info($bundle_name, $fields){
     );
     drupal_write_record('field_group', $field_group_tripalpane);
 
+    //write to the tripal_ds table to record the new tripal pane
+    $field_for_table = new stdClass();
+    $field_for_table->field_name = 'group_sequences_tripalpane';
+    $field_for_table->field_label = 'Data Sequences';
+    $field_for_table->entity_type = 'TripalEntity';
+    $field_for_table->bundle = $bundle_name;
+
+    drupal_write_record('tripal_ds', $field_for_table);
+
     //fieldset field to nest the table within
     $field_group_fieldset = new stdClass();
     $field_group_fieldset->disabled = FALSE; /* Edit this to true to make a default field_group disabled initially*/
@@ -293,6 +322,14 @@ function _data_sequence_field_group_info($bundle_name, $fields){
  */
 
 function _additional_fields_field_group_info($bundle_name, $field_label, $group_field_name, $fieldset_field_name, $field_name){
+    //write to the tripal_ds table to record the new tripal pane
+    $field_for_table = new stdClass();
+    $field_for_table->field_name = $group_field_name;
+    $field_for_table->field_label = $field_label;
+    $field_for_table->entity_type = 'TripalEntity';
+    $field_for_table->bundle = $bundle_name;
+
+    drupal_write_record('tripal_ds', $field_for_table);
 
     //fieldset field to nest the table within
     $field_group_fieldset = new stdClass();
@@ -314,7 +351,7 @@ function _additional_fields_field_group_info($bundle_name, $field_label, $group_
         'format_settings' => array(
             'label' => $field_label.' TripalPane',
             'instance_settings' => array(
-                'id' => '',
+                'id' => 'tripal_ds-fieldset-'.$group_field_name,
                 'classes' => $group_field_name.' field-group-tripalpane',
                 'description' => '',
             ),
@@ -335,7 +372,7 @@ function _additional_fields_field_group_info($bundle_name, $field_label, $group_
     $field_group->mode = 'default';
     $field_group->parent_name =  $group_field_name;
     $field_group->data = array(
-        'label' => $field_label.' Fieldset',
+        'label' => $field_label,
         'weight' => '30',
         'children' => array(
             0 =>$field_name,
@@ -343,8 +380,9 @@ function _additional_fields_field_group_info($bundle_name, $field_label, $group_
         'format_type' => 'table',
         'format_type' => 'fieldset',
         'format_settings' => array(
-            'label' => $field_label.' Fieldset',
+            'label' => $field_label,
             'instance_settings' => array(
+                'label_visibility' => '1',
                 'id' => '',
                 'classes' => $fieldset_field_name.' field-group-fieldset',
                 'description' => '',
@@ -354,5 +392,6 @@ function _additional_fields_field_group_info($bundle_name, $field_label, $group_
     );
 
     drupal_write_record('field_group', $field_group);
+
 }
 

+ 80 - 0
tripal_ds/includes/views/tripal_ds.views.inc

@@ -0,0 +1,80 @@
+<?php
+
+
+
+/**
+ * Implements hook_views_data().
+ */
+function tripal_ds_views_data() {
+
+    $data = array();
+
+    $data['tripal_ds']['table']['group'] = t('Tripal Panes');
+
+    $data['tripal_ds']['table']['base'] = array(
+        'title' => t('Tripal Panes'),
+        'help' => t('Contains Tripal Pane records we want exposed to Views.'),
+    );
+
+    $data['tripal_ds']['bundle'] = array(
+	   'title' => t('Bundle ID'),
+	   'help' => t('This the unque bundle name, eg bio_data_1.'),
+		'relationship' => array(
+		      'base' => 'tripal_entity', // The name of the table to join with.
+		      'base field' => 'bundle', // The name of the field on the joined table.
+		      // 'field' => 'nid' -- see hook_views_data_alter(); not needed here.
+		      'handler' => 'views_handler_relationship',
+		      'label' => t('Default label for the relationship'),
+		      'title' => t('Title shown when adding the relationship'),
+		      'help' => t('More information on this relationship'),
+		    ),    	
+		'filter' => array(
+      		'handler' => 'views_handler_filter_bundle',
+     	),
+    	'argument' => array(
+      		'handler' => 'views_handler_argument_string',
+    	),
+    	'field' => array(
+      		'handler' => 'views_handler_field',
+    	),
+  	);
+
+    $data['tripal_ds']['field_name'] = array(
+	   'title' => t('Field Name'),
+	   'help' => t('This the field name, it is not necessarily unique, like "summary" which might feature across several bundles.'),
+	   'field' => array(
+      		'handler' => 'views_handler_field',
+      		'click sortable' => TRUE, // This is use by the table display plugin.
+    	),
+	    'sort' => array(
+	      'handler' => 'views_handler_sort',
+	    ),
+	    'filter' => array(
+	      'handler' => 'views_handler_filter_string',
+	    ),
+	    'argument' => array(
+	      'handler' => 'views_handler_argument_string',
+	    ),
+    );
+
+    $data['tripal_ds']['field_label'] = array(
+	   'title' => t('Field Label'),
+	   'help' => t('The human readable name of the field, like "Data Sequences".'),
+	   'field' => array(
+      		'handler' => 'views_handler_field',
+      		'click sortable' => TRUE, // This is use by the table display plugin.
+    	),
+	    'sort' => array(
+	      'handler' => 'views_handler_sort',
+	    ),
+	    'filter' => array(
+	      'handler' => 'views_handler_filter_string',
+	    ),
+	    'argument' => array(
+	      'handler' => 'views_handler_argument_string',
+	    ),
+    );
+
+    return $data;
+}
+

+ 86 - 0
tripal_ds/includes/views/tripal_ds.views_default.inc

@@ -0,0 +1,86 @@
+<?php
+
+/**
+ * Implements hook_views_default_views().
+ */
+function tripal_ds_views_default_views() {
+ 
+$view = new view();
+$view->name = 'page_info_menu';
+$view->description = '';
+$view->tag = 'default';
+$view->base_table = 'tripal_ds';
+$view->human_name = 'Tripal Content Type Page Info';
+$view->core = 7;
+$view->api_version = '3.0';
+$view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */
+
+/* Display: Master */
+$handler = $view->new_display('default', 'Master', 'default');
+$handler->display->display_options['use_more_always'] = FALSE;
+$handler->display->display_options['access']['type'] = 'none';
+$handler->display->display_options['cache']['type'] = 'none';
+$handler->display->display_options['query']['type'] = 'views_query';
+$handler->display->display_options['exposed_form']['type'] = 'basic';
+$handler->display->display_options['pager']['type'] = 'full';
+$handler->display->display_options['pager']['options']['items_per_page'] = '10';
+$handler->display->display_options['style_plugin'] = 'default';
+$handler->display->display_options['row_plugin'] = 'fields';
+/* Field: Tripal Panes: Field Name */
+$handler->display->display_options['fields']['field_name']['id'] = 'field_name';
+$handler->display->display_options['fields']['field_name']['table'] = 'tripal_ds';
+$handler->display->display_options['fields']['field_name']['field'] = 'field_name';
+$handler->display->display_options['fields']['field_name']['label'] = '';
+$handler->display->display_options['fields']['field_name']['exclude'] = TRUE;
+$handler->display->display_options['fields']['field_name']['element_label_colon'] = FALSE;
+/* Field: Tripal Panes: Field Label */
+$handler->display->display_options['fields']['field_label']['id'] = 'field_label';
+$handler->display->display_options['fields']['field_label']['table'] = 'tripal_ds';
+$handler->display->display_options['fields']['field_label']['field'] = 'field_label';
+$handler->display->display_options['fields']['field_label']['label'] = '';
+$handler->display->display_options['fields']['field_label']['alter']['alter_text'] = TRUE;
+$handler->display->display_options['fields']['field_label']['alter']['text'] = '<a href="#" class="tripal_pane-toc-list-item-link" id ="[field_name]">[field_label] </a>';
+$handler->display->display_options['fields']['field_label']['alter']['link_class'] = '[field_label]';
+$handler->display->display_options['fields']['field_label']['element_label_colon'] = FALSE;
+/* Contextual filter: Tripal Panes: Bundle ID */
+$handler->display->display_options['arguments']['bundle']['id'] = 'bundle';
+$handler->display->display_options['arguments']['bundle']['table'] = 'tripal_ds';
+$handler->display->display_options['arguments']['bundle']['field'] = 'bundle';
+$handler->display->display_options['arguments']['bundle']['default_action'] = 'default';
+$handler->display->display_options['arguments']['bundle']['default_argument_type'] = 'php';
+$handler->display->display_options['arguments']['bundle']['default_argument_options']['code'] = '$url = current_path();
+$url_exploded = explode("/", $url);
+$tripal_entity_id = (int)$url_exploded[1];
+
+    $result = db_select(\'tripal_entity\', \'te\')
+      ->fields(\'te\', array(\'bundle\'))
+      ->condition(\'id\', $tripal_entity_id, \'=\')
+      ->execute()
+      ->fetchField();
+
+return $result;';
+$handler->display->display_options['arguments']['bundle']['summary']['number_of_records'] = '0';
+$handler->display->display_options['arguments']['bundle']['summary']['format'] = 'default_summary';
+$handler->display->display_options['arguments']['bundle']['summary_options']['items_per_page'] = '25';
+$handler->display->display_options['arguments']['bundle']['limit'] = '0';
+/* Filter criterion: Global: Fields comparison */
+$handler->display->display_options['filters']['fields_compare']['id'] = 'fields_compare';
+$handler->display->display_options['filters']['fields_compare']['table'] = 'views';
+$handler->display->display_options['filters']['fields_compare']['field'] = 'fields_compare';
+
+/* Display: Page */
+$handler = $view->new_display('page', 'Page', 'page');
+$handler->display->display_options['path'] = 'page_info_menu';
+
+/* Display: Block */
+$handler = $view->new_display('block', 'Block', 'block');
+$handler->display->display_options['defaults']['pager'] = FALSE;
+$handler->display->display_options['pager']['type'] = 'none';
+$handler->display->display_options['pager']['options']['offset'] = '0';
+
+ 
+$views[$view->name] = $view;
+ 
+// return views
+  return $views;
+}

+ 6 - 0
tripal_ds/theme/css/tripaldsfeature.css

@@ -11,6 +11,12 @@
 .ds-bottom {
   width: 100%;
 }
+
+.tripal-ds-button {
+  height: 15px;
+  vertical-align: text-top;
+}
+
 /*
 fieldset {
 	border: none!important;

BIN
tripal_ds/theme/images/close_btn.png


File diff suppressed because it is too large
+ 0 - 5
tripal_ds/theme/js/bootstrap.min.js


+ 67 - 1
tripal_ds/theme/js/tripal_ds.js

@@ -2,8 +2,74 @@
 
   Drupal.behaviors.tripal_ds = {
     attach: function (context, settings){
+    	console.log('tripal pane javascript');
+      // Add a close button for each pane except for the te_base
+      $('.tripal_pane-fieldset .fieldset-legend').each(function (i) {
+        if ($(this).parent().parent().attr('id') != 'tripal_ds-fieldset-te_base') {
+          $(this).append('<div class="tripal_pane-fieldset-close_button"><div id="tripal-pane-close-button" class="trip al-pane-button">CLOSE</div></div>');
+        }
+      });
 
+      // Hide the pane when the close button is clicked
+      $('.tripal_pane-fieldset-close_button').each(function (i) {
+        $(this).css('float', 'right');
+        $(this).css('cursor', 'pointer');
+        $(this).css('margin', '0px 5px');
+        $(this).click(function () {
+          var fs = $(this).parent().parent().parent();
+          var fsid = fs.attr('id');
+          if (fsid.indexOf('tripal_pane-fieldset-') == 0) {
+            $(fs).fadeOut(300);
+          }
+        });
+      });
+
+      // Move the tripal pane to the first position when its TOC item is clicked.
+      $('.tripal_pane-toc-list-item-link').each(function (i) {
+        $(this).click(function() {
+
+          var id = '.tripal_pane-fieldset-' + $(this).attr('id');
+          var prevObj = $(id).prev().attr('class');
+          console.log("id: ");
+          console.log(id);
+
+          //console.log(prevObj);
+
+            // If the user clicks on the tripal_pane-fieldset-group_summary_tripalpane TOC item, open the fieldset if it's closed
+            if (id == '.tripal_pane-fieldset-group_summary_tripalpane') {
+              if ($('.tripal_pane-fieldset-group_summary_tripalpane fieldset').hasClass('collapsed')) {
+            	  $('.tripal_pane-fieldset-group_summary_tripalpane fieldset').removeClass('collapsed');
+            	  $('.tripal_pane-fieldset-group_summary_tripalpane fieldset .fieldset-wrapper').show();
+              }
+              else {
+                 $('.tripal_pane-fieldset-group_summary_tripalpane fieldset').fadeTo(10, 0.3, function() {});
+                 $('.tripal_pane-fieldset-group_summary_tripalpane fieldset').fadeTo(200, 1, function() {});
+              }
+            }
+            // If the user clicks on other TOC item, move its fieldset to the top right below the te_base
+            else {
+              $(id + ' fieldset').removeClass('collapsed');
+              $(id + ' fieldset .fieldset-wrapper').show();
+              // Hightlight the fieldset instead of moving if it's already at the top
+              if (prevObj.indexOf('group-tripal-pane-content-top') == 0 && $('.tripal_pane-fieldset-group_summary_tripalpane fieldset').hasClass('collapsed')) {
+                $(id + ' fieldset').fadeTo(10, 0.3, function() {});
+                $(id + ' fieldset').fadeTo(200, 1, function() {});
+              }
+              else {
+                $(id + ' fieldset .fieldset-wrapper').hide();
+                var obj = $(id).detach();
+                $('.group-tripal-pane-content-top').after(obj);
+              }
+              // Close the te_base fieldset
+              $('.tripal_pane-fieldset-group_summary_tripalpane fieldset .fieldset-wrapper').hide();
+              $('.tripal_pane-fieldset-group_summary_tripalpane fieldset').addClass('collapsed');
+            }
+            $(id + ' fieldset .fieldset-wrapper').show(300);
+          //}
+          return false;
+        });
+      });
     },
   };
-
+  
 })(jQuery);

+ 1 - 0
tripal_ds/theme/templates/tripal-ds-feature.tpl.php

@@ -19,6 +19,7 @@
    </<?php print $left_wrapper ?>>
 
    <<?php print $right_wrapper ?> class="ds-right<?php print $right_classes; ?>">
+    <div class='group-tripal-pane-content-top'></div>
      <?php print $right; ?>
    </<?php print $right_wrapper ?>>
 

+ 48 - 0
tripal_ds/tripal_ds.install

@@ -0,0 +1,48 @@
+<?php
+/**
+ * @file
+ * Fieldgroup module install file.
+ */
+
+/**
+ * Implements hook_schema().
+ */
+function tripal_ds_schema() {
+  $schema['tripal_ds'] = array(
+    'description' => t('Table that contains the Tripal Pane fieldsets.'),
+
+    'fields' => array(
+      'id' => array(
+        'type' => 'serial',
+        'not null' => TRUE,
+        'description' => 'The primary identifier for a group',
+        'no export' => TRUE,
+      ),
+      'field_label' => array(
+        'type' => 'varchar',
+        'length' => 255,
+        'not null' => TRUE,
+        'default' => '',
+        'description' => 'The label of this Tripal Pane.',
+      ),
+      'field_name' => array(
+        'type' => 'varchar',
+        'length' => 255,
+        'not null' => TRUE,
+        'default' => '',
+        'description' => 'The name of this Tripal Pane.',
+      ),
+      'bundle' => array(
+        'type' => 'varchar',
+        'length' => 128,
+        'not null' => TRUE,
+        'default' => ''
+        ),
+    ),
+    'primary key' => array('id'),
+    'indexes' => array(
+      'field_name' => array('field_name'),
+    ),
+  );
+  return $schema;
+}

+ 32 - 3
tripal_ds/tripal_ds.module

@@ -7,14 +7,27 @@ require_once "includes/tripal_ds.field_formatter.inc";
 
 function tripal_ds_init() {
   drupal_add_css(drupal_get_path('module', 'tripal_ds') . '/theme/css/tripaldsfeature.css');
-  drupal_add_css(drupal_get_path('module', 'tripal_ds') . '/theme/css/bootstrap.css');
+  drupal_add_js(drupal_get_path('module', 'tripal_ds') . '/theme/js/tripal_ds.js');
+  
+  $theme_dir = url(drupal_get_path('module', 'tripal_ds') . '/theme');
+  drupal_add_js("var ds_theme_dir  = '$theme_dir';", 'inline', 'header');
 
 }
 
 /**
+ * Implements hook_views_api().
+ */
+function tripal_ds_views_api() {
+    return array(
+        'api' => 3,
+        'path' => drupal_get_path('module', 'tripal_ds') . '/includes/views',
+    );
+}
+
+/*
  * Implements hook_ds_layout_info() to define layouts from code in a module for
  * display suite
- */
+
 function tripal_ds_ds_layout_info() {
   $path = drupal_get_path('module', 'tripal_ds');
 
@@ -34,7 +47,7 @@ function tripal_ds_ds_layout_info() {
 
   return $layouts;
 }
-
+ */
 /**
  * Implements hook_bundle_postcreate().
  *
@@ -49,3 +62,19 @@ function tripal_ds_bundle_postcreate($bundle) {
 
 
 
+
+/*
+ * Code for the view of the menu items
+
+    //get tripal entity id from url then run it against tripal entity db
+    //and grab the bundle id, then pass bundle id to view
+    $url = current_path();
+    $url_exploded = explode("/", $url);
+    $tripal_entity_id = (int)$url_exploded[1];
+
+    $result = db_select('tripal_entity', 'te')
+      ->fields('te', array('bundle'))
+      ->condition('id', $tripal_entity_id, '=')
+      ->execute()
+      ->fetchField();
+*/

Some files were not shown because too many files changed in this diff