Last active
February 16, 2016 13:16
-
-
Save laocanio/9013ec7befc393304d88 to your computer and use it in GitHub Desktop.
PLACE
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Ionic Starter App | |
// angular.module is a global place for creating, registering and retrieving Angular modules | |
// 'starter' is the name of this angular module example (also set in a <body> attribute in index.html) | |
// the 2nd parameter is an array of 'requires' | |
// 'starter.services' is found in services.js | |
// 'starter.controllers' is found in controllers.js | |
angular.module('starter', ['ionic', 'starter.controllers', 'starter.services','jett.ionic.filter.bar']) | |
.run(function($ionicPlatform) { | |
$ionicPlatform.ready(function() { | |
// Hide the accessory bar by default (remove this to show the accessory bar above the keyboard | |
// for form inputs) | |
if (window.cordova && window.cordova.plugins && window.cordova.plugins.Keyboard) { | |
cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true); | |
cordova.plugins.Keyboard.disableScroll(true); | |
} | |
if (window.StatusBar) { | |
// org.apache.cordova.statusbar required | |
StatusBar.styleDefault(); | |
} | |
}); | |
}) | |
.config(function($stateProvider, $urlRouterProvider) { | |
// Ionic uses AngularUI Router which uses the concept of states | |
// Learn more here: https://github.com/angular-ui/ui-router | |
// Set up the various states which the app can be in. | |
// Each state's controller can be found in controllers.js | |
$stateProvider | |
// setup an abstract state for the tabs directive | |
.state('tab', { | |
url: '/tab', | |
abstract: true, | |
templateUrl: 'templates/tabs.html' | |
}) | |
// Each tab has its own nav history stack: | |
.state('tab.guardarpaciente', { | |
url: '/guardarpaciente', | |
views: { | |
'tab-dash': { | |
templateUrl: 'templates/tab-guardarpaciente.html', | |
controller: 'GuardarPacienteCtrl' | |
} | |
} | |
}) | |
.state('tab.listarpaciente', { | |
url: '/listarpaciente', | |
views: { | |
'tab-chats': { | |
templateUrl: 'templates/tab-listarpaciente.html', | |
controller: 'ListarPacienteCtrl' | |
} | |
} | |
}) | |
.state('tab.paciente-detalles', { | |
url: '/listarpaciente/:paciente', | |
views: { | |
'tab-chats': { | |
templateUrl: 'templates/paciente-detalles.html', | |
controller: 'PacientesDetaCtrl' | |
} | |
} | |
}) | |
.state('tab.account', { | |
url: '/account', | |
views: { | |
'tab-account': { | |
templateUrl: 'templates/tab-account.html', | |
controller: 'AccountCtrl' | |
} | |
} | |
}); | |
// if none of the above states are matched, use this as the fallback | |
$urlRouterProvider.otherwise('/tab/listarpaciente'); | |
}); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
angular.module('starter.controllers', []) | |
.controller ('GuardarPacienteCtrl', function($scope,$state, Paciente){ | |
$scope.paciente= | |
{ | |
nombre : '', | |
apellidos:'', | |
edad:'', | |
peso:'', | |
estatura:'' | |
}; | |
//button guardarpaciente | |
$scope.guardarPaciente= function(){ | |
Paciente.save($scope.paciente) | |
console.log($scope.paciente.nombre); | |
//$state.go("tab.paciente-detalles", {'paciente': $scope.paciente.nombre}) | |
$scope.paciente = {} | |
} | |
}) | |
.controller ('ListarPacienteCtrl', function($scope,$ionicListDelegate,$ionicFilterBar, Paciente){ | |
$scope.pacientes = Paciente.all() | |
$scope.listCanSwipe = true; | |
$scope.data = { | |
showDelete: false | |
}; | |
$scope.onpacienteDelete = function(paciente) { | |
console.log(paciente.nombre) | |
Paciente.remove(paciente) | |
}; | |
$scope.showFilterBar = function () { | |
filterBarInstance = $ionicFilterBar.show({items: $scope.pacientes,update: function (filteredItems) | |
{$scope.pacientes = filteredItems;}, filterProperties: 'description' }); }; | |
vm=$scope | |
}) | |
.controller('PacientesDetaCtrl', function($scope,$ionicModal, $state, $stateParams, Paciente) { | |
$scope.paciente = Paciente.get($stateParams.paciente); | |
$ionicModal.fromTemplateUrl('ventana-modificar.html',{ | |
scope:$scope, | |
animation:'slide-in-up', | |
}).then(function(modal){ | |
$scope.modal=modal; | |
}); | |
$scope.modificarPaciente=function(){ | |
$scope.modal.show(); | |
}; | |
$scope.cerrarModificacion=function(){ | |
$scope.modal.hide(); | |
Paciente.update($scope.paciente) | |
}; | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no, width=device-width"> | |
<title></title> | |
<link href="lib/ionic/css/ionic.css" rel="stylesheet"> | |
<link href="css/style.css" rel="stylesheet"> | |
<!-- IF using Sass (run gulp sass first), then uncomment below and remove the CSS includes above | |
<link href="css/ionic.app.css" rel="stylesheet"> | |
--> | |
<!-- ionic/angularjs js --> | |
<script src="lib/ionic/js/ionic.bundle.js"></script> | |
<!-- cordova script (this will be a 404 during development) --> | |
<script src="cordova.js"></script> | |
<!-- your app's js --> | |
<script src="js/app.js"></script> | |
<script src="js/controllers.js"></script> | |
<script src="js/services.js"></script> | |
<script src="lib/ngstorage/ngStorage.min.js"></script> | |
<link href="lib/ionic-filter-bar/dist/ionic.filter.bar.min.css" rel="stylesheet"> | |
<script src="lib/ionic-filter-bar/dist/ionic.filter.bar.min.js"></script> | |
</head> | |
<body ng-app="starter"> | |
<!-- | |
The nav bar that will be updated as we navigate between views. | |
--> | |
<ion-nav-bar class="bar-stable"> | |
<ion-nav-back-button> | |
</ion-nav-back-button> | |
</ion-nav-bar> | |
<!-- | |
The views will be rendered in the <ion-nav-view> directive below | |
Templates are in the /templates folder (but you could also | |
have templates inline in this html file if you'd like). | |
--> | |
<ion-nav-view></ion-nav-view> | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function ItemController($ionicFilterBar) { | |
var vm = this, | |
items = [], | |
filterBarInstance; | |
for (var i = 1; i <= 1000; i++) { | |
var paciente = moment().add(i, 'days'); | |
var item = { | |
description: 'Description for item ' + i, | |
paciente: itemPaciente.topaciente() | |
}; | |
items.push(item); | |
} | |
vm.items = items; | |
vm.showFilterBar = function () { | |
filterBarInstance = $ionicFilterBar.show({ | |
items: vm.items, | |
update: function (filteredItems) { | |
vm.items = filteredItems; | |
}, | |
filterProperties: 'description' | |
}); | |
}; | |
return vm; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<ion-view view-title="{{paciente.nombre}}"> | |
<ion-content class="padding"> | |
<ion-list> | |
<p> | |
Nombre: {{paciente.nombre}}</p> | |
<p> | |
Apellidos: {{paciente.apellidos}}</p> | |
<p> | |
Edad: {{paciente.edad}}</p> | |
<p> | |
Estatura: {{paciente.estatura}}</p> | |
<p> | |
Peso: {{paciente.peso}}</p> | |
<p> | |
Presion Cardiaca: {{paciente.presion}}</p> | |
<label class="item item-input" > | |
<button class="button ion-network" ng-click="modificarPaciente()"> Modificar Paciente </button> | |
</ion-item> | |
</ion-content> | |
</ion-view> | |
<script id="ventana-modificar.html" type="text/ng-template"> | |
<div class="modal"> | |
<ion-header-bar> | |
<h1 class="title">Editar paciente</h1> | |
</ion-header-bar> | |
<ion-content class="padding"> | |
<div class="list"> | |
<label class="item item-input"> | |
<input type="text" placeholder="Nombre" ng-model="paciente.nombre"> | |
</label> <br> | |
<label class="item item-input"> | |
<input type="text" placeholder="Apellidos" ng-model="paciente.apellidos"> | |
</label> <br> | |
<label class="item item-input"> | |
<input type="number" placeholder="Edad" ng-model="paciente.edad"> | |
</label> <br> | |
<label class="item item-input"> | |
<input type="number" placeholder="Peso" ng-model="paciente.peso"> | |
</label><br> | |
<label class="item item-input"> | |
<input type="number" placeholder="Presión" ng-model="paciente.presion"> | |
</label><br> | |
<label class="item item-input"> | |
<input type="number" placeholder="Estatura" ng-model="paciente.estatura"> | |
</label><br> | |
<label class="item item-input" > | |
<button class="button ion-person-add" ng-click="cerrarModificacion()"> Modificar </button> | |
</div> | |
</ion-content> | |
</ion-content> | |
</div> | |
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
angular.module('starter.services', ['ngStorage']) | |
.factory('Paciente', function($localStorage) { | |
// Might use a resource here that returns a JSON array | |
// Some fake testing data | |
return { | |
all: function() { | |
return $localStorage.pacientes; | |
}, | |
save: function(paciente) { | |
if(!$localStorage.pacientes){ | |
$localStorage.pacientes = [] | |
} | |
$localStorage.pacientes.push(paciente); | |
}, | |
newProject: function(pacientes) { | |
// Add a new project | |
return { | |
name: '' | |
}; | |
}, | |
get: function(nombrePaciente) { | |
for (var i = 0; i < $localStorage.pacientes.length; i++) { | |
if ($localStorage.pacientes[i].nombre === nombrePaciente) { | |
return $localStorage.pacientes[i]; | |
} | |
} | |
return null; | |
} | |
} | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<ion-view view-title="Agregar Paciente"> | |
<ion-content class="padding"> | |
<div class="list"> | |
<label class="item item-input"> | |
<input type="text" placeholder="Nombre" ng-model="paciente.nombre"> | |
</label> <br> | |
<label class="item item-input"> | |
<input type="text" placeholder="Apellidos" ng-model="paciente.apellidos"> | |
</label> <br> | |
<label class="item item-input"> | |
<input type="number" placeholder="Edad" ng-model="paciente.edad"> | |
</label> <br> | |
<label class="item item-input"> | |
<input type="number" placeholder="Peso" ng-model="paciente.peso"> | |
</label><br> | |
<label class="item item-input"> | |
<input type="number" placeholder="Presión" ng-model="paciente.presion"> | |
</label><br> | |
<label class="item item-input"> | |
<input type="number" placeholder="Estatura" ng-model="paciente.estatura"> | |
</label><br> | |
<label class="item item-input" > | |
<button class="button ion-person-add" ng-click="guardarPaciente()"> Agregar </button> | |
</div> | |
</ion-content> | |
</ion-view> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<ion-view view-title=""> | |
<ion-nav-buttons side="left"> | |
<div class="buttons"> | |
<button class="button button-icon icon ion-ios-minus-outline" | |
ng-click="data.showDelete = !data.showDelete"> Lista de pacientes</button> | |
</div> | |
</ion-nav-buttons> | |
<ion-content > | |
<button class="button button-icon ion-android-search" | |
ng-click="vm.showFilterBar()"></button> | |
<ion-list show-delete="data.showDelete" type="item-text-wrap" can-swipe="listCanSwipe"> | |
<ion-item ng-repeat="paciente in pacientes" | |
href="#/tab/listarpaciente/{{paciente.nombre}}"> | |
<p> {{paciente.nombre}}</p> | |
<p>{{paciente.apellidos}}</p> | |
<ion-delete-button class="ion-minus-circled" | |
ng-click="onpacienteDelete(paciente)"> | |
</ion-delete-button> | |
</ion-item> | |
</ion-content> | |
</ion-view> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- | |
Create tabs with an icon and label, using the tabs-positive style. | |
Each tab's child <ion-nav-view> directive will have its own | |
navigation history that also transitions its views in and out. | |
--> | |
<ion-tabs class="tabs-icon-top tabs-color-active-positive"> | |
<!-- Dashboard Tab --> | |
<ion-tab title="Agregar Paciente" icon-off="ion-person-add" | |
icon-on="ion-person-add" | |
href="#/tab/guardarpaciente" | |
> | |
<ion-nav-view name="tab-dash"> </ion-nav-view name="tab-dash"> | |
</ion-tab> | |
<!-- Buscar paciente--> | |
<ion-tab title="Buscar Paciente" | |
icon-off="ion-search" | |
icon-on="ion-search" | |
href="#/tab/listarpaciente"> | |
<ion-nav-view name="tab-chats"> </ion-nav-view name="tab-chats"> | |
</ion-tab> | |
</ion-tabs> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment