Open jjones646 opened 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.
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.
/submit/part
.Part
is created from the client's content.
part_num
variable is set directly from the given part_num
.location
is checked against the location from the database. If the submitted location is different from what is in the database, the object's location member is set from the given input after converting to upper case characters.description
is checked against the description from the database. If the submitted description is different from what is in the database AND the submitted description is not "", the object's description member is set from the given input after converting to lower case characters.name
is checked against the name from the database. If the submitted name is different from what is in the database, the object's name member is set from the given input directly.category
is checked against the category from the database. If the submitted category is different from what is in the database, the object's category is set from the given input after converting to lower case characters.datasheet
is checked against the datasheet from the database. If the submitted datasheet is different from what is in the database, the object's datasheet is set from the given datasheet directly.attribute
is checked against the database's data.attribute
has an identical name
AND value
to an entry already in the database for that part_id, it is discarded from being added.bag
is checked against the database's data.bag
has an identical barcode
AND quantity
to an entry already in the database for that part_id, it is discarded from being added.name
, location
, category
, and datasheet
can be updated for a part through the add parts interface.part_num
can not be changed (for typos).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.
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
.
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.
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.