Merge pull request #8 from alberanid/master

fields validation
This commit is contained in:
Davide Alberani 2015-03-23 23:07:42 +01:00
commit 966e4a4c8c
6 changed files with 60 additions and 28 deletions

View file

@ -1,24 +1,24 @@
<!-- show details of a single Event (editing also take place here) -->
<div class="container-fluid">
<div class="container">
<form ng-model="eventdetails" ng-submit="save()">
<div class="input-group input-group-lg">
<span class="input-group-addon" id="basic-addon1">Title</span>
<input type="text" class="form-control" placeholder="Title" aria-describedby="basic-addon-2" value="{{event.title}}" ng-model="event.title" ng-required="1">
<span class="input-group-addon">Title</span>
<input type="text" class="form-control" placeholder="Title" value="{{event.title}}" ng-model="event.title" ng-required="1">
</div>
<div class="input-group top5">
<span class="input-group-addon" id="basic-addon1">Short description</span>
<input type="text" class="form-control" placeholder="The event in one sentence" aria-describedby="basic-addon1" value="{{event['short-description']}}" ng-model="event['short-description']">
<span class="input-group-addon">Short description</span>
<input type="text" class="form-control" placeholder="The event in one sentence" value="{{event['short-description']}}" ng-model="event['short-description']">
</div>
<div class="input-group top5">
<span class="input-group-addon" id="basic-addon1">Begin time</span>
<input type="text" class="form-control" placeholder="Date and time" aria-describedby="basic-addon1" value="{{event['begin-datetime']}}" ng-model="event['begin-datetime']">
<span class="input-group-addon">Begin time</span>
<input type="datetime-local" class="form-control" placeholder="Date and time" value="{{event['begin-datetime']}}" ng-model="event['begin-datetime']">
</div>
<div class="input-group top5">
<span class="input-group-addon" id="basic-addon1">End time</span>
<input type="text" class="form-control" placeholder="Date and time" aria-describedby="basic-addon1" value="{{event['end-datetime']}}" ng-model="event['begin-endtime']">
<span class="input-group-addon">End time</span>
<input type="datetime-local" class="form-control" placeholder="Date and time" value="{{event['end-datetime']}}" ng-model="event['end-datetime']">
</div>
<input type="submit" style="position: absolute; left: -9999px; width: 1px; height: 1px;"/>
</form>

View file

@ -2,12 +2,19 @@
<div class="container">
<div class="row">
<div class="col-lg-12">
Search: <input ng-model="query">
Sort by:
<select ng-model="orderProp">
<option value="title">Alphabetical</option>
<option value="begin-datetime">Date</option>
</select>
<form class="form-inline">
<div class="form-group">
<label for="query-events">Search:</label>
<input type="text" id="query-events" class="form-control" placeholder="Event title" ng-model="query">
</div>
<div class="form-group">
<label for="events-order">Sort by:</label>
<select id="events-order" class="form-control" ng-model="orderProp">
<option value="title">Alphabetical</option>
<option value="begin-datetime">Date</option>
</select>
</div>
</form>
</div>
</div>
</div>

View file

@ -15,6 +15,12 @@
*/
String.prototype.getTime = function() {
var ms = Date.parse(this);
return new Date(ms);
};
/* Register our fantastic app. */
var eventManApp = angular.module('eventManApp', [
'ngRoute',

View file

@ -14,6 +14,18 @@ eventManServices.factory('Event', ['$resource',
return angular.fromJson(data).events;
}
},
get: {method: 'GET',
transformResponse: function(data, headers) {
data = angular.fromJson(data);
if (data && data['begin-datetime']) {
data['begin-datetime'] = data['begin-datetime'].getTime();
}
if (data && data['end-datetime']) {
data['end-datetime'] = data['end-datetime'].getTime();
}
return data;
}
},
update: {method: 'PUT'}
});
}]

View file

@ -1,19 +1,19 @@
<!-- show details of a single Person (editing also take place here) -->
<div class="container-fluid">
<div class="container">
<form ng-model="persondetails" ng-submit="save()">
<div class="input-group input-group-lg">
<span class="input-group-addon" id="basic-addon1">Name</span>
<input type="text" class="form-control" placeholder="Name" aria-describedby="basic-addon-2" value="{{person.name}}" ng-model="person.name" ng-required="1">
<span class="input-group-addon">Name</span>
<input type="text" class="form-control" placeholder="Name" value="{{person.name}}" ng-model="person.name" ng-required="1">
</div>
<div class="input-group input-group-lg top5">
<span class="input-group-addon" id="basic-addon1">Surname</span>
<input type="text" class="form-control" placeholder="Surname" aria-describedby="basic-addon1" value="{{person.surname}}" ng-model="person.surname">
<span class="input-group-addon">Surname</span>
<input type="text" class="form-control" placeholder="Surname" value="{{person.surname}}" ng-model="person.surname">
</div>
<div class="input-group top5">
<span class="input-group-addon" id="basic-addon1">Email</span>
<input type="text" class="form-control" placeholder="root@example.com" aria-describedby="basic-addon1" value="{{person.email}}" ng-model="person.email">
<span class="input-group-addon">Email</span>
<input type="email" class="form-control" placeholder="root@example.com" value="{{person.email}}" ng-model="person.email">
</div>
<input type="submit" style="position: absolute; left: -9999px; width: 1px; height: 1px;"/>

View file

@ -2,12 +2,19 @@
<div class="container">
<div class="row">
<div class="col-lg-12">
Search: <input ng-model="query">
Sort by:
<select ng-model="orderProp">
<option value="name">Alphabetical</option>
<option value="id">ID</option>
</select>
<form class="form-inline">
<div class="form-group">
<label for="query-persons">Search:</label>
<input type="text" id="query-persons" class="form-control" placeholder="Name or email" ng-model="query">
</div>
<div class="form-group">
<label for="persons-order">Sort by:</label>
<select id="persons-order" class="form-control" ng-model="orderProp">
<option value="name">Alphabetical</option>
<option value="_id">ID</option>
</select>
</div>
</form>
</div>
</div>
</div>