Commit 080b47c4 authored by Alejandro's avatar Alejandro

Adds listPet function in People View

This show the pets from one person.
parent 9399669b
...@@ -106,6 +106,18 @@ var PeopleView = (function() { ...@@ -106,6 +106,18 @@ var PeopleView = (function() {
} }
}; };
this.listPets = function (id) {
$('#genericContainer').empty();
$('#genericContainer').append("<div id='pets-container'>" +
"<h1 class=\"display-5 mt-3 mb-3\">Mascotas</h1>" +
"</div>");
let view = new PetsView(new PetsDAO(),
'pets-container','pets-container'
);
view.initList(id);
}
this.isEditing = function() { this.isEditing = function() {
return $(formQuery + ' input[name="id"]').val() != ""; return $(formQuery + ' input[name="id"]').val() != "";
}; };
...@@ -125,6 +137,7 @@ var PeopleView = (function() { ...@@ -125,6 +137,7 @@ var PeopleView = (function() {
}; };
}; };
var insertPeopleList = function(parent) { var insertPeopleList = function(parent) {
parent.append( parent.append(
'<table id="' + listId + '" class="table">\ '<table id="' + listId + '" class="table">\
...@@ -168,6 +181,7 @@ var PeopleView = (function() { ...@@ -168,6 +181,7 @@ var PeopleView = (function() {
<td class="col-sm-3">\ <td class="col-sm-3">\
<a class="edit btn btn-primary" href="#">Editar</a>\ <a class="edit btn btn-primary" href="#">Editar</a>\
<a class="delete btn btn-warning" href="#">Eliminar</a>\ <a class="delete btn btn-warning" href="#">Eliminar</a>\
<a class="pets btn btn-secondary" href="#">Mascotas</a>\
</td>\ </td>\
</tr>'; </tr>';
}; };
...@@ -184,6 +198,10 @@ var PeopleView = (function() { ...@@ -184,6 +198,10 @@ var PeopleView = (function() {
$('#person-' + person.id + ' a.delete').click(function() { $('#person-' + person.id + ' a.delete').click(function() {
self.deletePerson(person.id); self.deletePerson(person.id);
}); });
$('#person-' + person.id + ' a.pets').click(function () {
self.listPets(person.id);
})
}; };
var appendToTable = function(person) { var appendToTable = function(person) {
......
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