update
This commit is contained in:
@@ -5,7 +5,7 @@ import Pango from 'gi://Pango';
|
||||
import St from 'gi://St';
|
||||
|
||||
import * as D from './dates.js';
|
||||
import {editTodo, todoMenu, todoRow, todoTitle} from './todos.js';
|
||||
import {editTodo, todoClick, todoRow, todoTitle} from './todos.js';
|
||||
import {button, contextMenu, dropdown, openDatePicker, openTimePicker, Popover, scrollBox, textButton} from './widgets.js';
|
||||
|
||||
// Rote Linie für die aktuelle Uhrzeit wandert einmal pro Minute
|
||||
@@ -77,16 +77,15 @@ function assignLanes(items) {
|
||||
|
||||
// Menü an der Mausposition: Termin oder Todo für Tag und optional Uhrzeit anlegen.
|
||||
function createMenu(store, day, time = null) {
|
||||
const [x, y] = global.get_pointer();
|
||||
contextMenu([
|
||||
{label: 'Termin erstellen', onSelect: () => editEvent(store, {date: day, start: time}, {x, y})},
|
||||
{label: 'Todo erstellen', onSelect: () => editTodo(store, {date: day, time}, {x, y})},
|
||||
{label: 'Termin erstellen', onSelect: () => editEvent(store, {date: day, start: time})},
|
||||
{label: 'Todo erstellen', onSelect: () => editTodo(store, {date: day, time})},
|
||||
]);
|
||||
}
|
||||
|
||||
// Popover mit Titel sowie Von und Bis (Datum und Uhrzeit). Enter speichert.
|
||||
export function editEvent(store, event, anchor) {
|
||||
const popover = new Popover(anchor);
|
||||
// Popover am Mauszeiger mit Titel sowie Von und Bis (Datum und Uhrzeit). Enter speichert.
|
||||
export function editEvent(store, event) {
|
||||
const popover = new Popover();
|
||||
popover.addLabel(event.id ? 'Termin bearbeiten' : 'Neuer Termin', 'popover-title');
|
||||
const title = popover.addEntry(event.title ?? '', 'Titel');
|
||||
|
||||
@@ -148,6 +147,14 @@ export function eventMenu(store, event) {
|
||||
contextMenu([{label: 'Löschen', onSelect: () => store.removeEvent(event.id)}]);
|
||||
}
|
||||
|
||||
// Gilt überall, wo ein Termin steht: links bearbeiten, rechts Menü.
|
||||
function eventClick(store, event, mouseButton) {
|
||||
if (mouseButton === 3)
|
||||
eventMenu(store, event);
|
||||
else
|
||||
editEvent(store, event);
|
||||
}
|
||||
|
||||
export const CalendarPanel = GObject.registerClass(
|
||||
class CalendarPanel extends St.BoxLayout {
|
||||
_init(store) {
|
||||
@@ -237,22 +244,12 @@ class CalendarPanel extends St.BoxLayout {
|
||||
_eventEntry(event, styleClass) {
|
||||
const singleDay = endDateOf(event) === event.date;
|
||||
const text = event.start && singleDay ? `${event.start} ${event.title}` : event.title;
|
||||
return textButton(text, (b, mouseButton) => {
|
||||
if (mouseButton === 3)
|
||||
eventMenu(this._store, event);
|
||||
else
|
||||
editEvent(this._store, event, b);
|
||||
}, styleClass);
|
||||
return textButton(text, (_b, mouseButton) => eventClick(this._store, event, mouseButton), styleClass);
|
||||
}
|
||||
|
||||
_todoEntry(todo, styleClass) {
|
||||
const text = `${todo.done ? '☑' : '☐'} ${todo.time ? `${todo.time} ` : ''}${todoTitle(todo)}`;
|
||||
return textButton(text, (b, mouseButton) => {
|
||||
if (mouseButton === 3)
|
||||
todoMenu(this._store, todo);
|
||||
else
|
||||
editTodo(this._store, todo, b);
|
||||
}, `${styleClass} todo`);
|
||||
return textButton(text, (_b, mouseButton) => todoClick(this._store, todo, mouseButton), `${styleClass} todo`);
|
||||
}
|
||||
|
||||
// ---- Monat ----
|
||||
@@ -453,12 +450,7 @@ class CalendarPanel extends St.BoxLayout {
|
||||
clip_to_allocation: true,
|
||||
button_mask: St.ButtonMask.ONE | St.ButtonMask.THREE,
|
||||
});
|
||||
block.connect('clicked', (_b, mouseButton) => {
|
||||
if (mouseButton === 3)
|
||||
eventMenu(this._store, event);
|
||||
else
|
||||
editEvent(this._store, event, block);
|
||||
});
|
||||
block.connect('clicked', (_b, mouseButton) => eventClick(this._store, event, mouseButton));
|
||||
return block;
|
||||
}
|
||||
|
||||
@@ -472,12 +464,7 @@ class CalendarPanel extends St.BoxLayout {
|
||||
can_focus: true,
|
||||
button_mask: St.ButtonMask.ONE | St.ButtonMask.THREE,
|
||||
});
|
||||
block.connect('clicked', (_b, mouseButton) => {
|
||||
if (mouseButton === 3)
|
||||
eventMenu(this._store, event);
|
||||
else
|
||||
editEvent(this._store, event, block);
|
||||
});
|
||||
block.connect('clicked', (_b, mouseButton) => eventClick(this._store, event, mouseButton));
|
||||
return block;
|
||||
}
|
||||
|
||||
@@ -607,13 +594,11 @@ class CalendarPanel extends St.BoxLayout {
|
||||
const preset = {date: this._weekDays[first.day]};
|
||||
if (last.day !== first.day)
|
||||
preset.endDate = this._weekDays[last.day];
|
||||
let anchor = this._alldaySlots[last.day];
|
||||
if (!allDay) {
|
||||
preset.start = `${pad(first.hour)}:00`;
|
||||
preset.end = last.hour === 23 ? '23:59' : `${pad(last.hour + 1)}:00`;
|
||||
anchor = this._slots[last.day][last.hour];
|
||||
}
|
||||
const popover = editEvent(this._store, preset, anchor);
|
||||
const popover = editEvent(this._store, preset);
|
||||
popover.onClose = () => this._clearHighlight();
|
||||
}
|
||||
|
||||
@@ -643,12 +628,7 @@ class CalendarPanel extends St.BoxLayout {
|
||||
x_expand: true,
|
||||
button_mask: St.ButtonMask.ONE | St.ButtonMask.THREE,
|
||||
});
|
||||
b.connect('clicked', (_b, mouseButton) => {
|
||||
if (mouseButton === 3)
|
||||
eventMenu(this._store, event);
|
||||
else
|
||||
editEvent(this._store, event, b);
|
||||
});
|
||||
b.connect('clicked', (_b, mouseButton) => eventClick(this._store, event, mouseButton));
|
||||
list.add_child(b);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user