Snippets edited on a project page can't be disassociated from that
project on that page.
This commit is contained in:
parent
841264de0f
commit
dc94262bfb
|
@ -16,7 +16,7 @@ function readableByteSize(numBytes) {
|
|||
return new Intl.NumberFormat([], { maximumFractionDigits: (scale > 0 ? 2 : 0) }).format(numBytes) + scales[scale];
|
||||
}
|
||||
|
||||
function makeSnippetEdit(ownerName, ownerAvatar, ownerUrl, date, text, attachmentElement, projectIds, snippetId, originalSnippetEl) {
|
||||
function makeSnippetEdit(ownerName, ownerAvatar, ownerUrl, date, text, attachmentElement, projectIds, stickyProjectId, snippetId, originalSnippetEl) {
|
||||
let snippetEdit = snippetEditTemplate();
|
||||
let projectSelector = null;
|
||||
let originalAttachment = null;
|
||||
|
@ -60,10 +60,14 @@ function makeSnippetEdit(ownerName, ownerAvatar, ownerUrl, date, text, attachmen
|
|||
projEl.projectId.value = proj.id;
|
||||
projEl.projectLogo.src = proj.logo;
|
||||
projEl.projectName.textContent = proj.name;
|
||||
projEl.removeButton.addEventListener("click", function(ev) {
|
||||
projEl.root.remove();
|
||||
updateProjectSelector();
|
||||
});
|
||||
if (proj.id == stickyProjectId) {
|
||||
projEl.removeButton.remove();
|
||||
} else {
|
||||
projEl.removeButton.addEventListener("click", function(ev) {
|
||||
projEl.root.remove();
|
||||
updateProjectSelector();
|
||||
});
|
||||
}
|
||||
snippetEdit.projectList.appendChild(projEl.root);
|
||||
}
|
||||
|
||||
|
@ -338,7 +342,7 @@ function makeSnippetEdit(ownerName, ownerAvatar, ownerUrl, date, text, attachmen
|
|||
return snippetEdit;
|
||||
}
|
||||
|
||||
function editTimelineSnippet(timelineItemEl) {
|
||||
function editTimelineSnippet(timelineItemEl, stickyProjectId) {
|
||||
let ownerName = timelineItemEl.querySelector(".user")?.textContent;
|
||||
let ownerUrl = timelineItemEl.querySelector(".user")?.href;
|
||||
let ownerAvatar = timelineItemEl.querySelector(".avatar-icon")?.src;
|
||||
|
@ -353,7 +357,7 @@ function editTimelineSnippet(timelineItemEl) {
|
|||
projectIds.push(projid);
|
||||
}
|
||||
}
|
||||
let snippetEdit = makeSnippetEdit(ownerName, ownerAvatar, ownerUrl, creationDate, rawDesc, attachment, projectIds, timelineItemEl.getAttribute("data-id"), timelineItemEl);
|
||||
let snippetEdit = makeSnippetEdit(ownerName, ownerAvatar, ownerUrl, creationDate, rawDesc, attachment, projectIds, stickyProjectId, timelineItemEl.getAttribute("data-id"), timelineItemEl);
|
||||
timelineItemEl.parentElement.insertBefore(snippetEdit.root, timelineItemEl);
|
||||
timelineItemEl.remove();
|
||||
}
|
||||
|
|
|
@ -103,7 +103,7 @@
|
|||
const currentProjectId = {{ .Project.ID }};
|
||||
|
||||
document.querySelector(".create_snippet_link")?.addEventListener("click", function() {
|
||||
let snippetEdit = makeSnippetEdit(userName, userAvatar, userUrl, new Date(), "", null, [currentProjectId], null, null);
|
||||
let snippetEdit = makeSnippetEdit(userName, userAvatar, userUrl, new Date(), "", null, [currentProjectId], currentProjectId, null, null);
|
||||
document.querySelector(".timeline").insertBefore(snippetEdit.root, document.querySelector(".timeline").children[0]);
|
||||
document.querySelector(".create_snippet_link")?.remove();
|
||||
});
|
||||
|
@ -115,7 +115,7 @@
|
|||
parent = parent.parentElement;
|
||||
}
|
||||
if (parent && parent.classList.contains("timeline-item")) {
|
||||
editTimelineSnippet(parent);
|
||||
editTimelineSnippet(parent, currentProjectId);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
@ -175,7 +175,7 @@
|
|||
|
||||
{{ if .OwnProfile }}
|
||||
document.querySelector(".create_snippet_link")?.addEventListener("click", function() {
|
||||
let snippetEdit = makeSnippetEdit(userName, userAvatar, userUrl, new Date(), "", null, [], null, null);
|
||||
let snippetEdit = makeSnippetEdit(userName, userAvatar, userUrl, new Date(), "", null, [], null, null, null);
|
||||
document.querySelector(".timeline").insertBefore(snippetEdit.root, document.querySelector(".timeline").children[0]);
|
||||
document.querySelector(".create_snippet_link")?.remove();
|
||||
});
|
||||
|
@ -188,7 +188,7 @@
|
|||
parent = parent.parentElement;
|
||||
}
|
||||
if (parent && parent.classList.contains("timeline-item")) {
|
||||
editTimelineSnippet(parent);
|
||||
editTimelineSnippet(parent, null);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue