diff --git a/addon/adapters/sails-socket.js b/addon/adapters/sails-socket.js index 90f50ed..94369ae 100644 --- a/addon/adapters/sails-socket.js +++ b/addon/adapters/sails-socket.js @@ -123,7 +123,7 @@ export default SailsBaseAdapter.extend({ if (!record.id && message.id) { record.id = message.id; } - payload[pluralize(camelize(type.modelName))] = [record]; + payload[pluralize(camelize(type.typeKey))] = [record]; store.pushPayload(type, payload); }, @@ -150,7 +150,7 @@ export default SailsBaseAdapter.extend({ * @private */ _handleSocketRecordDeleted: function (store, type, message) { - var record = store.getById(type.modelName, message.id); + var record = store.getById(type.typeKey, message.id); if (record && typeof record.get('dirtyType') === 'undefined') { record.unloadRecord(); } @@ -195,7 +195,7 @@ export default SailsBaseAdapter.extend({ this._scheduledSubscriptions = {}; } // use an object and keys so that we don't have duplicate IDs - key = camelize(type.modelName); + key = camelize(type.typeKey); if (!this._scheduledSubscriptions[key]) { this._scheduledSubscriptions[key] = {}; } @@ -227,7 +227,7 @@ export default SailsBaseAdapter.extend({ payload[k] = Object.keys(data[k]); this._listenToSocket(k); } - self.debug(fmt('asking the API to subscribe to some records of type %@', Object.keys(data).join(', '))); + self.debug(fmt('asking the API to subscribe to some records of type %@', Ember.keys(data).join(', '))); // ask the API to subscribe to those records this.fetchCSRFToken().then(function () { self.checkCSRF(payload); diff --git a/addon/mixins/store.js b/addon/mixins/store.js index 82d1c70..1145575 100644 --- a/addon/mixins/store.js +++ b/addon/mixins/store.js @@ -28,11 +28,11 @@ var StoreMixin = Ember.Mixin.create({ * @method push * @inheritDoc */ - push: function (result) { + push: function (typeName/*, data, _partial*/) { var res = this._super.apply(this, arguments), id, type, adapter; - if (result.data && res && (id = res.get('id'))) { - type = this.modelFor(result.data.type); - adapter = this.adapterFor(type.modelName); + if (this._pushSubscribes && res && (id = res.get('id'))) { + type = this.modelFor(typeName); + adapter = this.adapterFor(type); if(adapter instanceof SailsSocketAdapter) { adapter._scheduleSubscribe(type, id); diff --git a/addon/serializers/sails.js b/addon/serializers/sails.js index 4e496fd..628b0b8 100644 --- a/addon/serializers/sails.js +++ b/addon/serializers/sails.js @@ -36,7 +36,7 @@ var SailsSerializer = DS.RESTSerializer.extend(WithLogger, { * @method extractArray * @inheritDoc */ - normalizeArrayResponse: blueprintsWrapMethod(function (store, primaryType, payload) { + extractArray: blueprintsWrapMethod(function (store, primaryType, payload) { var newPayload = {}; newPayload[pluralize(primaryType.typeKey)] = payload; return this._super(store, primaryType, newPayload); @@ -47,7 +47,7 @@ var SailsSerializer = DS.RESTSerializer.extend(WithLogger, { * @method extractSingle * @inheritDoc */ - normalizeSingleResponse: blueprintsWrapMethod(function (store, primaryType, payload, recordId) { + extractSingle: blueprintsWrapMethod(function (store, primaryType, payload, recordId) { var newPayload; if (payload === null) { return this._super.apply(this, arguments); @@ -62,7 +62,7 @@ var SailsSerializer = DS.RESTSerializer.extend(WithLogger, { * @method extractDeleteRecord * @inheritDoc */ - normalizeDeleteRecordResponse: blueprintsWrapMethod(function (store, type, payload, id, requestType) { + extractDeleteRecord: blueprintsWrapMethod(function (store, type, payload, id, requestType) { return this._super(store, type, null, id, requestType); }), @@ -73,7 +73,7 @@ var SailsSerializer = DS.RESTSerializer.extend(WithLogger, { */ serializeIntoHash: blueprintsWrapMethod(function (data, type, record, options) { var json; - if (Object.keys(data).length > 0) { + if (Ember.keys(data).length > 0) { this.error( fmt('trying to serialize multiple records in one hash for type %@', type.typeKey), data @@ -100,7 +100,7 @@ var SailsSerializer = DS.RESTSerializer.extend(WithLogger, { * @method extract * @inheritDoc */ - normalizeResponse: function (store, type/*, payload, id, requestType*/) { + extract: function (store, type/*, payload, id, requestType*/) { var adapter, typeKey, isUsingSocketAdapter; // this is the only place we have access to the store, so that we can get the adapter and check // if it is an instance of sails socket adapter, and so register for events if necessary on that diff --git a/package.json b/package.json index 8a3f0ee..c09ce9a 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { - "name": "bc-ember-data-sails", + "name": "ember-data-sails", "version": "0.0.16", "description": "Adapters and tools for EmberJS to work well with SailsJS", "directories": { @@ -11,17 +11,11 @@ "build": "ember build", "test": "ember test" }, - "repository": { - "type": "git", - "url": "git://github.com/brickclick/ember-data-sails.git.git#bc-ember-data-sails" - }, + "repository": "https://github.com/huafu/ember-data-sails.git", "engines": { "node": ">= 0.10.0" }, - "author": { - "name": "Brickclick", - "email": "kevin@brickclickrms.com" - }, + "author": "Huafu Gandon ", "license": "MIT", "devDependencies": { "broccoli-asset-rev": "^2.0.2", @@ -46,31 +40,5 @@ ], "ember-addon": { "configPath": "tests/dummy/config" - }, - "gitHead": "7df416974e7c85d63ff63b84c164c61c94ae7e56", - "bugs": { - "url": "https://github.com/brickclick/ember-data-sails.git/issues" - }, - "homepage": "https://github.com/brickclick/ember-data-sails.git", - "_id": "bc-ember-data-sails@0.0.16", - "_shasum": "97daa5da0ab54cff2e25b0f5baade7243b29c6c3", - "_from": "bc-ember-data-sails@*", - "_npmVersion": "2.7.4", - "_nodeVersion": "0.12.0", - "_npmUser": { - "name": "t3rminus", - "email": "k3vin.net@gmail.com" - }, - "dist": { - "shasum": "97daa5da0ab54cff2e25b0f5baade7243b29c6c3", - "tarball": "http://registry.npmjs.org/bc-ember-data-sails/-/bc-ember-data-sails-0.0.16.tgz" - }, - "maintainers": [ - { - "name": "t3rminus", - "email": "k3vin.net@gmail.com" - } - ], - "_resolved": "https://registry.npmjs.org/bc-ember-data-sails/-/bc-ember-data-sails-0.0.16.tgz", - "readme": "ERROR: No README data found!" + } }