mirror of
https://github.com/monkeytypegame/monkeytype.git
synced 2026-01-08 08:25:05 +08:00
added a button to clear tag pb
This commit is contained in:
parent
c5783c3f5d
commit
e404d818c1
3 changed files with 49 additions and 10 deletions
|
|
@ -781,7 +781,7 @@ exports.clearTagPb = functions.https.onCall((request, response) => {
|
|||
.collection(`users/${request.uid}/tags`)
|
||||
.doc(request.tagid)
|
||||
.update({
|
||||
pb: 0,
|
||||
personalBests: admin.firestore.FieldValue.delete(),
|
||||
})
|
||||
.then((e) => {
|
||||
return {
|
||||
|
|
|
|||
|
|
@ -26,6 +26,12 @@ export function show(action, id, name) {
|
|||
$("#tagsWrapper #tagsEdit .title").html("Remove tag " + name);
|
||||
$("#tagsWrapper #tagsEdit .button").html(`<i class="fas fa-check"></i>`);
|
||||
$("#tagsWrapper #tagsEdit input").addClass("hidden");
|
||||
} else if (action === "clearPb") {
|
||||
$("#tagsWrapper #tagsEdit").attr("action", "clearPb");
|
||||
$("#tagsWrapper #tagsEdit").attr("tagid", id);
|
||||
$("#tagsWrapper #tagsEdit .title").html("Clear PB for tag " + name);
|
||||
$("#tagsWrapper #tagsEdit .button").html(`<i class="fas fa-check"></i>`);
|
||||
$("#tagsWrapper #tagsEdit input").addClass("hidden");
|
||||
}
|
||||
|
||||
if ($("#tagsWrapper").hasClass("hidden")) {
|
||||
|
|
@ -134,6 +140,28 @@ function apply() {
|
|||
Notifications.add("Unknown error: " + e.data.message, -1);
|
||||
}
|
||||
});
|
||||
} else if (action === "clearPb") {
|
||||
Loader.show();
|
||||
CloudFunctions.clearTagPb({
|
||||
uid: firebase.auth().currentUser.uid,
|
||||
tagid: tagid,
|
||||
}).then((e) => {
|
||||
Loader.hide();
|
||||
let status = e.data.resultCode;
|
||||
if (status === 1) {
|
||||
Notifications.add("PB cleared", 1);
|
||||
DB.getSnapshot().tags.forEach((tag, index) => {
|
||||
if (tag.id === tagid) {
|
||||
tag.personalBests = {};
|
||||
}
|
||||
});
|
||||
ResultTagsPopup.updateButtons();
|
||||
Settings.update();
|
||||
ResultFilters.updateTags();
|
||||
} else if (status < -1) {
|
||||
Notifications.add("Unknown error: " + e.data.message, -1);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -427,6 +427,9 @@ function refreshTagsSettingsSection() {
|
|||
}">
|
||||
<div class="title">${tag.name}</div>
|
||||
</div>
|
||||
<div class="clearPbButton button">
|
||||
<i class="fas fa-crown"></i>
|
||||
</div>
|
||||
<div class="editButton button">
|
||||
<i class="fas fa-pen"></i>
|
||||
</div>
|
||||
|
|
@ -715,22 +718,27 @@ $(document).on(
|
|||
|
||||
$(document).on(
|
||||
"click",
|
||||
".pageSettings .section.tags .tagsList .tag .clearPbButton",
|
||||
".pageSettings .section.tags .tagsList .tag .editButton",
|
||||
(e) => {
|
||||
let target = e.currentTarget;
|
||||
let tagid = $(target).parent(".tag").attr("id");
|
||||
let tagname = $(target).siblings(".title")[0].innerHTML;
|
||||
SimplePopups.list.clearTagPb.show([tagid, tagname]);
|
||||
let tagid = $(e.currentTarget).parent(".tag").attr("id");
|
||||
let name = $(e.currentTarget)
|
||||
.siblings(".tagButton")
|
||||
.children(".title")
|
||||
.text();
|
||||
EditTagsPopup.show("edit", tagid, name);
|
||||
}
|
||||
);
|
||||
|
||||
$(document).on(
|
||||
"click",
|
||||
".pageSettings .section.tags .tagsList .tag .editButton",
|
||||
".pageSettings .section.tags .tagsList .tag .clearPbButton",
|
||||
(e) => {
|
||||
let tagid = $(e.currentTarget).parent(".tag").attr("id");
|
||||
let name = $(e.currentTarget).siblings(".title").text();
|
||||
EditTagsPopup.show("edit", tagid, name);
|
||||
let name = $(e.currentTarget)
|
||||
.siblings(".tagButton")
|
||||
.children(".title")
|
||||
.text();
|
||||
EditTagsPopup.show("clearPb", tagid, name);
|
||||
}
|
||||
);
|
||||
|
||||
|
|
@ -739,7 +747,10 @@ $(document).on(
|
|||
".pageSettings .section.tags .tagsList .tag .removeButton",
|
||||
(e) => {
|
||||
let tagid = $(e.currentTarget).parent(".tag").attr("id");
|
||||
let name = $(e.currentTarget).siblings(".title").text();
|
||||
let name = $(e.currentTarget)
|
||||
.siblings(".tagButton")
|
||||
.children(".title")
|
||||
.text();
|
||||
EditTagsPopup.show("remove", tagid, name);
|
||||
}
|
||||
);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue