Update the card modal to show flexible fields [2/2]
Icepool opened this issue · 3 comments
Purpose of the issue:
This issue relates to making flexible field data visible in the card modal.
Description of what flexible fields are:
These are extra dynamic fields that can be added to an artifact in TeamForge.
The structure of these flexible fields are in the TeamForge API Documentation in the "Tracker API" under "get /artifacts/{artifactid}".
Regarding our implementation:
Flex fields are only pulled in when requesting a specific artifact. To accont for this the JSON object returned from ajaxGetCard() has been slightly modified.
Responses are now separated into two categories: content from our database and content from teamforge. These are separated into and accessible via two keys within the returned JSON object.
Namely "dbValues" and "teamforgeValues".
Returned values and when what is returned:
An attempt to fetch the artifact data from teamforge is made when ajaxGetCard() is called.
If it's successful then the teamforge data (with some filtered out fields) along with the card data is returned. ("dbValues" contains card data, "teamforgeValues" contains teamforge data)
In the case that the teamforge fetch fails then a backup query is made to our database.
Then "dbValues" contains card data along with the artifact data we have saved in the database and "teamforgeValues" is null.
So, in short:
The object returned from ajaxGetCard() will be a bit different.
You'll still be able to step through "dbValues" the same way you did with the returned value in master, you'll just have to refer to the "dbValues" key while doing so.
"teamforgeValues" will be a bit more tricky though. It contains values along with the "flexFields" array containing flexible field objects. You should be able to loop through "teamforgeValues" and then just loop through the "flexFields" array when you get to it.
You can see the difference in the examples below.
One thing to note is that you can identify if the TeamForge request failed by checking if "teamforgeValues" is null.
Example, successful case:
{
"dbValues": {
"id": 3,
"category_id": 1,
"swimlane_id": null,
"created_at": "2017-12-20 08:26:13",
"updated_at": "2017-12-20 08:26:13"
},
"teamforgeValues": {
"id": "artf1071",
"title": "Artifact Title",
"description": "Artifact Description.",
"category": "",
"group": "",
"status": "Open",
"statusClass": "Open",
"customer": "",
"priority": 4,
"estimatedEffort": 0,
"actualEffort": 0,
"remainingEffort": 0,
"points": 0,
"closeDate": null,
"assignedTo": "enari",
"teamId": null,
"flexFields": [
{
"name": "Release notes title",
"values": [
"Release note title example"
],
"type": "String"
},
{
"name": "Release notes description",
"values": [
"Releas note description example"
],
"type": "String"
},
{
"name": "Analysis",
"values": [
"This is my analysis"
],
"type": "String"
},
{
"name": "Implementation",
"values": [
"I didn't find any issues during the implementation phase, implemented as analysed."
],
"type": "String"
},
{
"name": "Verification",
"values": [
"Code review, static code analysis and some manual testing in lab has been done."
],
"type": "String"
},
{
"name": "Rejection Reason",
"values": [
"No rejection."
],
"type": "String"
}
],
"lastModifiedBy": "christoffer",
"createdBy": "christoffer",
"lastModifiedDate": "2017-12-13T07:40:44.000+0000",
"createdDate": "2017-12-13T07:40:32.000+0000"
}
}
Example, teamforge fetch failed:
{
"dbValues": [
{
"id": 1,
"artifact_id": "artf1031",
"category_id": 1,
"swimlane_id": null,
"created_at": "2017-12-19 21:16:59",
"updated_at": "2017-12-19 21:16:59",
"assignedTo": "nobody",
"description": "Possible Issue",
"title": "[sample] Impediment One",
"teamforgeCreatedDate": "2017-11-29T10:57:52.000+0000",
"status": "Open"
}
],
"teamforgeValues": null
}
Tips For Testing:
The "Test Project" project has an artifact with the with the artifactId of "artf1071" and title of "Show more information about an artifact inlcuding flex fields when an item/post-it/card is pressed".
This artifact contains sample flexFields values.
Uselful links:
The structure of these flexible fields are in the TeamForge API Documentation in the "Tracker API" under "get /artifacts/{artifactid}".
If you go into the model view by clicking on "Model" instead of "Model Schema" you can see what types the returned value have. (The FlexField structure specification is at the very bottom)
Issue dependencies:
Simplified the object a bit for the success case by removing some more unneeded variables.
Description updated.
Added some tips for testing with the flexible fields.