mirror of
https://github.com/arnaucube/commonroutesWebApp.git
synced 2026-02-07 11:26:43 +01:00
improved main, implementing new travel
This commit is contained in:
34
views/newTravel/newTravel.html
Normal file
34
views/newTravel/newTravel.html
Normal file
@@ -0,0 +1,34 @@
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
<div class="col-sm-2">
|
||||
<button ng-click="selectType('offering')" type="button" class="btn btn-outline-success">Offering travel</button><br>
|
||||
<button ng-click="selectType('asking')" type="button" class="btn btn-outline-success">Asking travel</button><br>
|
||||
<button ng-click="selectType('package')" type="button" class="btn btn-outline-success">Asking package</button>
|
||||
</div>
|
||||
<div class="col-sm-10">
|
||||
<div class="panel">
|
||||
<div class="panel-heading c_deepPurpleG500to300">
|
||||
<h3 class="panel-title">
|
||||
<i ng-show="travel.type=='offering'" title="offering" class="fa fa-car fa-2x"></i>
|
||||
<i ng-show="travel.type=='asking'" title="asking" class="fa fa-question fa-2x"></i>
|
||||
<i ng-show="travel.type=='package'" title="package" class="fa fa-archive fa-2x"></i>
|
||||
<i style="margin-right: 20px;"></i>
|
||||
New {{travel.type}} travel
|
||||
</h3>
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
<div class="row">
|
||||
<div class="col-sm-4">
|
||||
<div ng-include="'views/newTravel/newofferingForm.html'"></div>
|
||||
</div>
|
||||
<div class="col-sm-8">
|
||||
<leaflet width="100%" height="500px" markers="markers" center="center"
|
||||
tiles="tiles" id="map-simple-map"></leaflet>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
66
views/newTravel/newTravel.js
Normal file
66
views/newTravel/newTravel.js
Normal file
@@ -0,0 +1,66 @@
|
||||
'use strict';
|
||||
|
||||
angular.module('app.newTravel', ['ngRoute'])
|
||||
|
||||
.config(['$routeProvider', function($routeProvider) {
|
||||
$routeProvider.when('/newTravel', {
|
||||
templateUrl: 'views/newTravel/newTravel.html',
|
||||
controller: 'NewTravelCtrl'
|
||||
});
|
||||
}])
|
||||
|
||||
.controller('NewTravelCtrl', function($scope, $http, toastr) {
|
||||
$scope.travel = {};
|
||||
|
||||
$scope.selectType = function(type) {
|
||||
$scope.travel.type = type;
|
||||
};
|
||||
|
||||
//map
|
||||
$scope.center = {
|
||||
/*lat: 0,
|
||||
lng: 0,
|
||||
zoom: 1*/
|
||||
};
|
||||
$scope.bounds = {};
|
||||
$scope.markers = [];
|
||||
$scope.tiles = {
|
||||
url: "http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png",
|
||||
options: {
|
||||
attribution: '<a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors'
|
||||
}
|
||||
};
|
||||
|
||||
$scope.doNewTravel = function() {
|
||||
$scope.postNewTravel();
|
||||
};
|
||||
$scope.postNewTravel = function() {
|
||||
$http({
|
||||
url: urlapi + 'travels',
|
||||
method: "POST",
|
||||
data: $scope.travel
|
||||
})
|
||||
.then(function(data) {
|
||||
console.log(data);
|
||||
window.location = "#app/travels";
|
||||
},
|
||||
function(data) { // optional
|
||||
// failed
|
||||
console.log(data);
|
||||
toastr.warning('Complete all parameters first');
|
||||
|
||||
});
|
||||
};
|
||||
$scope.allParametersCompleted = function() {
|
||||
if (($scope.travel.title != undefined) &&
|
||||
($scope.travel.from != undefined) &&
|
||||
($scope.travel.to != undefined) &&
|
||||
($scope.travel.date != undefined) &&
|
||||
($scope.travel.seats != undefined) &&
|
||||
($scope.travel.type != undefined)) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
});
|
||||
52
views/newTravel/newofferingForm.html
Normal file
52
views/newTravel/newofferingForm.html
Normal file
@@ -0,0 +1,52 @@
|
||||
<div class="form-group label-floating">
|
||||
<input ng-model="travel.title" abmFormControl class="form-control" placeholder="Title" type="text">
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="form-group label-floating col-md-6">
|
||||
<input ng-model="travel.from.name" abmFormControl class="form-control" placeholder="From" type="text">
|
||||
</div>
|
||||
<div class="form-group label-floating col-md-6">
|
||||
<input ng-model="travel.to.name" abmFormControl class="form-control" placeholder="To" type="text">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="form-group label-floating col-md-7">
|
||||
<input ng-model="travel.date" abmFormControl class="form-control" placeholder="Date" type="date">
|
||||
</div>
|
||||
<div class="form-group label-floatin col-md-5">
|
||||
<input class="form-control" type="time" name="usr_time" ng-model="travel.hour">
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="form-group col-md-4">
|
||||
<input class="form-control" type="number" name="seats" min="1" max="20" ng-model="travel.seats" placeholder="nºSeats">
|
||||
</div>
|
||||
<div class="col-md-8">
|
||||
<div class="form-group label-floating">
|
||||
<!--<input ng-model="travel.package" abmFormControl class="form-control" placeholder="Can carry package" type="text">-->
|
||||
<label class="form-check-label">
|
||||
<input class="form-check-input" type="checkbox" ng-model="travel.package"> Can carry package
|
||||
</label>
|
||||
</div>
|
||||
<div class="form-group label-floating">
|
||||
<!--<input ng-model="travel.collectivized" abmFormControl class="form-control" placeholder="Collectivized" type="text">-->
|
||||
<label class="form-check-label">
|
||||
<input class="form-check-input" type="checkbox" ng-model="travel.collectivized"> Collectivized
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group label-floating">
|
||||
<input ng-model="travel.description" abmFormControl class="form-control" placeholder="Description" type="text">
|
||||
</div>
|
||||
|
||||
<p class="padding" ng-show="allParametersCompleted()">
|
||||
<button ng-click="closeNewOfferingTravel()" class="btn btn-raised c_grey500">
|
||||
Cancel
|
||||
</button>
|
||||
<button ng-click="doNewTravel()" class="btn btn-raised c_deepPurple300 pull-right">
|
||||
Create travel
|
||||
</button>
|
||||
</p>
|
||||
</form>
|
||||
Reference in New Issue
Block a user