add tagging feature

This commit is contained in:
Kameron Kenny 2019-06-07 15:11:17 -04:00
parent c9fc3be285
commit 6f04566334
3 changed files with 52 additions and 1 deletions

View File

@ -65,6 +65,15 @@ function genList(punchList) {
list += "<div class='three columns " + itemStyle + "'>Status: " + punchList[i].progress + "</div>"; list += "<div class='three columns " + itemStyle + "'>Status: " + punchList[i].progress + "</div>";
list += "<div class='two columns " + itemStyle + "'>Priority: " + punchList[i].priority + "</div>"; list += "<div class='two columns " + itemStyle + "'>Priority: " + punchList[i].priority + "</div>";
list += "<div class='four columns " + itemStyle + "'>Need By: " + punchList[i].nDate + "</div>"; list += "<div class='four columns " + itemStyle + "'>Need By: " + punchList[i].nDate + "</div>";
if (punchList[i].tags != undefined) {
console.log(`Adding tags object to punchList[${item}]`);
list += "<div class='four columns " + itemStyle + "'>Tags: ";
for (t = 0; t < punchList[i].tags.length; t++) {
list += punchList[i].tags[t] + ", ";
}
list += "</div>";
}
list += "</div>"; list += "</div>";
list += "<div class='two columns'>"; list += "<div class='two columns'>";
list += "<div class=dropdown>"; list += "<div class=dropdown>";
@ -96,6 +105,14 @@ function genList(punchList) {
list += "<div class='three columns " + itemStyle + "'>Status: " + punchList[i].progress + "</div>"; list += "<div class='three columns " + itemStyle + "'>Status: " + punchList[i].progress + "</div>";
list += "<div class='two columns " + itemStyle + "'>Priority: " + punchList[i].priority + "</div>"; list += "<div class='two columns " + itemStyle + "'>Priority: " + punchList[i].priority + "</div>";
list += "<div class='four columns " + itemStyle + "'>Need By: " + punchList[i].nDate + "</div>"; list += "<div class='four columns " + itemStyle + "'>Need By: " + punchList[i].nDate + "</div>";
if (punchList[i].tags != undefined) {
console.log(`Adding tags object to punchList[${item}]`);
list += "<div class='four columns " + itemStyle + "'>Tags: ";
for (t = 0; t < punchList[i].tags.length; t++) {
list += punchList[i].tags[t] + ", ";
}
list += "</div>";
}
list += "</div>"; list += "</div>";
list += "<div class='two columns'>"; list += "<div class='two columns'>";
list += "<div class=dropdown>"; list += "<div class=dropdown>";
@ -129,6 +146,14 @@ function genList(punchList) {
list += "<div class='three columns " + itemStyle + "'>Status: " + punchList[i].progress + "</div>"; list += "<div class='three columns " + itemStyle + "'>Status: " + punchList[i].progress + "</div>";
list += "<div class='two columns " + itemStyle + "'>Priority: " + punchList[i].priority + "</div>"; list += "<div class='two columns " + itemStyle + "'>Priority: " + punchList[i].priority + "</div>";
list += "<div class='four columns " + itemStyle + "'>Need By: " + punchList[i].nDate + "</div>"; list += "<div class='four columns " + itemStyle + "'>Need By: " + punchList[i].nDate + "</div>";
if (punchList[i].tags != undefined) {
console.log(`Adding tags object to punchList[${item}]`);
list += "<div class='four columns " + itemStyle + "'>Tags: ";
for (t = 0; t < punchList[i].tags.length; t++) {
list += punchList[i].tags[t] + ", ";
}
list += "</div>";
}
list += "</div>"; list += "</div>";
list += "<div class='two columns'>"; list += "<div class='two columns'>";
list += "<div class=dropdown>"; list += "<div class=dropdown>";
@ -301,3 +326,28 @@ function submitEditPunch() {
putJson(jsonStr); putJson(jsonStr);
disableElement("editPunch"); disableElement("editPunch");
} }
function addTag() {
var item = document.getElementById("editID").value;
var newTag = document.getElementById("tag").value;
console.log(`Item: ${item}`);
console.log(`New Tag: ${newTag}`);
// make sure tags object exists
if (punchList[item].tags === undefined) {
console.log(`Adding tags object to punchList[${item}]`);
punchList[item].tags = [];
}
punchList[item].tags.push(newTag);
console.log(`${punchList[item].tags}`);
jsonStr = JSON.stringify(punchList);
putJson(jsonStr);
disableElement("editPunch");
enableElement("punchListAll");
}

View File

@ -39,6 +39,7 @@
<input type='text' id='timepickerEdit' class='datepicker-here u-full-width' data-timepicker='true' data-language='en'><br /> <input type='text' id='timepickerEdit' class='datepicker-here u-full-width' data-timepicker='true' data-language='en'><br />
<!-- <input type="text" id="editStartDate" value=""> --> <!-- <input type="text" id="editStartDate" value=""> -->
<textarea class="u-full-width" id="editNotes" value=""></textarea> <textarea class="u-full-width" id="editNotes" value=""></textarea>
<input type='text' id='tag' value="new Tag"><input onClick="addTag()" type=button value="ADD" />
<input class="u-full-width" onClick="submitEditPunch()" id="test" type="button" value="Update" /> <input class="u-full-width" onClick="submitEditPunch()" id="test" type="button" value="Update" />
</div> </div>
<div class="container row" id="newEvent"> <div class="container row" id="newEvent">

View File

@ -1,4 +1,4 @@
var version = "0.2.017", var version = "0.3.021",
debug = false, debug = false,
jsonUrl = "https://api.myjson.com/bins/1dodsj", jsonUrl = "https://api.myjson.com/bins/1dodsj",
showDone = false, showDone = false,