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

Clean up BarcodeItems resource in main area (non-admin) #593

Closed
18 of 19 tasks
armahillo opened this issue Oct 28, 2018 · 1 comment
Closed
18 of 19 tasks

Clean up BarcodeItems resource in main area (non-admin) #593

armahillo opened this issue Oct 28, 2018 · 1 comment
Assignees
Labels
CRITICAL This issue rolled a natural 20 and needs to be addressed with high priority In Progress refactor

Comments

@armahillo
Copy link
Collaborator

armahillo commented Oct 28, 2018

After discussing this extensively at the conference, here's the current Barcoding paradigm that I think we're going to use going forward:

Global Barcode Items

  • They are instances of BarcodeItem for which barcode_item.global? == true
  • These can only be created by SuperAdmins, but they are visible to all
  • They only ever point to CanonicalItem records (via the :barcodeable polymorphic association)
  • A single CanonicalItem may have multiple global BarcodeItems pointing to it ("Huggies 4T, 30ct", "Pampers 4T 30ct" and "Luvs 4T 30ct" would all point to the "4T" `)
  • These represent the "fall-through" barcode item values

"Local" Barcode items

  • They are instances of BarcodeItem for which barcode_item.global? == false
  • These can be created by anyone, but are scoped to the organization
  • They only ever point to Item records (via the :barcodeable polymorphic association)
  • A single Item can also have multiple BarcodeItems pointing to it, but the composite of :barcode_value + :organization_id must be unique (ie. a single organization cannot use the same barcode to point to multiple types)
  • These barcode values take precedence over globals because the user created them

Querying Barcodes

  • When an organization does a barcode lookup, it should return a single record, the first result of a set that is ranked by Local first, then Global
  • When there is only Global result (which map to a CanonicalItem), it will need to do a followup query to locate the oldest Item that the organization has that matches that CanonicalItem type (older results are more likely to be generic).
  • If nothing matches that, then there is no BarcodeItem defined for that item and it should raise a RecordNotFound and the controller should return a :404 status.

User Interface for Organizations (opining a bit here)

  • Remove the "Include barcodes that are globally available" filter
  • Only display Local barcodes in the organization namespace
  • Add the ability to filter by Base Item type (finish Tweak the Item / CanonicalItem association to use the partner_key trait instead of the integer key #588 first)
  • Remove the "Global" column from the organization namespace
  • Have "Add Another Barcode" display the barcode modal, if possible, and then refresh the table
  • Have a field to allow users to do barcode lookups from the BarcodeItems#index view -- boop a barcode and it filters to only show that result (Create a :by_value scope and then add it to the filters section)

User Interface for Admins

these are being moved over to #326 since they don't yet exist

  • Default view for Admin::BarcodeItems#index is global only (we will likely need to add will_paginate)
  • Filter on canonical item
  • Filter on "global?"
  • Filter on barcode value
  • Filter on organization
  • Add New Barcode for adding new Global barcodes (mapping to canonical items only)
  • Create a new action / view that creates a report of commonly used barcode values across multiple organizations

For "Clean up" we just need to audit these files to ensure they are in-line with the above behaviors:

/app/models/barcode_item.rb
/app/controllers/admin/barcode_items_controller.rb
/app/controllers/barcode_items_controller.rb
/app/views/admin/barcode_items/*
/app/views/barcode_items/*
/spec/controllers/admin/barcode_items_controller.rb
/spec/controllers/barcode_items_controller.rb
/spec/factories/barcode_items.rb
/spec/features/admin/barcode_items_spec.rb
/spec/features/barcode_items_spec.rb
/spec/models/barcode_item_spec.rb
/spec/support/barcode_helper.rb

Some of them may already be OK but we'll need to assess all of them to be sure.

@armahillo armahillo added refactor CRITICAL This issue rolled a natural 20 and needs to be addressed with high priority labels Oct 28, 2018
@armahillo armahillo added this to the Production Ready milestone Oct 28, 2018
@armahillo armahillo self-assigned this Oct 31, 2018
@armahillo
Copy link
Collaborator Author

Regarding:

When there is only Global result (which map to a CanonicalItem), it will need to do a followup query to locate the oldest Item that the organization has that matches that CanonicalItem type (older results are more likely to be generic).
If nothing matches that, then there is no BarcodeItem defined for that item and it should raise a RecordNotFound and the controller should return a :404 status.

I'm still mulling over the best place to put this method. I've considered BarcodeItem, Organization, and BarcodeItemsController so far. I can see pros and cons to each. Perhaps some hybrid solution?

Any thoughts on this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CRITICAL This issue rolled a natural 20 and needs to be addressed with high priority In Progress refactor
Projects
None yet
Development

No branches or pull requests

1 participant