Skip to content

OBPIH-6112 Add attributes section with inputs (fixes after QA)#4535

Merged
awalkowiak merged 7 commits intofeature/product-supplier-list-redesignfrom
OBPIH-6112-2
Mar 12, 2024
Merged

OBPIH-6112 Add attributes section with inputs (fixes after QA)#4535
awalkowiak merged 7 commits intofeature/product-supplier-list-redesignfrom
OBPIH-6112-2

Conversation

@alannadolny
Copy link
Collaborator

No description provided.

Comment on lines 12 to 13
query += " join a.entityTypeCodes etc where etc = :entityTypeCode and active = :active"
argumentsList += [entityTypeCode: entityTypeCode, active: active]
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wasn't sure how I should deal with the active property separately from entityTypeCode here, because the syntax of this query forced me to append the active in the where clause

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@alannadolny one minor thing for now, if you have above select a from Attribute a, and you use it in join as join a.entityTypeCodes then please use also a here as and a.active = :active for clarity.

@alannadolny
Copy link
Collaborator Author

I am marking this PR as a draft, to wait for Manon's response to proposed changes from Katarzyna.

@alannadolny alannadolny marked this pull request as draft March 7, 2024 11:52
@alannadolny alannadolny marked this pull request as ready for review March 11, 2024 15:54
if (entityTypeCode) {
query += " join a.entityTypeCodes etc where etc = :entityTypeCode"
argumentsList += [entityTypeCode: entityTypeCode]
query += " join a.entityTypeCodes etc where etc = :entityTypeCode and a.active = :active"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

by doing it like this, if you don't provide entityTypeCode, you would not include the active neither (which is supposed to be true by default).

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if we suppose to have a default value for active we could do it like (pseudocode, check if it works/adjust it)

String query = "select a from Attribute a"
String whereQuery = "where a.active = :active"
Map<String, String> argumentsList = [:]

if (entityTypeCode) {
        argumentsList += [entityTypeCode: entityTypeCode]
        query += " join a.entityTypeCodes etc"
        whereQuery += " and etc = :entityTypeCode"
}
argumentsList.active = active
query += whereQuery

return Attribute.executeQuery(query, argumentsList)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

<div>
<TextInput
required
title={{ id: '', defaultMessage: 'Other' }}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should the id be empty?

<TextInput
required
title={{ id: '', defaultMessage: 'Other' }}
errorMessage={inputValue === '' && translate(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what if inputValue would be null? Why don't we want to validate it then?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the value is null, we are treating the input as not touched previously

<Button
disabled={!inputValue}
defaultLabel="Confirm"
label=""
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should it be empty here and in the button above?

if (entityTypeCode) {
query += " join a.entityTypeCodes etc where etc = :entityTypeCode"
argumentsList += [entityTypeCode: entityTypeCode]
query += " join a.entityTypeCodes etc where etc = :entityTypeCode and a.active = :active"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can add a form with validation schema on this modal and

setValue(`attributes.${selectedAttribute?.id}`, { id: attribute?.id, value, label: value });

on form submit.
This will require a little more code but is probably the right approach
cc @kchelstowski

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, it is probably the right approach, but I think it's a little overkill to use a new hook and new validation schema to handle the one input with a text value, with validation only for the presence/absence of the entered value.

Comment on lines 29 to 33
const setAttributeValue = (attribute, value) => () => {
setValue(`attributes.${selectedAttribute?.id}`, { id: attribute?.id, value, label: value });
setInputValue(null);
close();
};
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this doesn't have to be a double callback

Suggested change
const setAttributeValue = (attribute, value) => () => {
setValue(`attributes.${selectedAttribute?.id}`, { id: attribute?.id, value, label: value });
setInputValue(null);
close();
};
const setAttributeValue = () => {
setValue(`attributes.${selectedAttribute?.id}`, { id: selectedAttribute?.id, value, label: inputValue });
setInputValue(null);
close();
};

am I wrong?

@awalkowiak awalkowiak merged commit 2bfae06 into feature/product-supplier-list-redesign Mar 12, 2024
@awalkowiak awalkowiak deleted the OBPIH-6112-2 branch March 12, 2024 12:00
awalkowiak pushed a commit that referenced this pull request Mar 12, 2024
* OBPIH-6112 Add validation for empty strings and add filtering for active attributes

* OBPIH-6112 Add new translations

* OBPIH-6112 Add new props and create variables for new modal

* OBPIH-6112 Add new modal

* OBPIH-6112 Handle attribute without options and allow Other

* OBPIH-6112 Change query in AttributeService

* OBPIH-6112 Changes after review
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants