Skip to content
This repository has been archived by the owner on May 12, 2023. It is now read-only.

Commit

Permalink
Event resource with workaround to cfpio/callForPapers#103
Browse files Browse the repository at this point in the history
  • Loading branch information
Jean-Louis Jouannic committed Jan 2, 2017
1 parent 49d5a58 commit 1bb0294
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/app/components/home/home.module.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
Expand Down
16 changes: 8 additions & 8 deletions src/app/components/home/welcome/welcome.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ <h3>Proposals</h3>
<div class="row">
<div class="col-md-12 col-sm-12">
<h1><i class="fa fa-comment-o"></i> Call for Papers</h1>
<h2>{{$ctrl.config.eventName}}, {{$ctrl.config.date}}</h2>
<h2>{{$ctrl.event.eventName}}, {{$ctrl.event.date}}</h2>
<hr>
</div>
</div>
Expand All @@ -25,14 +25,14 @@ <h2>{{$ctrl.config.eventName}}, {{$ctrl.config.date}}</h2>
<div class="col-md-5 col-sm-12">
<h3><i class="fa fa-calendar"></i> Agenda</h3>
<p><strong>opening :</strong> TODO</p>
<p><strong>closing :</strong> {{$ctrl.config.decisionDate}}</p>
<p><strong>Program announced :</strong> {{$ctrl.config.releaseDate}}</p>
<p><strong>closing :</strong> {{$ctrl.event.decisionDate}}</p>
<p><strong>Program announced :</strong> {{$ctrl.event.releaseDate}}</p>
</div>
<div class="col-md-5 col-sm-12">
<h3>About {{$ctrl.config.eventName}}</h3>
<i class="fa fa-video-camera"></i> Review {{$ctrl.config.eventName}} videos on <a href="#">Youtube</a>
<h3>About {{$ctrl.event.eventName}}</h3>
<i class="fa fa-video-camera"></i> Review {{$ctrl.event.eventName}} videos on <a href="#">Youtube</a>
<br>
<i class="fa fa-arrow-right"></i> {{$ctrl.config.eventName}} web site
<i class="fa fa-arrow-right"></i> {{$ctrl.event.eventName}} web site
</div>
</div>

Expand All @@ -41,7 +41,7 @@ <h3>About {{$ctrl.config.eventName}}</h3>
<div class="col-md-5 col-sm-5">
<div class="panel panel-default">
<div class="panel-heading">
<h3><i class="fa fa-bullhorn"></i> CFP is {{$ctrl.config.open ? 'Open' : 'Closed'}}</h3>
<h3><i class="fa fa-bullhorn"></i> CFP is {{$ctrl.event.open ? 'Open' : 'Closed'}}</h3>
</div>
<div class="panel-body">
<a href="#" class="btn btn-primary">Become a speaker</a>
Expand All @@ -54,7 +54,7 @@ <h3><i class="fa fa-bullhorn"></i> CFP is {{$ctrl.config.open ? 'Open' : 'Closed

<div class="col-md-12 col-sm-12" ng-show="$ctrl.tracks">
<h3><i class="fa fa-book"></i>Themes</h3>
<p>List of themes for {{$ctrl.config.eventName}}:</p>
<p>List of themes for {{$ctrl.event.eventName}}:</p>
<table class="table table-bordered table-striped">
<tbody>
<tr ng-repeat="track in $ctrl.tracks">
Expand Down
2 changes: 1 addition & 1 deletion src/app/components/home/welcome/welcome.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export const Welcome = {
controller: WelcomeController,
templateUrl: 'app/components/home/welcome/welcome.html',
bindings: {
config: '=application',
event: '=',
tracks: '=',
drafts: '=',
proposals: '='
Expand Down
24 changes: 24 additions & 0 deletions src/app/services/resources/event.service.js
Original file line number Diff line number Diff line change
@@ -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…
}
}
}
2 changes: 2 additions & 0 deletions src/app/services/resources/resources.module.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -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)

0 comments on commit 1bb0294

Please sign in to comment.