Commit f71bc5a3 authored by Eric Seigne's avatar Eric Seigne
Browse files

delete pref account in list

parent 5559a6a0
......@@ -393,14 +393,17 @@ function createIK(titre, ladate, message, arrivee, depart) {
gotoPage("frais-ik.html", true);
}
function makeOneAccount(id, title, mail) {
function makeOneAccount(fieldName,id, title, mail) {
let html = "";
html = "<ons-row>\n";
html += " <ons-col>\n";
html += " <span class=\"deleteiconAccount\">\n";
html += " <span class=\"deleteiconAccount2\" onclick=\"deletePrefAccount('" + id + "','" + fieldName + "');\"><i style=\"font-size: x-large;\" class=\"zmdi zmdi-close-circle-o\"></i></span>\n";
html += " </span>\n";
html += " <ons-card>\n";
html += " <ons-row>\n";
html += " <ons-col width=\"20%\">\n";
html += " <ons-icon icon=\"fa-user-tie\" size=\"50px\"></ons-icon>\n";
html += " <ons-icon icon=\"fa-user-tie\" size=\"50px\"></ons-icon>\n";
html += " </ons-col>\n";
html += " <ons-col style=\"text-align: center;\">\n";
html += " <div class=\"title\">\n";
......@@ -422,18 +425,34 @@ function makeOneAccount(id, title, mail) {
return html;
}
function deletePrefAccount(id,fieldName) {
let c = JSON.parse(localGetData("accounts"));
c.splice(id, 1);
if (c.length > 0) {
localStoreData("accounts", JSON.stringify(c));
}
else {
localStoreData("accounts", null);
}
feedMyAccounts(fieldName);
}
function feedMyAccounts(fieldName) {
console.log("appel de feedMyAccounts :: " + fieldName);
let formField = '#' + fieldName;
let html = "";
$(formField).empty();
let accounts = JSON.parse(localGetData("accounts"));
if (accounts !== null) {
let a = localGetData("accounts");
console.log("on a feedMyAccounts :: " + a);
if (a !== null && a !== "") {
console.log("on a feedMyAccounts non null ... ");
let accounts = JSON.parse(a);
for (let f = 0; f < accounts.length; f++) {
lemail = accounts[f]['email'];
html += makeOneAccount(f, lemail, lemail);
html += makeOneAccount(fieldName,f, lemail, lemail);
}
}
$(formField).append(html);
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment