Skip to content
Snippets Groups Projects
Commit fe6fd70f authored by Robert Goldmann's avatar Robert Goldmann
Browse files

#436 - functionality for editing existing charts

parent 49aa8698
Branches
Tags
No related merge requests found
Pipeline #1922 failed
package de.deadlocker8.budgetmaster.charts; package de.deadlocker8.budgetmaster.charts;
import de.deadlocker8.budgetmaster.categories.Category;
import de.deadlocker8.budgetmaster.controller.BaseController; import de.deadlocker8.budgetmaster.controller.BaseController;
import de.deadlocker8.budgetmaster.services.HelpersService; import de.deadlocker8.budgetmaster.services.HelpersService;
import de.deadlocker8.budgetmaster.settings.SettingsService; import de.deadlocker8.budgetmaster.settings.SettingsService;
...@@ -84,4 +83,35 @@ public class ChartController extends BaseController ...@@ -84,4 +83,35 @@ public class ChartController extends BaseController
return "redirect:/charts/manage"; return "redirect:/charts/manage";
} }
@RequestMapping("/charts/{ID}/requestDelete")
public String requestDeleteChart(Model model, @PathVariable("ID") Integer ID)
{
if(!isDeletable(ID))
{
return "redirect:/charts/manage";
}
model.addAttribute("charts", chartService.getRepository().findAllByOrderByNameAsc());
model.addAttribute("currentChart", chartService.getRepository().getOne(ID));
model.addAttribute("settings", settingsService.getSettings());
return "charts/manage";
}
@RequestMapping(value = "/charts/{ID}/delete")
public String deleteChart(Model model, @PathVariable("ID") Integer ID)
{
if(isDeletable(ID))
{
chartService.getRepository().delete(ID);
}
return "redirect:/charts/manage";
}
private boolean isDeletable(Integer ID)
{
Chart chartToDelete = chartService.getRepository().getOne(ID);
return chartToDelete != null && chartToDelete.getType() == ChartType.CUSTOM;
}
} }
...@@ -93,6 +93,8 @@ info.button.account.delete=Konto und Buchungen l ...@@ -93,6 +93,8 @@ info.button.account.delete=Konto und Buchungen l
info.title.transaction.delete=Buchung löschen info.title.transaction.delete=Buchung löschen
info.text.transaction.delete=Möchtest du die Buchung "{0}" wirklich unwiderruflich löschen? info.text.transaction.delete=Möchtest du die Buchung "{0}" wirklich unwiderruflich löschen?
info.text.transaction.repeating.delete=Möchtest du die Buchung "{0}" wirklich unwiderruflich löschen? <br>Hinweis: Es handelt sich um eine wiederholende Buchung. Beim Löschen dieser Buchung werden alle zugehörigen Wiederholungen ebenfalls gelöscht! info.text.transaction.repeating.delete=Möchtest du die Buchung "{0}" wirklich unwiderruflich löschen? <br>Hinweis: Es handelt sich um eine wiederholende Buchung. Beim Löschen dieser Buchung werden alle zugehörigen Wiederholungen ebenfalls gelöscht!
info.title.chart.delete=Diagramm löschen
info.text.chart.delete=Möchtest du das Diagramm "{0}" wirklich unwiderruflich löschen?
info.title.database.delete=Datenbank löschen info.title.database.delete=Datenbank löschen
info.header.text.database.delete=Soll die Datenbank wirklich unwiderruflich gelöscht werden?<br>Hinweis: Beim Löschen der Datenbank werden alle Buchungen, Kategorien und Konten unwiderruflich gelöscht. info.header.text.database.delete=Soll die Datenbank wirklich unwiderruflich gelöscht werden?<br>Hinweis: Beim Löschen der Datenbank werden alle Buchungen, Kategorien und Konten unwiderruflich gelöscht.
......
...@@ -93,6 +93,8 @@ info.button.account.delete=Delete Account and Transactions ...@@ -93,6 +93,8 @@ info.button.account.delete=Delete Account and Transactions
info.title.transaction.delete=Delete Entry info.title.transaction.delete=Delete Entry
info.text.transaction.delete=Do you really want to delete the entry "{0}"? This can''t be undone. info.text.transaction.delete=Do you really want to delete the entry "{0}"? This can''t be undone.
info.text.transaction.repeating.delete=Do you really want to delete the entry "{0}"? This can''t be undone.<br>Note: This transaction is a repeating transaction. Deleting this transaction will delete all related occurrences too! info.text.transaction.repeating.delete=Do you really want to delete the entry "{0}"? This can''t be undone.<br>Note: This transaction is a repeating transaction. Deleting this transaction will delete all related occurrences too!
info.title.chart.delete=Delete Chart
info.text.chart.delete=Do you really want to delete the chart "{0}"?
info.title.database.delete=Delete Database info.title.database.delete=Delete Database
info.header.text.database.delete=Do you really want to delete the database? This can''t be undone.<br>Note: Deleting the database will delete all transactions, categories and accounts permanently. info.header.text.database.delete=Do you really want to delete the database? This can''t be undone.<br>Note: Deleting the database will delete all transactions, categories and accounts permanently.
......
$( document ).ready(function() {
if($("#modalConfirmDelete").length)
{
$('#modalConfirmDelete').modal('open');
}
});
\ No newline at end of file
...@@ -55,24 +55,16 @@ ...@@ -55,24 +55,16 @@
</div> </div>
</div> </div>
<#if currentCategory??> <#if currentChart??>
<!-- confirm delete modal --> <!-- confirm delete modal -->
<div id="modalConfirmDelete" class="modal categoryDeleteModal background-color"> <div id="modalConfirmDelete" class="modal background-color">
<div class="modal-content"> <div class="modal-content">
<h4>${locale.getString("info.title.category.delete")}</h4> <h4>${locale.getString("info.title.chart.delete")}</h4>
<p>${locale.getString("info.text.category.delete", currentCategory.name)}</p> <p>${locale.getString("info.text.chart.delete", currentChart.getName())}</p>
<p>${locale.getString("info.text.category.delete.move")}</p>
<form name="DestinationCategory" id="formDestinationCategory" action="<@s.url '/categories/${currentCategory.ID?c}/delete'/>" method="post">
<input type="hidden" name="${_csrf.parameterName}" value="${_csrf.token}"/>
<#import "../helpers/validation.ftl" as validation>
<@newTransactionMacros.categorySelect availableCategories preselectedCategory "col s12 m12 l8 offset-l2" locale.getString("info.title.category.delete.move")/>
</form>
</div> </div>
<div class="modal-footer background-color"> <div class="modal-footer background-color">
<a href="<@s.url '/categories'/>" class="modal-action modal-close waves-effect waves-light red btn-flat white-text">${locale.getString("cancel")}</a> <a href="<@s.url '/charts/manage'/>" class="modal-action modal-close waves-effect waves-light red btn-flat white-text">${locale.getString("cancel")}</a>
<a id="buttonDeleteCategory" class="modal-action modal-close waves-effect waves-light green btn-flat white-text">${locale.getString("delete")}</a> <a href="<@s.url '/charts/${currentChart.getID()?c}/delete'/>" class="modal-action modal-close waves-effect waves-light green btn-flat white-text">${locale.getString("info.title.chart.delete")}</a>
</div> </div>
</div> </div>
</#if> </#if>
...@@ -80,5 +72,6 @@ ...@@ -80,5 +72,6 @@
<#import "../helpers/scripts.ftl" as scripts> <#import "../helpers/scripts.ftl" as scripts>
<@scripts.scripts/> <@scripts.scripts/>
<script src="<@s.url '/js/charts.js'/>"></script>
</body> </body>
</html> </html>
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment