Skip to content

Commit

Permalink
Update collection-action.js
Browse files Browse the repository at this point in the history
  • Loading branch information
devotox committed Jun 30, 2017
1 parent ad3f86a commit a8453dd
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions addon/utils/collection-action.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,16 @@ import { buildOperationUrl } from './build-url';
const { merge } = Ember;

export default function instanceOp(options) {
return function(payload) {
return function(payload, addToPath) {
let modelName = this.constructor.modelName || this.constructor.typeKey;
let requestType = (options.type || 'PUT').toUpperCase();
let urlType = options.urlType || requestType;
let adapter = this.store.adapterFor(modelName);
let fullUrl = buildOperationUrl(this, options.path, urlType, false);
let path = options.path;
if(addToPath) {
path = `${path}/${addToPath}`
}
let fullUrl = buildOperationUrl(this, path, urlType, false);
return adapter.ajax(fullUrl, requestType, merge(options.ajaxOptions || {}, { data: payload }));
};
}

0 comments on commit a8453dd

Please sign in to comment.