-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
renamed calendarDay to calendarDays as it show multiple days, added t…
…est vor eventsource subscribe to call the callback with existing events
- Loading branch information
Showing
7 changed files
with
267 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
65 changes: 65 additions & 0 deletions
65
app/scripts/modules/nx-calendar/directives/calendarDays.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
var app = angular.module('nx-calendar'); | ||
|
||
app.controller('nx-calendar-days-controller', function($scope, nxCalendarUtilities, nxEventSource) { | ||
|
||
var config = angular.extend({ | ||
start : 0 // first hour of the day | ||
, end : 24 // last hour of the day | ||
, timeFormat : 'HH:mm' | ||
, dayFormat : 'dddd' | ||
, weekFormat : 'wo' | ||
, day : moment() | ||
, days : 1 | ||
}, $scope.config || {}); | ||
|
||
config.day = moment(config.day); | ||
|
||
$scope.timeFormat = config.timeFormat; | ||
$scope.dayFormat = config.dayFormat; | ||
$scope.weekFormat = config.weekFormat; | ||
$scope.events = []; | ||
|
||
$scope.hours = nxCalendarUtilities.range(config.start, config.end, function(hour) { | ||
return moment().hour(hour).minute(0); | ||
}); | ||
|
||
$scope.days = nxCalendarUtilities.range(config.days).map(function(day) { | ||
return config.day.clone().add(day, 'day').startOf('day'); | ||
}); | ||
|
||
var filter = { | ||
start : $scope.days[0], | ||
end : $scope.days[$scope.days.length - 1].clone().endOf('day') | ||
}; | ||
if(config.source) filter.namespace = config.source; | ||
|
||
|
||
nxEventSource.subscribe($scope, null, filter, function($evt, data) { | ||
$scope.events = data.events; | ||
console.log('nxEventSource - Events'); | ||
$scope.events.map(function(evt) { | ||
console.log(nxEventSource.format(evt)) | ||
}); | ||
}); | ||
}); | ||
|
||
|
||
var directiveDefinition = function directiveDefinition() { | ||
return function(nxCalendarConfiguration) { | ||
var template = nxCalendarConfiguration.template; | ||
|
||
return { | ||
scope: { | ||
config: '=nxCalConfig' | ||
}, | ||
controller: 'nx-calendar-days-controller', | ||
templateUrl: template('calendarDays') | ||
}; | ||
}; | ||
}; | ||
|
||
['nxCalendarDays', 'nxCalDays'].map(function(directive) { | ||
app.directive(directive, directiveDefinition(directive)); | ||
}); | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
app/scripts/modules/nx-calendar/templates/calendarDays.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<table class="table nx-calendar day-view"> | ||
<thead> | ||
<th class="nx-calendar-first"> | ||
<dic class="nx-calendar-header-text">{{days[0] | moment:weekFormat}}</div> | ||
</th> | ||
<th ng-repeat="day in days" class="nx-calendar-header"> | ||
<div class="nx-calendar-header-text">{{day | moment:dayFormat}}</div> | ||
</th> | ||
</thead> | ||
<!-- | ||
@ days Days that are visible | ||
@ hours Hours that are already presented | ||
@ skip extra td's to be skipped | ||
<tbody whole-day-view days="days" hours="hours" skip="1"></tbody> | ||
--> | ||
<tbody class="nx-calendar-colwrapper"> | ||
<tr> | ||
<td class="nx-calendar-first"></td> | ||
<td colspan="{{days.length}}" class="nx-calendar-spanningwrapper"> | ||
<div class="nx-calendar-tg-hourmarkers"> | ||
<div class="nx-calendar-tg-markercell" ng-repeat="hour in hours"> | ||
<div class="nx-calendar-tg-dualmarker"></div> | ||
</div> | ||
</div> | ||
</td> | ||
</tr> | ||
</tbody> | ||
<tbody> | ||
<tr> | ||
<td class="nx-calendar-first nx-calendar-tg-hours"> | ||
<div class="nx-calendar-tg-hour-inner" ng-repeat="hour in hours"> | ||
<div class="nx-calendar-tg-hour-clock">{{hour | moment:timeFormat}}</div> | ||
</div> | ||
</td> | ||
<td ng-repeat="day in days" class="nx-calendar-tg-day-container"> | ||
<hour-view-event-container day="day" hours="hours"></hour-view-event-container> | ||
</td> | ||
</tr> | ||
</tbody> | ||
</table> |
Oops, something went wrong.