Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VAGOV-TEAM-96557: Default paragraphs #20382

Draft
wants to merge 23 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
b1e2164
Initial wiring for Layout page:
ryguyk Jan 23, 2025
874e301
Implements static structure of layout page.
ryguyk Jan 25, 2025
f143554
Updates links on home page to point to layout page.
ryguyk Jan 27, 2025
17d1acc
Moves chapter-of-type check from FormBuilderBase to DigitalFormsService.
ryguyk Jan 28, 2025
3d023d8
Adds getDigitalFormStepStatus to DigitalFormsService.
ryguyk Jan 28, 2025
24e4b93
- Defines variables for layout twig template.
ryguyk Jan 28, 2025
1fe7ccc
- Adds DigitalForm class as a wrapper around DigitalForm nodes.
ryguyk Jan 29, 2025
84285ec
Adds check in constructor to ensure passed-in node is a DigitalForm n…
ryguyk Jan 29, 2025
0222ad3
Updates getDigitalForm method to return null if the node is not a `di…
ryguyk Jan 29, 2025
ffaa14d
Updates DigitalFormsService methods to returned DigitalForm objects r…
ryguyk Jan 29, 2025
43a0bab
Adds __call magic method to DigitalForm class.
ryguyk Jan 29, 2025
4a7dea8
Updates Controller to accommodate changed architecture utilizing Digi…
ryguyk Jan 29, 2025
7ddeee9
Adds wrapDigitalForm to DigitalFormsService.
ryguyk Jan 29, 2025
4b40941
Updates Form classes to align with new DigitalForm wrapper-class arch…
ryguyk Jan 29, 2025
4dfe1bc
- Fixes error: DigitalFormsService method getDigitalForms was not ret…
ryguyk Jan 29, 2025
41dab8a
- Adds handling of additional (non-standard) steps.
ryguyk Jan 30, 2025
3f83025
Fixes typo on function annotation.
ryguyk Jan 30, 2025
85253d6
Adds method annotations for methods that are handled via the `__call`…
ryguyk Jan 30, 2025
2c3bbb5
Fixes case on param annotation.
ryguyk Jan 30, 2025
778ecae
Updates annotation to include more methods.
ryguyk Jan 30, 2025
0a8598d
Updates form-info submit button to redirect to layout page.
ryguyk Jan 31, 2025
a2db291
Removes caching on Form Builder pages.
ryguyk Feb 3, 2025
dd04e63
Adds "Your personal information" step when the form is first created …
ryguyk Jan 31, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
--vads-color-divider: #a9aeb1;
--color-shadow: #00000040;

color: var(--vads-color-base);
font-family: var(--font-family-serif);
}

Expand Down Expand Up @@ -85,6 +86,7 @@
a.form-builder-button {
border-radius: var(--units-0p5);
cursor: pointer;
font-family: var(--font-source-sans);
font-weight: var(--font-weight-bold);
padding: var(--units-1p5) var(--units-2p5);
text-decoration: none;
Expand All @@ -106,3 +108,20 @@ a.form-builder-button--primary:hover {
color: var(--vads-button-color-text-primary-on-light);
text-decoration: none;
}

.form-builder-button--secondary,
.form-builder-button--secondary:focus,
a.form-builder-button--secondary,
a.form-builder-button--secondary:focus {
background: rgba(0, 0, 0, 0);
border: var(--units-0p25) solid var(--vads-color-primary);
color: var(--vads-color-primary);
text-decoration: none;
}

.form-builder-button--secondary:hover,
a.form-builder-button--secondary:hover {
background: #dce4ef; /*secondary-button hover color missing from tokens*/
color: var(--vads-color-primary);
text-decoration: none;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
/* Page content*/
.form-builder-page-content--layout {
width: 620px;
}

.form-builder-content__page-help-text {
font-family: var(--font-source-sans);
margin-bottom: var(--units-6);
}

/* Step groups*/
.form-builder-layout-step-group {
font-family: var(--font-source-sans);
margin-top: var(--units-4);
}

.form-builder-layout-step-group__heading {
font-family: var(--font-family-serif);
margin-bottom: var(--units-5);
}

.form-builder-layout-step-group__heading--viewing-form {
margin-bottom: var(--units-2);
}

/* Individual steps */
.form-builder-layout-step {
border-bottom: var(--units-1px) solid var(--vads-color-base-light);
margin: var(--units-3) 0 0 0;
padding: 0 0 var(--units-3) var(--units-3);
position: relative;
}

.form-builder-layout-step-group > .form-builder-layout-step:last-child {
border-bottom: 0;
}

.form-builder-layout-step::before {
border-radius: var(--units-0p25);
color: var(--vads-color-white);
font-size: var(--font-size-sm);
font-weight: var(--font-weight-normal);
padding: var(--units-1px) var(--units-1);
position: absolute;
right: 0;
top: 0;
}

.form-builder-layout-step--complete::before {
background-color: var(
--vads-button-color-background-primary-alt-active-on-light
);
content: "COMPLETE";
}

.form-builder-layout-step--incomplete::before {
background-color: var(--vads-color-error-darker);
content: "INCOMPLETE";
}

.form-builder-layout-step__help-text {
color: var(--vads-color-gray-medium);
}

.form-builder-layout-step__view-link {
display: inline-block;
margin-top: var(--units-3);
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,13 @@ class VaGovFormBuilderController extends ControllerBase {
*/
const LIBRARY_PREFIX = 'va_gov_form_builder/va_gov_form_builder_styles__';

/**
* The entity type manager service.
*
* @var \Drupal\Core\Entity\EntityTypeManagerInterface
*/
protected $entityTypeManager;

/**
* The Drupal form builder.
*
Expand All @@ -51,42 +58,42 @@ class VaGovFormBuilderController extends ControllerBase {
protected $digitalFormsService;

/**
* The Digital Form node.
* The Digital Form object.
*
* When the page in question edits or references an existing
* digital form node, this property is populated. When the
* page creates a new digital form node or otherwise does
* not reference a node, this is empty.
*
* @var \Drupal\node\Entity\Node|null
* @var \Drupal\va_gov_form_builder\EntityWrapper\DigitalForm|null
*/
protected $digitalFormNode;
protected $digitalForm;

/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container) {
$instance = parent::create($container);

$instance->entityTypeManager = $container->get('entity_type.manager');
$instance->drupalFormBuilder = $container->get('form_builder');
$instance->digitalFormsService = $container->get('va_gov_form_builder.digital_forms_service');

return $instance;
}

/**
* Loads and sets the Digital Form node.
* Loads and sets the Digital Form object.
*
* @param string $nid
* The node id to load.
*
* @return bool
* TRUE if successfully loaded. FALSE otherwise.
*/
protected function loadDigitalFormNode($nid) {
$digitalFormNode = $this->digitalFormsService->getDigitalForm($nid);
if (!empty($digitalFormNode)) {
$this->digitalFormNode = $digitalFormNode;
protected function loadDigitalForm($nid) {
$this->digitalForm = $this->digitalFormsService->getDigitalForm($nid);
if ($this->digitalForm) {
return TRUE;
}

Expand All @@ -108,6 +115,11 @@ protected function getPage($pageContent, $subtitle, $libraries = NULL) {
$page = [
'#type' => 'page',
'content' => $pageContent,
'#cache' => [
// Do not cache Form Builder pages.
// @todo Make caching more granular/contextual.
'max-age' => 0,
],
// Add custom data.
'form_builder_page_data' => [
'subtitle' => $subtitle,
Expand Down Expand Up @@ -142,7 +154,7 @@ protected function getPage($pageContent, $subtitle, $libraries = NULL) {
*/
protected function getFormPage($formName, $subtitle, $libraries = NULL) {
// @phpstan-ignore-next-line
$form = $this->drupalFormBuilder->getForm('Drupal\va_gov_form_builder\Form\\' . $formName, $this->digitalFormNode);
$form = $this->drupalFormBuilder->getForm('Drupal\va_gov_form_builder\Form\\' . $formName, $this->digitalForm);

return $this->getPage($form, $subtitle, $libraries);
}
Expand Down Expand Up @@ -184,7 +196,7 @@ public function home() {
/**
* Form-info page.
*
* @param string $nid
* @param string|null $nid
* The node id, passed in when the page edits an existing node.
*/
public function formInfo($nid = NULL) {
Expand All @@ -194,7 +206,7 @@ public function formInfo($nid = NULL) {

if (!empty($nid)) {
// This is an edit.
$nodeFound = $this->loadDigitalFormNode($nid);
$nodeFound = $this->loadDigitalForm($nid);
if (!$nodeFound) {
throw new NotFoundHttpException();
}
Expand All @@ -203,13 +215,82 @@ public function formInfo($nid = NULL) {
return $this->getFormPage($formName, $subtitle, $libraries);
}

/**
* Layout page.
*
* @param string $nid
* The node id of the Digital Form.
*/
public function layout($nid) {
$nodeFound = $this->loadDigitalForm($nid);
if (!$nodeFound) {
throw new NotFoundHttpException();
}

$pageContent = [
'#theme' => self::PAGE_CONTENT_THEME_PREFIX . 'layout',
'#form_info' => [
'status' => $this->digitalForm->getStepStatus('form_info'),
'url' => Url::fromRoute('va_gov_form_builder.form_info.edit', ['nid' => $nid])->toString(),
],
'#intro' => [
'status' => $this->digitalForm->getStepStatus('intro'),
'url' => '',
],
'#your_personal_info' => [
'status' => $this->digitalForm->getStepStatus('your_personal_info'),
'url' => '',
],
'#address_info' => [
'status' => $this->digitalForm->getStepStatus('address_info'),
'url' => '',
],
'#contact_info' => [
'status' => $this->digitalForm->getStepStatus('contact_info'),
'url' => '',
],
'#additional_steps' => [
'steps' => array_map(function ($step) {
return [
// If an additional step exists, it's complete.
'type' => $step['type'],
'title' => $step['fields']['field_title'][0]['value'],
'status' => 'complete',
'url' => '',
];
}, $this->digitalForm->getNonStandarddSteps()),
'add_step' => [
'url' => '',
],
],
'#review_and_sign' => [
'status' => $this->digitalForm->getStepStatus('review_and_sign'),
'url' => '',
],
'#confirmation' => [
'status' => $this->digitalForm->getStepStatus('confirmation'),
'url' => '',
],
'#view_form' => [
'url' => '',
],
];
$subtitle = $this->digitalForm->getTitle();
$libraries = ['layout'];

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

/**
* Name-and-date-of-birth page.
*
* @param string $nid
* The node id of the Digital Form.
*/
public function nameAndDob($nid) {
$formName = 'NameAndDob';
$subtitle = 'Subtitle Placeholder';
$nodeFound = $this->loadDigitalFormNode($nid);
$nodeFound = $this->loadDigitalForm($nid);
if (!$nodeFound) {
throw new NotFoundHttpException();
}
Expand Down
Loading
Loading