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

559 GS1 codes #564

Merged
merged 35 commits into from
Feb 1, 2024
Merged

559 GS1 codes #564

merged 35 commits into from
Feb 1, 2024

Conversation

lache-melvin
Copy link
Collaborator

@lache-melvin lache-melvin commented Jan 31, 2024

Fixes #559
Fixes #548

Description

Adds add, view and delete capability for GS1 codes, with the restriction that the related PackSize node already exists.

View all GS1 codes:
Screenshot 2024-02-01 at 9 18 27 AM

Sorting the list e.g. by manufacturer is currently not supported, and searching is also not implemented. Unfortunately, I don't think its possible for us to sort or search the whole GS1 list by product, as DGraph requires those fields to be scalar types... if that search capability is desired in future, we could duplicate the entity data onto the GS1 node to be able to search on it.

Add modal searches existing pack size entities:
Screenshot 2024-02-01 at 9 19 04 AM

See number of related GS1s (is related a better word than linked? also GS1s or GTINs?) for a unit - lower nodes collapsed by default:
Screenshot 2024-02-01 at 9 19 45 AM

Lower nodes expandable if you want them to be:
Screenshot 2024-02-01 at 9 20 39 AM

Link takes you to a filtered view of GS1s for only that product:
Screenshot 2024-02-01 at 9 22 00 AM

Add modal PackSize options are filtered accordingly:
Screenshot 2024-02-01 at 9 23 46 AM

Tests:

  1. Tests have been added to cover changes introduced by this PR.
  • Tests OK.

@lache-melvin
Copy link
Collaborator Author

Support for viewing barcodes when unauthenticated added!

Copy link
Contributor

@jmbrunskill jmbrunskill left a comment

Choose a reason for hiding this comment

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

Looks awesome, heaps of work!

I tried to add a barcode and got this error

 Internal error: Failed to parse response: Error("invalid type: null, expected struct Entity", line: 1, column: 6409). The response body is: {"errors":[{"message":"Non-nullable field 'code' (type String!) was not present in result from Dgraph.  GraphQL error propagation triggered.","locations":[{"line":3,"column":3}],"path":

Will try to investigate further tomorrow to see what's gone wrong.


match result {
Some(data) => Ok(BarcodeCollection {
total_length: usize_to_u32(data.data.len()),
Copy link
Contributor

Choose a reason for hiding this comment

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

Probably should use the actual total/count from dgraph here since you have the first/offset, it won't return the right value when you have a limit on the results less than the total available records...

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 new_barcode.manufacturer.is_empty() {
return Err(ModifyBarcodeError::InternalError(
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
return Err(ModifyBarcodeError::InternalError(
return Err(ModifyBarcodeError::BadUserInput(

This is more a user error, similar for the others in validate

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@@ -74,6 +75,13 @@ type PropertyConfigurationItem {
url: String @dgraph(pred: "url")
}

type Barcode {
id: ID!
gtin: String! @id @dgraph(pred: "code") @search(by: [exact, trigram])
Copy link
Contributor

Choose a reason for hiding this comment

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

I like this using code in dgraph, kind of as our id look up.
Have created interaction_group_id and interaction_id in my other PR, but definitely complicates things a little bit...

useConfirmationModal,
} from 'frontend/common/src';

export const DeleteLinesDropdownItem = <T extends RecordWithId>({
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice! Like this component!

@@ -92,7 +92,7 @@ export const Site: FC = () => {
/>
}
/>
<Route path={'/details/:code'} element={<RedirectDetails />} />
<Route path={'/detail/:code'} element={<RedirectDetails />} />
Copy link
Contributor

Choose a reason for hiding this comment

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

Was this deliberate? I can't remember what the old link was like...

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Oh whoops didn't realise that made it in here... when we deployed the production version i realised the old links were /detail/:code, but we'd set up the redirect off /details... will do via separate PR for clarity 😎

const countChildBarcodes = (e: EntityData) => {
e.children?.forEach(c => {
count += c.barcodes.length;
countChildBarcodes(c);
Copy link
Contributor

Choose a reason for hiding this comment

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

Interesting that you can call a function you're creating as a const inside the function by the name. I guess it makes sense, but not obvious to me...

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... I suppose because it is defined above where it is called it all works out ok? It is a little funky though!

@lache-melvin
Copy link
Collaborator Author

Looks awesome, heaps of work!

I tried to add a barcode and got this error

 Internal error: Failed to parse response: Error("invalid type: null, expected struct Entity", line: 1, column: 6409). The response body is: {"errors":[{"message":"Non-nullable field 'code' (type String!) was not present in result from Dgraph.  GraphQL error propagation triggered.","locations":[{"line":3,"column":3}],"path":

Will try to investigate further tomorrow to see what's gone wrong.

Oh I had this issue yesterday viewing drug details on the 'loading in standard config' branch! I think I fixed it - have just merged develop in... if you know which product you tried to create the barcode for, would you mind trying again?

@jmbrunskill
Copy link
Contributor

Internal error: Failed to parse response: Error("invalid type: null, expected struct Entity",

It doesn't look to be related to barcodes at all, looks like we have problem with
Tetanus Toxoid Vaccine,64ed34bf in vaccines.csv or loader?

http://localhost:4201/browse/64ed34bf

Copy link
Contributor

@jmbrunskill jmbrunskill left a comment

Choose a reason for hiding this comment

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

Looks great! Couple of comments but merge away when you're ready.

@lache-melvin lache-melvin merged commit ca9f21b into develop Feb 1, 2024
1 check passed
@lache-melvin lache-melvin deleted the 559-gs1-codes branch February 1, 2024 21:28
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.

Support GS1 Codes Collapse nodes lower than the unit level
2 participants