Commit 29cf948a authored by Victor Mocelin's avatar Victor Mocelin

Adicionado funcionamento básico das listas

Criado um serviço para tratar da lista de palestras e outro para a lista de pessoas.
Implementado adição de palestra e de pessoas (usando o scanner), mas ainda não é permanente.
parent 3a64c942
......@@ -20,7 +20,10 @@
"cordova-plugin-whitelist",
"cordova-plugin-splashscreen",
"cordova-plugin-statusbar",
"ionic-plugin-keyboard"
"ionic-plugin-keyboard",
"cordova-plugin-barcodescanner"
],
"cordovaPlatforms": []
}
\ No newline at end of file
"cordovaPlatforms": [
"android"
]
}
......@@ -21,7 +21,7 @@
<script src="js/services.js"></script>
<script src="js/directives.js"></script>
<!-- Only required for Tab projects w/ pages in multiple tabs
<!-- Only required for Tab projects w/ pages in multiple tabs
<script src="lib/ionicuirouter/ionicUIRouter.js"></script>
-->
......
angular.module('app.controllers', [])
.controller('ceitificatorCtrl', function($scope) {
.controller('ceitificatorCtrl', function($scope, events) {
$scope.events = events;
})
.controller('novoEventoCtrl', function($scope) {
.controller('novoEventoCtrl', function($scope, events) {
$scope.formData = {};
$scope.addNewEvent = function (){
if ((!$scope.formData.newEvent || $scope.formData.newEvent.length === 0 || !$scope.formData.newEvent.trim()) ||
(!$scope.formData.speaker || $scope.formData.speaker.length === 0 || !$scope.formData.speaker.trim()))
alert("WTF?");
else
events.push({id: 3, name: $scope.formData.newEvent, speaker: $scope.formData.speaker});
};
})
.controller('listaDePresenAEventoXCtrl', function($scope) {
})
\ No newline at end of file
.controller('listaDePresenAEventoXCtrl', function($scope, people) {
$scope.people = people;
$scope.scan = function(){
cordova.plugins.barcodeScanner.scan(
function (result) {
$scope.$apply(function(){
people.push({id: '5', data: result.text});
});
},
function (error) {
alert("Scanning failed: " + error);
}
);
};
});
......@@ -7,29 +7,44 @@ angular.module('app.routes', [])
// Set up the various states which the app can be in.
// Each state's controller can be found in controllers.js
$stateProvider
.state('ceitificator', {
.state('ceitificator', {
url: '/home',
templateUrl: 'templates/ceitificator.html',
controller: 'ceitificatorCtrl'
controller: 'ceitificatorCtrl',
resolve: {
events: function(EventsService) {
return EventsService.getEvents();
}
}
})
.state('novoEvento', {
url: '/novo-evento',
templateUrl: 'templates/novoEvento.html',
controller: 'novoEventoCtrl'
controller: 'novoEventoCtrl',
resolve: {
events: function(EventsService) {
return EventsService.getEvents();
}
}
})
.state('listaDePresenAEventoX', {
url: '/presenca',
templateUrl: 'templates/listaDePresenAEventoX.html',
controller: 'listaDePresenAEventoXCtrl'
controller: 'listaDePresenAEventoXCtrl',
resolve: {
people: function(PeopleService) {
return PeopleService.getPeople();
}
}
})
$urlRouterProvider.otherwise('/home')
$urlRouterProvider.otherwise('/home');
});
\ No newline at end of file
});
......@@ -6,5 +6,48 @@ angular.module('app.services', [])
.service('BlankService', [function(){
}]);
}])
.service('EventsService', function($q) {
return {
events: [
{
id: '1',
name: 'Pick up apples',
speaker: 'hue'
},
{
id: '2',
name: 'Mow the lawn',
speaker: 'lol'
}
],
getEvents: function() {
return this.events;
},
addEvent: function(event){
this.events.push(event);
}
};
})
.service('PeopleService', function($q) {
return {
people: [
{
id: '1',
data: 'Lol'
},
{
id: '2',
data: 'hue'
}
],
getPeople: function() {
return this.people;
},
addPerson: function(person){
this.people.push(person);
}
}
});
......@@ -5,11 +5,9 @@
<div class="item item-body">
<a ui-sref="novoEvento" id="ceitificator-button2" class="button button-positive button-block icon-right ion-android-add-circle">Criar Novo</a>
<ion-list>
<ion-item ui-sref="listaDePresenAEventoX">Item 1</ion-item>
<ion-item ui-sref="listaDePresenAEventoX">Item 2</ion-item>
<ion-item ui-sref="listaDePresenAEventoX">Item 3</ion-item>
<ion-item ui-sref="listaDePresenAEventoX" ng-repeat="event in events">{{event.name}} - {{event.speaker}}</ion-item>
</ion-list>
</div>
</div>
</ion-content>
</ion-view>
\ No newline at end of file
</ion-view>
......@@ -2,13 +2,11 @@
<ion-content overflow-scroll="true" padding="true" class="has-header">
<div class="list card">
<div class="item item-body">
<button id="listaDePresenAEventoX-button9" class="button button-positive button-block icon-right ion-qr-scanner">Adicionar</button>
<button id="listaDePresenAEventoX-button9" class="button button-positive button-block icon-right ion-qr-scanner" ng-click="scan()">Adicionar</button>
<ion-list>
<ion-item>Item 1</ion-item>
<ion-item>Item 2</ion-item>
<ion-item>Item 3</ion-item>
<ion-item ng-repeat="person in people">{{person.data}}</ion-item>
</ion-list>
</div>
</div>
</ion-content>
</ion-view>
\ No newline at end of file
</ion-view>
......@@ -5,20 +5,20 @@
<form class="list">
<label class="item item-input">
<span class="input-label">Palestra</span>
<input type="text" placeholder="">
<input type="text" placeholder="" ng-model="formData.newEvent"/>
</label>
<label class="item item-input">
<span class="input-label">Palestrante</span>
<input type="text" placeholder="">
<input type="text" placeholder="" ng-model="formData.speaker"/>
</label>
<div class="spacer" style="width: 255px; height: 32px;"></div>
</form>
<div class="button-bar">
<a ui-sref="ceitificator" id="novoEvento-button6" class="button button-positive button-block button-outline icon-left ion-checkmark">Salvar</a>
<a ui-sref="ceitificator" id="novoEvento-button6" class="button button-positive button-block button-outline icon-left ion-checkmark" ng-click="addNewEvent()">Salvar</a>
<a ui-sref="ceitificator" id="novoEvento-button8" class="button button-assertive button-block button-outline icon-left ion-android-cancel">Cancelar</a>
</div>
</div>
</div>
<form class="list"></form>
</ion-content>
</ion-view>
\ No newline at end of file
</ion-view>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment