Skip to content

Commit

Permalink
Merge branch 'dev' into USAGOV-1789-wizard-datalayer
Browse files Browse the repository at this point in the history
  • Loading branch information
omerida authored Nov 1, 2024
2 parents 9986d3a + 1370284 commit 43cff6c
Show file tree
Hide file tree
Showing 8 changed files with 113 additions and 71 deletions.
1 change: 1 addition & 0 deletions config/sync/core.extension.yml
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ module:
usagov_benefit_finder_api: 0
usagov_benefit_finder_content: 0
usagov_benefit_finder_page: 0
usagov_ckeditor5_source_editing_fixup: 0
usagov_directories: 0
usagov_login: 0
usagov_menus: 0
Expand Down
2 changes: 1 addition & 1 deletion config/sync/editor.editor.uswds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ settings:
multiBlock: true
ckeditor5_sourceEditing:
allowed_tags:
- '<div>'
- '<div data-*>'
- '<a role>'
ckeditor5_style:
styles:
Expand Down
2 changes: 1 addition & 1 deletion config/sync/filter.format.uswds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ filters:
status: true
weight: -10
settings:
allowed_html: '<br> <p class="usa-intro text-align-left text-align-center text-align-right text-align-justify"> <h1 class="text-align-left text-align-center text-align-right text-align-justify"> <h2 class="font-serif-lg text-bold text-accent-cool-darker text-align-left text-align-center text-align-right text-align-justify"> <h3 class="text-align-left text-align-center text-align-right text-align-justify"> <h4 class="text-align-left text-align-center text-align-right text-align-justify"> <a class="usa-button usa-button--secondary usa-button--big" role href> <div class="usa-table-container--scrollable usa-sr-only usa-table__announcement-region text-align-left text-align-center text-align-right text-align-justify" aria-live> <strong> <em> <u> <blockquote> <ul> <ol reversed start> <li> <table class> <tr> <td rowspan colspan data-label data-sort-value> <th rowspan colspan scope data-label data-sortable role> <thead> <tbody> <tfoot> <caption> <drupal-media data-entity-type data-entity-uuid alt data-view-mode data-caption data-align> <drupal-paragraph data-embed-button data-entity-label data-paragraph-id data-paragraph-revision-id>'
allowed_html: '<br> <p class="usa-intro text-align-left text-align-center text-align-right text-align-justify"> <h1 class="text-align-left text-align-center text-align-right text-align-justify"> <h2 class="font-serif-lg text-bold text-accent-cool-darker text-align-left text-align-center text-align-right text-align-justify"> <h3 class="text-align-left text-align-center text-align-right text-align-justify"> <h4 class="text-align-left text-align-center text-align-right text-align-justify"> <a class="usa-button usa-button--secondary usa-button--big" role href> <div data-* class="usa-table-container--scrollable usa-sr-only usa-table__announcement-region text-align-left text-align-center text-align-right text-align-justify" aria-live> <strong> <em> <u> <blockquote> <ul> <ol reversed start> <li> <table class> <tr> <td rowspan colspan data-label data-sort-value> <th rowspan colspan scope data-label data-sortable role> <thead> <tbody> <tfoot> <caption> <drupal-media data-entity-type data-entity-uuid alt data-view-mode data-caption data-align> <drupal-paragraph data-embed-button data-entity-label data-paragraph-id data-paragraph-revision-id>'
filter_html_help: true
filter_html_nofollow: false
filter_table_attributes:
Expand Down
6 changes: 6 additions & 0 deletions scripts/dr-space-setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,12 @@ echo cf target -s $APP_SPACE
$echo cf target -s $APP_SPACE &> /dev/null
echo assertCurSpace $APP_SPACE
$echo assertCurSpace $APP_SPACE
echo "************************************************************************"
echo "Please remember to add each developer to the SpaceDeveloper group in the"
echo "newly created space."
echo
echo "Add devs in the CloudGov dashboard: https://dashboard.fr.cloud.gov/home"
echo "************************************************************************"
exit

echo cf target -s $APP_SPACE
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Module: usagov_ckeditor5_source_editing_fixup

This module exists solely to remove a restriction on adding elements to the list of "Manually editable HTML tags" in the "Source editing" CKEditor 5 plugin. The problem is that if a plugin that is installed but not enabled for the current editor's configuration specifies an element as allowed, the Source Editing plugin won't let you add that element by itself -- an error message advises you to enable the plugin instead.

In our case, we want to allow editors to add divs with data attributes. The conflict is with the USWDS Grid plugin, which we've chosen not to enable -- it also allows divs with "data-*" (that is, any data- attribute). But we don't want the behavior of that plugin! And since it's supplied in a module that offers multiple plugins, we can't simply disable or uninstall it.

There's probably more than one active bug report about this, but this is the one I found, and specifically, the comment suggesting the workaround used here: https://www.drupal.org/project/drupal/issues/3410100#comment-15457015

Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
name: 'USAGov CKEditor5 Source Editing Fixup'
type: module
description: 'Remove restrictions around elements that can be added for Source Editing mode'
core_version_requirement: ^9 || ^10
package: USAgov
dependencies:
- drupal:ckeditor5
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php

