]> git.ktnx.net Git - lsl.git/commitdiff
move edi list trigger to list name heading
authorDamyan Ivanov <dmn@debian.org>
Sat, 5 Mar 2022 21:27:40 +0000 (21:27 +0000)
committerDamyan Ivanov <dmn@debian.org>
Sat, 5 Mar 2022 21:27:40 +0000 (21:27 +0000)
no need to be able to edit non-selected lists. that would require that
pencil buttons are present for all lists (because of phones)

public/css/style.css
public/javascripts/lsl.js
views/index.tt

index 7ed63f71e7bbc98469493696ec5fdb44f47554cf..f419d54083745a0b8b90edcfae565531b3090286 100644 (file)
@@ -35,7 +35,7 @@ input {
 }
 
 h1 {
-font-size: 200%;
+font-size: 150%;
 color: #000;
 }
 
@@ -51,7 +51,7 @@ background-color: #ddd;
 display: grid;
 margin: 0 1em 1em 1em;
 }
-@media (min-width: 640pt) {
+@media (min-width: 500pt) {
     #page {
         grid-template-columns: auto minmax(25%,20em);
         grid-column-gap: 1em;
@@ -66,7 +66,6 @@ padding: 1em;
 }
 
 #sidebar {
-    min-width: 15em;
 }
 
 #about, #getting-started {
@@ -74,6 +73,13 @@ padding-left: 75px;
 padding-right: 30px;
 }
 
+#head-list-name {
+    display: grid;
+    grid-template-columns: auto 2em;
+    grid-column-gap: 1ex;
+    min-height: 2em;
+    align-items: center;
+}
 
 #header h1, #header h2 {margin: 0}
 #header { font-weight: bold; }
@@ -178,9 +184,8 @@ font-size: 10px;
     opacity: 1;
     padding: 0 0.5ex;
 }
-.list-edit-trigger:hover {
-    background: hsla(0, 0%, 80%, 1);
-    border-left: 1px solid black;
+#list-edit-trigger:hover {
+    background: hsla(0, 0%, 90%, 1);
 }
 
 #busy-screen {
@@ -231,23 +236,22 @@ ul#lists > li.selected {
 #new-list-item {
     margin-top: 1em;
 }
-span.list-edit-trigger {
-    visibility: hidden;
-    opacity: 0;
+#list-edit-trigger {
     transition: 0.25s;
-    height: 100%;
-    min-width: 2em;
+    height: 2em;
+    width: 2em;
     display: grid;
     align-items: center;
     justify-items: center;
-}
-ul#lists > li:hover span.list-edit-trigger {
-    visibility: visible;
-    opacity: 1;
+    border-radius: 0.75ex;
 }
 
 ul#lists > li.editing span.ui-icon-disk { display: inline-block; }
 
+ul#list-items {
+    padding: 0;
+}
+
 .ui-widget-overlay {
     opacity: 0.3;
 }
index 46eebf710524ffd374e0c4b48f91855c0577b516..7ca9c80847484985eddfb16fb3628232c8d3ea23 100644 (file)
@@ -80,15 +80,14 @@ function select_list(new_selected_list) {
 
     selected_list = new_selected_list;
 }
