cursor: pointer;
border: 1px solid transparent;
transition: 0.25s;
+ display: grid;
+ grid-template-columns: auto max-content;
+ column-gap: 1ex;
}
ul#lists > li:hover {
border: 1px solid black;
#new-list-item {
margin-top: 1em;
}
+span.list-edit-trigger {
+ visibility: hidden;
+ opacity: 0;
+ transition: 0.25s;
+ margin-top: auto;
+ margin-bottom: auto;
+}
+ul#lists > li:hover span.list-edit-trigger {
+ visibility: visible;
+ opacity: 1;
+}
+ul#lists > li span.ui-icon-disk,
+ul#lists > li.editing span.ui-icon-pencil {
+ display: none;
+}
+
+ul#lists > li.editing span.ui-icon-disk { display: inline-block; }
+
+.ui-widget-overlay {
+ opacity: 0.3;
+}
+.ui-dialog .ui-dialog-buttonpane .ui-dialog-buttonset {
+ float: none;
+ text-align: right;
+}
+.ui-dialog-buttonset > button.btn-delete {
+ float: left;
+}
+
+.ui-button.btn-delete:hover {
+ background: hsl(0, 70%, 92.9%);
+}
selected_list = new_selected_list;
}
+function edit_list(li) {
+ li.addClass('editing');
+
+ var d = $('<div>')
+ .append(
+ $('<fieldset>')
+ .append(
+ $('<legend>').text('List name'),
+ $('<input type="text" size="40">').val(li.data('lsl-name'))
+ )
+ );
+
+ d.dialog({
+ autoOpen: true,
+ modal: true,
+ title: 'Edit list',
+ close: ()=>{
+ li.removeClass('editing');
+ },
+ width: 'max-content',
+ buttons: [
+ {
+ class: 'btn-delete',
+ icon: 'ui-icon-trash',
+ text: 'Delete',
+ click: () => {
+ delete_list(li, d);
+ },
+ },
+ {
+ text: 'Cancel',
+ click: ()=>{ d.dialog('destroy'); },
+ },
+ {
+ icon: 'ui-icon-disk',
+ text: 'OK',
+ click: () => {
+ save_list(li, d);
+ },
+ },
+ ],
+ });
+}
+function delete_list(li, dlg) {
+ var lists_ver = lists_version;
+ $.ajax( li.data('lsl-uri'),
+ { type: 'DELETE' }
+ )
+ .done((d)=>{
+ lists_version = lists_ver + 1;
+ if (li.hasClass('selected')) {
+ var new_selected = li.next();
+ if (new_selected.length) {
+ select_list(new_selected)
+ }
+ else {
+ new_selected = li.prev();
+ if (new_selected.length) {
+ select_list(new_selected);
+ }
+ else {
+ $('#page').removeClass('have-lists');
+ }
+ }
+ }
+
+ li.remove();
+ dlg.dialog('destroy');
+ got_lists_version(d.lists_version);
+ });
+}
function load_lists() {
$.get(uri_base + '/api/v1/list')
.always(()=>{
.data('lsl-uri', list.uri)
.data('lsl-version', list.version)
.data('lsl-name', list.name)
- .text(list.name);
+ .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);
}
});
return true;
});
- $('ul#lists').on('click', 'li', ev=>{
- select_list($(ev.target));
- });
+ $('ul#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;
+ });
$('#new-list-item button').on('click', handle_new_list_item_submission);
$('#new-list-item input').on('keypress', ev => {
if (13 == ev.keyCode) {