RoboJackets / inventory-management

This tool is used by the Robocup Electrical subteam to document part information and location.
http://inventory.robojackets.org
13 stars 7 forks source link

Create interface for modifying a part's information #48

Open jjones646 opened 9 years ago

jjones646 commented 9 years ago

There is currently no way to modify information once it is committed to the database. When adding a part, the current PHP code checks for new information and updated quantities, but lacks major abilities for any further modifications.

This will most likely have to wait for authentication, but without an interface to edit part information (part number, attributes, barcodes, etc.), the inventory system probably won't last too long once we're no longer around.

I have had to edit some production database information (2 or 3 different times), and it is very tricky fixing that stuff through the phpMyAdmin interface. Having a streamlined interface for this would be far easier.

ryanstrat commented 9 years ago

This has kinda been done via the add parts interface. But the implementation is buggy with regards to attributes, since it will require some temporary tables to properly implement.

jjones646 commented 9 years ago

Yes, information can be modified through the add parts interface, but I have implemented quite a bit of validation checks when a part is submitted. Most of the end results worked out well, but there are a few quirks that are there now that I did not intend for.

I'll outline the steps that are taken when a part is submitted. It will be good to have for reference during this and will help me remember how I approached this when I did it a few months ago.

Server-side Operations for Add Part Interface:

This brings up a few notes after typing things out:

ryanstrat commented 9 years ago

Editing parts

Lets say, for example, that we build a new page for editing parts. you access it by clicking an edit button on each of the result cards. The edit interface would have to keep track of the part_ID, which is not typically handled at all client side. We could either create a new API endpoint or extend the existing one to have a different behavior if a part_ID is specified in the JSON object passed to the server.

Changing Attributes

If we want to properly update attributes, we need to take the updates set of attributes, put them into a temporary table, intersect the table with attributes. Then remove the NOT of the intersection of temp and attributes on attributes. This will leave the attributes table with only old attributes that exist in the new set. Then we find the new ones by performing the NOT of the intersection on the temp table and adding them to attributes.

jjones646 commented 9 years ago

I like the idea of adding a new API endpoint regarding the part_ID. There's potentially other areas that could take advantage of a part_ID endpoint that does not necessarily relate to modifying database information.

In regard to changing attributes, I think you just described the exact steps needed. Do you know of any other ways that it can be done? I don't believe there is actually a way to do it outside of SQL since the database is the only all-knowing-entity of the attribute/bag insert IDs. A PHP implementation would require an extensive algorithm that is just overkill here.