Skip to content

Commit

Permalink
Merge branch '4.x' into tv4g1-1509-sequence-fields
Browse files Browse the repository at this point in the history
  • Loading branch information
laceysanderson authored Oct 25, 2023
2 parents cef5845 + e518eb9 commit c62fa0b
Show file tree
Hide file tree
Showing 6 changed files with 706 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1014,6 +1014,33 @@ fields:
region: content
weight: 90

- name: gene_synonym
content_type: gene
label: Synonyms
type: chado_synonym_default
description: Alternate names, aliases or synonyms for this record.
cardinality: -1
required: false
storage_settings:
storage_plugin_id: chado_storage
storage_plugin_settings:
base_table: feature
linker_table: feature_synonym
linker_fkey_column: feature_id
settings:
termIdSpace: schema
termAccession: alternateName
display:
view:
default:
region: content
label: above
weight: 10
form:
default:
region: content
weight: 10

- name: mrna_name
content_type: mRNA
label: Name
Expand Down Expand Up @@ -1253,6 +1280,33 @@ fields:
region: content
weight: 90

- name: mrna_synonym
content_type: mRNA
label: Synonyms
type: chado_synonym_default
description: Alternate names, aliases or synonyms for this record.
cardinality: -1
required: false
storage_settings:
storage_plugin_id: chado_storage
storage_plugin_settings:
base_table: feature
linker_table: feature_synonym
linker_fkey_column: feature_id
settings:
termIdSpace: schema
termAccession: alternateName
display:
view:
default:
region: content
label: above
weight: 10
form:
default:
region: content
weight: 10

- name: phylotree_name
content_type: phylotree
label: Name
Expand Down Expand Up @@ -1573,6 +1627,33 @@ fields:
region: content
weight: 20

- name: dna_library_synonym
content_type: dna_library
label: Synonyms
type: chado_synonym_default
description: Alternate names, aliases or synonyms for this record.
cardinality: -1
required: false
storage_settings:
storage_plugin_id: chado_storage
storage_plugin_settings:
base_table: library
linker_table: library_synonym
linker_fkey_column: library_id
settings:
termIdSpace: schema
termAccession: alternateName
display:
view:
default:
region: content
label: above
weight: 10
form:
default:
region: content
weight: 10

- name: genome_assembly_name
content_type: genome_assembly
label: Name
Expand Down Expand Up @@ -2405,6 +2486,33 @@ fields:
region: content
weight: 90

- name: qtl_synonym
content_type: QTL
label: Synonyms
type: chado_synonym_default
description: Alternate names, aliases or synonyms for this record.
cardinality: -1
required: false
storage_settings:
storage_plugin_id: chado_storage
storage_plugin_settings:
base_table: feature
linker_table: feature_synonym
linker_fkey_column: feature_id
settings:
termIdSpace: schema
termAccession: alternateName
display:
view:
default:
region: content
label: above
weight: 10
form:
default:
region: content
weight: 10

- name: sequence_variant_name
content_type: sequence_variant
label: Name
Expand Down Expand Up @@ -2644,6 +2752,33 @@ fields:
region: content
weight: 90

- name: sequence_variant_synonym
content_type: sequence_variant
label: Synonyms
type: chado_synonym_default
description: Alternate names, aliases or synonyms for this record.
cardinality: -1
required: false
storage_settings:
storage_plugin_id: chado_storage
storage_plugin_settings:
base_table: feature
linker_table: feature_synonym
linker_fkey_column: feature_id
settings:
termIdSpace: schema
termAccession: alternateName
display:
view:
default:
region: content
label: above
weight: 10
form:
default:
region: content
weight: 10

- name: genetic_marker_name
content_type: genetic_marker
label: Name
Expand Down Expand Up @@ -2883,6 +3018,33 @@ fields:
region: content
weight: 90

- name: genetic_marker_synonym
content_type: genetic_marker
label: Synonyms
type: chado_synonym_default
description: Alternate names, aliases or synonyms for this record.
cardinality: -1
required: false
storage_settings:
storage_plugin_id: chado_storage
storage_plugin_settings:
base_table: feature
linker_table: feature_synonym
linker_fkey_column: feature_id
settings:
termIdSpace: schema
termAccession: alternateName
display:
view:
default:
region: content
label: above
weight: 10
form:
default:
region: content
weight: 10

- name: phenotypic_marker_name
content_type: phenotypic_marker
label: Name
Expand Down Expand Up @@ -3122,6 +3284,33 @@ fields:
region: content
weight: 90

- name: phenotypic_marker_synonym
content_type: phenotypic_marker
label: Synonyms
type: chado_synonym_default
description: Alternate names, aliases or synonyms for this record.
cardinality: -1
required: false
storage_settings:
storage_plugin_id: chado_storage
storage_plugin_settings:
base_table: feature
linker_table: feature_synonym
linker_fkey_column: feature_id
settings:
termIdSpace: schema
termAccession: alternateName
display:
view:
default:
region: content
label: above
weight: 10
form:
default:
region: content
weight: 10

- name: germplasm_name
content_type: germplasm
label: Name
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
<?php

namespace Drupal\tripal_chado\Plugin\Field\FieldFormatter;

use Drupal\tripal\TripalField\TripalFormatterBase;
use Drupal\Core\Field\FieldItemListInterface;
use Drupal\Core\Form\FormStateInterface;
use Drupal\tripal_chado\TripalField\ChadoFormatterBase;

/**
* Plugin implementation of Default Tripal field formatter for sequence data
*
* @FieldFormatter(
* id = "chado_synonym_formatter_default",
* label = @Translation("Chado Synonym Formatter"),
* description = @Translation("A chado synonym formatter"),
* field_types = {
* "chado_synonym_default"
* }
* )
*/
class ChadoSynonymFormatterDefault extends ChadoFormatterBase {

/**
* {@inheritdoc}
*/
public function viewElements(FieldItemListInterface $items, $langcode) {
$elements = [];

$list = [];
foreach($items as $delta => $item) {
$value = $item->get('name')->getString();
$list[$delta] = $value;
}

// Also need to make sure to not return markup if the field is empty.
if (empty($list)) {
return $elements;
}

// If more than one value has been found display all values in an unordered
// list.
if (count($list) > 1) {
$elements[0] = [
'#theme' => 'item_list',
'#list_type' => 'ul',
'#items' => $list,
'#wrapper_attributes' => ['class' => 'container'],
];
return $elements;
}

$elements[0] = [
'#type' => 'markup',
"#markup" => $list[0]
];
return $elements;
}
}
Loading

0 comments on commit c62fa0b

Please sign in to comment.