Skip to content

Commit

Permalink
Merge branch 'main' into VACMS-19794-connect-with-us-tech-debt
Browse files Browse the repository at this point in the history
  • Loading branch information
omahane authored Jan 21, 2025
2 parents 4cdd7a7 + f9490b7 commit 5e85423
Show file tree
Hide file tree
Showing 21 changed files with 625 additions and 244 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,18 @@
font-family: var(--font-family-serif);
}

/* links */
.form-builder-page-container a {
text-decoration: underline;
}

.form-builder-page-container a:focus,
.form-builder-page-container a:hover {
background-color: rgba(0, 0, 0, 0.05);
color: var(--vads-color-base);
text-decoration: underline;
}

/* headings */
.form-builder-page-container h1 {
font-size: var(--vads-font-size-heading-level-1);
Expand Down Expand Up @@ -56,3 +68,30 @@
line-height: var(--units-3);
padding: var(--units-1p5);
}

/* buttons */
.form-builder-button,
a.form-builder-button {
border-radius: var(--units-0p5);
cursor: pointer;
font-weight: var(--font-weight-bold);
padding: var(--units-1p5) var(--units-2p5);
text-decoration: none;
transition: none;
}

.form-builder-button--primary,
.form-builder-button--primary:focus,
a.form-builder-button--primary,
a.form-builder-button--primary:focus {
background: var(--vads-color-primary);
color: var(--vads-button-color-text-primary-on-light);
text-decoration: none;
}

