update
This commit is contained in:
@@ -18,9 +18,9 @@ export function todoTitle(todo) {
|
||||
return todo.title.split('\n')[0];
|
||||
}
|
||||
|
||||
// Popover mit Textfeld sowie Auswahl für Datum und Uhrzeit. Enter speichert.
|
||||
export function editTodo(store, todo, anchor) {
|
||||
const popover = new Popover(anchor);
|
||||
// Popover am Mauszeiger mit Textfeld sowie Auswahl für Datum und Uhrzeit. Enter speichert.
|
||||
export function editTodo(store, todo) {
|
||||
const popover = new Popover();
|
||||
popover.addLabel(todo.id ? 'Todo bearbeiten' : 'Neues Todo', 'popover-title');
|
||||
const text = popover.addEntry(todo.title ?? '', 'Was ist zu tun?');
|
||||
|
||||
@@ -63,7 +63,17 @@ export function todoMenu(store, todo) {
|
||||
contextMenu([{label: 'Löschen', onSelect: () => store.removeTodo(todo.id)}]);
|
||||
}
|
||||
|
||||
// Zeile mit Häkchen, Titel und Termin. Klick bearbeitet, Rechtsklick öffnet das Menü.
|
||||
// Gilt überall, wo ein Todo steht: links bearbeiten, Mitte abhaken, rechts Menü.
|
||||
export function todoClick(store, todo, mouseButton) {
|
||||
if (mouseButton === 2)
|
||||
store.toggleTodo(todo.id);
|
||||
else if (mouseButton === 3)
|
||||
todoMenu(store, todo);
|
||||
else
|
||||
editTodo(store, todo);
|
||||
}
|
||||
|
||||
// Zeile mit Häkchen, Titel und Termin. Links bearbeitet, Mitte hakt ab, rechts öffnet das Menü.
|
||||
export function todoRow(store, todo) {
|
||||
const row = new St.BoxLayout({style_class: 'todo-row', x_expand: true});
|
||||
|
||||
@@ -75,12 +85,8 @@ export function todoRow(store, todo) {
|
||||
check.connect('clicked', () => store.toggleTodo(todo.id));
|
||||
row.add_child(check);
|
||||
|
||||
const title = textButton(todoTitle(todo), (b, mouseButton) => {
|
||||
if (mouseButton === 3)
|
||||
todoMenu(store, todo);
|
||||
else
|
||||
editTodo(store, todo, b);
|
||||
}, todo.done ? 'todo-title done' : 'todo-title');
|
||||
const title = textButton(todoTitle(todo), (_b, mouseButton) => todoClick(store, todo, mouseButton),
|
||||
todo.done ? 'todo-title done' : 'todo-title');
|
||||
if (todo.done)
|
||||
title.child.clutter_text.set_markup(`<s>${escapeMarkup(todoTitle(todo))}</s>`);
|
||||
row.add_child(title);
|
||||
@@ -109,8 +115,7 @@ class TodoPanel extends St.BoxLayout {
|
||||
this.connect('button-press-event', (_actor, event) => {
|
||||
if (event.get_button() !== Clutter.BUTTON_SECONDARY)
|
||||
return Clutter.EVENT_PROPAGATE;
|
||||
const [x, y] = global.get_pointer();
|
||||
contextMenu([{label: 'Erstellen', onSelect: () => editTodo(store, {}, {x, y})}]);
|
||||
contextMenu([{label: 'Erstellen', onSelect: () => editTodo(store, {})}]);
|
||||
return Clutter.EVENT_STOP;
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user