Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions addon/utils/collection-action.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { assign } from '@ember/polyfills';
import Model from 'ember-data/model';
import { Value as JSONValue } from 'json-typescript';
import { _getModelClass, _getModelName, _getStoreFromRecord, buildOperationUrl } from './build-url';
Expand All @@ -25,7 +24,7 @@ export default function collectionOp<IN = any, OUT = any>(options: CollectionOpe
const fullUrl = buildOperationUrl(model, options.path, urlType, false);
const data = (options.before && options.before.call(model, payload)) || payload;
return adapter
.ajax(fullUrl, requestType, assign(options.ajaxOptions || {}, { data }))
.ajax(fullUrl, requestType, Object.assign(options.ajaxOptions || {}, { data }))
.then((response: JSONValue) => {
if (options.after && !model.isDestroyed) {
return options.after.call(model, response);
Expand Down
15 changes: 8 additions & 7 deletions addon/utils/member-action.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { assign } from '@ember/polyfills';
import Model from 'ember-data/model';
import { Value as JSONValue } from 'json-typescript';
import { _getModelClass, _getModelName, _getStoreFromRecord, buildOperationUrl } from './build-url';
Expand All @@ -23,12 +22,14 @@ export default function instanceOp<IN = any, OUT = any>(options: InstanceOperati
const adapter = store.adapterFor(modelName);
const fullUrl = buildOperationUrl(this, path, urlType);
const data = (before && before.call(this, payload)) || payload;
return adapter.ajax(fullUrl, requestType, assign(ajaxOptions || {}, { data })).then((response: JSONValue) => {
if (after && !this.isDestroyed) {
return after.call(this, response);
}
return adapter
.ajax(fullUrl, requestType, Object.assign(ajaxOptions || {}, { data }))
.then((response: JSONValue) => {
if (after && !this.isDestroyed) {
return after.call(this, response);
}

return response;
});
return response;
});
};
}
3 changes: 1 addition & 2 deletions tests/dummy/app/models/fruit.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
// BEGIN-SNIPPET fruit-model
import { assign } from '@ember/polyfills';
import { collectionAction, memberAction, serializeAndPush } from 'ember-api-actions';
import DS from 'ember-data';

const { attr, Model } = DS;

function mergeAttributes(attributes) {
const payload = this.serialize();
payload.data.attributes = assign(payload.data.attributes || {}, attributes);
payload.data.attributes = Object.assign(payload.data.attributes || {}, attributes);
return payload;
}
const Fruit = Model.extend({
Expand Down