From e3463031d660ad58e9282090fca2fb8604c62229 Mon Sep 17 00:00:00 2001
From: Alexis Poyen <apoyen@mail.apoyen.fr>
Date: Thu, 30 Apr 2020 17:04:32 +0200
Subject: [PATCH] Fix : some bug in interface

---
 web/components/bankerPage/bankAccount.js | 2 ++
 web/components/bankerPage/operations.js  | 3 ++-
 web/components/users/users.js            | 2 +-
 3 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/web/components/bankerPage/bankAccount.js b/web/components/bankerPage/bankAccount.js
index 5151c45..b1939e8 100644
--- a/web/components/bankerPage/bankAccount.js
+++ b/web/components/bankerPage/bankAccount.js
@@ -92,6 +92,7 @@ class BankAccount {
     this.bankAccount.Type = document.getElementById("account-type").value;
     this.bankAccount.Amount = 0;
     this.bankAccount.BankOverdraft = 0;
+    this.bankAccount.Operations = [];
     this.isNew = true;
     this.handleDom();
   }
@@ -143,6 +144,7 @@ class BankAccount {
         throw new Error(`Banker could not be updated (status ${response.status})`);
       }
       await this.parent.updateBankAccounts();
+      this.bankAccount = await response.json();
       document.getElementById(`accounts-account-edit-${this.bankAccount.ID}`).click();
     } catch (e) {
       Messages.Show("is-warning", e.message);
diff --git a/web/components/bankerPage/operations.js b/web/components/bankerPage/operations.js
index 50c0c50..e818896 100644
--- a/web/components/bankerPage/operations.js
+++ b/web/components/bankerPage/operations.js
@@ -102,7 +102,8 @@ class Operation {
   }
 
   async displayOperations(bankAccount) {
-    this.bankAccount = await this.updateBankAccount(bankAccount.ID);
+    if (bankAccount.ID != 0) this.bankAccount = await this.updateBankAccount(bankAccount.ID);
+    else this.bankAccount = bankAccount;
     const markup = this.bankAccount.Operations.map((operation) => this.operationTemplate(operation)).join("");
     document.getElementById("operations-table").innerHTML = markup;
 
diff --git a/web/components/users/users.js b/web/components/users/users.js
index 958c8e1..b294dda 100644
--- a/web/components/users/users.js
+++ b/web/components/users/users.js
@@ -79,7 +79,7 @@ class Users {
   }
 
   cleanUser(user) {
-    let props = ["password", "name", "surname", "memberOf"];
+    let props = ["password", "name", "surname", "memberOf", "displayName"];
     for (const prop of props) {
       user[prop] = user[prop] === undefined ? "" : user[prop];
     }
-- 
GitLab