Skip to content

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

@armahillo

Description

@armahillo

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.

Metadata

Metadata

Assignees

Labels

CRITICALThis issue rolled a natural 20 and needs to be addressed with high priorityIn Progressrefactor

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions