Browse Source

Fixed textarea description fields to support filters

Stephen Ficklin 9 years ago
parent
commit
987a0163f0

+ 3 - 4
tripal_analysis/includes/tripal_analysis.chado_node.inc

@@ -231,7 +231,7 @@ function chado_analysis_form($node, &$form_state) {
     ),
   );
   $form['description']= array(
-    '#type' => 'textarea',
+    '#type' => 'text_format',
     '#rows' => 15,
     '#title' => t('Materials & Methods (Description and/or Program Settings)'),
     '#required' => FALSE,
@@ -319,7 +319,6 @@ function tripal_analysis_validate($node, $form, &$form_state) {
 
   // remove surrounding white-space on submitted values
   $node->analysisname = trim($node->analysisname);
-  $node->description = trim($node->description);
   $node->program = trim($node->program);
   $node->programversion = trim($node->programversion);
   $node->algorithm = trim($node->algorithm);
@@ -408,13 +407,13 @@ function tripal_analysis_validate($node, $form, &$form_state) {
 function chado_analysis_insert($node) {
 
   $node->analysisname = trim($node->analysisname);
-  $node->description = trim($node->description);
   $node->program = trim($node->program);
   $node->programversion = trim($node->programversion);
   $node->algorithm = trim($node->algorithm);
   $node->sourcename = trim($node->sourcename);
   $node->sourceversion = trim($node->sourceversion);
   $node->sourceuri = trim($node->sourceuri);
+  $node->description  = trim($node->description['value']);
 
   // if there is an analysis_id in the $node object then this must be a sync so
   // we can skip adding the analysis as it is already there, although
@@ -514,13 +513,13 @@ function chado_analysis_delete($node) {
  */
 function chado_analysis_update($node) {
   $node->analysisname = trim($node->analysisname);
-  $node->description = trim($node->description);
   $node->program = trim($node->program);
   $node->programversion = trim($node->programversion);
   $node->algorithm = trim($node->algorithm);
   $node->sourcename = trim($node->sourcename);
   $node->sourceversion = trim($node->sourceversion);
   $node->sourceuri = trim($node->sourceuri);
+  $node->description  = trim($node->description['value']);
 
   // Create a timestamp so we can insert it into the chado database
   $time = $node->timeexecuted;

+ 5 - 7
tripal_contact/includes/tripal_contact.chado_node.inc

@@ -171,7 +171,7 @@ function chado_contact_form(&$node, $form_state) {
   );
 
   $form['description']= array(
-    '#type'          => 'textarea',
+    '#type'          => 'text_format',
     '#title'         => t('Contact Description'),
     '#description'   => t('A brief description of the contact'),
     '#required'      => TRUE,
@@ -262,8 +262,6 @@ function chado_contact_validate($node, $form, &$form_state) {
 
   // remove surrounding white-space on submitted values
   $node->contactname = property_exists($node, 'contactname') ? trim($node->contactname) : '';
-  $node->description = property_exists($node, 'description') ? trim($node->description) : '';
-
 
   // Validating for an update
   if (!is_null($node->nid)) {
@@ -374,8 +372,8 @@ function chado_contact_insert($node) {
   // we do need to proceed with insertion into the chado/drupal linking table.
   if (!property_exists($node, 'contact_id')) {
     // remove surrounding white-space on submitted values
-    $node->contactname    = trim($node->contactname);
-    $node->description    = trim($node->description);
+    $node->contactname = trim($node->contactname);
+    $node->description = trim($node->description['value']);
 
 
     // insert and then get the newly inserted contact record
@@ -451,8 +449,8 @@ function chado_contact_insert($node) {
  */
 function chado_contact_update($node) {
   // remove surrounding white-space on submitted values
-  $node->contactname          = trim($node->contactname);
-  $node->description    = trim($node->description);
+  $node->contactname = trim($node->contactname);
+  $node->description = trim($node->description['value']);
 
   $contact_id = chado_get_id_from_nid('contact', $node->nid) ;
 

+ 3 - 4
tripal_example/includes/tripal_example.chado_node.inc

@@ -220,7 +220,7 @@ function chado_example_form($node, &$form_state) {
   );
 
   $form['description'] = array(
-    '#type' => 'textarea',
+    '#type' => 'text_format',
     '#title' => t('Description'),
     '#required' => TRUE,
     '#default_value' => $description,
@@ -324,7 +324,6 @@ function chado_example_validate($node, $form, &$form_state) {
 
   // be sure to always trim text fields
   $node->uniquename   = property_exists($node, 'uniquename') ? trim($node->uniquename) : '';
-  $node->description  = property_exists($node, 'description') ? trim($node->description) : '';
 
   // Validating for an update. If the 'nid' property is present in the node then
   // this is an update and validation can be different for updates
@@ -385,7 +384,7 @@ function chado_example_insert($node) {
 
     // be sure to always trim text fields
     $node->uniquename   = trim($node->uniquename);
-    $node->description  = trim($node->description);
+    $node->description  = trim($node->description['value']);
 
     // get the example type record
     $type_cv = tripal_get_default_cv('example', 'type_id');
@@ -484,7 +483,7 @@ function chado_example_insert($node) {
 function chado_example_update($node) {
   // be sure to always trim text fields
   $node->uniquename   = trim($node->uniquename);
-  $node->description  = trim($node->description);
+  $node->description  = trim($node->description['value']);
 
   // use the chado_update_record() function to update the record
   $match = array(

+ 8 - 6
tripal_featuremap/includes/tripal_featuremap.chado_node.inc

@@ -100,7 +100,7 @@ function chado_featuremap_form($node, &$form_state) {
     '#maxlength'     => 255
   );
   $form['description']= array(
-    '#type'          => 'textarea',
+    '#type'          => 'text_format',
     '#title'         => t('Map Description'),
     '#description'   => t('A description of the map.'),
     '#required'      => TRUE,
@@ -155,6 +155,9 @@ function chado_featuremap_form($node, &$form_state) {
  */
 function chado_featuremap_validate($node, $form, &$form_state) {
 
+  if ($node->unittype_id == 0) {
+    form_set_error('unittype_id', 'Please provide a unit type for this map.');
+  }
   // We only want to validate when the node is saved.
   // Since this validate can be called on AJAX and Deletion of the node
   // we need to make this check to ensure queries are not executed
@@ -171,7 +174,6 @@ function chado_featuremap_validate($node, $form, &$form_state) {
 
   // trim white space from text fields
   $node->fmapname = property_exists($node, 'fmapname') ? trim($node->fmapname) : '';
-  $node->description = property_exists($node, 'description') ? trim($node->description) : '';
 
   $featuremap = 0;
   // check to make sure the unique name on the map is unique
@@ -268,8 +270,8 @@ function chado_featuremap_insert($node) {
   // we do need to proceed with insertion into the chado/drupal linking table.
   if (!property_exists($node, 'featuremap_id')) {
 
-    $node->fmapname       = trim($node->fmapname);
-    $node->description    = trim($node->description);
+    $node->fmapname = trim($node->fmapname);
+    $node->description  = trim($node->description['value']);
 
     $values = array(
       'name'        => $node->fmapname,
@@ -345,8 +347,8 @@ function chado_featuremap_insert($node) {
  */
 function chado_featuremap_update($node) {
 
-  $node->fmapname          = trim($node->fmapname);
-  $node->description    = trim($node->description);
+  $node->fmapname  = trim($node->fmapname);
+  $node->description  = trim($node->description['value']);
 
   $featuremap_id = chado_get_id_from_nid('featuremap', $node->nid) ;
 

+ 3 - 4
tripal_library/includes/tripal_library.chado_node.inc

@@ -165,7 +165,7 @@ function chado_library_form($node, &$form_state) {
   );
 
   $form['description']= array(
-    '#type'          => 'textarea',
+    '#type'          => 'text_format',
     '#title'         => t('Library Description'),
     '#description'   => t('A brief description of the library'),
     '#required'      => TRUE,
@@ -235,7 +235,6 @@ function chado_library_validate($node, $form, &$form_state) {
   // trim white space from text fields
   $node->libraryname = property_exists($node, 'libraryname') ? trim($node->libraryname) : '';
   $node->uniquename  = property_exists($node, 'uniquename') ? trim($node->uniquename) : '';
-  $node->description = property_exists($node, 'description') ? trim($node->description) : '';
 
   $lib = 0;
   // check to make sure the unique name on the library is unique
@@ -276,7 +275,7 @@ function chado_library_insert($node) {
   if (!property_exists($node, 'library_id')) {
     $node->libraryname = trim($node->libraryname);
     $node->uniquename  = trim($node->uniquename);
-    $node->description = trim($node->description);
+    $node->description  = trim($node->description['value']);
 
     $values = array(
       'name' => $node->libraryname,
@@ -344,7 +343,7 @@ function chado_library_update($node) {
 
   $node->libraryname = trim($node->libraryname);
   $node->uniquename  = trim($node->uniquename);
-  $node->description = trim($node->description);
+  $node->description  = trim($node->description['value']);
 
   // update the library record
   $library_id = chado_get_id_from_nid('library', $node->nid);

+ 3 - 4
tripal_organism/includes/tripal_organism.chado_node.inc

@@ -166,7 +166,7 @@ function chado_organism_form($node, $form_state) {
     '#default_value' => $common_name,
   );
   $form['description']= array(
-    '#type' => 'textarea',
+    '#type' => 'text_format',
     '#rows' => 15,
     '#title' => t('Description'),
     '#default_value' => $description,
@@ -235,7 +235,6 @@ function chado_organism_validate($node, $form, &$form_state) {
   $node->species      = property_exists($node, 'species') ? trim($node->species) : '';
   $node->abbreviation = property_exists($node, 'abbreviation') ? trim($node->abbreviation) : '';
   $node->common_name  = property_exists($node, 'common_name') ? trim($node->common_name) : '';
-  $node->description  = property_exists($node, 'description') ? trim($node->description) : '';
 
   // Validating for an update
   if (property_exists($node, 'organism_id')) {
@@ -296,7 +295,7 @@ function chado_organism_insert($node) {
     $node->species      = trim($node->species);
     $node->abbreviation = trim($node->abbreviation);
     $node->common_name  = trim($node->common_name);
-    $node->description  = trim($node->description);
+    $node->description  = trim($node->description['value']);
 
     $values = array(
       'genus'        => $node->genus,
@@ -367,7 +366,7 @@ function chado_organism_update($node) {
   $node->species      = trim($node->species);
   $node->abbreviation = trim($node->abbreviation);
   $node->common_name  = trim($node->common_name);
-  $node->description  = trim($node->description);
+  $node->description  = trim($node->description['value']);
 
   $organism_id = chado_get_id_from_nid('organism', $node->nid);
 

+ 3 - 4
tripal_project/includes/tripal_project.chado_node.inc

@@ -131,7 +131,7 @@ function chado_project_form(&$node, $form_state) {
   );
 
   $form['description']= array(
-    '#type'          => 'textarea',
+    '#type'          => 'text_format',
     '#title'         => t('Project Description'),
     '#description'   => t('A brief description of the project'),
     '#required'      => TRUE,
@@ -212,7 +212,6 @@ function chado_project_validate($node, $form, &$form_state) {
 
   // trim white space from text fields
   $node->title = property_exists($node, 'title') ? trim($node->title) : '';
-  $node->description = property_exists($node, 'description') ? trim($node->description) : '';
 
   $project = 0;
   // check to make sure the name on the project is unique
@@ -247,7 +246,7 @@ function chado_project_insert($node) {
   // we do need to proceed with insertion into the chado/drupal linking table.
   if (!property_exists($node, 'project_id')) {
     $node->title = trim($node->title);
-    $node->description = trim($node->description);
+    $node->description  = trim($node->description['value']);
 
     $values = array(
       'name' => $node->title,
@@ -348,7 +347,7 @@ function chado_project_delete($node) {
 function chado_project_update($node) {
 
   $node->title = trim($node->title);
-  $node->description = trim($node->description);
+  $node->description  = trim($node->description['value']);
 
   // update the project and the description
   $project_id = chado_get_id_from_nid('project', $node->nid) ;

+ 19 - 8
tripal_stock/includes/tripal_stock.chado_node.inc

@@ -196,8 +196,17 @@ function chado_stock_form($node, $form_state) {
 
   // TODO: Should we make this a textfield with an autocomplete field like the
   // feature type_id field?.
+  $st_cv = tripal_get_default_cv("stock", "type_id");
   $type_options = tripal_get_cvterm_default_select_options('stock', 'type_id', 'stock types');
   $type_options[0] = 'Select a Type';
+  $st_message = tripal_set_message("To add additional items to the stock type drop down list,
+     add a term to the " .
+    l($st_cv->name . " controlled vocabulary",
+      "admin/tripal/chado/tripal_cv/cv/" . $st_cv->cv_id . "/cvterm/add",
+      array('attributes' => array('target' => '_blank'))
+    ),
+    TRIPAL_INFO, array('return_html' => TRUE)
+  );
 
   $form['type_id'] = array(
     '#type' => 'select',
@@ -205,7 +214,8 @@ function chado_stock_form($node, $form_state) {
     '#description' => t('Select the stock type.'),
     '#options' => $type_options,
     '#default_value' => $type_id,
-    '#required'    => TRUE,
+    '#required' => TRUE,
+    '#suffix' => $st_message,
   );
 
   // get the list of organisms
@@ -226,7 +236,7 @@ function chado_stock_form($node, $form_state) {
   );
 
   $form['stock_description'] = array(
-    '#type' => 'textarea',
+    '#type' => 'text_format',
     '#title' => t('Notes'),
     '#default_value' => $sdescription,
     '#description' => t('Briefly enter any notes on the above stock. This should not include phenotypes or genotypes.'),
@@ -336,7 +346,6 @@ function chado_stock_validate(&$node, $form, &$form_state) {
   // remove surrounding whitespace
   $node->uniquename = property_exists($node, 'uniquename') ? trim($node->uniquename) : '';
   $node->sname = property_exists($node, 'sname') ? trim($node->sname) : '';
-  $node->stock_description = property_exists($node, 'stock_description') ? trim($node->stock_description) : '';
   $node->accession = property_exists($node, 'accession') ? trim($node->accession) : '';
   $node->db_description = property_exists($node, 'db_description') ? trim($node->db_description) : '';
 
@@ -449,9 +458,10 @@ function chado_stock_insert($node) {
   // we do need to proceed with insertion into the chado/drupal linking table.
   if (!property_exists($node, 'stock_id')) {
 
-    $node->uniquename   = trim($node->uniquename);
-    $node->sname        = trim($node->sname);
-    $node->accession    = trim($node->accession);
+    $node->uniquename = trim($node->uniquename);
+    $node->sname = trim($node->sname);
+    $node->accession = trim($node->accession);
+    $node->stock_description = trim($node->stock_description['value']);
 
     // before we can add the stock, we must add the dbxref if one has been
     // provided by the user.
@@ -554,8 +564,9 @@ function chado_stock_insert($node) {
  */
 function chado_stock_update($node) {
 
-  $node->uniquename   = trim($node->uniquename);
-  $node->sname        = trim($node->sname);
+  $node->uniquename = trim($node->uniquename);
+  $node->sname = trim($node->sname);
+  $node->stock_description = trim($node->stock_description['value']);
 
   if ($node->revision) {
     // there is no way to handle revisions in Chado but leave