{
"id": "145012",
"key": "ALOY-1254",
"fields": {
"issuetype": {
"id": "4",
"description": "An improvement or enhancement to an existing feature or task.",
"name": "Improvement",
"subtask": false
},
"project": {
"id": "11113",
"key": "ALOY",
"name": "Alloy",
"projectCategory": {
"id": "10400",
"description": "Tools for developing applications",
"name": "Tooling"
}
},
"fixVersions": [
{
"id": "17728",
"name": "Release 5.2.1",
"archived": false,
"released": true,
"releaseDate": "2016-03-25"
},
{
"id": "17983",
"name": "alloy 1.8.1",
"archived": false,
"released": true,
"releaseDate": "2016-03-22"
}
],
"resolution": {
"id": "1",
"description": "A fix for this issue is checked into the tree and tested.",
"name": "Fixed"
},
"resolutiondate": "2016-03-21T17:21:11.000+0000",
"created": "2015-02-20T15:25:03.000+0000",
"priority": {
"name": "None",
"id": "6"
},
"labels": [
"data-binding"
],
"versions": [
{
"id": "16595",
"name": "Alloy 1.5.1",
"archived": false,
"released": true,
"releaseDate": "2014-10-01"
},
{
"id": "16596",
"name": "Alloy 1.6.0",
"archived": false,
"released": true,
"releaseDate": "2015-05-21"
},
{
"id": "16692",
"name": "Alloy 1.7.0",
"archived": false,
"released": true,
"releaseDate": "2015-07-22"
}
],
"issuelinks": [],
"assignee": {
"name": "fokkezb",
"key": "fokke",
"displayName": "Fokke Zandbergen",
"active": true,
"timeZone": "Europe/Amsterdam"
},
"updated": "2016-03-30T09:07:04.000+0000",
"status": {
"description": "A resolution has been taken, and it is awaiting verification by reporter. From here issues are either reopened, or are closed.",
"name": "Resolved",
"id": "5",
"statusCategory": {
"id": 3,
"key": "done",
"colorName": "green",
"name": "Done"
}
},
"components": [
{
"id": "12326",
"name": "XML",
"description": "View XML and parsing"
}
],
"description": "While undocumented, with model-view binding the model is tried for a {{transform()}} method. With collection-view binding you have to use the {{dataTransform}} attribute in the view.\r\n\r\nIf the user doesn't use the {{dataTransform}} attribute we should try the model for a {{transform()}} method as well.\r\n\r\nh1. Current situation\r\n\r\n*index.xml*\r\n{code:xml}\r\n\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n\r\n{code}\r\n\r\n*index.js* (compiled)\r\n{code:javascript}\r\n function __alloyId10(e) {\r\n // ..\r\n __alloyId6.__transform = {};\r\n var __alloyId8 = Ti.UI.createTableViewRow({\r\n title: \"undefined\" != typeof __alloyId6.__transform[\"name\"] ? __alloyId6.__transform[\"name\"] : __alloyId6.get(\"name\")\r\n });\r\n // ..\r\n }\r\n // ..\r\n var __alloyId11 = function() {\r\n $.__alloyId4.text = _.isFunction(Alloy.Models.foo.transform) ? Alloy.Models.foo.transform()[\"name\"] : _.template(\"<%=foo.name%>\", {\r\n foo: Alloy.Models.foo.toJSON()\r\n });\r\n };\r\n{code}\r\n\r\nh1. Suggested change\r\n\r\nThe model's {{transform()}} method could be supported by changing the 3rd line off the compiled example to:\r\n\r\n{code:javascript}\r\n__alloyId6.__transform = _.isFunction(__alloyId6.transform) ? __alloyId6.transform() : {};\r\n{code}",
"attachment": [],
"flagged": false,
"summary": "Alloy: Support model transform() method for collection-view binding",
"creator": {
"name": "fokkezb",
"key": "fokke",
"displayName": "Fokke Zandbergen",
"active": true,
"timeZone": "Europe/Amsterdam"
},
"subtasks": [],
"reporter": {
"name": "fokkezb",
"key": "fokke",
"displayName": "Fokke Zandbergen",
"active": true,
"timeZone": "Europe/Amsterdam"
},
"environment": "Alloy 1.5.1.GA\r\nAlloy 1.7.0-dev",
"comment": {
"comments": [
{
"id": "344016",
"author": {
"name": "fokkezb",
"key": "fokke",
"displayName": "Fokke Zandbergen",
"active": true,
"timeZone": "Europe/Amsterdam"
},
"body": "I've updated the documentation with the missing {{transform()}} function:\r\nhttps://wiki.appcelerator.org/display/guides2/Alloy+Data+Binding",
"updateAuthor": {
"name": "fokkezb",
"key": "fokke",
"displayName": "Fokke Zandbergen",
"active": true,
"timeZone": "Europe/Amsterdam"
},
"created": "2015-02-20T15:35:57.000+0000",
"updated": "2015-02-20T15:35:57.000+0000"
},
{
"id": "379865",
"author": {
"name": "fokkezb",
"key": "fokke",
"displayName": "Fokke Zandbergen",
"active": true,
"timeZone": "Europe/Amsterdam"
},
"body": "PR: https://github.com/appcelerator/alloy/pull/768",
"updateAuthor": {
"name": "fokkezb",
"key": "fokke",
"displayName": "Fokke Zandbergen",
"active": true,
"timeZone": "Europe/Amsterdam"
},
"created": "2016-03-16T12:52:54.000+0000",
"updated": "2016-03-16T12:52:54.000+0000"
},
{
"id": "380741",
"author": {
"name": "hazemkhaled",
"key": "hazemkhaled",
"displayName": "Hazem Khaled",
"active": true,
"timeZone": "Europe/Istanbul"
},
"body": "I’m facing issue since Alloy 1.8.1 maybe related to here ALOY-1254, i've to add transform method extended in the model, and not working without it\r\n\r\n{code:xml|title=app/views/index.xml}\r\n\r\n\t\r\n\t\r\n\t\t\r\n\r\n{code}\r\n\r\n{code:javascript|title=app/controllers/index.js}\r\nAlloy.Globals.Models.store_selected.fecth();\r\nindex.open();\r\n{code}\r\n\r\n{code:javascript|title=app/models/store_selected.js}\r\nexports.definition = {\r\n\tconfig: {\r\n\t\tcolumns: {\r\n\t\t\t\"store_id\": \"INTEGER\",\r\n\t\t\t\"name\": \"TEXT\",\r\n\t\t\t\"displayname\": \"TEXT\",\r\n\t\t\t\"logo\": \"TEXT\",\r\n\t\t\t\"lang\": \"TEXT\",\r\n\t\t\t\"website_id\": \"INTEGER\",\r\n\t\t\t\"sort_order\": \"INTEGER\",\r\n\t\t\t\"group_id\": \"INTEGER\",\r\n\t\t\t\"root_category_id\": \"INTEGER\"\r\n\t\t},\r\n\t\tadapter: {\r\n\t\t\ttype: \"sql\",\r\n\t\t\tcollection_name: \"store_selected\",\r\n\t\t\tidAttribute: \"store_id\"\r\n\t\t}\r\n\t},\r\n\textendModel: function(Model) {\r\n\t\t_.extend(Model.prototype, {\r\n\t\t\ttransform: function transform() {\r\n\t\t\t\treturn this.toJSON();\r\n\t\t\t}\r\n\t\t});\r\n\t\treturn Model;\r\n\t},\r\n\textendCollection: function(Collection) {\r\n\t\t_.extend(Collection.prototype, {});\r\n\t\treturn Collection;\r\n\t}\r\n};\r\n{code}",
"updateAuthor": {
"name": "hazemkhaled",
"key": "hazemkhaled",
"displayName": "Hazem Khaled",
"active": true,
"timeZone": "Europe/Istanbul"
},
"created": "2016-03-27T00:31:19.000+0000",
"updated": "2016-03-27T00:31:19.000+0000"
},
{
"id": "380779",
"author": {
"name": "fokkezb",
"key": "fokke",
"displayName": "Fokke Zandbergen",
"active": true,
"timeZone": "Europe/Amsterdam"
},
"body": "[~hazemkhaled] thanks for reporting, I've logged this under ALOY-1474 and a fix is in ready soon.",
"updateAuthor": {
"name": "fokkezb",
"key": "fokke",
"displayName": "Fokke Zandbergen",
"active": true,
"timeZone": "Europe/Amsterdam"
},
"created": "2016-03-28T09:43:51.000+0000",
"updated": "2016-03-28T09:43:51.000+0000"
}
],
"maxResults": 4,
"total": 4,
"startAt": 0
}
}
}