From 1bb0294e8dcb852419396c982c98b328e72416d8 Mon Sep 17 00:00:00 2001 From: Jean-Louis Jouannic Date: Mon, 2 Jan 2017 17:08:20 +0100 Subject: [PATCH] Event resource with workaround to https://github.com/cfpio/callForPapers/issues/103 --- src/app/components/home/home.module.js | 2 +- src/app/components/home/welcome/welcome.html | 16 ++++++------- src/app/components/home/welcome/welcome.js | 2 +- src/app/services/resources/event.service.js | 24 +++++++++++++++++++ .../services/resources/resources.module.js | 2 ++ 5 files changed, 36 insertions(+), 10 deletions(-) create mode 100644 src/app/services/resources/event.service.js diff --git a/src/app/components/home/home.module.js b/src/app/components/home/home.module.js index bf8ba04..e623267 100644 --- a/src/app/components/home/home.module.js +++ b/src/app/components/home/home.module.js @@ -21,7 +21,7 @@ export const home = angular abstract: true, component: 'home', resolve: { - application: (Restangular) => Restangular.one('application').get(), + event: (Event) => Event.get(), tracks: (Tracks) => Tracks.getList(), formats: (Formats) => Formats.getList() } diff --git a/src/app/components/home/welcome/welcome.html b/src/app/components/home/welcome/welcome.html index 35cc889..2903afb 100644 --- a/src/app/components/home/welcome/welcome.html +++ b/src/app/components/home/welcome/welcome.html @@ -15,7 +15,7 @@

Proposals

Call for Papers

-

{{$ctrl.config.eventName}}, {{$ctrl.config.date}}

+

{{$ctrl.event.eventName}}, {{$ctrl.event.date}}


@@ -25,14 +25,14 @@

{{$ctrl.config.eventName}}, {{$ctrl.config.date}}

Agenda

opening : TODO

-

closing : {{$ctrl.config.decisionDate}}

-

Program announced : {{$ctrl.config.releaseDate}}

+

closing : {{$ctrl.event.decisionDate}}

+

Program announced : {{$ctrl.event.releaseDate}}

-

About {{$ctrl.config.eventName}}

- Review {{$ctrl.config.eventName}} videos on Youtube +

About {{$ctrl.event.eventName}}

+ Review {{$ctrl.event.eventName}} videos on Youtube
- {{$ctrl.config.eventName}} web site + {{$ctrl.event.eventName}} web site
@@ -41,7 +41,7 @@

About {{$ctrl.config.eventName}}

-

CFP is {{$ctrl.config.open ? 'Open' : 'Closed'}}

+

CFP is {{$ctrl.event.open ? 'Open' : 'Closed'}}

Become a speaker @@ -54,7 +54,7 @@

CFP is {{$ctrl.config.open ? 'Open' : 'Closed

Themes

-

List of themes for {{$ctrl.config.eventName}}:

+

List of themes for {{$ctrl.event.eventName}}:

diff --git a/src/app/components/home/welcome/welcome.js b/src/app/components/home/welcome/welcome.js index 54449f6..5cf153a 100644 --- a/src/app/components/home/welcome/welcome.js +++ b/src/app/components/home/welcome/welcome.js @@ -8,7 +8,7 @@ export const Welcome = { controller: WelcomeController, templateUrl: 'app/components/home/welcome/welcome.html', bindings: { - config: '=application', + event: '=', tracks: '=', drafts: '=', proposals: '=' diff --git a/src/app/services/resources/event.service.js b/src/app/services/resources/event.service.js new file mode 100644 index 0000000..b7a5315 --- /dev/null +++ b/src/app/services/resources/event.service.js @@ -0,0 +1,24 @@ +export const Event = (RestangularProvider) => { + 'ngInject' + + const applicationPath = 'application' + + const parseDate = (stringDate) => moment(stringDate, 'DD/MM/YYYY', true) + + RestangularProvider.addResponseInterceptor((data, operation, what) => { // temporary workaround to… + if (what === applicationPath && operation === 'get') { //… https://github.com/cfpio/callForPapers/issues/103 + ['date', 'decisionDate', 'releaseDate'].forEach((prop) => { + data[prop] = parseDate(data[prop]) + }) + } + return data + }) + + return { + '$get': (Restangular) => { + 'ngInject' + + return Restangular.one(applicationPath) // "application" resource not really RESTful… + } + } +} diff --git a/src/app/services/resources/resources.module.js b/src/app/services/resources/resources.module.js index 53fbd23..c2f70a0 100644 --- a/src/app/services/resources/resources.module.js +++ b/src/app/services/resources/resources.module.js @@ -2,6 +2,7 @@ import {Users} from './users.service' import {Drafts, Proposals} from './proposals.service' import {Tracks} from './tracks.service' import {Formats} from './formats.service' +import {Event} from './event.service' const dependencies = [ 'restangular', @@ -14,3 +15,4 @@ export const resources = angular.module('io.cfp.front.services.resource', [...de .factory('Proposals', Proposals) .factory('Tracks', Tracks) .factory('Formats', Formats) + .provider('Event', Event)