Commit 1ba41f8e authored by Ivanq's avatar Ivanq

Merge branch 'status'

parents 99c74d5c 2ba21d6b
<?xml version="1.0" ?><svg height="1024" width="1024" xmlns="http://www.w3.org/2000/svg"><path fill="#FFF" d="M704 316.03099999999995l-96 96L768 576l256-256-96-96L769.25 382.781 704 316.03099999999995zM512 832c-176.781 0-320-143.25-320-320 0-176.781 143.219-320 320-320 88.375 0 168.375 35.844 226.25 93.75l90.562-90.5C747.75 114.125 635.75 64 512 64 264.562 64 64 264.562 64 512c0 247.438 200.562 448 448 448 247.438 0 448-200.562 448-448L759.75 712.25C768.688 701.25 684.75 832 512 832zM576 256H448v320h128V256zM448 768h128V640H448V768z"/></svg>
\ No newline at end of file
<?xml version="1.0" ?><svg height="1024" width="896" xmlns="http://www.w3.org/2000/svg"><path fill="#FFF" d="M639.125 767.25C585.75 807.375 520 832 448 832c-176.781 0-320-143.25-320-320 0-45.562 9.781-88.781 27-128H64v-99.469C24.312 351.438 0 428.594 0 512c0 247.438 200.562 448 448 448 107.375 0 204.5-39.312 281.75-102.25L768 896V704H576L639.125 767.25zM384 768h128V640H384V768zM512 256H384v320h128V256zM896 512c0-247.438-200.562-448-448-448-107.406 0-204.531 39.312-281.656 102.344L128 128v192h192l-63.156-63.156C310.281 216.688 376 192 448 192c176.75 0 320 143.219 320 320 0 45.562-9.75 88.75-27 128h91v99.5C871.688 672.562 896 595.5 896 512z"/></svg>
\ No newline at end of file
......@@ -255,6 +255,30 @@ class Repository {
return row;
});
}
changeIssueStatus(id, jsonId, open) {
return this.zeroAuth.requestAuth()
.then(auth => {
return this.zeroDB.changeRow(
"merged-GitCenter/" + this.address + "/data/users/" + auth.address + "/data.json",
"merged-GitCenter/" + this.address + "/data/users/" + auth.address + "/content.json",
"issues",
issue => {
if(issue.id != id) {
return issue;
}
if(open) {
issue.open = true;
issue.reopened = true;
} else {
issue.open = false;
}
return issue;
}
);
});
}
translateDate(date) {
date = new Date(date);
......
......@@ -82,4 +82,8 @@
.comment-submit {
float: right;
}
.comment-submit-close {
float: right;
margin-right: 16px;
}
\ No newline at end of file
......@@ -29,7 +29,7 @@
Code
</a>
<a id="issues_link" class="tab">
<img src="../../img/issue-opened.svg" width="16">
<img src="../../img/issue-open.svg" width="16">
Issues
</a>
<a class="tab">
......
......@@ -27,7 +27,7 @@
Code
</a>
<a id="issues_link" class="tab">
<img src="../img/issue-opened.svg" width="16">
<img src="../img/issue-open.svg" width="16">
Issues
</a>
<a class="tab">
......
......@@ -28,7 +28,7 @@
Code
</a>
<a id="issues_link" class="tab tab-current">
<img src="../../img/issue-opened.svg" width="16">
<img src="../../img/issue-open.svg" width="16">
Issues
</a>
<a class="tab">
......
......@@ -24,7 +24,7 @@ repo.addMerger()
tr.appendChild(title);
let icon = document.createElement("img");
icon.src = "../../img/issue-" + (issue.open ? "opened" : "closed") + ".svg";
icon.src = "../../img/issue-" + (issue.open ? (issue.reopened ? "reopened" : "open") : "closed") + ".svg";
icon.className = "issue-icon";
title.insertBefore(icon, title.firstChild);
......
......@@ -29,7 +29,7 @@
Code
</a>
<a id="issues_link" class="tab tab-current">
<img src="../../../img/issue-opened.svg" width="16">
<img src="../../../img/issue-open.svg" width="16">
Issues
</a>
<a class="tab">
......
......@@ -25,13 +25,22 @@
margin-top: 4px;
margin-right: 16px;
padding: 4px 8px;
background-color: #2B3;
border-radius: 4px;
vertical-align: top;
font-size: 16px;
color: #FFF;
}
.issue-status-open {
background-color: #2B3;
}
.issue-status-closed {
background-color: #B23;
}
.issue-status-reopened {
background-color: #B2E;
}
.issue-status img {
display: inline-block;
height: 16px;
......
......@@ -29,7 +29,7 @@
Code
</a>
<a id="issues_link" class="tab tab-current">
<img src="../../../img/issue-opened.svg" width="16">
<img src="../../../img/issue-open.svg" width="16">
Issues
</a>
<a class="tab">
......@@ -39,7 +39,10 @@
</main>
<div class="info">
<div class="issue-status"><img src="../../../img/issue-opened-white.svg">Open</div>
<div class="issue-status issue-status-open" id="issue_status">
<img id="issue_status_img" src="../../../img/issue-opened-white.svg">
<span id="issue_status_text">Open</span>
</div>
<div class="issue-title">
<span id="issue_title"></span>
<span class="issue-id">
......@@ -52,7 +55,9 @@
<div class="comments">
<textarea class="comment-content-edit" id="comment_content" placeholder="Join the conversation!"></textarea>
<a class="button comment-submit" id="comment_submit">Submit</a>
<a class="button button-blue comment-submit" id="comment_submit">Comment</a>
<a class="button comment-submit-close" id="comment_submit_close">Comment</a>
</div>
<template id="edit_icon_tmpl">
......
......@@ -10,7 +10,6 @@ if(isNaN(id) || isNaN(jsonId)) {
}
function showComment(comment) {
console.log(comment);
let node = document.createElement("div");
node.className = "comment" + (jsonId == comment.json_id ? " comment-owned" : "");
......@@ -27,7 +26,18 @@ function showComment(comment) {
document.getElementById("comments").appendChild(node);
}
function drawIssueStatus() {
let statusText = issue.open ? (issue.reopened ? "reopened" : "open") : "closed";
document.getElementById("issue_status").className = "issue-status issue-status-" + statusText;
document.getElementById("issue_status_img").src = "../../../img/issue-" + statusText + "-white.svg";
document.getElementById("issue_status_text").innerHTML = statusText[0].toUpperCase() + statusText.substr(1);
document.getElementById("comment_submit_close").innerHTML = "Comment and " + (issue.open ? "close" : "reopen") + " issue";
}
let issue;
repo.addMerger()
.then(() => {
return repo.getContent();
......@@ -38,11 +48,15 @@ repo.addMerger()
return repo.getIssue(id, jsonId);
})
.then(issue => {
.then(i => {
issue = i;
document.getElementById("issue_title").textContent = issue.title;
document.getElementById("issue_id").textContent = id;
document.getElementById("issue_json_id").textContent = jsonId;
drawIssueStatus();
return repo.getIssueComments(id, jsonId);
})
.then(comments => {
......@@ -50,7 +64,7 @@ repo.addMerger()
document.getElementById("comment_submit").onclick = () => {
let contentNode = document.getElementById("comment_content");
if(contentNode.disabled) {
if(contentNode.disabled || contentNode.value == "") {
return;
}
......@@ -64,4 +78,40 @@ repo.addMerger()
contentNode.disabled = false;
});
};
document.getElementById("comment_submit_close").onclick = () => {
let contentNode = document.getElementById("comment_content");
if(contentNode.disabled) {
return;
}
contentNode.disabled = true;
let promise;
if(contentNode.value == "") {
promise = Promise.resolve();
} else {
promise = repo.addIssueComment(id, jsonId, contentNode.value)
.then(comment => {
showComment(comment);
});
}
promise
.then(() => {
return repo.changeIssueStatus(id, jsonId, !issue.open);
})
.then(() => {
if(issue.open) {
issue.open = false;
} else {
issue.open = true;
issue.reopened = true;
}
drawIssueStatus();
contentNode.value = "";
contentNode.disabled = false;
});
};
});
\ No newline at end of file
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