Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
68efc61
Added HTML attributes and date validation constriant
MattOz-CDS Oct 19, 2021
f335acb
Fixed coding standard issues
MattOz-CDS Oct 19, 2021
c10c240
Fixed coding standard issues
MattOz-CDS Oct 19, 2021
0691a9f
Fixed coding standard issues
MattOz-CDS Oct 19, 2021
7644b9c
Fixed coding standard issues
MattOz-CDS Oct 19, 2021
ca3b0cc
Fixed coding standard issues
MattOz-CDS Oct 19, 2021
bd38d32
Merge remote-tracking branch 'remotes/origin/feature/os-places-geocod…
Adnan-cds Oct 20, 2021
274a9df
Added styling to localgov forms date element
MattOz-CDS Feb 9, 2022
ded7731
Merge branch 'feature/localgov-forms-date-styling' into wip/all-pr-20…
MattOz-CDS Feb 9, 2022
cc02aec
Merge branch '1.x' into wip/all-pr-2021-10-20
Adnan-cds Feb 10, 2022
5e78b4d
Add media query and selectors
cjstevens78 Feb 14, 2022
7ef75a7
Merge remote-tracking branch 'origin/fix/3-non-existent-php-interface…
Adnan-cds Feb 25, 2022
072b3c3
Merge pull request #16 from localgovdrupal/feature/date-validation
Adnan-cds Mar 11, 2022
c3726a3
Removed redundant function and applied coding standard
MattOz-CDS Mar 19, 2022
18275ce
Merge branch 'feature/localgov-forms-date-styling' into wip/all-pr-20…
MattOz-CDS Mar 21, 2022
fd54bcd
Chore: Deleting unneeded config schema.
Adnan-cds Mar 25, 2022
c1b8ea9
Feature: Config for manual address entry.
Adnan-cds Mar 25, 2022
528d7b1
Feature: Conditional display of Manual address entry button.
Adnan-cds Mar 25, 2022
14273d6
Test: Manual address entry button.
Adnan-cds Mar 28, 2022
143ea9b
Test: Deprecated code usage fixes.
Adnan-cds Mar 28, 2022
16bced4
Merge pull request #19 from localgovdrupal/feature/9-cant-find-the-ad…
Adnan-cds Mar 28, 2022
7ebea9b
Added validation above input field
MattOz-CDS Apr 28, 2022
d21c8eb
Corrected comment typo
MattOz-CDS Apr 29, 2022
47ebb2e
Fixed coding standard error
MattOz-CDS May 12, 2022
efc3002
Fixed coding standard error in libraries yaml
MattOz-CDS May 12, 2022
0fab376
Merge pull request #21 from localgovdrupal/feature/date-styling-and-v…
Adnan-cds May 13, 2022
8e43465
Added the localgov date field required error class
MattOz-CDS May 20, 2022
8c6abfa
Added the localgov date field required error class
MattOz-CDS May 20, 2022
c94ebe9
Merge branch '1.x' into feature/date-styling-and-validation
MattOz-CDS May 23, 2022
a38a6b3
Removed redundant validation contraint
MattOz-CDS May 26, 2022
8585d6b
Added date time preprocess to achieve theme override
MattOz-CDS May 26, 2022
5fb1e99
Added amd amended if condition
MattOz-CDS May 26, 2022
4378a76
Coding standard fix - added comment
MattOz-CDS May 26, 2022
607bdfa
Removed unneeded function
MattOz-CDS May 27, 2022
38e1a08
Added a check to see thatform element is a localgov form date element
MattOz-CDS May 27, 2022
40988c4
Removed classes from classList contains function
MattOz-CDS May 27, 2022
246accc
Removed redundant twig templates
MattOz-CDS May 27, 2022
b2e6f30
Removed commented code
MattOz-CDS May 27, 2022
7048cd4
Removed classes from classList contains function
MattOz-CDS May 27, 2022
6c2c81e
Removed unneeded theme function
MattOz-CDS May 27, 2022
d28e7b4
Added theme wrapper declaration
MattOz-CDS May 27, 2022
e3d15ad
Amended if condition
MattOz-CDS May 27, 2022
29e4863
Added date styling fix
MattOz-CDS May 27, 2022
5dd5a81
Removed js that moved the error message above form inpuut
MattOz-CDS Jun 7, 2022
5204af2
Removed reference to js from localgov_forms.libraries.yml
MattOz-CDS Jun 7, 2022
04e9d7d
Updated workflow
MattOz-CDS Jun 23, 2022
a9eee6a
Coding Standards fix
MattOz-CDS Jun 23, 2022
f9bd92b
Coding standards: Resolved deprecation notice.
Adnan-cds Aug 1, 2022
a5926eb
Fix: Non-numeric date handling for PHP 8.x.
Adnan-cds Aug 1, 2022
5361b4c
Fix: Non-numeric date handling for PHP 8.x.
Adnan-cds Aug 1, 2022
c199a9f
Merge branch 'wip/all-pr-2021-10-20' into feature/date-styling-and-va…
Adnan-cds Aug 4, 2022
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
88 changes: 60 additions & 28 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
name: Test LocalGov Drupal
##
# Managed by https://github.com/localgovdrupal/github_workflow_manager
---
name: Test localgovdrupal/localgov_forms drupal-module

