-
Notifications
You must be signed in to change notification settings - Fork 87
Enhancement: Almost all Http methods need to be configurable #401
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -96,7 +96,7 @@ RMModule.factory('RMRecordApi', ['RMUtils', function(Utils) { | |
* @property {mixed} $pk The record primary key | ||
* @property {object} $scope The collection scope (hierarchical scope, not angular scope) | ||
*/ | ||
return { | ||
return { | ||
|
||
/** | ||
* @memberof RecordApi# | ||
|
@@ -271,6 +271,8 @@ RMModule.factory('RMRecordApi', ['RMUtils', function(Utils) { | |
* @description Shortcut method used to extend and save a model. | ||
* | ||
* This method will not force a PUT, if object is new `$update` will attempt to POST. | ||
* It is posible to change the methods used for PUT and POST operations by setting | ||
* the `putMethod` and `postMethod` configuration. | ||
* | ||
* @param {object} _other Data to change | ||
* @return {RecordApi} self | ||
|
@@ -319,7 +321,11 @@ RMModule.factory('RMRecordApi', ['RMUtils', function(Utils) { | |
}) | ||
}; | ||
} else { | ||
request = { method: 'PUT', url: url, data: this.$wrap(Utils.UPDATE_MASK) }; | ||
request = { | ||
method: this.$type.getProperty('putMethod', 'PUT'), // allow user to override put method | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Line is too long. |
||
url: url, | ||
data: this.$wrap(Utils.UPDATE_MASK) | ||
}; | ||
} | ||
|
||
this | ||
|
@@ -341,7 +347,12 @@ RMModule.factory('RMRecordApi', ['RMUtils', function(Utils) { | |
url = this.$url('create') || this.$scope.$url(); | ||
Utils.assert(!!url, 'Cant $create if parent scope is not bound'); | ||
|
||
request = { method: 'POST', url: url, data: this.$wrap(Utils.CREATE_MASK) }; | ||
request = { | ||
method: this.$type.getProperty('postMethod', 'POST'), // allow user to override post method | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Line is too long. |
||
url: url, | ||
data: this.$wrap(Utils.CREATE_MASK) | ||
}; | ||
|
||
this | ||
.$dispatch('before-save', [request]) | ||
.$dispatch('before-create', [request]) | ||
|
@@ -370,7 +381,8 @@ RMModule.factory('RMRecordApi', ['RMUtils', function(Utils) { | |
* | ||
* @description Begin a server request to destroy the resource. | ||
* | ||
* The request's promise can be accessed using the `$asPromise` method. | ||
* The request's promise can be accessed using the `$asPromise` method. It is posible to change | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Line is too long. |
||
* the methods used for DELETE operations by setting the `deleteMethod` configuration. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Line is too long. |
||
* | ||
* @return {RecordApi} this | ||
*/ | ||
|
@@ -379,7 +391,10 @@ RMModule.factory('RMRecordApi', ['RMUtils', function(Utils) { | |
var url = this.$url('destroy'); | ||
if(url) | ||
{ | ||
var request = { method: 'DELETE', url: url }; | ||
var request = { | ||
method: this.$type.getProperty('deleteMethod', 'DELETE'), // allow user to override delete method | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Line is too long. |
||
url: url | ||
}; | ||
|
||
this | ||
.$dispatch('before-destroy', [request]) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Line is too long.