Преглед изворни кода

final touches on the github issue 91 to reroll the field groups

Shawna Spoor пре 7 година
родитељ
комит
27e62b7c6e

+ 6 - 25
tripal_ds/includes/tripal_ds.field_formatter.inc

@@ -21,25 +21,6 @@ function tripal_ds_field_group_formatter_info() {
   );
 }
 
-/**
- * Implements hook_field_group_format_settings().
- * If the group has no format settings, default ones will be added.
- * @params Object $group The group object.
- * @return Array $form The form element for the format settings.
- */
-function tripal_ds_field_group_format_settings($group) {
-  $form = array();
-
-  // Add instance_settings.
-  switch ($group->format_type) {
-    case 'tripalpane':
-      $form['label']['#description'] = t('Please enter a label for collapsible elements');
-      break;
-  }
-
-  return $form;
-}
-
 /*
  * Implements field_group_pre_render_<format-type>.
  * Format type: Tripalpane.
@@ -49,14 +30,14 @@ function tripal_ds_field_group_format_settings($group) {
  * @param $form The root element or form.
  */
 function tripal_ds_field_group_pre_render(&$element, $group, &$form) {
-  $group_name = $group->group_name;
-  //watchdog('debug', '<pre>$group->description: '. print_r($group->description, TRUE) .'</pre>');
-  watchdog('debug', '<pre>$$group->format_settings: '. print_r($group->format_settings['instance_settings'], TRUE) .'</pre>');
   switch ($group->format_type) {
     case 'tripalpane':
-      $element['#prefix'] = '<div class="tripal_pane-fieldset-'.$group_name.' '.$group_name.' tripal_pane"> <span class="field-group-format-title">' . check_plain(t($group->label)) . '</span>';
-      if (!empty($group->description)) {
-        $element['#prefix'] .= '<div class="description">' . $group->description . '</div>';
+      $group_name = $group->group_name;
+      $description = $group->format_settings['instance_settings']['description'];
+      $classes = $group->format_settings['instance_settings']['classes'];
+      $element['#prefix'] = '<div class="tripal_pane-fieldset-'.$group_name.' '.$group_name.' tripal_pane '.$classes.'"> <span class="field-group-format-title">' . check_plain(t($group->label)) . '</span>';
+      if (!empty($description)) {
+        $element['#prefix'] .= '<div class="description">' . $description . '</div>';
       }
       $element['#suffix'] = '</div>';
       break;

+ 22 - 36
tripal_ds/includes/tripal_ds.field_group.inc

@@ -1,10 +1,9 @@
 <?php
 /**
-* Implements hook_field_group_info().
-*/
-
+ * @param $bundle_name
+ * @param $fields
+ */
 function _summary_field_group_info($bundle_name, $fields){
-
   //Tripal pane to nest the summary fieldset within.
   $field_group_tripalpane = new stdClass();
   $field_group_tripalpane->disabled = FALSE; /* Edit this to true to make a default field_group disabled initially*/
@@ -32,11 +31,9 @@ function _summary_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.
   tripal_ds_bundle_menu_item($bundle_name, 'Summary', 'group_summary_tripalpane', 'TripalEntity');
 
-
   //Table of fields.
   $field_group = new stdClass();
   $field_group->disabled = FALSE; /* Edit this to true to make a default field_group disabled initially*/
@@ -68,13 +65,12 @@ function _summary_field_group_info($bundle_name, $fields){
   );
 
   drupal_write_record('field_group', $field_group);
-
-
 }
-/**
-* Implements hook_field_group_info().
-*/
 
+/**
+ * @param $bundle_name
+ * @param $fields
+ */
 function _prop_field_group_info($bundle_name, $fields){
   //Tripal pane  to nest the fieldset within.
   $field_group_tripalpane = new stdClass();
@@ -97,17 +93,15 @@ function _prop_field_group_info($bundle_name, $fields){
       'label' => 'Properties',
       'instance_settings' => array(
         'id' => 'tripal_ds-fieldset-group_prop_tripalpane',
-        'classes' => 'group-prop-tripalpane field-group-tripalpane hideTripalPane',
+        'classes' => 'hideTripalPane 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.
+  //Write to the tripal_ds table to record the new tripal pane.
   tripal_ds_bundle_menu_item($bundle_name, 'Properties', 'group_prop_tripalpane', 'TripalEntity');
 
-
   //Table of fields.
   $field_group = new stdClass();
   $field_group->disabled = FALSE; /* Edit this to true to make a default field_group disabled initially*/
@@ -137,13 +131,13 @@ function _prop_field_group_info($bundle_name, $fields){
       ),
     ),
   );
-
   drupal_write_record('field_group', $field_group);
 }
-/**
-* Implements hook_field_group_info().
-*/
 
+/**
+ * @param $bundle_name
+ * @param $fields
+ */
 function _data_sequence_field_group_info($bundle_name, $fields){
   //Tripal pane  to nest the fieldset within.
   $field_group_tripalpane = new stdClass();
@@ -166,13 +160,12 @@ function _data_sequence_field_group_info($bundle_name, $fields){
       'label' => 'Data Sequences',
       'instance_settings' => array(
         'id' => 'tripal_ds-fieldset-group_sequence_tripalpane',
-        'classes' => 'group-sequence-tripalpane field-group-tripalpane hideTripalPane',
+        'classes' => 'hideTripalPane group-sequence-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.
   tripal_ds_bundle_menu_item($bundle_name, 'Sequence', 'group_sequence_tripalpane', 'TripalEntity');
 
@@ -205,15 +198,13 @@ function _data_sequence_field_group_info($bundle_name, $fields){
       ),
     ),
   );
-
   drupal_write_record('field_group', $field_group);
 }
 
 /**
-* Implements hook_field_group_info().
-* Processes all additional fields into Tripal Panes
-*/
-
+ * @param $bundle_name
+ * @param $fields
+ */
 function _additional_fields_field_group_info($bundle_name, $field_label, $group_field_name, $field_name){
   //Write to the tripal_ds table to record the new tripal pane.
   tripal_ds_bundle_menu_item($bundle_name, $field_label, $group_field_name, 'TripalEntity');
@@ -239,20 +230,18 @@ function _additional_fields_field_group_info($bundle_name, $field_label, $group_
       'label' => $field_label,
       'instance_settings' => array(
         'id' => 'tripal_ds-fieldset-'.$group_field_name,
-        'classes' => $group_field_name.' field-group-tripalpane hideTripalPane',
+        'classes' =>'hideTripalPane '.$group_field_name.' field-group-tripalpane',
         'description' => '',
       ),
     ),
   );
-
   drupal_write_record('field_group', $field_group_fieldset);
-
 }
+
 /**
  * Implements hook_field_group_info().
  */
 function _publication_prop_field_group_info($bundle_name, $fields){
-
   //Tripal pane  to nest the fieldset within.
   $field_group_tripalpane = new stdClass();
   $field_group_tripalpane->disabled = FALSE; /* Edit this to true to make a default field_group disabled initially*/
@@ -274,17 +263,15 @@ function _publication_prop_field_group_info($bundle_name, $fields){
       'label' => 'Properties',
       'instance_settings' => array(
         'id' => 'tripal_ds-fieldset-group_prop_tripalpane',
-        'classes' => 'group-prop-tripalpane field-group-tripalpane hideTripalPane',
+        'classes' => 'hideTripalPane 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.
+  //Write to the tripal_ds table to record the new tripal pane.
   tripal_ds_bundle_menu_item($bundle_name, 'Properties', 'group_prop_tripalpane', 'TripalEntity');
 
-
   //Table of fields.
   $field_group = new stdClass();
   $field_group->disabled = FALSE; /* Edit this to true to make a default field_group disabled initially*/
@@ -318,6 +305,5 @@ function _publication_prop_field_group_info($bundle_name, $fields){
       ),
     ),
   );
-
   drupal_write_record('field_group', $field_group);
-}
+}

+ 7 - 2
tripal_ds/theme/css/tripaldsfeature.css

@@ -34,7 +34,7 @@
     border-radius: 4px;
 }
 
-.tripal_pane span {
+.tripal_pane > span {
     background: #dbdbdb;
     border: 1px solid #ccc;
     border-bottom: none;
@@ -54,4 +54,9 @@
     -moz-border-radius-topright: 4px;
     -webkit-border-top-right-radius: 4px;
     border-top-right-radius: 4px;
-}
+}
+
+.tripal_pane > div {
+    padding: 0px 10px;
+}
+