Skip to content

Commit 614c6cb

Browse files
committed
Merge branch 'eventManagement' of https://github.com/damienmoulard/Zenergy.git
2 parents a7f2354 + 19c2050 commit 614c6cb

File tree

3 files changed

+96
-20
lines changed

3 files changed

+96
-20
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,68 @@
11
<h1>Create a new ponctual event</h1>
22
<div class="container " ng-controller="ponctualEventCreationPageController">
3+
34
<div class="row">
4-
<!--
5-
<div name="formRegistration" class="col-md-3 col-lg-offset-4">
6-
<form ng-submit="register()">
75

8-
<div class="form-group">
9-
<input type="email" class="form-control" ng-model="user.mail" placeholder="Event name" required>
10-
</div>
6+
<div name="formPonctualEvent" class="col-md-3 col-lg-offset-4">
117

8+
<form ng-submit="createEvent()">
9+
1210
<div class="form-group">
13-
<input type="password" id="password" name="user.password" class="form-control" ng-model="user.password" placeholder="Password" required>
11+
<input class="form-control" ng-model="ponctualEvent.event.eventName" placeholder="Event name" required>
1412
</div>
1513

1614
<div class="form-group">
17-
<input type="password" id="passwordBis" name="passwordBis" class="form-control" ng-model="user.passwordBis" placeholder="Password Confirmation" required samepassword="password">
15+
<div class="input-group">
16+
<div class="input-group-btn">
17+
<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Select an activity <span class="caret"></span></button>
18+
<ul class="dropdown-menu" ng-repeat="activity in filtered = (activities | filter: query)">
19+
<li><a ng-click="activitySelected(activity)">{{activity.activityName}}</a></li>
20+
</ul>
21+
</div>
22+
<input type="text" class="form-control" id="selectedActivity" disabled>
23+
</div>
1824
</div>
19-
<p class="text-danger" ng-if="passNotMatch">Passwords don't match</p>
2025

2126
<div class="form-group">
22-
<input type="text" class="form-control" ng-model="user.firstName" placeholder="Firstname">
27+
<div class="input-group">
28+
<div class="input-group-btn">
29+
<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Select a room <span class="caret"></span></button>
30+
<ul class="dropdown-menu" ng-repeat="room in filtered = (rooms | filter: query)">
31+
<li><a ng-click="roomSelected(room)">{{room.roomName}}</a></li>
32+
</ul>
33+
</div>
34+
<input type="text" class="form-control" id="selectedRoom" disabled>
35+
</div>
2336
</div>
2437

2538
<div class="form-group">
26-
<input type="text" class="form-control" ng-model="user.lastName" placeholder="Lastname">
39+
<input type="date" format="yyyy-MM-dd" name="ponctualEvent.eventDate" class="form-control" ng-model="ponctualEvent.eventDate" placeholder="Date" required>
40+
<p class="text-danger" ng-if="dateError">You can't create an event in the past. Unless you are a wizard. Which I doubt.</p>
2741
</div>
2842

2943
<div class="form-group">
30-
<input type="text" class="form-control" ng-model="user.adr1" placeholder="Address">
44+
<input type="time" format="HH:mm" min="08:00" max="20:00" name="ponctualEvent.event.timeBegin" class="form-control" ng-model="ponctualEvent.event.timeBegin" placeholder="Time of the event beginning" required>
3145
</div>
3246

3347
<div class="form-group">
34-
<input type="text" class="form-control" ng-model="user.adr2" placeholder="Rest of the address ">
48+
<input type="number" min="0.5" step="0.5" name="ponctualEvent.event.eventDurationHours" class="form-control" ng-model="ponctualEvent.event.eventDurationHours" placeholder="Duration in hours (can be 1.5)" required>
3549
</div>
3650

3751
<div class="form-group">
38-
<input type="text" class="form-control" ng-model="user.pc" placeholder="Postal Code ">
52+
<input name="ponctualEvent.event.eventDescription" class="form-control" ng-model="ponctualEvent.event.eventDescription" placeholder="Description" required>
3953
</div>
4054

4155
<div class="form-group">
42-
<input type="text" class="form-control" ng-model="user.town" placeholder="Town ">
56+
<input type="number" min="0" step="0.01" name="ponctualEvent.event.eventPrice" class="form-control" ng-model="ponctualEvent.event.eventPrice" placeholder="Price (€)" required>
4357
</div>
4458