on:
push:
Expand All @@ -8,33 +11,43 @@ on:
branches:
- '1.x'

env:
LOCALGOV_DRUPAL_PROJECT: localgovdrupal/localgov_forms
LOCALGOV_DRUPAL_PROJECT_PATH: web/modules/contrib/localgov_forms

jobs:

build:
name: Install LocalGov Drupal
runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
include:
- localgov-version: "2.x"
drupal-version: "~9.1"
php-version: "7.4"
localgov-version:
- '2.x'
drupal-version:
- '~9.3'
php-version:
- '7.4'
- '8.1'

steps:

- name: Save git branch and git repo names to env if this is not a pull request
if: github.event_name != 'pull_request'
run: |
echo "GIT_BASE=${GITHUB_REF#refs/heads/}" >> $GITHUB_ENV
echo "GIT_BRANCH=${GITHUB_REF#refs/heads/}" >> $GITHUB_ENV
echo "GIT_REPO=${GITHUB_REPOSITORY}" >> $GITHUB_ENV
echo "HEAD_USER=localgovdrupal" >> $GITHUB_ENV

- name: Save git branch and git repo names to env if this is a pull request
if: github.event_name == 'pull_request'
run: |
echo "GIT_BASE=${GITHUB_BASE_REF}" >> $GITHUB_ENV
echo "GIT_BRANCH=${GITHUB_HEAD_REF}" >> $GITHUB_ENV
echo "GIT_REPO=${{ github.event.pull_request.head.repo.full_name }}" >> $GITHUB_ENV
export HEAD="${{ github.event.pull_request.head.label }}"
echo "HEAD_USER=${HEAD%%:*}" >> $GITHUB_ENV

- name: Set composer branch reference for version branches
if: endsWith(github.ref, '.x')
Expand Down Expand Up @@ -74,11 +87,18 @@ jobs:
composer --working-dir=./html require --no-install drupal/core-recommended:${{ matrix.drupal-version }} drupal/core-composer-scaffold:${{ matrix.drupal-version }} drupal/core-project-message:${{ matrix.drupal-version }} drupal/core-dev:${{ matrix.drupal-version }}
composer --working-dir=./html install

- name: Obtain the test target from the repo that triggered this workflow
- name: Obtain the test target using Composer
if: env.HEAD_USER == 'localgovdrupal'
run: |
composer --working-dir=html config repositories.1 vcs git@github.com:${GIT_REPO}.git
composer --working-dir=html config repositories.1 vcs git@github.com:${LOCALGOV_DRUPAL_PROJECT}.git
composer global config github-oauth.github.com ${{ github.token }}
composer --working-dir=./html require --with-all-dependencies localgovdrupal/${{ github.event.repository.name }}:"${COMPOSER_REF} as ${LATEST_RELEASE}"
composer --working-dir=./html require --with-all-dependencies ${LOCALGOV_DRUPAL_PROJECT}:"${COMPOSER_REF} as ${LATEST_RELEASE}"

- name: Obtain the test target using Git
if: env.HEAD_USER != 'localgovdrupal'
uses: actions/checkout@v2
with:
path: ${{ env.LOCALGOV_DRUPAL_PROJECT_PATH }}

phpcs:
name: Coding standards checks
Expand All @@ -88,12 +108,16 @@ jobs:
strategy:
fail-fast: false
matrix:
include:
- localgov-version: "2.x"
drupal-version: "~9.1"
php-version: "7.4"
localgov-version:
- '2.x'
drupal-version:
- '~9.3'
php-version:
- '7.4'
- '8.1'

steps:

- name: Cached workspace
uses: actions/cache@v2
with:
Expand All @@ -105,12 +129,12 @@ jobs:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '7.4'
php-version: ${{ matrix.php-version }}

