Skip to content

Commit

Permalink
Add addToPath
Browse files Browse the repository at this point in the history
  • Loading branch information
devotox committed Jun 30, 2017
1 parent 08dda18 commit ad3f86a
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions addon/utils/member-action.js
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);
let path = options.path;
if(addToPath) {
path = `${path}/${addToPath}`
}
let fullUrl = buildOperationUrl(this, path, urlType);
return adapter.ajax(fullUrl, requestType, merge(options.ajaxOptions || {}, { data: payload }));
};
}

0 comments on commit ad3f86a

Please sign in to comment.