-function edit_list(li) {
-    li.addClass('editing');
-
+function edit_list() {
     var d = $('<div>')
         .append(
             $('<fieldset>')
                 .append(
                     $('<legend>').text('List name'),
-                    $('<input type="text" size="40">').val(li.data('lsl-name'))
+                    $('<input type="text" size="40">')
+                    .val(selected_list.data('lsl-name'))
                 )
         );
 
@@ -96,9 +95,6 @@ function edit_list(li) {
         autoOpen: true,
         modal: true,
         title: 'Edit list',
-        close: ()=>{
-            li.removeClass('editing');
-        },
         width: 'max-content',
         buttons: [
             {
@@ -106,7 +102,7 @@ function edit_list(li) {
                 icon: 'ui-icon-trash',
                 text: 'Delete',
                 click: () => {
-                    delete_list(li, d);
+                    delete_list(d);
                 },
             },
             {
@@ -117,38 +113,41 @@ function edit_list(li) {
                 icon: 'ui-icon-disk',
                 text: 'OK',
                 click: () => {
-                    save_list(li, d);
+                    save_list(d);
                 },
             },
         ],
     });
 }
-function delete_list(li, dlg) {
-    // TODO: fetch all list items and store all data in a "Deleted"
+function delete_list(dlg) {
+    // TODO: store all data including list items in a "Deleted"
     // pop-up with an "Undo" link that can be used to restore the list
     var lists_ver = lists_version;
-    $.ajax( li.data('lsl-uri'),
+    $.ajax( selected_list.data('lsl-uri'),
         { type: 'DELETE' }
     )
     .done((d)=>{
         lists_version = lists_ver + 1;
-        if (li.hasClass('selected')) {
-            var new_selected = li.next();
+        var deleted_list = selected_list;
+
+        var new_selected = deleted_list.next();
+        if (new_selected.length) {
+            select_list(new_selected)
+        }
+        else {
+            new_selected = deleted_list.prev();
             if (new_selected.length) {
-                select_list(new_selected)
+                select_list(new_selected);
             }
             else {
-                new_selected = li.prev();
-                if (new_selected.length) {
-                    select_list(new_selected);
-                }
-                else {
-                    $('#page').removeClass('have-lists');
-                }
+                $('#page').removeClass('have-lists');
             }
         }
 
-        li.remove();
+        deleted_list.remove();
+        dlg.dialog('destroy');
+        got_lists_version(d.lists_version);
+    });
         dlg.dialog('destroy');
         got_lists_version(d.lists_version);
     });
@@ -199,10 +198,6 @@ function load_lists() {
                     .append(
                         $('<span class="list-name">')
                         .text(list.name)
-                    )
-                    .append(
-                        $('<span class="list-edit-trigger">')
-                        .append('<span class="ui-icon ui-icon-pencil">')
                     );
                 lists.append(list_item);
             }
@@ -320,14 +315,14 @@ $(function(){
 
         return true;
     });
-    $('ul#lists')
+    $('#lists')
         .on('click', 'li', ev=>{
             select_list($(ev.target).closest('li'));
-        })
-        .on('click', 'li > span.list-edit-trigger', ev => {
-            edit_list($(ev.target).closest('li'));
-            return false;
         });
+    $('#list-edit-trigger').on('click', ev => {
+        edit_list();
+        return false;
+    });
     $('#new-list-item button').on('click', handle_new_list_item_submission);
     $('#new-list-item input').on('keypress', ev => {
         if (13 == ev.keyCode) {
index 8e1357568279966fe885f3fdc3283e43cf4951da..069f5f4df84251d3dee7f8ca99a511a96220e712 100644 (file)
@@ -4,7 +4,12 @@
 <div id="page" class="loading-lists" lsl-uri-base="<% request.uri_base %>" lsl-environment="<% settings.environment %>" >
   <div id="content">
     <div id="header">
-      <h1 id="selected-list-name" class="needs-lists"></h1>
+      <div id="head-list-name" class="needs-lists">
+        <span id="selected-list-name"></span>
+        <span id="list-edit-trigger">
+          <span class="ui-icon ui-icon-pencil"></span>
+        </span>
+      </div>
       <div class="have-no-lists">
         <div class="table-2-col">
           <h1>First create a shopping list</h1><div class="arrow">→</div>
@@ -19,7 +24,7 @@
         The list has no items
       </div>
       <div id="new-list-item" class="input-with-button">
-        <input type="text" size="15" maxlength="80" name="new_list_item" />
+        <input type="text" size="10" axlength="80" name="new_list_item" />
         <button id="add-list-item" class="ui-icon-plusthick">Add</button>
       </div>
     </div>