- name: Run coding standards checks
run: |
cd html
./bin/phpcs -p ./web/modules/contrib/localgov_forms
./bin/phpcs -p ${LOCALGOV_DRUPAL_PROJECT_PATH}

phpstan:
name: Deprecated code checks
Expand All @@ -120,12 +144,16 @@ jobs:
strategy:
fail-fast: false
matrix:
include:
- localgov-version: "2.x"
drupal-version: "~9.1"
php-version: "7.4"
localgov-version:
- '2.x'
drupal-version:
- '~9.3'
php-version:
- '7.4'
- '8.1'

steps:

- name: Cached workspace
uses: actions/cache@v2
with:
Expand All @@ -137,13 +165,12 @@ jobs:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '7.4'
php-version: ${{ matrix.php-version }}

- name: Run deprecated code checks
run: |
cd html
./bin/phpstan analyse -c ./phpstan.neon ./web/modules/contrib/localgov_forms

./bin/phpstan analyse -c ./phpstan.neon ${LOCALGOV_DRUPAL_PROJECT_PATH}
phpunit:
name: PHPUnit tests
needs: build
Expand All @@ -152,12 +179,16 @@ jobs:
strategy:
fail-fast: false
matrix:
include:
- localgov-version: "2.x"
drupal-version: "~9.1"
php-version: "7.4"
localgov-version:
- '2.x'
drupal-version:
- '~9.3'
php-version:
- '7.4'
- '8.1'

steps:

- name: Clone Drupal container
uses: actions/checkout@v2
with:
Expand All @@ -178,5 +209,6 @@ jobs:
- name: Run PHPUnit tests
run: |
mkdir -p ./html/web/sites/simpletest && chmod 777 ./html/web/sites/simpletest
sed -i "s#http://localgov.lndo.site#http://drupal#" ./html/phpunit.xml.dist
docker exec -t drupal bash -c 'chown docker:docker -R /var/www/html'
docker exec -u docker -t drupal bash -c "cd /var/www/html && ./bin/paratest --processes=4"
docker exec -u docker -t drupal bash -c "cd /var/www/html && ./bin/paratest --processes=4 ${{ env.LOCALGOV_DRUPAL_PROJECT_PATH }}"
20 changes: 0 additions & 20 deletions config/schema/localgov_forms.geocoder.schema.yml

This file was deleted.

15 changes: 15 additions & 0 deletions js/address_change.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@
// Reset the form.
resetButton.click(function () {
resetAddressLookUpForm(addressLookupElement, $(this), 'hard');

// Hide manual entry button if asked for.
if (typeof drupalSettings.centralHub.isManualAddressEntryBtnAlwaysVisible !== 'undefined' && drupalSettings.centralHub.isManualAddressEntryBtnAlwaysVisible) {
var manualButton = addressLookupElement.parent().find('.js-manual-address');
manualButton.show();
}
});

// Append the reset button.
Expand All @@ -30,6 +36,7 @@

/**
* Reset Address Lookup Form.
*
* @param {jQuery} addressLookupElement
* Address lookup element.
* @param {jQuery} resetButton
Expand Down Expand Up @@ -149,6 +156,8 @@
var selectList = selectListContainer.find('.js-address-select');
var error = selectListContainer.find('.js-address-error');
var resetButton = addressLookupElement.find('.js-reset-address');
var manualButton = addressLookupElement.find('.js-manual-address');
var manualAddressContainer = addressLookupElement.find('+ .js-address-entry-container');
var ajaxProgressElement = addressLookupElement.find('.ajax-progress');

// This ajac was either not initiated by the address lookup,
Expand All @@ -157,6 +166,12 @@
return;
}

// Unhide the manual entry button only when manual address entry fields
// are hidden.
if (typeof settings.centralHub.isManualAddressEntryBtnAlwaysVisible !== 'undefined' && !settings.centralHub.isManualAddressEntryBtnAlwaysVisible && manualAddressContainer.is(':hidden')) {
manualButton.show();
}

// If there has been a search.
if ((selectList.find('option').length > 0 && searchElement.val().length > 0) || error.length > 0) {
searchButton.removeClass('js-searching');
Expand Down
28 changes: 19 additions & 9 deletions js/address_select.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
(function ($, Drupal) {

/**
* Add manual entry button
* Adds manual entry button.
*
* @param {jQuery} centralHubElement
* Centralhub address element.
*/
Expand All @@ -29,28 +30,35 @@
}

