From 75de23d1c23291d2e88907d2d6dc7a910d97728c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Lo=C3=AFs=20Poujade?= <lois.poujade@tetras-libre.fr>
Date: Mon, 25 Apr 2022 11:42:08 +0200
Subject: [PATCH] ui + fix

---
 capsule-prototype/css/popup.css       | 16 +++++++++++++++-
 capsule-prototype/index.html          |  2 +-
 capsule-prototype/js/online-script.js | 11 ++++-------
 3 files changed, 20 insertions(+), 9 deletions(-)

diff --git a/capsule-prototype/css/popup.css b/capsule-prototype/css/popup.css
index 5f75752..b8f80ff 100644
--- a/capsule-prototype/css/popup.css
+++ b/capsule-prototype/css/popup.css
@@ -1,14 +1,28 @@
 
+#popupLabelsInput {
+  padding: 0;
+}
+
 #popupLabelsInput label {
   cursor: pointer;
   width: fit-content;
-  padding: 2px;
+  padding: 1px;
+  margin: 1px;
 }
 
 #popupLabelsInput input:checked + label {
   background-color: rgba(255, 255, 255, .5);
 }
 
+#new_annotation_label {
+  color: white;
+  background-color: rgba(0, 0, 0, .5);
+  border: 0;
+  margin: 0;
+  margin-bottom: 2px;
+  font-size: 100%;
+}
+
 #popupSpace, #popupAlertSpace, #popupAddLinkSpace, #popupSettingsSpace {
 	width: 100%;
 	height: 100%;
diff --git a/capsule-prototype/index.html b/capsule-prototype/index.html
index a366e79..0e4a981 100644
--- a/capsule-prototype/index.html
+++ b/capsule-prototype/index.html
@@ -188,7 +188,7 @@
           <div class="popupRightItem" id="popupLabels" title="Labels"></div>
           <!-- templates -->
           <div id='popupLabelsInput' class='popupInput flex-col'>
-            <input type='text' id='new_annotation_label' />
+            <input type='text' id='new_annotation_label' placeholder='Add a new tag' class='editmode' />
             <input class='annotation_labels_template' type='checkbox' id='' value='' style='display: none;' />
             <label class='annotation_labels_template' for='' style='display: none;'></label>
           </div>
diff --git a/capsule-prototype/js/online-script.js b/capsule-prototype/js/online-script.js
index 9cff9ad..ad86b90 100644
--- a/capsule-prototype/js/online-script.js
+++ b/capsule-prototype/js/online-script.js
@@ -816,12 +816,10 @@ function closeInputs() {
 
 				var keyDoc = $(this).parent().attr("keydoc");
         var newLabels = '';
-        $('[name="annotation_labels"]:checked')
+        $('input.annotation_labels:checked')
           .toArray().forEach(e => {
             newLabels += e.value + ';';
-            e.checked = false;
           })
-        console.log('new labels: ', newLabels);
         setMetaFromDom(keyDoc, "Rekall->Labels", newLabels);
 
         if (newLabels === '') {
@@ -850,7 +848,7 @@ function closeInputs() {
 				setMetaFromDom(keyDoc, "Rekall->Link", newLink);
 
 				if(newLink!="") {
-					if(rekall_common.owner.canEdit) $("#popupLink").html(newLink).removeClass("empty");
+          if(rekall_common.owner.canEdit) $("#popupLink").html(newLink).removeClass("empty");
 					else $("#popupLink").html("<a href='"+newLink+"' target='_blank'>"+newLink+"</a>").removeClass("empty");
 				}
 				else $("#popupLink").html("+ Add a link").addClass("empty");
@@ -998,11 +996,10 @@ function openMosaic() {
           $('.mosaic_label_filter').toArray().forEach(f => {
             f.my_state = undefined;
             $(f).removeClass('mosaic_label_filter_enabled');
-            labels.add(f.innerHTML);
           });
         }
         $('.mosaic_item').toArray().forEach(t => {
-          if (Array.from(labels).map(l => t.dataset.rekallLabels.indexOf(l) != -1).includes(true))
+          if (!labels.size || Array.from(labels).map(l => t.dataset.rekallLabels.indexOf(l) != -1).includes(true))
             $(t).show();
           else
             $(t).hide();
@@ -1098,9 +1095,9 @@ bgColorLeft = getTagGradientColor(tag);
 	else $("#popupSpeed").html("+ Set video speed during this annotation").addClass("empty");
 
 	var labels = tag.getMetadata("Rekall->Labels");
+  $('input.annotation_labels').attr('checked', false);
   if (labels && labels != '') {
     var _labels = labels.split(';');
-    console.log('got labels', _labels);
     $('input.annotation_labels').toArray().forEach(e => {
       e.checked = (_labels.indexOf(e.value) != -1);
     })
-- 
GitLab