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

Commit 5716932

Browse files
committedFeb 4, 2016
Almost done it to the V1
1 parent 0b926a6 commit 5716932

12 files changed

+155
-33
lines changed
 

‎bower.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"moment": "~2.10.6",
1717
"animate.css": "~3.4.0",
1818
"angular": "~1.4.2",
19-
"angular-dragdrop": "~1.0.13"
19+
"angular-native-dragdrop": "~1.2.0"
2020
},
2121
"devDependencies": {
2222
"angular-mocks": "~1.4.2"
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,14 @@
11
angular.module('schedit').directive('scEventList', function(){
22
return {
33
templateUrl: 'app/components/eventList/eventList.template.html',
4-
scope:{
5-
events: '=scEvents'
6-
},
4+
scope:{},
75
bindToController:true,
86
controllerAs:'list',
9-
controller:function($scope){
7+
controller:function($scope, EventHelper){
108
var vm = this;
11-
$scope.$watch(function(){
12-
return vm.events;
13-
}, function(){
14-
console.log(vm);
15-
})
9+
vm.events = EventHelper.events;
10+
vm.spaceGap = EventHelper.spaceGap;
11+
vm.getNbSpaces = EventHelper.getNbSpaces;
1612
}
1713
}
1814
})
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,21 @@
11
<div class="panel panel-primary minh" style="border-radius:0px">
22
<div class="panel-heading no-radius" style="border-radius:0px">Events</div>
33
<div class="panel-body">
4-
<div drag="true" ng-model="event" jqyoui-options="{revert:'invalid'}" jqyoui-draggable="{animated:true}" ng-hide="!event.name" ng-repeat="event in list.events" class="panel panel-primary event">
5-
<div class="panel-heading no-radius">{{event.name}}</div>
4+
<div class="row">
5+
<div class="col-xs-12">
6+
<input class="form-control" style="margin-bottom:10px;" type="text" ng-model="list.filter" placeholder="Filter by name">
7+
<select style="margin-bottom:10px;" type="text" ng-model="list.status">
8+
<option value="">All</option>
9+
<option value="true">Sheduled</option>
10+
<option selected="selected" value="false">Not sheduled</option>
11+
</select>
12+
<span>Filter by status</span>
13+
</div>
14+
<div class="col-xs-12">
15+
<div ng-repeat="event in list.events | filter:{name:list.filter, scheduled:list.status}" class="panel event" ng-class="{'panel-primary':!event.scheduled, 'panel-success':event.scheduled}">
16+
<div on-drop-success="list.dropSuccess(event)" ui-draggable="true" drag="event" class="panel-heading no-radius">{{list.getNbSpaces(event)*list.spaceGap}}min - {{event.name}}</div>
17+
</div>
18+
</div>
619
</div>
720
</div>
821
</div>

‎src/app/components/schedit.directive.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@ angular.module('schedit').directive('scSchedit', function(){
77
},
88
bindToController:true,
99
controllerAs:'schedit',
10-
controller:function($scope){
10+
controller:function($scope, EventHelper){
1111
var vm = this;
1212
$scope.$watch(function(){
1313
return vm.events;
1414
}, function(){
15-
console.log(vm);
15+
EventHelper.events = vm.events;
1616
})
1717
}
1818
}

‎src/app/components/schedit.template.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<sc-event-list sc-events='schedit.events'></sc-event-list>
55
</div>
66
<div class="col-xs-8 minh padding-xs">
7-
<sc-schedule sc-rooms='schedit.options.rooms' sc-nb-space="schedit.options.nbSpace"></sc-schedule>
7+
<sc-schedule sc-rooms='schedit.options.rooms' sc-time="schedit.options.time"></sc-schedule>
88
</div>
99
</div>
1010
</div>

‎src/app/components/schedule/schedule.directive.js

+64-5
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,75 @@ angular.module('schedit').directive('scSchedule', function(){
33
templateUrl: 'app/components/schedule/schedule.template.html',
44
scope:{
55
rooms: '=scRooms',
6-
nbSpace: '=scNbSpace'
6+
time: '=scTime'
77
},
88
bindToController:true,
99
controllerAs:'schedule',
10-
controller:function($scope){
10+
controller:function($scope,EventHelper){
1111
var vm = this;
12-
vm.spaces= [];
13-
for(i=0; i<vm.nbSpace; i++){
14-
vm.spaces.push({status:'empty'});
12+
EventHelper.spaceGap = vm.time.spaceGap;
13+
14+
var initSchedule = function(){
15+
vm.nbSpace = ((24 - vm.time.startHour - (24 - vm.time.endHour))*60) / vm.time.spaceGap;
16+
vm.gapPerHour = 60/(vm.time.spaceGap);
17+
vm.gaps = []
18+
for(var i=0; i<vm.gapPerHour; i++){
19+
vm.gaps.push(i*vm.time.spaceGap);
20+
}
21+
console.log(vm.gaps);
22+
for(var j=0; j<vm.rooms.length; j++){
23+
var room = vm.rooms[j];
24+
room.spaces = [];
25+
for(var i=0; i<vm.nbSpace; i++){
26+
room.spaces.push({empty:true, canDrop:true});
27+
}
28+
}
1529
}
30+
31+
var canDrop = function(list, index, nbSpace){
32+
for(var i=0; i<nbSpace; i++){
33+
if(list[index+i]){
34+
if(!list[index+i].empty){
35+
return false;
36+
}
37+
}
38+
}
39+
return true;
40+
}
41+
42+
$scope.$on('ANGULAR_DRAG_START',function(event,originEvent,channel,data){
43+
var nbSpace = EventHelper.getNbSpaces(data.data);
44+
for(var j=0; j<vm.rooms.length; j++){
45+
var room = vm.rooms[j];
46+
for(var i=0; i<room.spaces.length; i++){
47+
room.spaces[i].canDrop = canDrop(room.spaces, i, nbSpace);
48+
}
49+
}
50+
})
51+
52+
$scope.$on('ANGULAR_DRAG_END',function(event,originEvent,channel){
53+
for(var j=0; j<vm.rooms.length; j++){
54+
var room = vm.rooms[j];
55+
for(var i=0; i<room.spaces.length; i++){
56+
room.spaces[i].canDrop = true;
57+
}
58+
}
59+
$scope.$apply();
60+
})
61+
62+
vm.getNbSpaces = EventHelper.getNbSpaces;
63+
64+
vm.setEvent = function(list, index, data){
65+
var nbSpace = EventHelper.getNbSpaces(data);
66+
for(var i=0; i<nbSpace; i++){
67+
data.scheduled = true;
68+
list[index+i].event = data;
69+
list[index+i].empty = false;
70+
}
71+
EventHelper.updateEvent(data);
72+
}
73+
74+
initSchedule();
1675
}
1776
}
1877
})

‎src/app/components/schedule/schedule.template.html

+7-9
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,15 @@
77
<div class="panel panel-info minh">
88
<div class="panel-heading no-radius">{{room.name}}</div>
99
<div class="panel-body margin-left-wider">
10-
<div jqyoui-options="{hoverClass:'hover'}" drop="true" jqyoui-droppable ng-model="space" ng-repeat="(index,space) in schedule.spaces">
11-
<span ng-switch="index%4" class="hour-helper">
12-
<span ng-switch-when="0" >{{index/4}}h</span>
13-
<span ng-switch-when="1" class="tiny">15</span>
14-
<span ng-switch-when="2" class="tiny">30</span>
15-
<span ng-switch-when="3" class="tiny">45</span>
10+
<div ng-class="{danger:!space.canDrop}" ui-on-drop="schedule.setEvent(room.spaces, index ,$data)" drag-hover-class="hover" ng-repeat="(index,space) in room.spaces">
11+
<span class="hour-helper">
12+
<span ng-show="index%schedule.gapPerHour === 0">{{schedule.time.startHour + index/schedule.gapPerHour}}h</span>
13+
<span ng-show="$index === index%schedule.gapPerHour && $index !== 0" ng-repeat="gap in schedule.gaps" class="tiny">{{gap}}</span>
1614
</span>
17-
<span ng-show="space.name">{{space.name | limitTo:10}}...</span>
18-
<div ng-show="index%4 !== 0" style="border-bottom:solid 0.5px">
15+
<span ng-show="space.event.name">{{space.event.name | limitTo:10}}...</span>
16+
<div class="schedule-spacer" ng-show="index%schedule.gapPerHour !== 0" style="border-bottom:solid 0.5px">
1917
</div>
20-
<div ng-show="index%4 === 0" style="border-bottom:solid 2px">
18+
<div class="schedule-spacer" ng-show="index%schedule.gapPerHour === 0" style="border-bottom:solid 2px">
2119
</div>
2220
</div>
2321
</div>

‎src/app/core/EventHelper.service.js

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
angular.module('schedit').service('EventHelper', function(){
2+
3+
var service = {};
4+
service.spaceGap = 15;
5+
service.spaceMapping = {
6+
"Docker Docker Docker":45,
7+
"Black Belt Tech":30,
8+
"Ecosystem":60,
9+
"Pre-Registration, Registration":60,
10+
"Registration":45,
11+
"Party":30,
12+
"Wild Cards":30,
13+
"Use Case":15,
14+
"break":15,
15+
"default":30
16+
}
17+
18+
service.getNbSpaces = function(event){
19+
if(service.spaceMapping[event['event_type']]){
20+
result = service.spaceMapping[event['event_type']]/service.spaceGap;
21+
}else{
22+
result = service.spaceMapping["default"]/service.spaceGap;
23+
}
24+
return result;
25+
}
26+
27+
service.events = {};
28+
29+
service.updateEvent = function(updatedEvent){
30+
angular.forEach(service.events,function(event){
31+
if(event.id === updatedEvent.id){
32+
event.scheduled = updatedEvent.scheduled;
33+
}
34+
})
35+
}
36+
37+
return service
38+
39+
})

‎src/app/index.controller.js

+10-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
angular.module('schedit').controller('IndexController', function($http){
22
var vm = this;
33

4-
$http.get('app/shedule.json').success(function(data){
4+
$http.get('app/schedule.json').success(function(data){
5+
angular.forEach(data,function(event){
6+
event.scheduled = false;
7+
})
58
vm.events = data;
69
});
710

@@ -25,6 +28,11 @@ angular.module('schedit').controller('IndexController', function($http){
2528
id:6,
2629
name:'Atelier2'
2730
}],
28-
nbSpace:96,
31+
time:{
32+
startDate: "2016-03-23",
33+
startHour: 7,
34+
endHour: 20,
35+
spaceGap: 15 //in minutes
36+
}
2937
}
3038
})

‎src/app/index.css

+10-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
.hour-helper{
2929
position:relative;
3030
font-size: 0.6em;
31-
top:9px;
31+
top:-13px;
3232
left:-16px;
3333
}
3434

@@ -56,3 +56,12 @@
5656
.hover{
5757
background-color:#CCC;
5858
}
59+
60+
.danger{
61+
background-color:#FFBDBD;
62+
}
63+
64+
.schedule-spacer{
65+
position:relative;
66+
top:-21.6px;
67+
}

‎src/app/index.module.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22
'use strict';
33

44
angular
5-
.module('schedit', ['ngDragDrop']);
5+
.module('schedit', ['ang-drag-drop']);
66

77
})();
File renamed without changes.

0 commit comments

Comments
 (0)
This repository has been archived.