4559
<div class="form-group">
46-
<input type="text" class="form-control" ng-model="user.phone" placeholder="Phone ">
60+
<input type="number" min="0" name="ponctualEvent.event.eventMaxPeople" class="form-control" ng-model="ponctualEvent.event.eventMaxPeople" placeholder="Maximum number of participants" required>
4761
</div>
4862

49-
<input type="submit" id="submit" value="Sign in" class="btn btn-primary" />
50-
</form>
63+
<input type="submit" id="submit" value="Validate" class="btn btn-primary" />
64+
</form>
5165
</div>
52-
-->
5366
</div>
5467
</div>
5568

Zenergy/Zenergy/Scripts/Controllers/eventsManagementPageController.js

+3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
zenergyApp.controller("eventsManagementPageController", ["$scope", "$http", "tokenService", "$window", "$location", function ($scope, $http, tokenService, $window, $location) {
22

33
// Get manager events
4+
// TODO : get THIS MANAGER events
45
var response = $http({
56
url: '/api/ponctualEvents',
67
method: 'GET',
@@ -19,6 +20,8 @@
1920

2021
// Store the event rw in the events array
2122
$scope.eventToUpdate = eventRow;
23+
// $scope.eventToUpdate = ponctualEvents[eventRow];
24+
// comme ça on met ça en paramettre du put, on se fait plus chier avec les index
2225

2326
// Show modal to update infos
2427
$('#myModal').modal('show');

Zenergy/Zenergy/Scripts/Controllers/ponctualEventCreationPageController.js

+61-1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,66 @@
2828
console.log($scope.rooms);
2929
});
3030

31-
$scope.ponctualEvent = {};
31+
$scope.ponctualEvent = { eventId: 1, eventDate: new Date(), event: { eventId: 1, roomId: '', activityId: '', eventName: '', eventPrice: '', eventDurationHours: '', eventMaxPeople: '', eventDescription: '', timeBegin: '' } };
32+
$scope.regular = false;
3233

34+
// When an activity is selected in the form
35+
$scope.activitySelected = function (activity) {
36+
$('#selectedActivity').attr("placeholder", activity.activityName);
37+
$scope.ponctualEvent.event.activityId = activity.activityId;
38+
}
39+
40+
// When a room is selected in the form
41+
$scope.roomSelected = function (room) {
42+
$('#selectedRoom').attr("placeholder", room.roomName);
43+
$scope.ponctualEvent.event.roomId = room.roomId;
44+
}
45+
46+
// If user wants to create a ponctual event
47+
$scope.ponctualSelected = function () {
48+
$('#ponctualSelect').attr("class", "active");
49+
$('#regularSelect').attr("class", "");
50+
$scope.regular = false;
51+
}
52+
53+
$scope.regularSelected = function () {
54+
$('#ponctualSelect').attr("class", "");
55+
$('#regularSelect').attr("class", "active");
56+
$scope.regular = true;
57+
}
58+
59+
$scope.createEvent = function () {
60+
console.log($scope.ponctualEvent);
61+
62+
$scope.hasError = false;
63+
$scope.dateError = false;
64+
65+
var today = new Date();
66+
if ($scope.ponctualEvent.eventDate <= today) {
67+
$scope.hasError = true;
68+
$scope.dateError = true;
69+
}
70+
71+
var date = new Date($scope.ponctualEvent.event.timeBegin);
72+
$scope.ponctualEvent.event.timeBegin = date.getHours().toString() + ":" + date.getMinutes().toString();
73+
console.log($scope.ponctualEvent.event.timeBegin);
74+
75+
if (!$scope.hasError)
76+
{
77+
var response = $http({
78+
url: '/api/ponctualEvents',
79+
method: 'POST',
80+
data: $scope.ponctualEvent,
81+
headers: {
82+
'Content-Type': 'application/json'
83+
}
84+
}).then(function successCallback(response) {
85+
bootbox.alert("Your event is now created!", function () {
86+
$location.path("/#/MyEvents");
87+
});
88+
}, function errorCallback(response) {
89+
bootbox.alert("There has been an error during the event creation. Please check your event information.");
90+
});
91+
}
92+
}
3393
}]);

0 commit comments

Comments
 (0)