Skip to content
Snippets Groups Projects
Commit 29cf948a authored by Victor Mocelin's avatar Victor Mocelin
Browse files

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
No related branches found
No related tags found
No related merge requests found
......@@ -20,7 +20,10 @@
"cordova-plugin-whitelist",
"cordova-plugin-splashscreen",
"cordova-plugin-statusbar",
"ionic-plugin-keyboard"
"ionic-plugin-keyboard",
"cordova-plugin-barcodescanner"
],
"cordovaPlatforms": []
"cordovaPlatforms": [
"android"
]
}
angular.module('app.controllers', [])
.controller('ceitificatorCtrl', function($scope) {
.controller('ceitificatorCtrl', function($scope, events) {
$scope.events = events;
})
.controller('novoEventoCtrl', function($scope) {
})
.controller('listaDePresenAEventoXCtrl', 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, 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);
}
);
};
});
......@@ -13,22 +13,37 @@ angular.module('app.routes', [])
.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');
......
......@@ -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,9 +5,7 @@
<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>
......
......@@ -2,11 +2,9 @@
<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>
......
......@@ -5,16 +5,16 @@
<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>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment