Skip to content

Commit

Permalink
Merge pull request #482 from Born-Digital-US/ISSUE-481
Browse files Browse the repository at this point in the history
ISSUE-481 -- Remove hard-coded ado type field in ado type to view mode mapping form
  • Loading branch information
DiegoPino authored Nov 20, 2024
2 parents 728535f + 8d543e2 commit 95ae15f
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions src/Form/ViewModeMappingSettingsForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use Drupal\Core\Form\ConfigFormBase;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Url;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Drupal\Core\Config\ConfigFactoryInterface;
use Drupal\search_api\Entity\Index;
Expand Down Expand Up @@ -55,7 +56,7 @@ public function buildForm(array $form, FormStateInterface $form_state) {
$config = $this->config('format_strawberryfield.viewmodemapping_settings');
$form['info'] = [
'#markup' => $this->t(
'This Form allows you to map ADO (Archipelago Digital Object) "types" to existing Drupal View Mode Configurations.'
'This Form allows you to map ADO (Archipelago Digital Object) "types" to Drupal View Modes.'
),
];

Expand Down Expand Up @@ -127,6 +128,22 @@ public function buildForm(array $form, FormStateInterface $form_state) {
],
],
];
$form['usage_notes'] = [
'#title' => $this->t('Usage Notes'),
'#type' => 'fieldset',
'#collapsible' => FALSE,
'#collapsed' => FALSE,
'#tree' => TRUE,
'notes_list' => [
'#theme' => 'item_list',
'#items' => [
$this->t('"The ADO Type" refers to the solr indexed value as configured in the Archipelago @solr_settings_link form. Note that it could be referring to any "type" value nested at any level in your JSON metadata.',
['@solr_settings_link' => \Drupal::service('link_generator')->generate('Important Solr Settings', Url::fromRoute('strawberryfield.important_solr_settings_form'))]),
$this->t('You may select "!" if you need to map an ADO JSON "type" value to a View Mode where that type is not yet available. After creating the mapping, you can edit the ADO Type directly.'),
$this->t('If more than one view mode mapping is enabled for a given "type" value, the <strong>first</strong> will prevail.'),
],
],
];
$storedsettings = $config->get('type_to_viewmode');
if (empty(
$form_state->get(
Expand Down Expand Up @@ -221,9 +238,10 @@ protected function getTypesFromSolr() {
->getStorage('search_api_index')
->loadMultiple();

$field = $this->config('strawberryfield.archipelago_solr_settings.ado_type')->get('field') ?? 'type_1';
$facets = [
'type' => [
'field' => 'type_1',
'field' => $field,
'limit' => 50,
'operator' => 'AND',
'min_count' => 1,
Expand Down

0 comments on commit 95ae15f

Please sign in to comment.