diff --git a/src/lib/ng-noosfero-api/http/article.service.ts b/src/lib/ng-noosfero-api/http/article.service.ts index 108f951..cdf890b 100644 --- a/src/lib/ng-noosfero-api/http/article.service.ts +++ b/src/lib/ng-noosfero-api/http/article.service.ts @@ -36,28 +36,6 @@ export class ArticleService extends RestangularService { return rootElement.one(path, id).get(queryParams, headers); } - // // TODO create a handle ErrorFactory too and move handleSuccessFactory and handleErrorFactory - // // to a base class (of course we will have to creates a base class too) - // handleSuccessFactory(deferred: ng.IDeferred): (response: restangular.IResponse) => void { - // let self = this; - // let successFunction = (response: restangular.IResponse): void => { - // this.$log.debug("Request successfull executed", self, response); - // deferred.resolve(response.data); - // }; - // return successFunction; - // } - // - // handleErrorFactory(deferred: ng.IDeferred): (response: restangular.IResponse) => void { - // let self = this; - // let successFunction = (response: restangular.IResponse): void => { - // this.$log.error("Error executing request", self, response); - // deferred.reject(response.data); - // }; - // return successFunction; - // } - - // TODO -> change all Restangular services to this approach "Return promise to a specific type" - // it makes easy consume the service getByProfile(profile: noosfero.Profile, params?: any): ng.IPromise> { let profileElement = this.profileService.get(profile.id); return this.list(profileElement, params); diff --git a/src/lib/ng-noosfero-api/http/restangular_service.ts b/src/lib/ng-noosfero-api/http/restangular_service.ts index c872ced..b2653d8 100644 --- a/src/lib/ng-noosfero-api/http/restangular_service.ts +++ b/src/lib/ng-noosfero-api/http/restangular_service.ts @@ -221,70 +221,6 @@ export abstract class RestangularService { } } - // /** - // * (description) - // * - // * @protected - // * @template T - // * @param {restangular.IElement} elementRoot (description) - // * @param {*} [element] (description) - // * @param {string} [path] (description) - // * @param {*} [params] (description) - // * @param {*} [headers] (description) - // * @returns {ng.IPromise} (description) - // */ - // protected post(elementRoot: restangular.IElement, element?: any, path?: string, params?: any, headers?: any): ng.IPromise { - // let deferred = this.$q.defer(); - - // let postData = {}; - // postData[this.getDataKeys().singular] = element; - - // this.customPOST( - // elementRoot, - // postData, - // this.getResourcePath(), - // {} - // ) - // .then(this.getPostSuccessHandleFunction(deferred)) - // .catch(this.getHandleErrorFunction(deferred)); - - // return deferred.promise; - // } - - - // protected customGET(elementRoot: restangular.IElement, path?: string, params?: any, headers?: any): ng.IPromise { - // let deferred = this.$q.defer(); - // if (headers) { - // headers['Content-Type'] = 'application/json'; - // } else { - // headers = { 'Content-Type': 'application/json' }; - // } - // elementRoot.customGET(path, params, headers) - // .then(this.getHandleSuccessFunction(deferred)) - // .catch(this.getHandleErrorFunction(deferred)); - // return deferred.promise; - // } - - // /** - // * (description) - // * - // * @protected - // * @param {restangular.IElement} elementRoot (description) - // * @param {*} [elem] (description) - // * @param {string} [path] (description) - // * @param {*} [params] (description) - // * @param {*} [headers] (description) - // * @returns (description) - // */ - // protected customPOST(elementRoot: restangular.IElement, elem?: any, path?: string, params?: any, headers?: any) { - // if (headers) { - // headers['Content-Type'] = 'application/json'; - // } else { - // headers = { 'Content-Type': 'application/json' }; - // } - // return elementRoot.customPOST(elem, path, params, headers); - // } - /** HANDLERS */ protected getHandleSuccessFunction(deferred: ng.IDeferred>, responseKey?: string): (response: restangular.IResponse) => void { let self = this; @@ -328,33 +264,4 @@ export abstract class RestangularService { } /** END HANDLERS */ - // /** - // * (description) - // * - // * @template T - // * @param {ng.IDeferred} deferred (description) - // * @returns {(response: restangular.IResponse) => void} (description) - // */ - // protected getPostSuccessHandleFunction(deferred: ng.IDeferred): (response: restangular.IResponse) => void { - // let self = this; - // /** - // * (description) - // * - // * @param {restangular.IResponse} response (description) - // */ - // let successFunction = (response: restangular.IResponse): void => { - // if (self.$log) { - // self.$log.debug("Post successfully executed", self, response); - // } - // let data = response.data; - // - // if ((data).hasOwnProperty(self.getDataKeys().singular)) { - // deferred.resolve(data[self.getDataKeys().singular]); - // } else { - // deferred.resolve(data); - // } - // }; - // return successFunction; - // } - } -- libgit2 0.21.2