1
0
mirror of https://github.com/krateng/maloja.git synced 2023-08-10 21:12:55 +03:00

Only showing valid icons for merging

This commit is contained in:
krateng 2022-04-21 17:02:10 +02:00
parent 713dbc34bb
commit 20092df02c
9 changed files with 59 additions and 4 deletions

View File

@ -44,7 +44,7 @@ errors = {
"error":{
'type':'missing_scrobble_data',
'value':e.params,
'desc':"A scrobble requires these parameters."
'desc':"The scrobble is missing needed parameters."
}
}),
database.exceptions.EntityExists: lambda e: (409,{

View File

@ -86,6 +86,9 @@
{% block icon_bar %}{% endblock %}
{% include 'icons/settings.jinja' %}
</div>
<script>
showValidMergeIcons();
</script>
<div id="notification_area">

View File

@ -32,6 +32,7 @@
{% include 'icons/edit.jinja' %}
{% include 'icons/merge.jinja' %}
{% include 'icons/merge_mark.jinja' %}
{% include 'icons/merge_cancel.jinja' %}
{% endif %}
{% endblock %}

View File

@ -1,4 +1,4 @@
<div title="Merge" id="mergeicon" class="clickable_icon" onclick="merge()">
<div title="Merge" id="mergeicon" class="clickable_icon hide" onclick="merge()">
<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
<g>
<path fill="none" d="M0 0h24v24H0z"/>

View File

@ -0,0 +1,10 @@
<div title="Cancel merge" id="mergecancelicon" class="clickable_icon hide" onclick="cancelMerge()">
<svg version="1.1" id="Capa_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
viewBox="0 0 47.095 47.095" style="enable-background:new 0 0 47.095 47.095;" xml:space="preserve">
<g>
<path d="M45.363,36.234l-13.158-13.16l12.21-12.21c2.31-2.307,2.31-6.049,0-8.358c-2.308-2.308-6.05-2.307-8.356,0l-12.212,12.21
L11.038,1.906c-2.309-2.308-6.051-2.308-8.358,0c-2.307,2.309-2.307,6.049,0,8.358l12.81,12.81L1.732,36.831
c-2.309,2.31-2.309,6.05,0,8.359c2.308,2.307,6.049,2.307,8.356,0l13.759-13.758l13.16,13.16c2.308,2.308,6.049,2.308,8.356,0
C47.673,42.282,47.672,38.54,45.363,36.234z"/>
</g>
</div>

View File

@ -1,4 +1,4 @@
<div title="Mark for merging" id="mergemarkicon" class="clickable_icon" onclick="markForMerge()">
<div title="Mark for merging" id="mergemarkicon" class="clickable_icon hide" onclick="markForMerge()">
<svg viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg">
<path fill-rule="evenodd" d="M10,0 L10,2.60002 C12.2108812,3.04881281 13.8920863,4.95644867 13.9950026,7.27443311 L14,7.5 L14,11.2676 C14.5978,11.6134 15,12.2597 15,13 C15,14.1046 14.1046,15 13,15 C11.8954,15 11,14.1046 11,13 C11,12.3166462 11.342703,11.713387 11.8656124,11.3526403 L12,11.2676 L12,7.5 C12,6.259091 11.246593,5.19415145 10.1722389,4.73766702 L10,4.67071 L10,7 L6,3.5 L10,0 Z M3,1 C4.10457,1 5,1.89543 5,3 C5,3.68333538 4.65729704,4.28663574 4.13438762,4.6473967 L4,4.73244 L4,11.2676 C4.5978,11.6134 5,12.2597 5,13 C5,14.1046 4.10457,15 3,15 C1.89543,15 1,14.1046 1,13 C1,12.3166462 1.34270296,11.713387 1.86561238,11.3526403 L2,11.2676 L2,4.73244 C1.4022,4.38663 1,3.74028 1,3 C1,1.89543 1.89543,1 3,1 Z"/>
</svg>

View File

@ -27,6 +27,7 @@
{% include 'icons/edit.jinja' %}
{% include 'icons/merge.jinja' %}
{% include 'icons/merge_mark.jinja' %}
{% include 'icons/merge_cancel.jinja' %}
{% endif %}
{% endblock %}

View File

@ -156,5 +156,5 @@ input:focus {
.hide {
display:none;
display:none !important;
}

View File

@ -108,6 +108,38 @@ function doneEditing() {
// MERGING
function showValidMergeIcons() {
const lcst = window.sessionStorage;
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));
var mergeicon = document.getElementById('mergeicon');
var mergemarkicon = document.getElementById('mergemarkicon');
var mergecancelicon = document.getElementById('mergecancelicon');
mergeicon.classList.add('hide');
mergemarkicon.classList.add('hide');
mergecancelicon.classList.add('hide');
if (current_stored.length == 0) {
mergemarkicon.classList.remove('hide');
}
else {
mergecancelicon.classList.remove('hide');
if (current_stored.includes(entity_id)) {
}
else {
mergemarkicon.classList.remove('hide');
mergeicon.classList.remove('hide');
}
}
}
function markForMerge() {
const lcst = window.sessionStorage;
var key = "marked_for_merge_" + entity_type;
@ -117,6 +149,7 @@ function markForMerge() {
current_stored = [...new Set(current_stored)];
lcst.setItem(key,current_stored); //this already formats it correctly
notify("Success","Marked " + entity_name + " for merge, currently " + current_stored.length + " marked!")
showValidMergeIcons();
}
function merge() {
@ -147,3 +180,10 @@ function merge() {
lcst.removeItem(key);
}
function cancelMerge() {
const lcst = window.sessionStorage;
var key = "marked_for_merge_" + entity_type;
lcst.setItem(key,[]);
showValidMergeIcons();
}