mirror of
https://github.com/krateng/maloja.git
synced 2023-08-10 21:12:55 +03:00
Added client logic for merging
This commit is contained in:
parent
0d985ff706
commit
57e66fdafd
@ -1,19 +1,6 @@
|
||||
// JS for all web interface editing / deletion of scrobble data
|
||||
|
||||
|
||||
|
||||
function toggleDeleteConfirm(element) {
|
||||
element.parentElement.parentElement.classList.toggle('active');
|
||||
}
|
||||
|
||||
function deleteScrobble(id,element) {
|
||||
element.parentElement.parentElement.parentElement.classList.add('removed');
|
||||
|
||||
neo.xhttpreq("/apis/mlj_1/delete_scrobble",data={'timestamp':id},method="POST",callback=(()=>null),json=true);
|
||||
|
||||
}
|
||||
|
||||
|
||||
// HELPERS
|
||||
function selectAll(e) {
|
||||
// https://stackoverflow.com/a/6150060/6651341
|
||||
var range = document.createRange();
|
||||
@ -23,6 +10,18 @@ function selectAll(e) {
|
||||
sel.addRange(range);
|
||||
}
|
||||
|
||||
// DELETION
|
||||
function toggleDeleteConfirm(element) {
|
||||
element.parentElement.parentElement.classList.toggle('active');
|
||||
}
|
||||
|
||||
function deleteScrobble(id,element) {
|
||||
element.parentElement.parentElement.parentElement.classList.add('removed');
|
||||
neo.xhttpreq("/apis/mlj_1/delete_scrobble",data={'timestamp':id},method="POST",callback=(()=>null),json=true);
|
||||
}
|
||||
|
||||
|
||||
// EDIT NAME
|
||||
function editEntity() {
|
||||
|
||||
var namefield = document.getElementById('main_entity_name');
|
||||
@ -40,20 +39,18 @@ function editEntity() {
|
||||
namefield.textContent = entity_name;
|
||||
namefield.blur();
|
||||
}
|
||||
|
||||
})
|
||||
|
||||
// emergency, not pretty because it will move cursor
|
||||
namefield.addEventListener('input',function(e){
|
||||
if (namefield.textContent.includes("\n")) {
|
||||
namefield.textContent = namefield.textContent.replace("\n","");
|
||||
}
|
||||
|
||||
})
|
||||
|
||||
// manually clicking away OR enter
|
||||
namefield.addEventListener('blur',function(e){
|
||||
doneEditing();
|
||||
|
||||
})
|
||||
|
||||
namefield.focus();
|
||||
@ -88,6 +85,36 @@ function doneEditing() {
|
||||
json=true
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
// MERGING
|
||||
|
||||
function markForMerge() {
|
||||
const lcst = window.localStorage;
|
||||
var key = "marked_for_merge_" + entity_type;
|
||||
var current_stored = (lcst.getItem(key) || '').split(",");
|
||||
current_stored = current_stored.filter((x)=>x).map((x)=>parseInt(x));
|
||||
current_stored.push(entity_id);
|
||||
current_stored = [...new Set(current_stored)];
|
||||
lcst.setItem(key,current_stored); //this already formats it correctly
|
||||
}
|
||||
|
||||
function merge() {
|
||||
const lcst = window.localStorage;
|
||||
var key = "marked_for_merge_" + entity_type;
|
||||
var current_stored = lcst.getItem(key).split(",");
|
||||
current_stored = current_stored.filter((x)=>x).map((x)=>parseInt(x));
|
||||
|
||||
neo.xhttpreq(
|
||||
"/apis/mlj_1/merge_" + entity_type + "s",
|
||||
data={
|
||||
'source_ids':current_stored,
|
||||
'target_id':entity_id
|
||||
},
|
||||
method="POST",
|
||||
callback=(()=>window.location.reload()),
|
||||
json=true
|
||||
);
|
||||
|
||||
lcst.removeItem(key);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user