Skip to content

Commit

Permalink
Issue #3442343: Better up the description in the recipes step and hav…
Browse files Browse the repository at this point in the history
…e the logic of in_varbase_demo to work for Conditional Form Fields when Varbase Demo is checked and unchanged
  • Loading branch information
Natshah committed Apr 29, 2024
1 parent 3b3fcf7 commit 014c62f
Show file tree
Hide file tree
Showing 3 changed files with 82 additions and 13 deletions.
2 changes: 1 addition & 1 deletion configbit/demo.content.varbase.bit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ config_bit:
dependencies:
varbase_demo:
title: 'Varbase Demo'
description: '<p>If you''re evaluating Varbase, installing demo content will help you get an idea of how Varbase works, and what features are included.</p><div class="messages-list__item messages messages--info"><div class="messages__header"><h2 id="message-status-title" class="messages__title">Uncheck to be able to select recipes.</h2></div><div class="messages__content">As Varbase Demo will enable all features to demo them.</p></div></div>'
description: '<p>Installing demo content gives you a taste of what Varbase offers and its key features. It''s a handy way to explore Varbase''s functionality and see it in action.</p><div class="messages-list__item messages messages--info"><div class="messages__header"><h2 id="message-status-title" class="messages__title">Please note:</h2></div><div class="messages__content">You have the option to uncheck the Varbase Demo box to select specific recipes. Varbase Demo enables all features for demonstration purposes.</p></div></div>'
selected: true
config_form: false
11 changes: 11 additions & 0 deletions configbit/extra.components.varbase.bit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,54 +15,65 @@ config_bit:
selected: false
config_form: true
formbit: "src/FormBit/varbase_ai.formbit.php"
in_varbase_demo: false
editoria11y:
title: "Editorial Accessibility Checker"
description: 'Adds an automatic checker tool for accessibility with the integration of the <a href="https://www.drupal.org/project/editoria11y" target="_blank">Editoria11y Accessibility Checker</a>, a user-friendly tool dedicated to automatically identifying and addressing straightforward accessibility issues in various contexts.'
selected: true
config_form: false
in_varbase_demo: true
vmi:
title: "View Modes Inventory"
description: "The most common view modes you'll need for almost any site. This will provide you with a set of content <em>View Modes</em> for various teaser styles. All of which are mobile-first, media-aware, and ready for you to customize your site."
selected: true
config_form: false
in_varbase_demo: true
varbase_heroslider:
title: "Hero Slider"
description: 'A rich hero slider that allows you to display video and/or image slides. It implements the universal "Hero Slider" to be used in your homepage.</a>.'
selected: false
config_form: false
in_varbase_demo: true
varbase_carousels:
title: "Varbase Carousels"
description: 'Provides the necessary tools to build carousels in your website. You will be able to create carousels on the spot and place it anywhere in the site.'
selected: false
config_form: false
in_varbase_demo: true
varbase_search:
title: "Varbase Search"
description: 'A suite of site search engine tools to help you build better search performance, customization, and search experience. Built using <a href="https://www.drupal.org/project/search_api" target="_blank">Search API</a>.'
selected: false
config_form: false
in_varbase_demo: true
varbase_blog:
title: "Varbase Blog"
description: "Provides the necessary tools to build blogs in your website."
selected: false
config_form: false
in_varbase_demo: true
varbase_auth:
title: "Varbase Social Single Sign-On"
description: 'Adds single sign-on using existing information from a social networking service such as Facebook, Twitter or Google. Built using <a href="https://www.drupal.org/project/social_api" target="_blank">Social API</a>.'
selected: false
config_form: true
formbit: "src/FormBit/varbase_auth.formbit.php"
in_varbase_demo: true
varbase_api:
title: "Varbase API"
description: "A JSON:API implementation with authentication and authorization that allows for easy ingestion of content by other applications."
selected: false
config_form: false
in_varbase_demo: true
google_analytics:
title: "Google Analytics"
description: 'Adds the <a href="https://www.drupal.org/project/google_analytics" target="_blank">Google Analytics</a> web statistics tracking system to your website.'
selected: false
config_form: false
in_varbase_demo: true
google_tag:
title: "Google Tag Manager"
description: 'Adds an integration with the <a href="https://www.drupal.org/project/google_tag" target="_blank">Google Tag Manager</a> (GTM) application.'
selected: false
config_form: false
in_varbase_demo: true
82 changes: 70 additions & 12 deletions src/Form/AssemblerForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public function buildForm(array $form, FormStateInterface $form_state, array &$i
$form['extra_components_introduction'] = [
'#weight' => -1,
'#prefix' => '<p>',
'#markup' => $this->t("Install additional ready-to-use features in your site."),
'#markup' => $this->t("Effortlessly integrate ready-to-use feature recipes for immediate website functionality."),
'#suffix' => '</p>',
];

Expand Down Expand Up @@ -171,6 +171,7 @@ public function buildForm(array $form, FormStateInterface $form_state, array &$i
$checkbox_title = '';
$checkbox_description = '';
$checkbox_selected = FALSE;
$in_varbase_demo = FALSE;

if (isset($extra_feature_info['title'])) {
$checkbox_title = $extra_feature_info['title'];
Expand All @@ -184,36 +185,93 @@ public function buildForm(array $form, FormStateInterface $form_state, array &$i
$checkbox_selected = $extra_feature_info['selected'];
}

if (isset($extra_feature_info['in_varbase_demo'])) {
$in_varbase_demo = $extra_feature_info['in_varbase_demo'];
}

$form['extra_features'][$extra_feature_key] = [
'#type' => 'checkbox',
'#title' => $checkbox_title,
'#description' => $checkbox_description,
'#default_value' => $checkbox_selected,
'#states' => [
'disabled' => [
':input[name="varbase_demo"]' => ['checked' => TRUE],
],
'enabled' => [
':input[name="varbase_demo"]' => ['checked' => FALSE],
],
],
];

if ($in_varbase_demo) {
if ($checkbox_selected) {
$form['extra_features'][$extra_feature_key]['#states'] = [
'disabled' => [
':input[name="varbase_demo"]' => ['checked' => TRUE],
],
'enabled' => [
':input[name="varbase_demo"]' => ['checked' => FALSE],
],
];
}
else {
$form['extra_features'][$extra_feature_key]['#states'] = [
'disabled' => [
':input[name="varbase_demo"]' => ['checked' => TRUE],
],
'enabled' => [
':input[name="varbase_demo"]' => ['checked' => FALSE],
],
'checked' => [
':input[name="varbase_demo"]' => ['checked' => TRUE],
],
'unchecked' => [
':input[name="varbase_demo"]' => ['checked' => FALSE],
],
];
}
}
else {
if ($checkbox_selected) {
$form['extra_features'][$extra_feature_key]['#states'] = [
'disabled' => [
':input[name="varbase_demo"]' => ['checked' => TRUE],
],
'enabled' => [
':input[name="varbase_demo"]' => ['checked' => FALSE],
],
];
}
}

if (isset($extra_feature_info['config_form'])
&& $extra_feature_info['config_form'] == TRUE) {

$form['extra_features'][$extra_feature_key . '_config'] = [
'#type' => 'fieldset',
'#title' => $checkbox_title,
'#states' => [
];

if ($in_varbase_demo) {
$form['extra_features'][$extra_feature_key . '_config']['#states'] = [
'visible' => [
':input[name="' . $extra_feature_key . '"]' => ['checked' => TRUE],
'and',
':input[name="varbase_demo"]' => ['checked' => TRUE],
],
'invisible' => [
':input[name="' . $extra_feature_key . '"]' => ['checked' => FALSE],
'and',
':input[name="varbase_demo"]' => ['checked' => FALSE],
],
],
];
'disabled' => [
':input[name="varbase_demo"]' => ['checked' => TRUE],
],
];
}
else {
$form['extra_features'][$extra_feature_key . '_config']['#states'] = [
'visible' => [
':input[name="' . $extra_feature_key . '"]' => ['checked' => TRUE],
],
'invisible' => [
':input[name="' . $extra_feature_key . '"]' => ['checked' => FALSE],
],
];
}

if (isset($extra_feature_info['formbit'])) {
$formbit_file_name = \Drupal::service('extension.list.profile')->getPath('varbase') . '/' . $extra_feature_info['formbit'];
Expand Down

0 comments on commit 014c62f

Please sign in to comment.