Skip to content

Commit

Permalink
Avoid flickering when checking calendar events (#932)
Browse files Browse the repository at this point in the history
  • Loading branch information
Acylation authored Sep 19, 2024
1 parent 46dda2c commit 81816da
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 13 deletions.
2 changes: 2 additions & 0 deletions src/ui/views/Board/components/Board/ColumnHeader.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@
return;
}
event.stopPropagation();
if (closestAnchor.hasClass("internal-link")) {
event.preventDefault();
Expand Down
14 changes: 14 additions & 0 deletions src/ui/views/Calendar/CalendarView.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,17 @@
}
}
function handleRecordCheck(record: DataRecord) {
if (booleanField) {
api.updateRecord(
updateRecordValues(record, {
[booleanField.name]: !record.values[booleanField.name],
}),
fields
);
}
}
function handleRecordClick(entry: DataRecord) {
if (entry) {
new EditNoteModal(
Expand Down Expand Up @@ -261,6 +272,9 @@
onRecordChange={(record) => {
handleRecordChange(date, record);
}}
onRecordCheck={(record) => {
handleRecordCheck(record);
}}
onRecordAdd={() => {
handleRecordAdd(date);
}}
Expand Down
13 changes: 12 additions & 1 deletion src/ui/views/Calendar/components/Calendar/Day.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@
*/
export let onRecordClick: (record: DataRecord) => void;
/**
* onRecordCheck runs when the user Checks / Unchecks a calendar event.
*/
export let onRecordCheck: (record: DataRecord) => void;
/**
* onRecordChange runs when the user changes the checked state.
*/
Expand Down Expand Up @@ -69,7 +74,13 @@
style:width={width + "%"}
>
<Date {today}>{date.date()}</Date>
<EventList {checkField} {records} {onRecordClick} {onRecordChange} />
<EventList
{checkField}
{records}
{onRecordClick}
{onRecordCheck}
{onRecordChange}
/>
</div>

<style>
Expand Down
15 changes: 3 additions & 12 deletions src/ui/views/Calendar/components/Calendar/EventList.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@
DataValue,
Optional,
} from "src/lib/dataframe/dataframe";
import { updateRecordValues } from "src/lib/datasources/helpers";
import { getRecordColorContext, handleHoverLink } from "src/ui/views/helpers";
import { settings } from "src/lib/stores/settings";
export let records: DataRecord[];
export let checkField: string | undefined;
export let onRecordClick: (record: DataRecord) => void;
export let onRecordCheck: (record: DataRecord) => void;
export let onRecordChange: (record: DataRecord) => void;
function asOptionalBoolean(value: Optional<DataValue>): Optional<boolean> {
Expand Down Expand Up @@ -62,17 +62,8 @@
checked={checkField !== undefined
? asOptionalBoolean(record.values[checkField])
: undefined}
on:check={({ detail: checked }) => {
if (checkField) {
onRecordChange(
updateRecordValues(record, {
[checkField]: checked,
})
);
}
}}
on:click={() => {
onRecordClick(record);
on:check={() => {
onRecordCheck(record);
}}
>
<InternalLink
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
return;
}
event.stopPropagation();
if (closestAnchor.hasClass("internal-link")) {
event.preventDefault();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
return;
}
event.stopPropagation();
if (closestAnchor.hasClass("internal-link")) {
event.preventDefault();
Expand Down

0 comments on commit 81816da

Please sign in to comment.