@@ -91,16 +91,17 @@ To define `customAction` and customize it by using ember-data flow, adapters and
91
91
- ` actionId ` - id of the action which can be handled later on in adpaters and serializers
92
92
- ` options ` - optional parameter which will overwrite the configuration options
93
93
94
- If you want to customize your request in your adapter please, implement our adapter mixin, eg :
94
+ If you want to customize your request in your adapter please, implement our adapter mixin:
95
95
``` js
96
96
import JSONAPIAdapter from ' ember-data/adapters/json-api' ;
97
97
import { AdapterMixin } from ' ember-custom-actions' ;
98
98
99
99
export default JSONAPIAdapter .extend (AdapterMixin);
100
100
```
101
101
102
- You can customize following methods in the adpater:
102
+ Now you can customize following methods in the adpater:
103
103
* [ urlForCustomAction] ( #urlForCustomAction )
104
+ * [ dataForCustomAction] ( #dataForCustomAction )
104
105
* [ methodForCustomAction] ( #methodForCustomAction )
105
106
* [ headersForCustomAction] ( #headersForCustomAction )
106
107
@@ -111,10 +112,10 @@ You can define your custom path for every `customAction` by adding a conditional
111
112
``` js
112
113
export default JSONAPIAdapter .extend (AdapterMixin, {
113
114
urlForCustomAction (modelName , id , snapshot , actionId , queryParams ) {
114
- if (requestType === ' myPublishAction' ) {
115
+ if (actionId === ' myPublishAction' ) {
115
116
return ' https://my-custom-api.com/publish'
116
117
}
117
-
118
+
118
119
return this ._super (... arguments );
119
120
}
120
121
});
@@ -130,7 +131,7 @@ export default JSONAPIAdapter.extend(AdapterMixin, {
130
131
if (requestType === ' myPublishAction' ) {
131
132
return ` ${ this ._buildURL (modelName, id)} /publish` ;
132
133
}
133
-
134
+
134
135
return this ._super (... arguments );
135
136
}
136
137
});
@@ -147,7 +148,7 @@ export default JSONAPIAdapter.extend(AdapterMixin, {
147
148
if (params .actionId === ' myPublishAction' ) {
148
149
return ' PUT' ;
149
150
}
150
-
151
+
151
152
return this ._super (... arguments );
152
153
}
153
154
});
@@ -166,14 +167,14 @@ export default JSONAPIAdapter.extend(AdapterMixin, {
166
167
' Authorization-For-Custom-Action' : ' mySuperToken123'
167
168
};
168
169
}
169
-
170
+
170
171
return this ._super (... arguments );
171
172
}
172
173
});
173
174
```
174
175
175
176
#### dataForCustomAction
176
- You can define your custom headers for every ` customAction ` by adding a conditional:
177
+ You can define your custom data for every ` customAction ` by adding a conditional:
177
178
178
179
``` js
179
180
import { AdapterMixin } from ' ember-custom-actions' ;
@@ -185,7 +186,7 @@ export default JSONAPIAdapter.extend(AdapterMixin, {
185
186
myParam: ' send it to the server'
186
187
};
187
188
}
188
-
189
+
189
190
return this ._super (... arguments );
190
191
}
191
192
});
0 commit comments