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

poc tags ok peage/parking

parent 66d233bb
......@@ -16,6 +16,7 @@
<form id="leformPeage" name="leformPeage">
<input type="hidden" name="typeFrais" value="peage">
<input type="hidden" id="updateID" name="updateID" value="0">
<input type="hidden" id="tags" name="tags" value="">
<input type="hidden" id="photoFacturette" name="photoFacturette" value="">
<ons-row vertical-align="baseline">
<ons-col>
......@@ -57,6 +58,15 @@
</ons-list>
</fieldset>
<fieldset data-role="controlgroup" data-type="horizontal" data-mini="true">
<legend class="translate">expenseTags</legend>
<ons-button class="translate" style="float: right;">
<ons-icon icon="md-plus" onclick="showTagsListDialog();"> </ons-icon>
</ons-button>
<ons-list id='listeTags' style="float:left;">
</ons-list>
</fieldset>
<div id='feedPaiements'></div>
<div id="interobjets"></div>
......@@ -113,5 +123,82 @@
}
}
function showTagsListDialog() {
globalMyNavigator.pushPage("tags.html", { data: { showApplyButton: true } });
}
ons.getScriptPage().onInit = function () {
// feedList('listeTags', '', '');
}
/**
* Ajoute une entrée à la liste
**/
function makeOneTagListEntry(id, l_title, l_subtitle, l_value) {
let h = "";
var valA = { "id": id, "slug": l_value, "label": l_title };
let val = btoa(JSON.stringify(valA));
//tentative avec checkbox
h += "<ons-list-item tappable>\n";
h += " <label class=\"left\"><ons-icon icon=\"md-close\" onclick=\"removeOneTag('" + id + "');\"></ons-icon></label>\n";
h += " <label for=\"" + l_value + "\" class=\"center\">" + l_title + "</label>\n";
h += "</ons-list-item>\n";
return h;
}
//Actualisation des tags, retour de la page de choix des tags
function removeOneTag(id) {
console.log("Il faut supprimer " + id);
let t = $('#tags').val();
console.log("t = " + t);
let liste = JSON.parse(t);
console.log("Liste: " + liste);
liste.splice(id, 1);
refreshTags(liste);
}
//Actualisation des tags, retour de la page de choix des tags
function refreshTags(liste) {
let formField = "#listeTags";
let html = "";
let arrayTags = [];
$(formField).empty();
console.log("Appel de refreshTags");
if (liste.length > 0) {
let f = 0;
liste.forEach(e => {
let val = JSON.parse(atob(e));
html += makeOneTagListEntry(f, val.label, val.label, val.slug);
arrayTags[f] = e;
f += 1;
});
}
$('#tags').val(JSON.stringify(arrayTags));
$(formField).append(html);
}
//Actualisation des tags, retour de la page de choix des tags
function addTags(liste) {
let formField = "#listeTags";
let html = "";
let arrayTags = [];
console.log("Appel de addTags");
if (liste.length > 0) {
let f = 0;
liste.forEach(e => {
let val = JSON.parse(atob(e.value));
console.log(e.value + " :: " + val.slug + " :: " + val.label);
html += makeOneTagListEntry(f, val.label, val.label, val.slug);
arrayTags[f] = e.value;
f += 1;
});
}
$('#tags').val(JSON.stringify(arrayTags));
$(formField).append(html);
}
</script>
</ons-page>
</ons-page>
\ No newline at end of file
......@@ -137,5 +137,6 @@
"pleaseSelectTagsBefore": "Please select tags you want to delete before",
"tags": "Tags",
"apply": "Apply",
"tagsAvailable": "Tags available"
"tagsAvailable": "Tags available",
"expenseTags": "Tags"
}
\ No newline at end of file
......@@ -139,5 +139,6 @@
"pleaseSelectTagsBefore": "Veuillez choisir quelles étiquettes vous voulez supprimer avant de cliquer sur ce bouton",
"tags": "Étiquettes",
"apply": "Valider",
"tagsAvailable": "Étiquettes disponibles"
"tagsAvailable": "Étiquettes disponibles",
"expenseTags": "Étiquettes"
}
\ No newline at end of file
......@@ -71,5 +71,6 @@
</ons-row> -->
</div>
<script type="text/javascript">
ons.preload('tags.html');
</script>
</ons-page>
\ No newline at end of file
<ons-page id="ONSFraisIK">
<ons-page id="ONSTagsList">
<ons-toolbar modifier="material">
<div id="titreNav" class="left" onclick="gotoPage('menu.html');">
<span class="translate">tags</span>
......@@ -22,9 +22,9 @@
<ons-icon icon="md-plus"></ons-icon>
</ons-fab>
<ons-bottom-toolbar style="display: none;;">
<ons-bottom-toolbar id="toolbarApply" style="display: none;">
<div style="text-align: center; margin-top: 4px;">
<ons-button modifier="material" onclick="getAllCheckedBoxes();"><span class="translate">apply</span></ons-button>
<ons-button modifier="material" onclick="applyTags();"><span class="translate">apply</span></ons-button>
</div>
</ons-bottom-toolbar>
<div id="container">
......@@ -135,12 +135,22 @@
/**
* récupère la liste de toutes les checkbox cochées
*/
function getAllCheckedBoxes() {
function applyTags() {
console.log("applyTags");
let checkedBoxes = document.querySelectorAll('.checkbox__input:checked');
checkedBoxes.forEach(e => {
let val = JSON.parse(atob(e.value));
myDebug(val.slug + " :: " + val.label);
});
if (checkedBoxes.length > 0) {
checkedBoxes.forEach(e => {
let val = JSON.parse(atob(e.value));
console.log(e.value + " :: " + val.slug + " :: " + val.label);
});
}
else {
ons.notification.toast(trans('pleaseSelectTagsBefore'), { timeout: 2000, animation: 'fall' });
}
if (globalMyNavigator.topPage.data.showApplyButton) {
globalMyNavigator.popPage({ callback: addTags(checkedBoxes) });
}
}
/**
......@@ -211,6 +221,12 @@
ons.getScriptPage().onInit = function () {
//Faut il afficher le bouton appliquer ? oui si on arrive depuis une page de frais
if (globalMyNavigator.topPage.data.showApplyButton) {
console.log("On affiche le bouton apply");
$('#toolbarApply').show();
}
// var t = [];
// t.push({ id: 120, slug: 'projet-208', label: "Projet modélisation 208" });
// t.push({ id: 130, slug: 'client-104', label: "Client CAP-REL" });
......
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