arnaucube
arnaucube/openEventsPlatformAppPublic Self-hosted repository
newEvent categories selection implemented, and image by url (temporalment)
arnaucode idoctnef@openmailbox.org
Fri, 24 Feb 2017 00:33:16 +0100
commit

8b1e678202f64f53d9260c19d75cd8775760a68b

parent

e102427098014a4b82e46ebd9855acee6da9ccfa

2 files changed, 39 insertions(+), 12 deletions(-)

jump to
M www/js/newEvent.js → www/js/newEvent.js

@@ -3,8 +3,10 @@

.controller('NewEventCtrl', function($scope, $http, $ionicModal, $timeout, $ionicLoading, $filter, leafletData, leafletBoundsHelpers) { + + //initialization $scope.event={}; - $scope.event.categories=[{name: "prova"}]; + $scope.event.categories=[]; $scope.event.location={ direction: "", geo: {

@@ -13,6 +15,32 @@ long: "",

name: "" } }; + + //get list of categories + $scope.categories; + $http.get(urlapi + 'categoriesList') + .then(function(data){ + $scope.categories=data.data; + console.log($scope.categories); + }, function(data){ + console.log('data error'); + console.log(data); + $ionicLoading.show({ template: 'Error connecting server', noBackdrop: true, duration: 2000 }); + + }); + $scope.categorySelected = function(){ + $scope.event.categories=[]; + for(var i=0; i<$scope.categories.length; i++) + { + if($scope.categories[i].selected) + { + $scope.event.categories.push($scope.categories[i]); + } + } + console.log($scope.event.categories); + }; + + $scope.postEvent = function(){ $http({ url: urlapi + 'events',
M www/templates/newEvent.html → www/templates/newEvent.html

@@ -15,17 +15,16 @@ <label class="item-input">

<span class="input-label">{{'Hour' | translate}}</span> <input ng-model="event.date" type="time" placeholder=""> </label> - <!--<label class="item item-input item-select"> - <div class="input-label"> - Categories - </div> - <select> - <option>Xerrada</option> - <option>Esport</option> - <option>Debat</option> - <option>Taller</option> - </select> - </label>--> + <label class="item item-input"> + <input type="text" ng-model="event.img" placeholder="img"> + </label> + <ion-list> + Categories: + <ion-checkbox ng-model="category.selected" ng-repeat="category in categories" + ng-click="categorySelected()"> + {{category.name}} + </ion-checkbox> + </ion-list> <label class="item item-input"> <input type="text" ng-model="event.location.direction" placeholder="Direction"> </label>