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

#419 - externalized custom select macros to file

parent c7bf2896
No related branches found
No related tags found
No related merge requests found
......@@ -13,6 +13,7 @@
<#import "categoriesFunctions.ftl" as categoriesFunctions>
<#import "../transactions/newTransactionMacros.ftl" as newTransactionMacros>
<#import "../helpers/customSelectMacros.ftl" as customSelectMacros>
<main>
<div class="card main-card background-color">
......@@ -72,7 +73,7 @@
<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.customSelect availableCategories preselectedCategory "col s12 m12 l8 offset-l2" locale.getString("info.title.category.delete.move")/>
<@customSelectMacros.customSelect availableCategories preselectedCategory "col s12 m12 l8 offset-l2" locale.getString("info.title.category.delete.move")/>
</form>
</div>
......
<#import "../categories/categoriesFunctions.ftl" as categoriesFunctions>
<#macro customSelect categories selectedCategory inputClasses labelText>
<div class="row">
<div class="input-field ${inputClasses}">
<i class="material-icons prefix">label</i>
<label class="input-label" for="transaction-category">${labelText}</label>
<div class="category-select-wrapper" id="transaction-category">
<div class="custom-select">
<div class="category-select__trigger" tabindex="0"><div id="custom-select-selected-item"><#if selectedCategory??><@customSelectOptionContent selectedCategory "no-margin-left"/></#if></div>
<div class="category-select-arrow"></div>
</div>
<div class="custom-select-options">
<#list categories as category>
<#if category.getType() == "REST">
<#continue>
</#if>
<#if selectedCategory??>
<#if selectedCategory.getID()?c == category.getID()?c>
<@customSelectOption category true/>
<#else>
<@customSelectOption category false/>
</#if>
<#continue>
</#if>
<#if category.getType() == "NONE">
<@customSelectOption category true/>
<#continue>
</#if>
<@customSelectOption category false/>
</#list>
</div>
</div>
<input type="hidden" name="category" class="hidden-input-custom-select" <#if selectedCategory??>value="${selectedCategory.getID()?c}"</#if>/>
</div>
</div>
</div>
</#macro>
<#macro customSelectOption category isSelected>
<div class="custom-select-option <#if isSelected>selected</#if>" data-value="${category.getID()?c}">
<@customSelectOptionContent category/>
</div>
</#macro>
<#macro customSelectOptionContent category classes="" datasetValue="">
<@categoriesFunctions.categoryCircle category "category-circle-small ${classes}" datasetValue=""/>
<span class="custom-select-item-name">${categoriesFunctions.getCategoryName(category)}</span>
</#macro>
\ No newline at end of file
......@@ -22,6 +22,8 @@
<#import "../transactions/newTransactionMacros.ftl" as newTransactionMacros>
<#import "templateFunctions.ftl" as templateFunctions>
<#import "../helpers/customSelectMacros.ftl" as customSelectMacros>
<main>
<div class="card main-card background-color">
......@@ -51,7 +53,7 @@
<@newTransactionMacros.transactionAmount template/>
<#-- category -->
<@newTransactionMacros.customSelect categories template.getCategory() "col s12 m12 l8 offset-l2" locale.getString("transaction.new.label.category")/>
<@customSelectMacros.customSelect categories template.getCategory() "col s12 m12 l8 offset-l2" locale.getString("transaction.new.label.category")/>
<#-- description -->
<@newTransactionMacros.transactionDescription template/>
......
......@@ -88,59 +88,6 @@
</script>
</#macro>
<#import "../categories/categoriesFunctions.ftl" as categoriesFunctions>
<#macro customSelect categories selectedCategory inputClasses labelText>
<div class="row">
<div class="input-field ${inputClasses}">
<i class="material-icons prefix">label</i>
<label class="input-label" for="transaction-category">${labelText}</label>
<div class="category-select-wrapper" id="transaction-category">
<div class="custom-select">
<div class="category-select__trigger" tabindex="0"><div id="custom-select-selected-item"><#if selectedCategory??><@customSelectOptionContent selectedCategory "no-margin-left"/></#if></div>
<div class="category-select-arrow"></div>
</div>
<div class="custom-select-options">
<#list categories as category>
<#if category.getType() == "REST">
<#continue>
</#if>
<#if selectedCategory??>
<#if selectedCategory.getID()?c == category.getID()?c>
<@customSelectOption category true/>
<#else>
<@customSelectOption category false/>
</#if>
<#continue>
</#if>
<#if category.getType() == "NONE">
<@customSelectOption category true/>
<#continue>
</#if>
<@customSelectOption category false/>
</#list>
</div>
</div>
<input type="hidden" name="category" class="hidden-input-custom-select" <#if selectedCategory??>value="${selectedCategory.getID()?c}"</#if>/>
</div>
</div>
</div>
</#macro>
<#macro customSelectOption category isSelected>
<div class="custom-select-option <#if isSelected>selected</#if>" data-value="${category.getID()?c}">
<@customSelectOptionContent category/>
</div>
</#macro>
<#macro customSelectOptionContent category classes="" datasetValue="">
<@categoriesFunctions.categoryCircle category "category-circle-small ${classes}" datasetValue=""/>
<span class="custom-select-item-name">${categoriesFunctions.getCategoryName(category)}</span>
</#macro>
<#macro transactionStartDate transaction currentDate>
<div class="row">
<div class="input-field col s12 m12 l8 offset-l2">
......
......@@ -22,6 +22,7 @@
<@navbar.navbar "transactions" settings/>
<#import "newTransactionMacros.ftl" as newTransactionMacros>
<#import "../helpers/customSelectMacros.ftl" as customSelectMacros>
<main>
<div class="card main-card background-color">
......@@ -51,7 +52,7 @@
<@newTransactionMacros.transactionAmount transaction/>
<#-- category -->
<@newTransactionMacros.customSelect categories transaction.getCategory() "col s12 m12 l8 offset-l2" locale.getString("transaction.new.label.category")/>
<@customSelectMacros.customSelect categories transaction.getCategory() "col s12 m12 l8 offset-l2" locale.getString("transaction.new.label.category")/>
<#-- date -->
<@newTransactionMacros.transactionStartDate transaction currentDate/>
......
......@@ -21,6 +21,7 @@
<@navbar.navbar "transactions" settings/>
<#import "newTransactionMacros.ftl" as newTransactionMacros>
<#import "../helpers/customSelectMacros.ftl" as customSelectMacros>
<main>
<div class="card main-card background-color">
......@@ -49,7 +50,7 @@
<@newTransactionMacros.transactionAmount transaction/>
<#-- category -->
<@newTransactionMacros.customSelect categories transaction.getCategory() "col s12 m12 l8 offset-l2" locale.getString("transaction.new.label.category")/>
<@customSelectMacros.customSelect categories transaction.getCategory() "col s12 m12 l8 offset-l2" locale.getString("transaction.new.label.category")/>
<#-- date -->
<@newTransactionMacros.transactionStartDate transaction currentDate/>
......
......@@ -22,6 +22,7 @@
<@navbar.navbar "transactions" settings/>
<#import "newTransactionMacros.ftl" as newTransactionMacros>
<#import "../helpers/customSelectMacros.ftl" as customSelectMacros>
<main>
<div class="card main-card background-color">
......@@ -49,7 +50,7 @@
<@newTransactionMacros.transactionAmount transaction/>
<#-- category -->
<@newTransactionMacros.customSelect categories transaction.getCategory() "col s12 m12 l8 offset-l2" locale.getString("transaction.new.label.category")/>
<@customSelectMacros.customSelect categories transaction.getCategory() "col s12 m12 l8 offset-l2" locale.getString("transaction.new.label.category")/>
<#-- date -->
<@newTransactionMacros.transactionStartDate transaction currentDate/>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment