{ "id": "108399", "key": "ALOY-481", "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": [], "resolution": null, "resolutiondate": null, "created": "2013-01-22T22:22:33.000+0000", "priority": { "name": "High", "id": "2" }, "labels": [], "versions": [], "issuelinks": [ { "id": "25027", "type": { "id": "10003", "name": "Relates", "inward": "relates to", "outward": "relates to" }, "outwardIssue": { "id": "107860", "key": "ALOY-462", "fields": { "summary": "Update Backbone to 0.9.10 and Underscore 1.4.3", "status": { "description": "The issue is considered finished, the resolution is correct. Issues which are closed can be reopened.", "name": "Closed", "id": "6", "statusCategory": { "id": 3, "key": "done", "colorName": "green", "name": "Done" } }, "priority": { "name": "High", "id": "2" }, "issuetype": { "id": "4", "description": "An improvement or enhancement to an existing feature or task.", "name": "Improvement", "subtask": false } } } } ], "assignee": null, "updated": "2018-03-07T22:25:40.000+0000", "status": { "description": "This issue was once resolved, but the resolution was deemed incorrect. From here issues are either marked assigned or resolved.", "name": "Reopened", "id": "4", "statusCategory": { "id": 2, "key": "new", "colorName": "blue-gray", "name": "To Do" } }, "components": [ { "id": "12329", "name": "Runtime", "description": "Generic bucket for uncategorized runtime issues" } ], "description": "The success and error callbacks for sync adapters in alloy now do not conform to the expected returned parameters as specified by the Backbone docs, seen here: http://backbonejs.org/#Model-fetch\r\n\r\nWe need to update all supported adapters to send these parameters to the success and error callbacks.", "attachment": [], "flagged": false, "summary": "Update all supported sync adapters to send correct parameters to success and error callbacks", "creator": { "name": "tlukasavage", "key": "tlukasavage", "displayName": "Tony Lukasavage", "active": true, "timeZone": "America/Los_Angeles" }, "subtasks": [], "reporter": { "name": "tlukasavage", "key": "tlukasavage", "displayName": "Tony Lukasavage", "active": true, "timeZone": "America/Los_Angeles" }, "environment": null, "comment": { "comments": [ { "id": "235452", "author": { "name": "tlukasavage", "key": "tlukasavage", "displayName": "Tony Lukasavage", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Changing the internal success/error handler signature appears to cause problems with backbone 0.9.2. We can revisit this issue when backbone is updated.", "updateAuthor": { "name": "tlukasavage", "key": "tlukasavage", "displayName": "Tony Lukasavage", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2013-01-23T04:03:23.000+0000", "updated": "2013-01-23T04:03:23.000+0000" }, { "id": "327000", "author": { "name": "ppritchard", "key": "ppritchard", "displayName": "Peter Eddy Pritchard", "active": true, "timeZone": "America/Los_Angeles" }, "body": "I have updated my own projects to use 0.9.10 and latest underscore & underscore.deferred.\r\n\r\nI return a promise in my sync() functions.\r\n\r\nhttps://github.com/wookiehangover/underscore.Deferred supports done(), fail(), always() and then(), which has proven completely awesome to work with.\r\n\r\nBTW >>> I test for options.success.length to see if the callback is looking for 1 or 3 params ... this is the major difference between 0.9.2 & 0.9.10.\r\n\r\nI have tested my latest code with the latest Backbone 1.1.2 & underscore 1.7.0, but I have nothing currently deployed running these versions.\r\n\r\nthe sync() function I handle the success handler issue with:\r\n\r\n\tvar success = options.success;\r\n\toptions.success = function(resp) {\r\n\t\tif( success.length>1 ) {\r\n \t\tsuccess(model, resp, options);\r\n \t} else {\r\n \t\tsuccess(resp);\r\n \t}\r\n \t\tmodel.trigger('sync', model, resp, options);\r\n\t};\r\n\r\nand then in alloy.js, I override Alloy.M & Alloy.C (and mixin underscore deferred and underscore string libraries:\r\n\r\n// The sync() function for Models and Collections should return a result ... otherwise fetch() and save(), etc\r\n// won't return a result ... unlike jQuery usage, which returns a jqXHR (a Deferred object)\r\nAlloy.M = function(name, modelDesc, migrations) {\r\n var config = modelDesc.config, type = (config.adapter ? config.adapter.type : null) || 'localDefault';\r\n type === 'localDefault' && (type = 'sql');\r\n var adapter = require('alloy/sync/' + type), extendObj = {\r\n defaults: config.defaults,\r\n sync: function(method, model, opts) {\r\n var config = model.config || {}, adapterObj = config.adapter || {}, type = (config.adapter ? config.adapter.type : null) || 'localDefault';\r\n type === 'localDefault' && (type = 'sql');\r\n // Make sure to return the value from this ...\r\n return require('alloy/sync/' + type).sync(method, model, opts);\r\n }\r\n }, extendClass = {};\r\n migrations && (extendClass.migrations = migrations);\r\n _.isFunction(adapter.beforeModelCreate) && (config = adapter.beforeModelCreate(config, name) || config);\r\n \r\n // Add support for custom super-class\r\n var superClass = config.superClass || Backbone.Model;\r\n var Model = superClass.extend(extendObj, extendClass);\r\n Model.prototype.config = config;\r\n _.isFunction(modelDesc.extendModel) && (Model = modelDesc.extendModel(Model) || Model);\r\n _.isFunction(adapter.afterModelCreate) && adapter.afterModelCreate(Model, name);\r\n return Model;\r\n};\r\n\r\nAlloy.C = function(name, modelDesc, model) {\t\r\n // Add support for custom super-class\r\n modelDesc.config = modelDesc.config || {};\r\n var superClass = Backbone.Collection;\r\n var extendObj = {\r\n model: model,\r\n sync: function(method, model, opts) {\r\n // var config = model.config || {}, type = (config.adapter ? config.adapter.type : null) || \"localDefault\";\r\n // type === \"localDefault\" && (type = \"sql\");\r\n // Make sure to return the value from this ...\r\n return this.adapter.sync(method, model, opts);\r\n }\r\n }, Collection = superClass.extend(extendObj), config = Collection.prototype.config = model.prototype.config;\r\n \r\n var _adapter = config.collection_adapter || config.adapter || {type:\"localDefault\"};\r\n var type = _adapter.type; \r\n Collection.prototype.adapter = require(\"alloy/sync/\" + type);\r\n var adapter = require(\"alloy/sync/\" + type);\r\n \r\n _.isFunction(adapter.afterCollectionCreate) && adapter.afterCollectionCreate(Collection);\r\n _.isFunction(modelDesc.extendCollection) && (Collection = modelDesc.extendCollection(Collection) || Collection);\r\n \r\n return Collection;\r\n};\r\n\r\n// Replace Backbone.Model with Associated.Model for nested object support\r\nvar AssociatedModel = require('backbone-associations').AssociatedModel;\r\nvar BackboneModel = Backbone.Model;\r\nBackbone.Model = AssociatedModel;\r\n\r\n// Add support for deferreds\r\nAlloy._.mixin( require('underscore.deferred') );\r\n\r\n// Import Underscore.string to separate object, because there are conflict functions (include, reverse, contains)\r\nAlloy._.mixin( require('underscore.string') );\r\n", "updateAuthor": { "name": "ppritchard", "key": "ppritchard", "displayName": "Peter Eddy Pritchard", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2014-10-05T04:21:12.000+0000", "updated": "2014-10-05T04:21:12.000+0000" }, { "id": "327003", "author": { "name": "ppritchard", "key": "ppritchard", "displayName": "Peter Eddy Pritchard", "active": true, "timeZone": "America/Los_Angeles" }, "body": "sorry for the \"code in comment\". the point of the code dump was to show that I had to override Alloy.M & Alloy.C to return the value obtained from sync(). The other bits are things I drop into every Alloy project I work on. (Backbone without promises is not Backbone) ", "updateAuthor": { "name": "ppritchard", "key": "ppritchard", "displayName": "Peter Eddy Pritchard", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2014-10-05T04:37:12.000+0000", "updated": "2014-10-05T04:39:55.000+0000" }, { "id": "327004", "author": { "name": "ppritchard", "key": "ppritchard", "displayName": "Peter Eddy Pritchard", "active": true, "timeZone": "America/Los_Angeles" }, "body": "And that I allow for a configurable Model super class as well", "updateAuthor": { "name": "ppritchard", "key": "ppritchard", "displayName": "Peter Eddy Pritchard", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2014-10-05T04:42:13.000+0000", "updated": "2014-10-05T04:42:13.000+0000" } ], "maxResults": 4, "total": 4, "startAt": 0 } } }