Archived
1
0
Fork 0

Add locales to index

This commit is contained in:
Ethanell 2020-08-18 16:48:09 +02:00
parent a9f2b6c7a8
commit 13f2d6558f
3 changed files with 50 additions and 35 deletions

View file

@ -18,5 +18,15 @@
"made": "Made with ❤️ by",
"contact": "Contact",
"orderIssue": "Order issue"
},
"index": {
"welcome": "Welcome to Sandwiches Order Doua",
"department": "Department",
"firstName": "First name",
"lastName": "Last name",
"command": "Command",
"sandwich": "Sandwich",
"day": "Day",
"pay": "Pay"
}
}

View file

@ -1,5 +1,10 @@
const commandAction = document.getElementById("command-action");
const rmButton = document.getElementById("remove-command");
const locals = {
command: document.querySelector("#command1>h2").innerHTML.replace(" 1", ""),
sandwich: document.querySelector("label[for='sandwich1']").innerHTML,
day: document.querySelector("label[for='day1']").innerHTML
};
function lastCommandId() {
let list = document.querySelectorAll("div.command h2");
@ -9,14 +14,14 @@ function lastCommandId() {
document.getElementById("add-command").addEventListener("click", () => {
let id = lastCommandId() + 1;
commandAction.insertAdjacentHTML("beforebegin", `<div id="command${id}" class="command">
<h2>Command ${id}</h2>
<h2>${locals.command} ${id}</h2>
<div class="field">
<label for="sandwich">Sandwich:</label>
<input id="sandwich" type="list" list="sandwich-list" name="sandwich${id}" autocomplete="off" required>
<label for="sandwich${id}">${locals.sandwich}</label>
<input id="sandwich${id}" type="list" list="sandwich-list" name="sandwich${id}" autocomplete="off" required>
</div>
<div class="field">
<label for="day">Day:</label>
<input id="day" type="date" name="date${id}" required>
<label for="day${id}">${locals.day}</label>
<input id="da${id}y" type="date" name="date${id}" required>
</div>
</div>`);
document.getElementById("command"+lastCommandId()).scrollIntoView({behavior: "smooth"});

View file

@ -3,37 +3,37 @@ extends layout
block content
div.card
h1= title
p Welcome to Sandwiches Order Doua
p=__("index.welcome")
form#command(action="/command" method="POST")
div.field
label(for="department") Department:
label(for="department")=__("index.department")+":"
input#department(type="list" list="department-list" name="department" value=user ? user.DepartmentName : "" autocomplete="off" required)
datalist#department-list
each department in departments
option(value=department.name)
div.field
label(for="firstname") First name:
label(for="firstname")=__("index.firstName")+":"
input#firstname(type="text" name="firstName" value=user ? user.firstName : "" required)
div.field
label(for="lastname") Last name:
label(for="lastname")=__("index.lastName")+":"
input#lastname(type="text" name="lastName" value=user ? user.lastName : "" required)
div#command1.command
h2 Command 1
h2=__("index.command")+" 1"
div.field
label(for="sandwich") Sandwich:
input#sandwich(type="list" list="sandwich-list" name="sandwich1" autocomplete="off" required)
label(for="sandwich1")=__("index.sandwich")+":"
input#sandwich1(type="list" list="sandwich-list" name="sandwich1" autocomplete="off" required)
div.field
label(for="day") Day:
input#day(type="date" name="date1" required)
label(for="day1")=__("index.day")+":"
input#day1(type="date" name="date1" required)
div#command-action
a#add-command +
a#remove-command.hide -
div.field
input#send(type="submit" value="Pay")
input#send(type="submit" value=__("index.pay"))
datalist#sandwich-list
each sandwich in sandwiches