/**
* Hide manual address form
* Hide manual address form.
*
* @param {jQuery} centralHubElement
* Central hub address lookup element.
* @param {String} type
* 'soft' = Do not clear the address values.
* (used when an address is selected)
* 'hard' = Clear the address values.
* @param {Object} settings
* drupalSettings.
*/
function hideManualAddress(centralHubElement, type) {
function hideManualAddress(centralHubElement, type, settings) {
var manualAddressContainer = centralHubElement.find('.js-address-entry-container');
var manualButton = centralHubElement.find('.js-manual-address');
var addressSelectContainer = centralHubElement.find('.js-address-select-container');
manualAddressContainer.addClass('hidden');
if (type == 'hard') {

if (type == 'hard') {
// Clear all values.
manualAddressContainer.find('input').val('');

// Trigger change events so UPRN and extra fields are cleared.
manualAddressContainer.find('input').first().trigger('change');
}
manualButton.removeClass('hidden');

// Hide manual entry button if asked for.
if (typeof settings.centralHub.isManualAddressEntryBtnAlwaysVisible !== 'undefined' && !settings.centralHub.isManualAddressEntryBtnAlwaysVisible) {
manualButton.hide();
}
}

/**
Expand All @@ -67,7 +75,7 @@
var addressError = addressSelectContainer.find('.js-address-error');
manualAddressContainer.removeClass('hidden');
// manualAddressContainer.find('input').val('');
manualButton.addClass('hidden');
manualButton.hide();
// addressSelectContainer.addClass('hidden');
// addressSelect.val('0');
// Clear the search element when entering a manual address.
Expand Down Expand Up @@ -171,7 +179,7 @@
showManualAddress(centralHubElement);
} else if ($(this).val() == 0) {
// If choosing the empty option, clear out the address fields.
hideManualAddress(centralHubElement, 'hard');
hideManualAddress(centralHubElement, 'hard', drupalSettings);
}
};

Expand Down Expand Up @@ -202,15 +210,17 @@
$('.js-webform-type-localgov-webform-uk-address', context).once('localgov-address-webform').each(function () {
var centralHubElement = $(this);
addManualEntryButton(centralHubElement);

// Hide the manual address element, if it has no values.
if (!isManualAddressEntered(centralHubElement)) {
hideManualAddress(centralHubElement, 'soft');
hideManualAddress(centralHubElement, 'soft', settings);
}

// centralHubElement.find('.js-address-searchstring').change(function() {
// hideManualAddress(centralHubElement, 'hard');
// });
centralHubElement.find('.js-reset-address').click(function () {
hideManualAddress(centralHubElement, 'hard');
hideManualAddress(centralHubElement, 'hard', settings);
});
hideAddressSearchErrors(centralHubElement);
});
Expand Down
4 changes: 2 additions & 2 deletions localgov_forms.module
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
* Hook implementations.
*/

module_load_include('inc', 'webform', 'includes/webform.theme.template');

/**
* Implements hook_theme().
*/
Expand All @@ -29,6 +27,8 @@ function localgov_forms_theme() {
*/
function template_preprocess_localgov_forms_uk_address(array &$variables) {
// Here you can get the composite element and alter it.
Drupal::moduleHandler()->loadInclude('webform', 'inc', 'includes/webform.theme.template');

_template_preprocess_webform_composite($variables);
}

Expand Down
40 changes: 40 additions & 0 deletions modules/localgov_forms_date/css/date.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
.localgov-forms-date {
display: flex;
flex-wrap: wrap;
}

.localgov-forms-date div[class*="-day"] {
margin-left: 0em;
flex: 1;
max-width: 100%;
margin-top: 0.5em;
margin-right: 0.5em;
}

.localgov-forms-date div[class*="-month"] {
flex: 2;
margin: 0.5em;
max-width: 100%;
}

.localgov-forms-date div[class*="-year"] {
flex: 3;
max-width: 100%;
margin: 0.5em;
}

.localgov-forms-date > .form-item--error-message {
flex: 0 0 100%;
}

@media screen and (min-width: 64rem) {
.localgov-forms-date div[class*="-day"] {
max-width: 6%;
}
.localgov-forms-date div[class*="-month"] {
max-width: 6%;
}
.localgov-forms-date div[class*="-year"] {
max-width: 9%;
}
}
5 changes: 5 additions & 0 deletions modules/localgov_forms_date/localgov_forms_date.libraries.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
localgov_forms_date:
version: VERSION
css:
theme:
css/date.css: {}
Loading