Skip to content

Commit

Permalink
fix(FSADT1-848): fixing external form style (#568)
Browse files Browse the repository at this point in the history
* fix: fixing progress state when error

* fix: fixing error notification

Fixing error notification below progress indication.

* fix: fixing dropdown

* fix: fixing multi select

* chore: updating stubs to add more addresses

* fix: fixing dropdown not changing when selection change

* feat: add formErrors variable

* chore: redoing css changes - Part #1

* feat: display address extra errors

* feat: move extra errors to the error component

* chore: redoing css changes - Part #2

* feat: replace formErrors argument with notification approach

* feat: scroll to new contact

* feat: add callback argument to useFocus

* feat: make the bindings to create and scroll to new contact

* chore: minor adjusments on useFocus

* chore: redoing css changes - Part #3

* chore: redoing css changes - Part #4

* test: test the validation function and the error component

* fix: update contactType value on select

* test: ignore already valid location

* test: remove outdated test

* feat: add parameter for the shadow directive

* feat: display progress indicator vertically

Also adds some changes for displaying it horizontally.

* FSADT1-868: Allowed special characters. Done olnly in the Frontend as the Backend was already allowing special charactes.

* test: add getMany command

* test: add progress indicator tests

* fixed inline notification colors

* Removed wrong style

* Added property needed

* feat: show logout modal

* refactor: unify code for the logout button in different sizes

* feat: show help modal

* feat: use media query instead of outerWidth to determine screen size

* Removed class that was causing issues with the logout button

* Revert "Removed class that was causing issues with the logout button"

This reverts commit 827e496.

* Fixed logout button

* feat: adjust header buttons

* Fixed mask issue with the postal code

* Renamed some files before refactoring code

* no message

* Made code reviews

* chore: remove console.log

* fix: prevent an older request from overwriting the results

* Made requiered changes

* Removed repeatead code

* Removed unneeded setting

* fix: do not always block response from older request

It should be allowed when no newer request was yet responded.

* chore: use simple counter to generate requestId

* fix: init fetching

* test: fix test

* Fixed file

* Added javadoc comment as per requested by SonarCloud

* docs: improve comment

* feat: adjust header logo and buttons

* feat: adjust header spaces and breakpoints

* chore: use date milliseconds as id

* fix: fix build issue

* fix: prevent error in the workflow

* fix: attempt to fix tests in the workflow

* fix: remove package from optimizeDeps

As an attempt to prevent error in the workflow.

* refactor: requested changes from review

* Refactored code - Part #1

* Made code reviews

* Formatted and beautified code

* style: small changes to code style

* chore: fix code linter

* Refactored code - Part #1.1

* fix: Fixed sonarcloud security hotspot issue

* fix: Fixed security hotspot

* Refactored code - Part #2

* Refactored code - Part #2.1

* fix: fix header small screen

* fix: attempt to fix side effect in the workflow

* chore: submitting small changes

* fix(FSADT1-884): fixing steps being enable

- adjusted the steps to be disable by default
- only enable if valid and only for the next step

* chore: sorting import

* fix(FSADT1-887): fixing typo on step 4

* fix(FSADT1-889): fixing font style

* fix: Fixed security hotspot and improved wording

* fix: Fixed security hotspot

* fix(FSADT1-888): fixing spacing between radio buttons

* Trying a different approach to solve the security hotspot issue

* fix(FSADT1-892): fixing submission page

* Trying a different approach to solve the security hotspot issue #2

* fix(FSADT1-894): fixing field spacing and width

* fix(FSADT1-891): fixing modal spacing

* fix(FSADT1-889): fixing notification body content

* fix(FSADT1-890): fixing component alignment

* fix: Fixed security hotspot

* fix: Fixed security hotspot

* Made code reviews

* Removed unused variable

* Refactored code and made code reviews

* feat: adjust margins

* fix(FSADT1-884): removing navigation link

* Made code reviews

* fix: header height

* chore: replace mock e-mail from .local to .com

* fix: do not pre-validate current step

* feat: replace margin with padding

* FSADT1-899: Removed unneeded validation

* ci: updating trivy to fix issues

* no message

* no message

* Tried to skip SonarCloud validation

* Skipped SonarCloud validation

* chore: adding us address stub data

* fix(FSADT1-884): fixing subtitle style

* fix: autocomplete after changing country

* fix: fix subtitle style for vertical progress indicator

* fis(FSADT1-894): fixing style for inline and text

* Made code reviews

* FSADT1-879

* - Made code reviews
- Removed unused code

* Made code reviews

* Made code reviews

* Made improvement

* feat: clear text displayed on combo-box

* fix: clear text displayed on combo-box

Without using any private properties from the component.

* refactor: move iteration props

* fix: fix link to bceid

* chore: remove unused import

* fix: remove placeholders on country and province

* fix: fix casing for Business information

* fix: fix doc coment closing

For some reason this was messing the code displayed in the Chrome browser
sources.

* fix: conditions used on postalCode validations

* chore: fix VS Code resolution for source and test files

By fixing the test configuration and eliminating a conflict with the app
one.

* test: use a new query command after a click

Since it's unsafe to chain after a click.

* test: force click button

* fix: prevent completing business step with invalid data

* fix: prevent fetching for name "undefined"

* test: wait before clicking the option

* Made a minor change for internal emails after a conversation with Andrew.

* style: add semi-colon as requested after review

* style: add the dollar signal to all conditions

* feat: turn the dollar signal required

* Made code reviews

* Made more code reviews

* Made this to prevent perisisting information mutliple times

* test: wait for the option's inner element to become visible

* fix: emit error always for text-input

Instead of only when the error changes.

* fix: update error status on Address step text fields

So to be able to properly make it valid later when it gets resolved.

* fix: update Street address empty status properly

* test: emit empty true when contents is empty

* docs: refer specific Jira issue

* fix:
- Renamed variable and added an new property to make it more generic
- Beautified code

* fix:
- Renamed variable and added an new property in test file

* fix: Made code reviews and removed unneeded prop I added

* fix: update error status on Contacts step text fields

So to be able to properly make it valid later when it gets resolved.

* test: emit valid events properly

* no message

* fix:
- Renamed variable with a proper name
- Made code reviews

* docs: improve comment

* docs: improve comment

* fix: synchronize dropdown value

* fix: get country validation

* fix: validate after changed from outside

* test: define some tests to be implemented

* test: province gets cleared

* docs: add issue references

* test: revalidates when changed from outside

Also fixes another test.

* Fast commit to switch branches

* fix: validate the item code instead of its name

* test: update tests

* fix: remove meaningless tag

* fix: do not display field as invalid

When the field is empty and user didn't have a chance to add its value yet.
For example, when it gets auto-changed as a result of changing another field.

* Fast commit to switch branches

* fix: Made code reviews and added birth date field

* fix: Fixed logo for small screens

* test: do not emit error in specific situation

* feat: use variable to tell if selection was a user event

* test: update tests

* chore: use variable to tell if the change was a user event

* test: update test

* feat: add tooltip to button Next

* fix: proceed applying part to next level

Regardless of current element already having a part attribute.

* chore: adjust combo-boxes focus outline

* Fast commit to switch branches

* Modified gitignore

* feat:
- Removed unused code
- Made code reviews

* feat:
- Made more code reviews

* Fast commit to switch branches

* Renamed class with a more generic name

* Fast commit to switch branches

* Made more code reviews

* Fast commit to switch branches

* Pushed common functions

* Fast commit to switch branches

* fix: fix AutoComplete events

- fix empty value;
- always emit the error;
- do not validate at each key pressed.

* test: add empty and error tests

* fix: fix initial empty value

* removed unneeded key

* fix: allow selecting item identical to the typed value

* test: update test

* Fast commit to switch branches

* test: add address group test

* Fast commit to switch branches

* test: fix import

* feat: show loading icon on auto-complete fields

* feat: allow some time before showing the loading icon

* chore: add helper text

* fix: validate multi-select field

* fix: remove deleted address from contacts

* Fast commit to switch branches

* chore: small fix to remove extra spaces on the first step

* - Made code reviews
- Improve code and made it more genetic

* Made code reviews

* FSADT1-928

* Fixed code smell issues

* Fixed code smell issues

* Create unit test

* chore: forcing update

* Changed annotation

* Renamed file as it had a typo

* chore: apply custom directives to unit tests

* Fixed some smell issues

* test: attempt to fix test on github actions

* Made more code reviews

* Made more code reviews

* chore: adjust Application submitted breakpoints

* chore: adjust margins on Application submitted

* fix: adjust header buttons breakpoint

Import missing variable.

* Added more coverage

* Beautified CSS file

---------

Co-authored-by: Fernando Terra <[email protected]>
Co-authored-by: Maria Martinez <[email protected]>
Co-authored-by: Maria Martinez <[email protected]>
  • Loading branch information
4 people committed Oct 23, 2023
1 parent d3b0fce commit 09952b3
Show file tree
Hide file tree
Showing 63 changed files with 2,793 additions and 2,077 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -570,4 +570,5 @@ frontend/cypress/videos/*
reports/
frontend/reports/

**/sonar-report.xml
**/sonar-report.xml
**/config/*.jks
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
[![MIT License](https://img.shields.io/github/license/bcgov/nr-forest-client.svg)](/LICENSE.md)
[![Lifecycle](https://img.shields.io/badge/Lifecycle-Experimental-339999)](https://github.com/bcgov/repomountie/blob/master/doc/lifecycle-badges.md)


The nr-forest-client is a node.js application built with [Vue.js](https://vuejs.org) in typescript as frontend, [Spring boot java](https://spring.io/projects/spring-boot#learn) as backend, postgres and oracle for database, integrated with the [greenfield-template](https://github.com/bcgov/greenfield-template) to automate the process for testing, security scanning, code quality checking, image building and deploying.

## Frontend
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@
import ca.bc.gov.app.dto.client.ClientNameCodeDto;
import ca.bc.gov.app.dto.client.ClientSubmissionDto;
import ca.bc.gov.app.dto.client.ClientValueTextDto;
import ca.bc.gov.app.dto.client.CodeNameDto;
import ca.bc.gov.app.dto.cognito.AuthResponse;
import ca.bc.gov.app.dto.cognito.AuthResponseDto;
import ca.bc.gov.app.dto.legacy.ForestClientDto;
import lombok.extern.slf4j.Slf4j;
Expand Down Expand Up @@ -68,6 +70,7 @@
ClientNameCodeDto.class,
ClientSubmissionDto.class,
ClientValueTextDto.class,
CodeNameDto.class,
BcRegistryAddressDto.class,
BcRegistryBusinessAdressesDto.class,
BcRegistryBusinessDto.class,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package ca.bc.gov.app.controller.client;

import ca.bc.gov.app.dto.client.ClientAddressDto;
import ca.bc.gov.app.dto.client.ClientNameCodeDto;
import ca.bc.gov.app.dto.client.CodeNameDto;
import ca.bc.gov.app.service.client.ClientAddressService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
Expand Down Expand Up @@ -45,14 +45,14 @@ public class ClientAddressController {
array = @ArraySchema(
schema = @Schema(
name = "NameCode",
implementation = ClientNameCodeDto.class
implementation = CodeNameDto.class
)
)
)
)
}
)
public Flux<ClientNameCodeDto> findPossibleAddresses(
public Flux<CodeNameDto> findPossibleAddresses(
@Parameter(description =
"The name or ISO 2 or 3 character code for the country to search in, defaults to CA",
example = "UK")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import ca.bc.gov.app.dto.bcregistry.ClientDetailsDto;
import ca.bc.gov.app.dto.client.ClientLookUpDto;
import ca.bc.gov.app.dto.client.ClientNameCodeDto;
import ca.bc.gov.app.dto.client.CodeNameDto;
import ca.bc.gov.app.dto.client.EmailRequestDto;
import ca.bc.gov.app.exception.NoClientDataFound;
import ca.bc.gov.app.service.client.ClientService;
Expand Down Expand Up @@ -40,17 +40,23 @@ public Mono<ClientDetailsDto> getClientDetails(@PathVariable String clientNumber
}

@GetMapping("/activeCountryCodes")
public Flux<ClientNameCodeDto> listCountries(
public Flux<CodeNameDto> listCountries(
@RequestParam(value = "page", required = false, defaultValue = "0")
Integer page,
@RequestParam(value = "size", required = false, defaultValue = "10")
Integer size) {
return clientService
.listCountries(page, size);
}

@GetMapping("/getCountryByCode/{countryCode}")
public Mono<Object> getCountryByCode(
@PathVariable String countryCode) {
return clientService.getCountryByCode(countryCode);
}

@GetMapping("/activeCountryCodes/{countryCode}")
public Flux<ClientNameCodeDto> listProvinces(
public Flux<CodeNameDto> listProvinces(
@PathVariable String countryCode,
@RequestParam(value = "page", required = false, defaultValue = "0")
Integer page,
Expand All @@ -61,13 +67,13 @@ public Flux<ClientNameCodeDto> listProvinces(
}

@GetMapping("/activeClientTypeCodes")
public Flux<ClientNameCodeDto> findActiveClientTypeCodes() {
public Flux<CodeNameDto> findActiveClientTypeCodes() {
return clientService
.findActiveClientTypeCodes(LocalDate.now());
}

@GetMapping("/activeContactTypeCodes")
public Flux<ClientNameCodeDto> listClientContactTypeCodes(
public Flux<CodeNameDto> listClientContactTypeCodes(
@RequestParam(value = "page", required = false, defaultValue = "0")
Integer page,
@RequestParam(value = "size", required = false, defaultValue = "10")
Expand Down

This file was deleted.

40 changes: 40 additions & 0 deletions backend/src/main/java/ca/bc/gov/app/dto/client/CodeNameDto.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package ca.bc.gov.app.dto.client;

import io.swagger.v3.oas.annotations.media.Schema;

/**
* The {@code CodeNameDto} class represents a simple data transfer object (DTO) that encapsulates
* a name and code for a specific object. It is used to transfer this information between different
* parts of an application.
* This class is annotated with Swagger annotations for generating API documentation. It provides
* a description and example JSON representation for the object it represents.
*
* <p>
* Example JSON representation:
* <pre>{@code
* {
* "code": "00000002",
* "name": "BAXTER"
* }
* }</pre>
* </p>
*
* @see Schema
*/
@Schema(
description = "A simple name and code object",
title = "NameCode",
example = """
{
"code": "00000002",
"name": "BAXTER"
}"""
)
public record CodeNameDto(
@Schema(description = "The code for that specific object", example = "00000002")
String code,

@Schema(description = "The name information for that specific object", example = "BAXTER")
String name
) {
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,11 @@ public class CountryCodeEntity extends ExpirableBaseEntity {
@NotNull
private Integer order;

public CountryCodeEntity(
@NotNull @Size(min = 2, max = 2) String countryCode,
@NotNull String description) {
this.countryCode = countryCode;
this.description = description;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
import ca.bc.gov.app.dto.client.AddressCompleteRetrieveListDto;
import ca.bc.gov.app.dto.client.AddressError;
import ca.bc.gov.app.dto.client.ClientAddressDto;
import ca.bc.gov.app.dto.client.ClientNameCodeDto;
import ca.bc.gov.app.dto.client.ClientValueTextDto;
import ca.bc.gov.app.dto.client.CodeNameDto;
import ca.bc.gov.app.exception.AddressLookupException;
import java.util.List;
import java.util.Map;
Expand Down Expand Up @@ -34,7 +34,7 @@ public ClientAddressService(
this.addressCompleteApi = addressCompleteApi;
}

public Flux<ClientNameCodeDto> findPossibleAddresses(
public Flux<CodeNameDto> findPossibleAddresses(
String country, Integer maxSuggestions, String searchTerm) {
log.info("Searching for address {} for country {}", searchTerm, country);
return
Expand Down Expand Up @@ -95,7 +95,7 @@ public Flux<ClientNameCodeDto> findPossibleAddresses(
})
.flatMapMany(Flux::fromIterable)
.filter(address -> "Retrieve" .equalsIgnoreCase(address.next()))
.map(address -> new ClientNameCodeDto(
.map(address -> new CodeNameDto(
address.id(),
String.format("%s %s", address.text().trim(), address.description().trim())
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
import ca.bc.gov.app.dto.client.ClientAddressDto;
import ca.bc.gov.app.dto.client.ClientContactDto;
import ca.bc.gov.app.dto.client.ClientLookUpDto;
import ca.bc.gov.app.dto.client.ClientNameCodeDto;
import ca.bc.gov.app.dto.client.ClientValueTextDto;
import ca.bc.gov.app.dto.client.CodeNameDto;
import ca.bc.gov.app.dto.client.EmailRequestDto;
import ca.bc.gov.app.dto.legacy.ForestClientDto;
import ca.bc.gov.app.exception.ClientAlreadyExistException;
Expand Down Expand Up @@ -57,14 +57,14 @@ public class ClientService {
* <p>The order is by description.</p>
*
* @param targetDate The date to be used as reference.
* @return A list of {@link ClientNameCodeDto}
* @return A list of {@link CodeNameDto}
*/
public Flux<ClientNameCodeDto> findActiveClientTypeCodes(LocalDate targetDate) {
public Flux<CodeNameDto> findActiveClientTypeCodes(LocalDate targetDate) {

return
clientTypeCodeRepository
.findActiveAt(targetDate)
.map(entity -> new ClientNameCodeDto(
.map(entity -> new CodeNameDto(
entity.getCode(),
entity.getDescription()
)
Expand All @@ -79,12 +79,33 @@ public Flux<ClientNameCodeDto> findActiveClientTypeCodes(LocalDate targetDate) {
*
* @param page The page number, it is a 0-index base.
* @param size The amount of entries per page.
* @return A list of {@link ClientNameCodeDto} entries.
* @return A list of {@link CodeNameDto} entries.
*/
public Flux<ClientNameCodeDto> listCountries(int page, int size) {
public Flux<CodeNameDto> listCountries(int page, int size) {
return countryCodeRepository
.findBy(PageRequest.of(page, size, Sort.by("order", "description")))
.map(entity -> new ClientNameCodeDto(entity.getCountryCode(), entity.getDescription()));
.map(entity -> new CodeNameDto(entity.getCountryCode(), entity.getDescription()));
}

/**
* Retrieves country information by its country code. This method queries the
* {@code countryCodeRepository} to find a country entity with the specified country code. If a
* matching entity is found, it is mapped to a {@code CodeNameDto} object, which encapsulates the
* country code and description. The resulting data is wrapped in a Mono, which represents the
* asynchronous result of the operation.
*
* @param countryCode The code of the country to retrieve information for.
* @return A Mono that emits the {@code CodeNameDto} object if a matching country is found, or an
* empty result if no match is found.
*
* @see CodeNameDto
* @see countryCodeRepository
*/
public Mono<Object> getCountryByCode(String countryCode) {
return countryCodeRepository
.findByCountryCode(countryCode)
.map(entity -> new CodeNameDto(entity.getCountryCode(),
entity.getDescription()));
}

/**
Expand All @@ -95,12 +116,12 @@ public Flux<ClientNameCodeDto> listCountries(int page, int size) {
* @param countryCode The code of the country to list provinces from.
* @param page The page number, it is a 0-index base.
* @param size The amount of entries per page.
* @return A list of {@link ClientNameCodeDto} entries.
* @return A list of {@link CodeNameDto} entries.
*/
public Flux<ClientNameCodeDto> listProvinces(String countryCode, int page, int size) {
public Flux<CodeNameDto> listProvinces(String countryCode, int page, int size) {
return provinceCodeRepository
.findByCountryCode(countryCode, PageRequest.of(page, size, Sort.by("description")))
.map(entity -> new ClientNameCodeDto(entity.getProvinceCode(), entity.getDescription()));
.map(entity -> new CodeNameDto(entity.getProvinceCode(), entity.getDescription()));
}

/**
Expand All @@ -109,12 +130,12 @@ public Flux<ClientNameCodeDto> listProvinces(String countryCode, int page, int s
*
* @param page The page number, it is a 0-index base.
* @param size The amount of entries per page.
* @return A list of {@link ClientNameCodeDto} entries.
* @return A list of {@link CodeNameDto} entries.
*/
public Flux<ClientNameCodeDto> listClientContactTypeCodes(int page, int size) {
public Flux<CodeNameDto> listClientContactTypeCodes(int page, int size) {
return contactTypeCodeRepository
.findBy(PageRequest.of(page, size))
.map(entity -> new ClientNameCodeDto(
.map(entity -> new CodeNameDto(
entity.getContactTypeCode(),
entity.getDescription()));
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,22 @@
package ca.bc.gov.app.service.client;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.mockito.Mockito.when;

import ca.bc.gov.app.extensions.AbstractTestContainerIntegrationTest;
import ca.bc.gov.app.dto.client.CodeNameDto;
import ca.bc.gov.app.entity.client.CountryCodeEntity;
import ca.bc.gov.app.repository.client.CountryCodeRepository;
import java.time.LocalDate;
import java.util.stream.Stream;
import lombok.extern.slf4j.Slf4j;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.MethodSource;
import org.mockito.Mock;
import org.springframework.beans.factory.annotation.Autowired;
import reactor.core.publisher.Mono;
import reactor.test.StepVerifier;

@Slf4j
Expand All @@ -18,6 +25,9 @@ class ClientServiceIntegrationTest extends AbstractTestContainerIntegrationTest

@Autowired
private ClientService service;

@Mock
private CountryCodeRepository countryCodeRepository;

@ParameterizedTest
@MethodSource("date")
Expand All @@ -29,6 +39,19 @@ void shouldListCodeAsExpected(LocalDate date) {
.expectNextCount(11)
.verifyComplete();
}

@Test
void testGetCountryByCode() {

CountryCodeEntity countryCodeEntity = new CountryCodeEntity("CA", "Canada");
CodeNameDto expectedDto = new CodeNameDto("CA", "Canada");

when(countryCodeRepository.findByCountryCode("CA")).thenReturn(Mono.just(countryCodeEntity));

Mono<Object> resultMono = service.getCountryByCode("CA");

StepVerifier.create(resultMono).expectNext(expectedDto).verifyComplete();
}

private static Stream<LocalDate> date() {
return
Expand Down
Loading

0 comments on commit 09952b3

Please sign in to comment.