Ver Fonte

Update the display and some of the data for currency.

Lee Morgan há 4 anos atrás
pai
commit
716b686925
4 ficheiros alterados com 10 adições e 3 exclusões
  1. 2 0
      controllers/currency.js
  2. 1 0
      models/currency.js
  3. 5 1
      views/currency/new.html
  4. 2 2
      views/main/index.html

+ 2 - 0
controllers/currency.js

@@ -14,6 +14,7 @@ module.exports = {
         year: Number
         comment: String
         name: String
+        currencyCode: String
         value: Number
     }
     req.files = {
@@ -37,6 +38,7 @@ module.exports = {
                 let currency = new Currency({
                     location: req.body.location,
                     name: req.body.name,
+                    currencyCode: req.body.currencyCode,
                     value: req.body.value,
                     type: req.body.type,
                     year: req.body.year,

+ 1 - 0
models/currency.js

@@ -8,6 +8,7 @@ const CurrencySchema = new mongoose.Schema({
     year: Number,
     comment: String,
     name: String,
+    currencyCode: String,
     value: Number
 });
 

+ 5 - 1
views/currency/new.html

@@ -28,6 +28,10 @@
                 <input name="name" type="text" required>
             </label>
 
+            <label>Currency Code
+                <input name="currencyCode" type="Text" required>
+            </label>
+
             <label>Value
                 <input name="value" type="number" required>
             </label>
@@ -41,7 +45,7 @@
             </label>
 
             <label>Year
-                <input name="year" type="number" required>
+                <input name="year" type="number">
             </label>
 
             <label>Comments

+ 2 - 2
views/main/index.html

@@ -415,8 +415,8 @@
                 for(let i = 0; i < currencies.length; i++){
                     if(currencies[i].location.toLowerCase() === location){
                         let currency = template.cloneNode(true);
-                        currency.querySelector(".location").innerText = currencies[i].location.toUpperCase();
-                        currency.querySelector(".info").innerText = `${currencies[i].value} ${currencies[i].name} (${currencies[i].year})`;
+                        currency.querySelector(".location").innerText = `${currencies[i].location.toUpperCase()} (${currencies[i].name})`;
+                        currency.querySelector(".info").innerText = `${currencies[i].value} ${currencies[i].currencyCode}`;
                         currency.querySelector(".frontImage").src = currencies[i].frontImage;
                         currency.querySelector(".backImage").src = currencies[i].backImage;
                         currency.querySelector(".comment").innerText = currencies[i].comment;