Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions sauco/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
.DS_Store
node_modules
/dist

# local env files
.env.local
.env.*.local

# Log files
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# Editor directories and files
.idea
.vscode
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw*
26 changes: 26 additions & 0 deletions sauco/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# sauco

## Project setup
```
npm install
```

### Compiles and hot-reloads for development
```
npm run serve
```

### Compiles and minifies for production
```
npm run build
```

### Run your tests
```
npm run test
```

### Lints and fixes files
```
npm run lint
```
5 changes: 5 additions & 0 deletions sauco/babel.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module.exports = {
presets: [
'@vue/app'
]
}
12,377 changes: 12,377 additions & 0 deletions sauco/package-lock.json

Large diffs are not rendered by default.

45 changes: 45 additions & 0 deletions sauco/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
{
"name": "sauco",
"version": "0.1.0",
"private": true,
"scripts": {
"serve": "vue-cli-service serve",
"build": "vue-cli-service build",
"lint": "vue-cli-service lint"
},
"dependencies": {
"element-ui": "^2.4.9",
"router": "^1.3.3",
"vue": "^2.5.17"
},
"devDependencies": {
"@vue/cli-plugin-babel": "^3.0.4",
"@vue/cli-plugin-eslint": "^3.0.4",
"@vue/cli-service": "^3.0.4",
"vue-template-compiler": "^2.5.17"
},
"eslintConfig": {
"root": true,
"env": {
"node": true
},
"extends": [
"plugin:vue/essential",
"eslint:recommended"
],
"rules": {},
"parserOptions": {
"parser": "babel-eslint"
}
},
"postcss": {
"plugins": {
"autoprefixer": {}
}
},
"browserslist": [
"> 1%",
"last 2 versions",
"not ie <= 8"
]
}
Binary file added sauco/public/favicon.ico
Binary file not shown.
25 changes: 25 additions & 0 deletions sauco/public/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<!-- import CSS -->
<link rel="stylesheet" href="https://unpkg.com/element-ui/lib/theme-chalk/index.css">
<!-- import JavaScript -->
<script src="https://unpkg.com/element-ui/lib/index.js"></script>
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<title>Sauco ®| Tp. 7</title>
<link rel="shortcut icon" type="image/png" href="https://www.telegraph.co.uk/content/dam/technology/2017/11/01/emoji_update_2017_1_trans_NvBQzQNjv4BqqVzuuqpFlyLIwiB6NTmJwfSVWeZ_vEN7c6bHu2jJnT8.png?imwidth=450">
</head>

<body>
<noscript>
<strong>We're sorry but Sauco's TP7 proyect doesn't work properly without JavaScript enabled. Please enable it to continue.</strong>
</noscript>
<div id="app"></div>
<!-- built files will be auto injected -->
</body>

</html>
44 changes: 44 additions & 0 deletions sauco/src/App.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<template>
<el-container>
<el-header class="header">
<span>TP N°007</span>
</el-header>
<el-main>
<el-tabs @tab-click="handleClick" class="tabs">
<el-tab-pane label="Home" name="/"></el-tab-pane>
<el-tab-pane label="Agregar" name="/add"></el-tab-pane>
</el-tabs>
<router-view></router-view>
</el-main>
</el-container>
</template>

<script>
import router from "@/router";
export default {
name: 'app',
methods:{
handleClick(tab){
router.push(tab.$options.propsData.name);
}
}
//nada que observar por aqui
}
</script>

<style>
#app {
font-family: 'Avenir', Helvetica, Arial, sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
text-align: center;
color: #2c3e50;
margin-top: 60px;
}
.header{
background-color: #a4ccdb;
text-align: right;
font-size: 50px;
}

</style>
Binary file added sauco/src/assets/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
161 changes: 161 additions & 0 deletions sauco/src/components/AddPerson.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,161 @@
<template>
<section class='addPerson'>
<span class="title">
{{this.title}} persona
</span>
<el-form :model="persona" :rules="rules" ref="persona">
<el-form-item label="Nombre" prop="nombre">
<el-input v-model="persona.nombre" id="name" placeholder="Ingrese nombre"></el-input>
</el-form-item>
<el-form-item label="Edad" prop="edad">
<el-input type="number" v-model.number="persona.edad" id="edad" min="0"></el-input>
</el-form-item>
<el-form-item label="Sexo" prop="sexo">
<el-select v-model="persona.sexo" placeholder="Seleccione">
<el-option label="Masculino" value="Masculino"></el-option>
<el-option label="Femenino" value="Femenino"></el-option>
<el-option label="Pansexual" value="Pansexual"></el-option>
<el-option label="Hermafrodita" value="Hermafrodita"></el-option>
<el-option label="Otro" value="Otro"></el-option>
</el-select>
</el-form-item>
<div class="action" v-if="title ==='Editar'">
<el-button type="primary" @click="edit('persona')">Confirmar</el-button>
<el-button @click="cancelar">Cancelar</el-button>
</div>
<div class="action" v-else>
<el-button type="primary" @click="agregar('persona')">Confirmar</el-button>
</div>
</el-form>
</section>
</template>

<script>
import router from "@/router";
import pplService from "@/services/pplService";
export default {
name: 'add-person',
data() {
var checkAge = (rule, value, callback) => {
if (!value) {
return callback(new Error('Edad requerida'));
}
else {
if (value < 1) {
callback(new Error('Edad incorrecta'));
} else {
callback();
}
}
};
return {
title: '',
errores: [],
persona: {
id: 0,
nombre: "",
edad: 0,
sexo: ""
},
rules: {
nombre: [
{ required: true, message: "Falta el nombre", trigger: 'blur' },
],
edad: [
{ validator: checkAge, trigger: 'blur' }
],
sexo: [
{ required: true, message: "Falta el sexo", trigger: 'blur' },
]
}
}
},
beforeMount() {
this.checkStatus();
},
methods: {
checkStatus() {
if (this.$route.params.id !== undefined) {
this.title = "Editar"
pplService.getOne(this.$route.params.id) // eslint-disable-next-line
.then((p) => this.persona = p, (error) => console.log(error));
} else {
this.title = "Agregar";
this.persona.nombre = "";
this.persona.edad = 0;
this.persona.sexo = "";
}
},
cancelar() {
router.push("/");
},
edit(formName) {
this.$refs[formName].validate((valid) => {
if (!valid) { // eslint-disable-next-line
console.log('Complete los campos');
return false;
} else {
pplService.replace(this.persona);
this.$notify({
title: 'Exito',
message: 'Hemos editado la persona',
type: 'info',
showClose: false
});
router.push("/");
}
});
},
agregar(formName) {
this.$refs[formName].validate((valid) => {
if (!valid) { // eslint-disable-next-line
console.log('Complete los campos');
return false;
} else {
pplService.save(
this.persona.nombre,
this.persona.edad,
this.persona.sexo
);
this.$notify({
title: 'Exito',
message: 'Hemos agregado la persona',
type: 'success',
showClose: false
});
this.persona.nombre = "";
this.persona.edad = "";
this.persona.sexo = "";
router.push("/");
}
});
},
}
}
</script>

<style>
.pointer {
cursor: pointer;
}

.addPerson {
width: 100%;
}

.inputDetails {
display: inline-block;
padding: 0 5px 5px 0;
}

.title {
font-family: Arial, Helvetica, sans-serif;
font-size: 20px;
margin-left: 30px;
}

.action {
padding: 5px 5px 0 0;
vertical-align: bottom;
}
</style>
46 changes: 46 additions & 0 deletions sauco/src/components/PersonItem.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<template>
<li class="liItem">
{{people.nombre}} de
{{people.edad}} años,
{{people.sexo}}
<button class="button" @click="editMe"><i class="material-icons fs18">{{editBtn}}</i></button>
<button class="button" @click="deleteMe"><i class="material-icons fs18">delete</i></button>
</li>
</template>
<script>
export default {
name: 'person-item',
data(){
return{
editBtn : "edit"
}
},
props: {
people: Object,
},
methods: {
editMe(){
this.$emit('edit',this.people.id);
if(this.editBtn === "edit"){
this.editBtn = "cancel";
} else {
this.editBtn = "edit";
}
},
deleteMe(){
this.$emit('delete', this.people.id);
}
}
}
</script>

<style>
.fs18{
font-size: 18px;
}
.button{
cursor: pointer;
margin-left:5px;
}
</style>

Loading