Drobne upravy + pretextovani budgetu

This commit is contained in:
Michal Kváček
2018-12-11 13:13:09 +01:00
parent 7363b6f7a9
commit effafd9daa
4 changed files with 30 additions and 24 deletions
+11 -16
View File
@@ -85,28 +85,23 @@ var templateData = {
albumsCount: 0, albumsCount: 0,
budget: [ budget: [
{ {
name: "Rozlucka se svobodou", name: "Svatební cesta",
limit: 20000, limit: 30000,
items: [ items: [
{ {
name: "Polozka 1", name: "Letenky",
bought: false,
price: 1200
},
{
name: "Polozka 2",
bought: false,
price: 1200
},
{
name: "Polozka 3",
bought: true, bought: true,
price: 1200 price: 2 * 6000
}, },
{ {
name: "Polozka 4", name: "Ubytování v hotelu",
bought: false, bought: false,
price: 1200 price: 7 * 1100
},
{
name: "Ostatní výdaje",
bought: false,
price: 10000
}, },
] ]
} }
+7 -3
View File
@@ -20,11 +20,15 @@ $ (document).on ('click', '.delete-button a', function () {
$ (document).on ('click', '.js-delete-button', function () { $ (document).on ('click', '.js-delete-button', function () {
var target = $ (this).data ('target'); var target = $ (this).data ('target');
var isExisting = $ (this).closest (target).hasClass('existing');
$ (this).closest (target).remove (); $ (this).closest (target).remove ();
var url = $ (this).data ('href'); if (isExisting) {
if (typeof url != 'undefined') { var url = $ (this).data ('href');
$.get (url); if (typeof url != 'undefined') {
$.get (url);
}
} }
}); });
+11 -4
View File
@@ -1,12 +1,19 @@
<div class="heading-budget my-3 col-md-12"> <div class="heading-budget my-3 col-md-12">
<h1>Správa rozpočtu</h1> <h1>Správa rozpočtu</h1>
<% if (budget.length > 0) { %>
<a href="#addItem" class="btn btn-info btn-lg" data-toggle="modal" data-target="#addItem"> <a href="#addItem" class="btn btn-info btn-lg" data-toggle="modal" data-target="#addItem">
Přidat položky Přidat výdaje
</a>
<a href="#addGroup" class="btn btn-info btn-lg" data-toggle="modal" data-target="#addGroup">
Upravit skupiny
</a> </a>
<a href="#addGroup" class="btn btn-info btn-lg" data-toggle="modal" data-target="#addGroup">
Upravit skupiny výdajů
</a>
<% } else { %>
<a href="#addGroup" class="btn btn-info btn-lg" data-toggle="modal" data-target="#addGroup">
Přidat skupinu výdajů
</a>
<% } %>
</div> </div>
<%- include('../partials/notification.ejs', {parameter: "newGroup", notifiactionText: "Skupina úspěšně vytvořena."}) %> <%- include('../partials/notification.ejs', {parameter: "newGroup", notifiactionText: "Skupina úspěšně vytvořena."}) %>
@@ -25,7 +25,7 @@
<% for (var i in budget) { %> <% for (var i in budget) { %>
<tr class="add-group-template draggable template-container__item existing"> <tr class="add-group-template draggable template-container__item existing">
<td> <td>
<input type="text" class="form-control" name="group[<% i %>]" value="<%= budget[i].name %>"> <input type="text" class="form-control" required name="group[<% i %>]" value="<%= budget[i].name %>">
</td> </td>
<td style="width: 25%"> <td style="width: 25%">