From cd75166da6a3bc56031c478b2f6232e69e9f9e5e Mon Sep 17 00:00:00 2001 From: dave Date: Fri, 5 Jun 2020 13:00:54 -0400 Subject: [PATCH 1/2] Added support for description field to labels. Made Commit Changes button available immediately after a Copy and ignored all duplicate labels on Copy. --- js/app.js | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/js/app.js b/js/app.js index 4bbb2be..0526223 100644 --- a/js/app.js +++ b/js/app.js @@ -179,12 +179,30 @@ $(document).ready(function () { return "Basic " + Base64.encode(username + ":" + password); } - function createNewLabelEntry(label, mode) { + function nameExists(name) { + return new Promise((resolve, reject) => { + var found = false; + $('.label-entry').each(function(index) { + var labelObject = serializeLabel($(this)); + if (labelObject.name == name){ + found = true; + }; + }); + resolve(found); + return found; + }); + } + + async function createNewLabelEntry(label, mode) { var action = ' action="none" '; var uncommitedSignClass = ""; if(mode === 'copy' || mode === 'new'){ + // see if the name already exists. If it does the default action will be to skip it. + var exists = await nameExists(label.name); + if (exists) return; // Don't create the label entry. + action = ' action="create" new="true" '; uncommitedSignClass = ' uncommited '; } @@ -197,6 +215,7 @@ $(document).ready(function () { } var origNameVal = ' orig-val="' + label.name + '"'; + var origDescriptionVal = ' orig-val="' + label.description + '"'; var origColorVal = ' orig-val="' + label.color + '"'; var newElementEntry = $('\ @@ -205,6 +224,7 @@ $(document).ready(function () { #\ \ \ + \ \ '); @@ -359,6 +379,8 @@ $('#copyFromRepoButton').click(function(e) { if(username && repo){ apiCallListLabels(username, repo, 'copy', function(response) { theButton.button('reset'); + $('#commitButton').removeAttr('disabled'); + $('#commitButton').removeClass('disabled'); });//set addUncommited to true because those are coming from another repo } else{ @@ -406,10 +428,11 @@ $('#commitButton').click(function(e) { /** * Makes a label entry out of a div having the class .label-entry */ - function serializeLabel(jObjectLabelEntry) { + function serializeLabel(jObjectLabelEntry) { return { name: jObjectLabelEntry.children().filter('[name="name"]').val(), color: jObjectLabelEntry.children().filter('[name="color"]').val(), + description: jObjectLabelEntry.children().filter('[name="description"]').val(), originalName: jObjectLabelEntry.children().filter('[name="name"]').attr('orig-val') }; } @@ -611,4 +634,4 @@ $('#commitButton').click(function(e) { };//end of Base64 -}); //end of doc ready +}); //end of doc ready \ No newline at end of file From c795cdfb801766f145dbe089ee0a0404796e9274 Mon Sep 17 00:00:00 2001 From: dave Date: Fri, 5 Jun 2020 13:29:45 -0400 Subject: [PATCH 2/2] Fixed error with Add new label. --- js/app.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/js/app.js b/js/app.js index 0526223..4fd7db6 100644 --- a/js/app.js +++ b/js/app.js @@ -200,13 +200,15 @@ $(document).ready(function () { if(mode === 'copy' || mode === 'new'){ // see if the name already exists. If it does the default action will be to skip it. - var exists = await nameExists(label.name); - if (exists) return; // Don't create the label entry. - + if(mode === 'copy'){ + var exists = await nameExists(label.name); + if (exists) return; // Don't create the label entry. + } + action = ' action="create" new="true" '; uncommitedSignClass = ' uncommited '; } - + if(label === undefined || label === null){ label = { name: "",