ng:autobind></script>
<script>
-Calendar.$inject = ['$xhr', '$resource'];
+Calendar.$inject = ['$xhr', '$resource','$log'];
-function Calendar($xhr,$resource){
- console.info('Calendar');
+function Calendar($xhr,$resource,$log){
+ $log.info('Calendar');
var self = this;
$xhr("GET"
, "/reservations/get/www.google.com/calendar/ical/8tg8ecg285qshtp75813jktqa0%40group.calendar.google.com/private-b9d68b530fde2c6060979f8a05aa0865/basic.ics"
, function(code, response){
- console.log('xhr calendar', code, response);
+ $log.log('xhr calendar', code, response);
self.data = response;
}
);
$xhr("GET"
, "/reservations/events/submited"
, function(code, response){
- console.log('xhr submited', code, response);
+ $log.log('xhr submited', code, response);
self.submited = response;
}
);
self.reservation.status = 'event';
this.select_event = function(c) {
- console.info('select_event', c);
+ $log.info('select_event', c);
self.reservation.event = c;
self.reservation.status = 'changed';
if (self.submited) self.reservation.slot_nr = ++self.submited[c.UID];
this.save_submission = function() {
if ( self.reservation && self.reservation.event ) {
- console.info('submit save');
+ $log.info('submit save');
self.reservation.status = 'saved';
self.reservation.$save();
self.load_submited();
} else {
- console.info('submit ignored');
+ $log.info('submit ignored');
}
}
+ this.event_full = function(e) {
+ if ( ! self.submited ) return 0;
+
+ var count = self.submited[e.UID];
+ if ( count === undefined ) return 0;
+ if ( parseInt(count) < parseInt(e.slots) ) return 0;
+ return 1;
+ }
}
// http://groups.google.com/group/angular/browse_thread/thread/af68afb22fd2d2ab/18fc5e3216a77e53?show_docid=18fc5e3216a77e53
<title>Reservations</title>
<style>
+li {
+ margin-bottom: 1em;
+}
</style>
</head>
<ul>
<li ng:repeat="c in data.events" ng:show="reservation.status == 'event'">
{{c.DTSTART}} - {{c.DTEND}}
-<a href="" ng:click="select_event(c)" ng:show="! reservation.event && c.UID != reservation.event.UID">{{c.SUMMARY}}</a>
-<b ng:show="reservation.event && reservation.event.UID == c.UID">{{c.SUMMARY}}</b>
-<em ng:show="submited[c.UID]">
-broj prijava: {{submited[c.UID]}}
-</em>
-<em ng:show="c.slots">/{{c.slots}}</em>
+
+<span ng:show="! event_full(c)">
+ <a href="" ng:click="select_event(c)">{{c.SUMMARY}}</a>
+ <em ng:show="submited[c.UID]">prijava: {{submited[c.UID]}}</em>
+ <em ng:show="c.slots">mjesta: {{c.slots}}</em>
+</span>
+
+<span ng:show="event_full(c)">
+ <b>{{c.SUMMARY}}</b>
+ <em>popunjena sva mjesta: {{c.slots}}</em>
+</span>
+
<div>{{c.LOCATION}}</div>
<div ng:show="c.DESCRIPTION">
{{c.DESCRIPTION}}