.form-builder-button--primary:hover,
a.form-builder-button--primary:hover {
background: var(--vads-color-primary-dark);
color: var(--vads-button-color-text-primary-on-light);
text-decoration: none;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/* Headings */
.form-builder-page-content--home .form-builder-content-section__heading {
font-size: var(--vads-font-size-heading-level-4);
}

/* New form */
.form-builder-content-section--new-form__subheading {
margin-bottom: var(--units-3);
}

/* Recent Forms */
.form-builder-content-section--recent-forms {
margin-top: 60px;
}

.form-builder-content-section--recent-forms__forms-list {
border-top: var(--units-1px) solid var(--vads-color-base-light);
list-style-type: none;
margin: 0;
padding-bottom: var(--units-3);
padding-top: var(--units-1p5);
}

.form-builder-content-section--recent-forms__form-list-item {
margin-bottom: var(--units-1p5);
}

.form-builder-content-section--recent-forms__form-link {
font-weight: var(--font-weight-bold);
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Drupal\va_gov_form_builder\Controller;

use Drupal\Core\Controller\ControllerBase;
use Drupal\Core\Url;
use Symfony\Component\DependencyInjection\ContainerInterface;

/**
Expand All @@ -24,6 +25,16 @@
*/
class VaGovFormBuilderController extends ControllerBase {

/**
* The prefix for the page-content theme definitions.
*/
const PAGE_CONTENT_THEME_PREFIX = 'page_content__va_gov_form_builder__';

/**
* The prefix for the page-specific style libraries.
*/
const LIBRARY_PREFIX = 'va_gov_form_builder/va_gov_form_builder_styles__';

/**
* The Drupal form builder.
*
Expand All @@ -32,40 +43,41 @@ class VaGovFormBuilderController extends ControllerBase {
private $drupalFormBuilder;

/**
* The page subtitle.
* The Digital Forms service.
*
* @var string
* @var \Drupal\va_gov_form_builder\Service\DigitalFormsService
*/
private $subtitle;
private $digitalFormsService;

/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container) {
$instance = parent::create($container);
$instance->drupalFormBuilder = $container->get('form_builder');
$instance->digitalFormsService = $container->get('va_gov_form_builder.digital_forms_service');

return $instance;
}

/**
* Returns a render array representing the page with the passed-in form.
* Returns a render array representing the page with the passed-in content.
*
* @param string $formName
* The filename of the form to be rendered.
* @param string $nid
* The node id, passed in when the form in question edits an existing node.
* @param array $pageContent
* A render array representing the page content.
* @param string $subtitle
* The subtitle for the page.
* @param string $libraries
* Libraries for the page, in addition to the Form Builder general library,
* which is added automatically.
*/
private function getFormPage($formName, $nid = NULL) {
// @phpstan-ignore-next-line
$form = $this->drupalFormBuilder->getForm('Drupal\va_gov_form_builder\Form\\' . $formName, $nid);

return [
private function getPage($pageContent, $subtitle, $libraries = NULL) {
$page = [
'#type' => 'page',
'content' => $form,
'content' => $pageContent,
// Add custom data.
'form_builder_page_data' => [
'subtitle' => $this->subtitle,
'subtitle' => $subtitle,
],
// Add styles.
'#attached' => [
Expand All @@ -74,37 +86,86 @@ private function getFormPage($formName, $nid = NULL) {
],
],
];

if (!empty($libraries)) {
foreach ($libraries as $library) {
$page['#attached']['library'][] = self::LIBRARY_PREFIX . $library;
}
}

return $page;
}

/**
* Entry point for the VA Form Builder. Redirects to the intro page.
* Returns a render array representing the page with the passed-in form.
*
* @param string $formName
* The filename of the form to be rendered.
* @param string $subtitle
* The subtitle for the page.
* @param string $libraries
* Libraries for the page, in addition to the Form Builder general library,
* which is added automatically.
* @param string $nid
* The node id, passed in when the form in question edits an existing node.
*/
private function getFormPage($formName, $subtitle, $libraries = NULL, $nid = NULL) {
// @phpstan-ignore-next-line
$form = $this->drupalFormBuilder->getForm('Drupal\va_gov_form_builder\Form\\' . $formName, $nid);

return $this->getPage($form, $subtitle, $libraries);
}

/**
* Entry point for the VA Form Builder. Redirects to the home page.
*/
public function entry() {
return $this->redirect('va_gov_form_builder.intro');
return $this->redirect('va_gov_form_builder.home');
}

/**
* Intro page.
* Home page.
*/
public function intro() {
$this->subtitle = 'Subtitle Placeholder';
return $this->getFormPage('Intro');
public function home() {
// Passing "FALSE" to fetch draft nodes rather than only published nodes.
$digitalForms = $this->digitalFormsService->getDigitalForms(FALSE);

$recentForms = [];
foreach ($digitalForms as $digitalForm) {
$recentForms[] = [
'nid' => $digitalForm->id(),
'title' => $digitalForm->getTitle(),
'formNumber' => $digitalForm->get('field_va_form_number')->value,
];
}

$pageContent = [
'#theme' => self::PAGE_CONTENT_THEME_PREFIX . 'home',
'#build_form_url' => Url::fromRoute('va_gov_form_builder.start_conversion')->toString(),
'#recent_forms' => $recentForms,
];
$subtitle = 'Select a form';
$libraries = ['home'];

return $this->getPage($pageContent, $subtitle, $libraries);
}

/**
* Start-conversion page.
*/
public function startConversion() {
$this->subtitle = 'Subtitle Placeholder';
return $this->getFormPage('StartConversion');
$formName = 'StartConversion';
$subtitle = 'Subtitle Placeholder';
return $this->getFormPage($formName, $subtitle);
}

/**
* Name-and-date-of-birth page.
*/
public function nameAndDob($nid) {
$this->subtitle = 'Subtitle Placeholder';
return $this->getFormPage('NameAndDob', $nid);
$formName = 'NameAndDob';
$subtitle = 'Subtitle Placeholder';
return $this->getFormPage($formName, $subtitle, NULL, $nid);
}

}
103 changes: 0 additions & 103 deletions docroot/modules/custom/va_gov_form_builder/src/Form/Intro.php

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ protected function setDigitalFormNodeFromFormState(array &$form, FormStateInterf
* Submit handler for the 'Back' button.
*/
public function backButtonSubmitHandler(array &$form, FormStateInterface $form_state) {
$form_state->setRedirect('va_gov_form_builder.intro');
$form_state->setRedirect('va_gov_form_builder.home');
}

/**
Expand Down
Loading

0 comments on commit 5e85423

Please sign in to comment.