From 8338d440937ca8d385a358017f60ac88ba9b2c48 Mon Sep 17 00:00:00 2001
From: dcz <dcz@ipipan.waw.pl>
Date: Fri, 13 Oct 2023 08:16:48 +0200
Subject: [PATCH] Notes for all only on the display page.

---
 entries/static/entries/js/unification_entries_list.js | 11 +++++++----
 .../unification/Unification/LexicalUnitEdit.vue       |  9 ++++++---
 .../unification/hierarchy/HierarchyEdit.vue           |  3 ++-
 .../unification/shared/LexicalUnitDisplay.vue         |  4 ++--
 users/templates/notes.html                            |  4 +++-
 5 files changed, 20 insertions(+), 11 deletions(-)

diff --git a/entries/static/entries/js/unification_entries_list.js b/entries/static/entries/js/unification_entries_list.js
index 39de361..3542ef8 100644
--- a/entries/static/entries/js/unification_entries_list.js
+++ b/entries/static/entries/js/unification_entries_list.js
@@ -84,8 +84,11 @@ function setup_lexical_units_table(drilldown, lexical_units, can_see_assignees,
     });
 }
 
-function show_notes_form($container, pk, model, refreshFunction, type, title, body) {
+function show_notes_form($container, pk, model, refreshFunction, type, showForAllCheckbox, title, body) {
     $('.note-form', $container).html($('#note-form-template > div', $container).clone());
+    if(showForAllCheckbox) {
+        $('#for_all_div', $container).hide();
+    }
     $('.hide-note-form', $container).click(function () {
         $('.note-form', $container).html('');
     });
@@ -119,14 +122,14 @@ function show_notes_form($container, pk, model, refreshFunction, type, title, bo
     }
 }
 
-function setup_notes($container, $template, pk, model, refreshFunction, type, title, body) {
+function setup_notes($container, $template, pk, model, refreshFunction, type, showForAllCheckbox, title, body) {
     $container.html($template.children().clone());
     $('.show-note-form', $container).click(function () {
-        show_notes_form($container, pk, model, refreshFunction, type, title, body);
+        show_notes_form($container, pk, model, refreshFunction, type, showForAllCheckbox, title, body);
         return false
     });
     if(title || body) {
-        show_notes_form($container, pk, model, refreshFunction, type, title, body);
+        show_notes_form($container, pk, model, refreshFunction, type, showForAllCheckbox, title, body);
     }
     $.ajax({
         type: 'get',
diff --git a/frontend/src/components/unification/Unification/LexicalUnitEdit.vue b/frontend/src/components/unification/Unification/LexicalUnitEdit.vue
index 4643ecd..a2158a4 100644
--- a/frontend/src/components/unification/Unification/LexicalUnitEdit.vue
+++ b/frontend/src/components/unification/Unification/LexicalUnitEdit.vue
@@ -118,16 +118,19 @@ Object.assign(LexicalUnitEdit, {
       }
     },
     setup_notes_unified_frame() {
-      setup_notes($('#notes-component'), $('#lexical-unit-notes-template'), this.unified_frame.id, 'unifier.UnifiedFrame', this.setup_notes_unified_frame, 'unified_frame');
+      setup_notes($('#notes-component'), $('#lexical-unit-notes-template'), this.unified_frame.id, 'unifier.UnifiedFrame',
+          this.setup_notes_unified_frame, 'unified_frame', true);
     },
     setup_notes_slowal_frame() {
       if (this.active_slowal_frame) {
-        setup_notes($('#notes-component'), $('#lexical-unit-notes-template'), this.active_slowal_frame.id, 'semantics.Frame', this.setup_notes_slowal_frame, 'semantics_frame');
+        setup_notes($('#notes-component'), $('#lexical-unit-notes-template'), this.active_slowal_frame.id,
+            'semantics.Frame', this.setup_notes_slowal_frame, 'semantics_frame', true);
       }
     },
     setup_notes_slowal_frame_with_title_and_body(title, body) {
       this.right_pane_tab = 'notes';
-      setup_notes($('#notes-component'), $('#lexical-unit-notes-template'), this.active_slowal_frame.id, 'semantics.Frame', this.setup_notes_slowal_frame, 'semantics_frame', title, body);
+      setup_notes($('#notes-component'), $('#lexical-unit-notes-template'), this.active_slowal_frame.id,
+          'semantics.Frame', this.setup_notes_slowal_frame, 'semantics_frame', true, title, body);
     },
     unifiedFrameArgumentSelected(argument) {
       if (this.active_unified_frame_argument === argument) {
diff --git a/frontend/src/components/unification/hierarchy/HierarchyEdit.vue b/frontend/src/components/unification/hierarchy/HierarchyEdit.vue
index 07878c4..4b610c1 100644
--- a/frontend/src/components/unification/hierarchy/HierarchyEdit.vue
+++ b/frontend/src/components/unification/hierarchy/HierarchyEdit.vue
@@ -157,7 +157,8 @@ Object.assign(HierarchyEdit, {
       });
     },
     setup_notes_unified_frame() {
-      setup_notes($('#notes-component'), $('#lexical-unit-notes-template'), this.unified_frame.id, 'unifier.UnifiedFrame', this.setup_notes_unified_frame, 'hierarchy_frame');
+      setup_notes($('#notes-component'), $('#lexical-unit-notes-template'), this.unified_frame.id, 'unifier.UnifiedFrame',
+              this.setup_notes_unified_frame, 'hierarchy_frame', true);
     },
     unifiedFrameArgumentSelected(argument) {
       if (this.active_unified_frame_argument === argument) {
diff --git a/frontend/src/components/unification/shared/LexicalUnitDisplay.vue b/frontend/src/components/unification/shared/LexicalUnitDisplay.vue
index 1fcce50..d5c7ef9 100644
--- a/frontend/src/components/unification/shared/LexicalUnitDisplay.vue
+++ b/frontend/src/components/unification/shared/LexicalUnitDisplay.vue
@@ -131,7 +131,7 @@ export default {
       return !has_permission("users.view_assignment");
     },
     setup_notes () {
-      setup_notes($('#lexical-unit-notes'), $('#lexical-unit-notes-template'), this.lexicalUnitId, 'meanings.LexicalUnit', this.setup_notes);
+      setup_notes($('#lexical-unit-notes'), $('#lexical-unit-notes-template'), this.lexicalUnitId, 'meanings.LexicalUnit', this.setup_notes, 'display', true);
     },
     meaningLuSelected(selectedLus) {
       this.selectedLus = selectedLus;
@@ -167,7 +167,7 @@ export default {
           this.examples = response.examples;
 
           window.update_last_visited(response.last_visited);
-          window.setup_notes($('#lexical-unit-notes'), $('#lexical-unit-notes-template'), this.lexicalUnitId, 'meanings.LexicalUnit', this.setup_notes);
+          window.setup_notes($('#lexical-unit-notes'), $('#lexical-unit-notes-template'), this.lexicalUnitId, 'meanings.LexicalUnit', this.setup_notes, 'display', false);
         }.bind(this),
         error: function(request, errorType, errorMessage) {
           show_error(errorType + ' (' + errorMessage + ')');
diff --git a/users/templates/notes.html b/users/templates/notes.html
index d58844e..4aacec3 100644
--- a/users/templates/notes.html
+++ b/users/templates/notes.html
@@ -15,8 +15,10 @@
                     Superleksykograf
                 {% endif %}
                 <input id="super" name="super" type="checkbox" title="{% if is_superlexicograf %} {% trans 'Notatka widoczna dla użytkownika' %} {% else %} {% trans 'Notatka widoczna dla superleksykografa' %} {% endif %}" />
+                <div id="for_all_div">
                     Widoczna dla wszystkich
-                <input id="for_all" name="for_all" type="checkbox" title="Notatka widoczna dla wszystkich" />
+                    <input id="for_all" name="for_all" type="checkbox" title="Notatka widoczna dla wszystkich" />
+                </div>
                 <input id="title" name="title" class="form-control mb-2" placeholder="{% trans 'Tytuł notatki' %}" />
                 <textarea id="note" name="note" class="form-control" placeholder="{% trans 'Treść notatki' %}"></textarea>
                 </div>
-- 
GitLab