From 2b5aefded5204dd0f30e90015cde6cbebaf3fe96 Mon Sep 17 00:00:00 2001
From: Robert Goldmann <deadlocker@gmx.de>
Date: Tue, 16 Mar 2021 00:00:18 +0100
Subject: [PATCH] #419 - show account image if available

---
 src/main/resources/static/css/accounts.css         |  5 +++++
 .../templates/helpers/customSelectMacros.ftl       | 14 +++++++-------
 .../transactions/newTransactionNormal.ftl          |  1 +
 .../transactions/newTransactionRepeating.ftl       |  1 +
 .../transactions/newTransactionTransfer.ftl        |  1 +
 5 files changed, 15 insertions(+), 7 deletions(-)

diff --git a/src/main/resources/static/css/accounts.css b/src/main/resources/static/css/accounts.css
index c4ca1f394..12f3d4f6a 100644
--- a/src/main/resources/static/css/accounts.css
+++ b/src/main/resources/static/css/accounts.css
@@ -43,3 +43,8 @@
 #account-icon-preview:hover {
     cursor: pointer;
 }
+
+.account-select-icon {
+    height: 34px;
+    width: 34px;
+}
diff --git a/src/main/resources/templates/helpers/customSelectMacros.ftl b/src/main/resources/templates/helpers/customSelectMacros.ftl
index 2b420d5ec..def09ab38 100644
--- a/src/main/resources/templates/helpers/customSelectMacros.ftl
+++ b/src/main/resources/templates/helpers/customSelectMacros.ftl
@@ -100,13 +100,13 @@
 </#macro>
 
 <#macro accountIcon account classes="" datasetValue="">
-    <div class="category-circle ${classes} category-square" style="background-color: #FF0000" <#if datasetValue?has_content>data-value="${account.getID()}"</#if>>
-        <span style="color: #FFFFFF}">
-<#--            <#if account.getIcon()??>-->
-<#--                <i class="${category.getIcon()}"></i>-->
-<#--            <#else>-->
+    <div class="category-circle ${classes} category-square <#if account.getIcon()?? == false>background-blue</#if>" <#if datasetValue?has_content>data-value="${account.getID()}"</#if>>
+        <#if account.getIcon()??>
+            <img src="${account.getIcon().getBase64EncodedImage()}" class="account-select-icon"/>
+        <#else>
+            <span class="text-white">
                 ${account.getName()?capitalize[0]}
-<#--            </#if>-->
-        </span>
+            </span>
+        </#if>
     </div>
 </#macro>
\ No newline at end of file
diff --git a/src/main/resources/templates/transactions/newTransactionNormal.ftl b/src/main/resources/templates/transactions/newTransactionNormal.ftl
index d8d9464a1..3cab51c25 100644
--- a/src/main/resources/templates/transactions/newTransactionNormal.ftl
+++ b/src/main/resources/templates/transactions/newTransactionNormal.ftl
@@ -15,6 +15,7 @@
         <@header.style "categories"/>
         <@header.style "collapsible"/>
         <@header.style "categorySelect"/>
+        <@header.style "accounts"/>
         <#import "/spring.ftl" as s>
     </head>
     <@header.body>
diff --git a/src/main/resources/templates/transactions/newTransactionRepeating.ftl b/src/main/resources/templates/transactions/newTransactionRepeating.ftl
index 3dbde48c2..488fab6d7 100644
--- a/src/main/resources/templates/transactions/newTransactionRepeating.ftl
+++ b/src/main/resources/templates/transactions/newTransactionRepeating.ftl
@@ -14,6 +14,7 @@
         <@header.style "datepicker"/>
         <@header.style "categories"/>
         <@header.style "categorySelect"/>
+        <@header.style "accounts"/>
         <#import "/spring.ftl" as s>
     </head>
     <@header.body>
diff --git a/src/main/resources/templates/transactions/newTransactionTransfer.ftl b/src/main/resources/templates/transactions/newTransactionTransfer.ftl
index 345b19c4a..678233326 100644
--- a/src/main/resources/templates/transactions/newTransactionTransfer.ftl
+++ b/src/main/resources/templates/transactions/newTransactionTransfer.ftl
@@ -15,6 +15,7 @@
         <@header.style "categories"/>
         <@header.style "collapsible"/>
         <@header.style "categorySelect"/>
+        <@header.style "accounts"/>
         <#import "/spring.ftl" as s>
     </head>
     <@header.body>
-- 
GitLab