Add material type-item associations
Description
Environment
Potential Workaround
is cloned by
relates to
Checklist
hideTestRail: Results
Activity

shale99 April 3, 2017 at 9:21 AM
- i am making a change here so that to update / delete a material type - you should send the material type code instead of the material type id. i am also blocking edits if the MT is being used by items

Matt Connolly March 30, 2017 at 12:32 PM
At the moment, storing the material type name instead of ID presents the following problem. If I ...
Create a material type (say, "Book")
Assign it to several items (so there are four items of the "Book" type)
and then try to delete the Book material type,
the operation fails because Book is in use. That's good!
But if I then
edit the "Book" type to have a different name (say, "Hardcover Book")
and try to delete that material type
the operation succeeds. The Book/Hardcover Book is now gone, but the items still have "Book" as a material type - one that no longer exists.

shale99 March 29, 2017 at 5:43 PMEdited
note that there is also a check that the code in the item actually exists in the material type table - if it does not - the insert (of the item) will fail

shale99 March 29, 2017 at 4:06 PM
Hi Matt
I think we are saving a code - the material type in my opinion will grow to contain more data. What is stored in the item itself is a key - book , audio, video, journal, article, dvd, etc...
This key can be used to look up more info about the material type (not that there is any yet , but there will be) from the material table as the key is a unique index in the material table.
The advantage is that no join is needed to join between the item and the material type - the code can be used for i18n translation as it is a descriptive code. The record may be displayed in many languages and there will be no reason to display the code - this would be the case as well if an actual value was in the item - it would need to be i18n'ed
Look at this as a unique descriptive code that has UIusage (i18n) , and backend usage (unique index for lookups)
Point two is correct - there is a check if the code exists in any items
Does that make sense?

Matt Connolly March 29, 2017 at 3:24 PM
I have a couple of questions about this that I was asking about, but maybe it makes more sense to ask them here to get more people involved. I'm wondering:
1) Why are keys for things like material type and location being stored in the item model by name instead of ID? It seems to me that that would cause problems if the name of a material type were changed after being assigned to one or more item records. (This relates to the issue Mike raises in STRIPES-282.)
2) Does Jakub's comment above indicate that attempting to delete a material type will fail if the type is attached to any item record? If not, how is this enforced?
Details
Assignee
Matt ConnollyMatt ConnollyReporter
Matt ConnollyMatt ConnollyLabels
Priority
P3Sprint
NoneTestRail: Cases
Open TestRail: CasesTestRail: Runs
Open TestRail: Runs
Details
Details
Assignee

Reporter

This splits off the scenario goals from LIBAPP-139 that pertain to associations between material types and items (as opposed to pure material type CRUDing)
Scenario
Given the Material type control
When a new Material type is created
Then:
It should display in the Material type menu on the Item details page (this will require change Material type to a dropdown menu on the item create and edit pages)
Scenario
Given the Material type control
When a new Material type is deleted
Then:
It should be removed from the Material type menu on the Item details page
Scenario
Given a Material type is assigned to an Item record
When delete is attempted
Then it should not be allowed (delete should be supressed however is easiest for now - disabled button, error message, whatever - we'll modify later)
Scenario
Given the Material type control
When a new Material type is edited
Then:
The edits should be reflected in the list of created Material types in Settings