Commit 00490a95afcbf738715d446b8dcd9e71021579b1
1 parent
a9aa5894
Exists in
master
and in
31 other branches
removed commented pieces of code
Showing
2 changed files
with
0 additions
and
115 deletions
Show diff stats
src/lib/ng-noosfero-api/http/article.service.ts
@@ -36,28 +36,6 @@ export class ArticleService extends RestangularService<noosfero.Article> { | @@ -36,28 +36,6 @@ export class ArticleService extends RestangularService<noosfero.Article> { | ||
36 | return rootElement.one(path, id).get<C>(queryParams, headers); | 36 | return rootElement.one(path, id).get<C>(queryParams, headers); |
37 | } | 37 | } |
38 | 38 | ||
39 | - // // TODO create a handle ErrorFactory too and move handleSuccessFactory and handleErrorFactory | ||
40 | - // // to a base class (of course we will have to creates a base class too) | ||
41 | - // handleSuccessFactory<T>(deferred: ng.IDeferred<T>): (response: restangular.IResponse) => void { | ||
42 | - // let self = this; | ||
43 | - // let successFunction = (response: restangular.IResponse): void => { | ||
44 | - // this.$log.debug("Request successfull executed", self, response); | ||
45 | - // deferred.resolve(response.data); | ||
46 | - // }; | ||
47 | - // return successFunction; | ||
48 | - // } | ||
49 | - // | ||
50 | - // handleErrorFactory<T>(deferred: ng.IDeferred<T>): (response: restangular.IResponse) => void { | ||
51 | - // let self = this; | ||
52 | - // let successFunction = (response: restangular.IResponse): void => { | ||
53 | - // this.$log.error("Error executing request", self, response); | ||
54 | - // deferred.reject(response.data); | ||
55 | - // }; | ||
56 | - // return successFunction; | ||
57 | - // } | ||
58 | - | ||
59 | - // TODO -> change all Restangular services to this approach "Return promise to a specific type" | ||
60 | - // it makes easy consume the service | ||
61 | getByProfile<T>(profile: noosfero.Profile, params?: any): ng.IPromise<noosfero.RestResult<noosfero.Article>> { | 39 | getByProfile<T>(profile: noosfero.Profile, params?: any): ng.IPromise<noosfero.RestResult<noosfero.Article>> { |
62 | let profileElement = this.profileService.get(<number>profile.id); | 40 | let profileElement = this.profileService.get(<number>profile.id); |
63 | return this.list(profileElement, params); | 41 | return this.list(profileElement, params); |
src/lib/ng-noosfero-api/http/restangular_service.ts
@@ -221,70 +221,6 @@ export abstract class RestangularService<T extends noosfero.RestModel> { | @@ -221,70 +221,6 @@ export abstract class RestangularService<T extends noosfero.RestModel> { | ||
221 | } | 221 | } |
222 | } | 222 | } |
223 | 223 | ||
224 | - // /** | ||
225 | - // * (description) | ||
226 | - // * | ||
227 | - // * @protected | ||
228 | - // * @template T | ||
229 | - // * @param {restangular.IElement} elementRoot (description) | ||
230 | - // * @param {*} [element] (description) | ||
231 | - // * @param {string} [path] (description) | ||
232 | - // * @param {*} [params] (description) | ||
233 | - // * @param {*} [headers] (description) | ||
234 | - // * @returns {ng.IPromise<T>} (description) | ||
235 | - // */ | ||
236 | - // protected post<T>(elementRoot: restangular.IElement, element?: any, path?: string, params?: any, headers?: any): ng.IPromise<T> { | ||
237 | - // let deferred = this.$q.defer<T>(); | ||
238 | - | ||
239 | - // let postData = <any>{}; | ||
240 | - // postData[this.getDataKeys().singular] = element; | ||
241 | - | ||
242 | - // this.customPOST( | ||
243 | - // elementRoot, | ||
244 | - // postData, | ||
245 | - // this.getResourcePath(), | ||
246 | - // {} | ||
247 | - // ) | ||
248 | - // .then(this.getPostSuccessHandleFunction(deferred)) | ||
249 | - // .catch(this.getHandleErrorFunction(deferred)); | ||
250 | - | ||
251 | - // return deferred.promise; | ||
252 | - // } | ||
253 | - | ||
254 | - | ||
255 | - // protected customGET<C>(elementRoot: restangular.IElement, path?: string, params?: any, headers?: any): ng.IPromise<C> { | ||
256 | - // let deferred = this.$q.defer<C>(); | ||
257 | - // if (headers) { | ||
258 | - // headers['Content-Type'] = 'application/json'; | ||
259 | - // } else { | ||
260 | - // headers = { 'Content-Type': 'application/json' }; | ||
261 | - // } | ||
262 | - // elementRoot.customGET(path, params, headers) | ||
263 | - // .then(this.getHandleSuccessFunction<C>(deferred)) | ||
264 | - // .catch(this.getHandleErrorFunction<C>(deferred)); | ||
265 | - // return deferred.promise; | ||
266 | - // } | ||
267 | - | ||
268 | - // /** | ||
269 | - // * (description) | ||
270 | - // * | ||
271 | - // * @protected | ||
272 | - // * @param {restangular.IElement} elementRoot (description) | ||
273 | - // * @param {*} [elem] (description) | ||
274 | - // * @param {string} [path] (description) | ||
275 | - // * @param {*} [params] (description) | ||
276 | - // * @param {*} [headers] (description) | ||
277 | - // * @returns (description) | ||
278 | - // */ | ||
279 | - // protected customPOST(elementRoot: restangular.IElement, elem?: any, path?: string, params?: any, headers?: any) { | ||
280 | - // if (headers) { | ||
281 | - // headers['Content-Type'] = 'application/json'; | ||
282 | - // } else { | ||
283 | - // headers = { 'Content-Type': 'application/json' }; | ||
284 | - // } | ||
285 | - // return elementRoot.customPOST(elem, path, params, headers); | ||
286 | - // } | ||
287 | - | ||
288 | /** HANDLERS */ | 224 | /** HANDLERS */ |
289 | protected getHandleSuccessFunction<C>(deferred: ng.IDeferred<noosfero.RestResult<C | T | any>>, responseKey?: string): (response: restangular.IResponse) => void { | 225 | protected getHandleSuccessFunction<C>(deferred: ng.IDeferred<noosfero.RestResult<C | T | any>>, responseKey?: string): (response: restangular.IResponse) => void { |
290 | let self = this; | 226 | let self = this; |
@@ -328,33 +264,4 @@ export abstract class RestangularService<T extends noosfero.RestModel> { | @@ -328,33 +264,4 @@ export abstract class RestangularService<T extends noosfero.RestModel> { | ||
328 | } | 264 | } |
329 | /** END HANDLERS */ | 265 | /** END HANDLERS */ |
330 | 266 | ||
331 | - // /** | ||
332 | - // * (description) | ||
333 | - // * | ||
334 | - // * @template T | ||
335 | - // * @param {ng.IDeferred<T>} deferred (description) | ||
336 | - // * @returns {(response: restangular.IResponse) => void} (description) | ||
337 | - // */ | ||
338 | - // protected getPostSuccessHandleFunction<T>(deferred: ng.IDeferred<T>): (response: restangular.IResponse) => void { | ||
339 | - // let self = this; | ||
340 | - // /** | ||
341 | - // * (description) | ||
342 | - // * | ||
343 | - // * @param {restangular.IResponse} response (description) | ||
344 | - // */ | ||
345 | - // let successFunction = (response: restangular.IResponse): void => { | ||
346 | - // if (self.$log) { | ||
347 | - // self.$log.debug("Post successfully executed", self, response); | ||
348 | - // } | ||
349 | - // let data = response.data; | ||
350 | - // | ||
351 | - // if ((<Object>data).hasOwnProperty(self.getDataKeys().singular)) { | ||
352 | - // deferred.resolve(data[self.getDataKeys().singular]); | ||
353 | - // } else { | ||
354 | - // deferred.resolve(data); | ||
355 | - // } | ||
356 | - // }; | ||
357 | - // return successFunction; | ||
358 | - // } | ||
359 | - | ||
360 | } | 267 | } |