/**
* Implements hook_config_schema_info_alter().
*
* This enables us to add elements to the "Source Editing" elements of a
* CKEditor5 editor configuration, even if a disabled plugin would also supply them.
* See https://www.drupal.org/project/drupal/issues/3410100#comment-15457015
*/
function usagov_ckeditor5_source_editing_fixup_config_schema_info_alter(&$definitions) {
if (isset($definitions['ckeditor5.plugin.ckeditor5_sourceEditing'])) {
unset($definitions['ckeditor5.plugin.ckeditor5_sourceEditing']['mapping']['allowed_tags']['sequence']['constraints']['SourceEditingRedundantTags']);
}
}
144 changes: 75 additions & 69 deletions web/themes/custom/usagov/scripts/callCenterWaitTimeLookup.js
Original file line number Diff line number Diff line change
@@ -1,82 +1,88 @@
jQuery(document).ready(async function () {
"use strict";

var waittime = (function() {
if (jQuery("html[lang|='en']").length ||
jQuery("html[lang|='es']").length) {
jQuery.ajax({
"url": "https://s3-us-gov-west-1.amazonaws.com/cg-4d6fb302-315f-403e-a96e-a7563ccddd3d/1.0/waittime.json",
"type": "GET",
"success": function (response) {
var json = jQuery.parseJSON(response);
var seconds = -1;
function checkPagePath() {
if (
window.location.pathname === "/phone" ||
window.location.pathname === "/es/llamenos" ||
window.location.pathname === "/chat" ||
window.location.pathname === "/es/chat"
) {
return true;
}
}

if (jQuery("html[lang|='en']").length) {
seconds = json.enEstimatedWaitTimeSeconds;
}
if (jQuery("html[lang|='es']").length) {
seconds = json.spEstimatedWaitTimeSeconds;
}
function getCallCenterWaitTime() {
let jsonSeconds;
let jsonTimestamp;
jQuery.ajax({
"url": "https://s3-us-gov-west-1.amazonaws.com/cg-4d6fb302-315f-403e-a96e-a7563ccddd3d/1.0/waittime.json",
"type": "GET",
"dataType": "json",
"success": function (response) {
if (window.location.pathname === "/phone") {
jsonSeconds = response.call.estimatedWaitTimeSeconds.en;
}
else if (window.location.pathname === "/es/llamenos") {
jsonSeconds = response.call.estimatedWaitTimeSeconds.sp;
}
else if (window.location.pathname === "/chat") {
jsonSeconds = response.chat.estimatedWaitTimeSeconds.en;
}
else if (window.location.pathname === "/es/chat") {
jsonSeconds = response.chat.estimatedWaitTimeSeconds.sp;
}

if (seconds >= 0) {
var minutes = Math.floor(seconds / 60);
var remainingMinutes = minutes % 60;
seconds = seconds - (minutes * 60);
var content = "Estimated wait time: ";
var secondsText = " second";
var minuteText = " minute";
var noneText = "None";
jsonTimestamp = response.timestamp;
createDisplayWaitTime(jsonSeconds, jsonTimestamp);
},
"error": function (xhr, status, error) {
console.log(error);
},
});
}

if (jQuery("html[lang|='es']").length) {
content = "Tiempo de espera estimado: ";
secondsText = " segundo";
minuteText = " minuto";
noneText = "Ninguno";
}
function checkTimeStamp(timestamp) {
let timeOfEstimate = timestamp ? timestamp : 0;
if (Date.now() / 1000 - timeOfEstimate < 600) {
return true;
}
}

if (remainingMinutes > 0) {
content += remainingMinutes + minuteText;
if (remainingMinutes > 1) {
content += "s";
}
}
function createDisplayWaitTime(actualSeconds, timestamp) {
// If the estimated time was captured over 10 minutes ago, remain silent.
if (checkTimeStamp(timestamp)) {
let displayTime;
if (actualSeconds !== -1) {
if (actualSeconds < 60) {
displayTime = 1;
}
else {
displayTime = Math.round(actualSeconds / 60);
}
displayWaitTime(displayTime);
}
}
}

if (seconds > 0) {
if (remainingMinutes > 0) {
content += ", ";
}
content += seconds + secondsText;
if (seconds > 1) {
content += "s";
}
}
function displayWaitTime(displayTime) {
let docLang = [document.documentElement.lang];

if (minutes === 0 && seconds === 0) {
content = content + noneText;
}
let plural = displayTime > 1;
const plurals = plural ? "s" : "";

// If the estimated time was captured over 10 minutes ago, remain silent.
var timeOfEstimate = json.timestamp ? json.timestamp : 0;
if (Date.now()/1000 - timeOfEstimate > 600) {
content = "";
}
const displayText =
docLang[0] === "es"
? `El tiempo aproximado de espera es <strong>${displayTime} minuto${plurals}</strong>.`
: `The current estimated wait time is <strong>${displayTime} minute${plurals}</strong>.`;

jQuery('#callCenterTime').html(content);
}
},
"error": function (xhr, status, error) {
console.log('fail');
console.log(error);
jQuery('#callCenterTime').html(error);
}
});
}
});
jQuery('div[data-call-wait="showTime"]').replaceWith(
`<div class="paragraph paragraph--type--uswds-alert paragraph--view-mode--embed paragraph--id--2485 usa-alert usa-alert--slim usa-alert--no-icon" data-call-wait='showTime'><div class="usa-alert__body"> <div class="field field--name-field-alert-body field--type-text field--label-hidden field__item">${displayText}</div> </div> </div>`
);
}

if (jQuery('#callCenterTime').length > 0) {
waittime();
setInterval(function() {
waittime();
}, 60 * 1000);
// upgrade: only apply to phone pages using Drupal library in usagov.libraries.yml
if (checkPagePath()) {
getCallCenterWaitTime();
}
});
});

0 comments on commit 43cff6c

Please sign in to comment.