From eac5c099061c234cb286d9c3cbfdde3534d1fa07 Mon Sep 17 00:00:00 2001 From: Kameron Kenny Date: Wed, 26 Jun 2019 09:16:49 -0400 Subject: [PATCH] tags --- punch_list/backlog.html | 1 + punch_list/backlogManage.js | 172 +++++++++++++++++++++++++----------- punch_list/metadata.js | 2 +- 3 files changed, 124 insertions(+), 51 deletions(-) diff --git a/punch_list/backlog.html b/punch_list/backlog.html index d83cb6f..9fbc5ba 100644 --- a/punch_list/backlog.html +++ b/punch_list/backlog.html @@ -56,6 +56,7 @@ + Clear Tags
diff --git a/punch_list/backlogManage.js b/punch_list/backlogManage.js index 9a65f56..9651419 100644 --- a/punch_list/backlogManage.js +++ b/punch_list/backlogManage.js @@ -90,47 +90,114 @@ function genList(punchList, element) { var list = '
    '; for (i = 0; i < listLength; i++) { - if (punchList[i].progress.toLowerCase() === "in progress") { var style = "inProgress" } else { var style = "punch-default" } - if (punchList[i].progress.toLowerCase() === "done" && punchList[i].priority != 99999) { - setPriority(punchList[i].uuid, 99999); - } else if (punchList[i].progress.toLowerCase() != "done"){ - list += '
  1. '; - list += '
    '; - list += '
    '; - list += punchList[i].priority + '
    ' + punchList[i].subject + '
    '; - list += '
    ' + punchList[i].progress + '
    '; - if (style === "inProgress") { - list += ''; - } else if (style === "punch-default") { - list += ''; + if (window.tagFilterItem != undefined) { + console.log('in tags filter'); + if (punchList[i].tags != undefined && punchList[i].tags.includes(window.tagFilterItem)) { + if (punchList[i].progress.toLowerCase() === "in progress") { var style = "inProgress" } else { var style = "punch-default" } + if (punchList[i].progress.toLowerCase() === "done" && punchList[i].priority != 99999) { + setPriority(punchList[i].uuid, 99999); + } else if (punchList[i].progress.toLowerCase() != "done"){ + list += '
  2. '; + list += '
    '; + list += '
    '; + list += punchList[i].priority + '
    ' + punchList[i].subject + '
    '; + list += '
    ' + punchList[i].progress + '
    '; + if (style === "inProgress") { + list += ''; + } else if (style === "punch-default") { + list += ''; + } + if ( punchList[i].nDate != null && punchList[i].nDate != undefined && punchList[i].nDate != '' ) { + list += '
    ' + punchList[i].nDate + '
    '; + } else { + list += '
     
    '; + } + if ( (new Date(punchList[i].nDate).getTime() - new Date().getTime()) <= 0 ) { + console.log('overdue'); + list += '
    OVERDUE
    '; + } else if ( ((new Date(punchList[i].nDate).getTime() - new Date().getTime()) / 1000) <= 259200 ) { + console.log('due soon'); + list += '
    DUE SOON
    '; + } else { + list += '
     
    '; + } + if ( punchList[i].tags != undefined ) { + list += '
    '; + for (t = 0; t < punchList[i].tags.length; t++) { + list += '' + punchList[i].tags[t] + ''; + if ( (t + 1) < punchList[i].tags.length ) { + list += ", "; + } + } + } + list += '
    '; + list += '
    '; + if ( punchList[i].nDate > "" ) { + list += '
    Needed By:
    ' + punchList[i].nDate + '
    '; + } + if ( punchList[i].tags != undefined && punchList[i].tags != [] ) { + list += '
    Tags:
    ' + punchList[i].tags + '
    '; + } + if ( punchList[i].notes != "" ) { + list += '
    '; + } + list += ''; + list += '
  3. '; + } } - //console.log("Need by " + new Date(punchList[i].nDate).getTime()); - //console.log("Now " + new Date().getTime()); - //console.log("gap " + (new Date(punchList[i].nDate).getTime() - new Date().getTime())); - list += '
    ' + punchList[i].nDate + '
    '; - if ( (new Date(punchList[i].nDate).getTime() - new Date().getTime()) <= 0 ) { - console.log('overdue'); - list += '
    OVERDUE
    '; - } else if ( ((new Date(punchList[i].nDate).getTime() - new Date().getTime()) / 1000) <= 259200 ) { - console.log('due soon'); - list += '
    DUE SOON
    '; + } else { + console.log('in no tags filter'); + if (punchList[i].progress.toLowerCase() === "in progress") { var style = "inProgress" } else { var style = "punch-default" } + if (punchList[i].progress.toLowerCase() === "done" && punchList[i].priority != 99999) { + setPriority(punchList[i].uuid, 99999); + } else if (punchList[i].progress.toLowerCase() != "done"){ + list += '
  4. '; + list += '
    '; + list += '
    '; + list += punchList[i].priority + '
    ' + punchList[i].subject + '
    '; + list += '
    ' + punchList[i].progress + '
    '; + if (style === "inProgress") { + list += ''; + } else if (style === "punch-default") { + list += ''; + } + if ( punchList[i].nDate != null && punchList[i].nDate != undefined && punchList[i].nDate != '' ) { + list += '
    ' + punchList[i].nDate + '
    '; + } else { + list += '
     
    '; + } + if ( (new Date(punchList[i].nDate).getTime() - new Date().getTime()) <= 0 ) { + console.log('overdue'); + list += '
    OVERDUE
    '; + } else if ( ((new Date(punchList[i].nDate).getTime() - new Date().getTime()) / 1000) <= 259200 ) { + console.log('due soon'); + list += '
    DUE SOON
    '; + } else { + list += '
     
    '; + } + if ( punchList[i].tags != undefined ) { + list += '
    '; + for (t = 0; t < punchList[i].tags.length; t++) { + list += '' + punchList[i].tags[t] + ''; + if ( (t + 1) < punchList[i].tags.length ) { + list += ", "; + } + } + } + list += '
    '; + list += '
    '; + if ( punchList[i].nDate > "" ) { + list += '
    Needed By:
    ' + punchList[i].nDate + '
    '; + } + if ( punchList[i].tags != undefined && punchList[i].tags != [] ) { + list += '
    Tags:
    ' + punchList[i].tags + '
    '; + } + if ( punchList[i].notes != "" ) { + list += '
    '; + } + list += ''; + list += '
  5. '; } - list += ''; - list += '
    '; -// list += punchList[i].progress + '
    '; -// list += 'Created: ' + punchList[i].cDate + '
    '; -// list += 'Modified: ' + punchList[i].mDate + '
    '; - if ( punchList[i].nDate > "" ) { - list += '
    Needed By:
    ' + punchList[i].nDate + '
    '; - } - if ( punchList[i].tags != undefined && punchList[i].tags != [] ) { - list += '
    Tags:
    ' + punchList[i].tags + '
    '; - } - if ( punchList[i].notes != "" ) { - list += '
    '; - } - list += ''; - list += '
    '; } } @@ -377,7 +444,8 @@ function editPunch(uuid) { html += '
    Progress:
    '; html += progress; html += '
    '; - html += '
    Tags:
    '; + html += '
    Tags:
    ' + tags + '
    '; + html += '
    Add Tag:
    '; html += '
    Notes:
    '; html += ''; html += ''; @@ -411,30 +479,34 @@ function submitEditPunch(uuid) { disableElement("editPunch"); } -function addTag() { +function addTag(uuid) { /* Before doing this, Refresh the array, So that we don't overwrite data */ -getJson(); - var item = document.getElementById("editID").value; - var newTag = document.getElementById("tag").value.toLowerCase(); + var item = findArrayId(uuid); +// var item = document.getElementById("addTag-" + uuid).value; + var newTag = document.getElementById("addTag-" + uuid).value.toLowerCase(); + var stripLeadingSpace = newTag.replace(', ', ','); + var newTags = stripLeadingSpace.split(","); - 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}`); + for ( nt = 0; nt < newTags.length; nt++ ) { + punchList[item].tags.push(newTags[nt]); + console.log(`${punchList[item].tags}`); + } jsonStr = JSON.stringify(punchList); putJson(jsonStr); - disableElement("editPunch"); - enableElement("punchListAll"); + editPunch(uuid); +// disableElement("editPunch"); +// enableElement("punchListAll"); + disableElement("punchListAll"); } function clearDefault(a){ diff --git a/punch_list/metadata.js b/punch_list/metadata.js index e27ff69..e10fa48 100644 --- a/punch_list/metadata.js +++ b/punch_list/metadata.js @@ -1,4 +1,4 @@ -var version = "0.5.333", +var version = "0.6.001", debug = false, jsonUrl = "https://api.myjson.com/bins/1dodsj", showDone = false,