Skip to content

Commit

Permalink
Módulo 5
Browse files Browse the repository at this point in the history
  • Loading branch information
leamarty committed Dec 27, 2015
1 parent 324a5d7 commit 9d0c5f4
Show file tree
Hide file tree
Showing 13 changed files with 167 additions and 0 deletions.
Binary file modified M4/Módulo 4.pptx
Binary file not shown.
Binary file added M5/Módulo 5.pptx
Binary file not shown.
28 changes: 28 additions & 0 deletions M5/practica/bower.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"name": "modulo 5",
"version": "0.0.5",
"homepage": "https://github.com/leamarty/cursoweb",
"description": "Agregamos AngularJS al frontend",
"main": "index.html",
"keywords": [
"curso"
],
"private": true,
"ignore": [
"**/.*",
"bower_components"
],
"dependencies": {
"angular": "~1.4.8",
"angular-route": "~1.4.8",
"angular-ui-select2": "~0.0.5",
"bootstrap": "~3.3.5",
"jquery": "~2.1.4",
"restangular": "~1.5.1",
"select2": "~3.5.3",
"underscore": "~1.8.3"
},
"resolutions": {
"select2": "~3.5.3"
}
}
10 changes: 10 additions & 0 deletions M5/practica/estilos.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#boton-buscar {
padding: 13px 15px;
}
.alert {
display: none;
margin-bottom: 0 !important;
}
.bold {
font-weight: bold;
}
9 changes: 9 additions & 0 deletions M5/practica/html/cliente/listado.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<table>
<thead></thead>
<tbody>
<tr ng-repeat="cliente in clientes">
<td>{{ cliente.id }}</td>
<td>{{ cliente.razon_social }}</td>
</tr>
</tbody>
</table>
1 change: 1 addition & 0 deletions M5/practica/html/cliente/nuevo.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
View de nuevo cliente
53 changes: 53 additions & 0 deletions M5/practica/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<!DOCTYPE html>
<html lang="en" ng-app="cursoweb">
<head>
<title>La web del curso</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link type="text/css" rel="stylesheet" href="estilos.css"/>
<link rel="stylesheet" href="bower_components/bootstrap/dist/css/bootstrap.min.css">
<!-- Vendor -->
<script src="bower_components/jquery/dist/jquery.min.js"></script>
<script src="bower_components/angular/angular.js"></script>
<script src="bower_components/angular-route/angular-route.min.js"></script>
<script src="bower_components/select2/select2.min.js"></script>
<script src="bower_components/angular-ui-select2/src/select2.js"></script>
<script src="bower_components/underscore/underscore-min.js"></script>
<script src="bower_components/restangular/dist/restangular.min.js"></script>
<!-- App -->
<script src="js/angular-app.js"></script>
<script src="js/controllers/main-controller.js"></script>
<script src="js/routes.js"></script>
<script src="js/directivas/ocultar.js"></script>
<!-- Controllers -->
<script src="js/controllers/cliente/listado.js"></script>
<script src="js/controllers/cliente/nuevo.js"></script>
</head>
<body>
<div class="container" ng-controller="MainController">
<div class="row">
<div class="col-md-12">
<div class="jumbotron text-center">
<h1>Telapong S.A.</h1>
<p>Listado de clientes oficiales</p>
</div>
</div>
</div>
<div class="row">
<div class="col-md-12">
<nav class="navbar navbar-default">
<ul class="nav navbar-nav">
<li id="menu-listado" class="{{ menuActivo == 'cliente_listado' ? 'active' : '' }}">
<a href="#/cliente/listado">Listado</a>
</li>
<li id="menu-nuevo" class="{{ menuActivo == 'cliente_nuevo' ? 'active' : '' }}">
<a href="#/cliente/nuevo">Nuevo</a>
</li>
</ul>
</nav>
</div>
</div>
<div ng-view></div>
</div>
</body>
</html>
6 changes: 6 additions & 0 deletions M5/practica/js/angular-app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
var cursoweb = angular.module('cursoweb', [
'ngRoute',
'ui.select2',
'restangular'
]);

7 changes: 7 additions & 0 deletions M5/practica/js/controllers/cliente/listado.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
cursoweb.controller('ClienteListado', function ($scope) {
$scope.$parent.menuActivo = 'cliente_listado';

$scope.clientes = [
{id: 5, razon_social: 'hola'}
]
});
3 changes: 3 additions & 0 deletions M5/practica/js/controllers/cliente/nuevo.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
cursoweb.controller('ClienteNuevo', function ($scope, Nombre) {
$scope.$parent.menuActivo = 'cliente_nuevo';
});
20 changes: 20 additions & 0 deletions M5/practica/js/controllers/main-controller.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
cursoweb.controller('MainController', function ($scope, $timeout) {

$scope.menuActivo = '';

$scope.clientes = [];

$scope.buscar = function () {
$scope.clientes.push({
id: $scope.clientes.length + 1,
nombre: 'Pepe',
edad: 5
});
};

$scope.borrar = function (cliente, index) {
$scope.clientes.splice(index, 1);
alert('Ya borre el cliente ' + cliente.nombre);
};

});
10 changes: 10 additions & 0 deletions M5/practica/js/directivas/ocultar.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
cursoweb.directive('ocultar', function () {
return {
restrict: 'A',
link: function (scope, element, attrs) {
setTimeout(function () {
element.hide();
}, (attrs.ocultarTiempo || 2) * 1000);
}
};
});
20 changes: 20 additions & 0 deletions M5/practica/js/routes.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
cursoweb.config(function ($routeProvider) {
$routeProvider
.when('/cliente/listado', {
templateUrl: 'html/cliente/listado.html',
controller: 'ClienteListado'
})
.when('/cliente/nuevo', {
templateUrl: 'html/cliente/nuevo.html',
controller: 'ClienteNuevo'
})
/*
.when('/cliente/:id', {
templateUrl: '',
controller: ''
})
*/
.otherwise({
redirectTo: '/cliente/listado'
})
});

0 comments on commit 9d0c5f4

Please sign in to comment.