Skip to content

A fully open source & end-to-end encrypted note taking alternative to Evernote.

web: add support for sorting reminders

Abdullah Atta696116ac8512
diff --git a/apps/web/src/components/group-header/index.tsx b/apps/web/src/components/group-header/index.tsx
index a41c309d7..a623b88a5 100644
--- a/apps/web/src/components/group-header/index.tsx
+++ b/apps/web/src/components/group-header/index.tsx
@@ -56,22 +56,27 @@ type GroupingMenuOptions = {
isUngrouped: boolean;
};
-const groupByMenu: (options: GroupingMenuOptions) => MenuItem = (options) => ({
- type: "button",
- key: "groupBy",
- title: "Group by",
- icon: GroupBy.path,
- menu: {
- items: map(options, [
- { key: "none", title: "None" },
- { key: "default", title: "Default" },
- { key: "year", title: "Year" },
- { key: "month", title: "Month" },
- { key: "week", title: "Week" },
- { key: "abc", title: "A - Z" }
- ])
- }
-});
+const groupByMenu: (options: GroupingMenuOptions) => MenuItem | null = (
+ options
+) =>
+ options.groupingKey === "reminders"
+ ? null
+ : {
+ type: "button",
+ key: "groupBy",
+ title: "Group by",
+ icon: GroupBy.path,
+ menu: {
+ items: map(options, [
+ { key: "none", title: "None" },
+ { key: "default", title: "Default" },
+ { key: "year", title: "Year" },
+ { key: "month", title: "Month" },
+ { key: "week", title: "Week" },
+ { key: "abc", title: "A - Z" }
+ ])
+ }
+ };
const orderByMenu: (options: GroupingMenuOptions) => MenuItem = (options) => ({
type: "button",
@@ -90,12 +95,20 @@ const orderByMenu: (options: GroupingMenuOptions) => MenuItem = (options) => ({
{
key: "asc",
title:
- options.groupOptions.sortBy === "title" ? "A - Z" : "Oldest - newest"
+ options.groupOptions.sortBy === "title"
+ ? "A - Z"
+ : options.groupOptions.sortBy === "dueDate"
+ ? "Earliest first"
+ : "Oldest - newest"
},
{
key: "desc",
title:
- options.groupOptions.sortBy === "title" ? "Z - A" : "Newest - oldest"
+ options.groupOptions.sortBy === "title"
+ ? "Z - A"
+ : options.groupOptions.sortBy === "dueDate"
+ ? "Latest first"
+ : "Newest - oldest"
}
])
}
@@ -130,6 +143,11 @@ const sortByMenu: (options: GroupingMenuOptions) => MenuItem = (options) => ({
title: "Date modified",
isHidden: options.groupingKey !== "tags"
},
+ {
+ key: "dueDate",
+ title: "Due date",
+ isHidden: options.groupingKey !== "reminders"
+ },
{
key: "title",
title: "Title",
@@ -314,7 +332,7 @@ function GroupHeader(props: GroupHeaderProps) {
{index === 0 && (
<Flex mr={1}>
- {groupingKey && groupingKey !== "reminders" && (
+ {groupingKey && (
<IconButton
testId={`${groupingKey}-sort-button`}
icon={groupOptions.sortDirection === "asc" ? SortAsc : SortDesc}
@@ -331,26 +349,26 @@ function GroupHeader(props: GroupHeaderProps) {
isUngrouped: false,
refresh
};
+ const groupBy = groupByMenu({
+ ...menuOptions,
+ parentKey: "groupBy"
+ });
+
+ const menuItems = [
+ orderByMenu({
+ ...menuOptions,
+ parentKey: "sortDirection"
+ }),
+ sortByMenu({
+ ...menuOptions,
+ parentKey: "sortBy"
+ })
+ ];
+ if (groupBy) menuItems.push(groupBy);
- openMenu(
- [
- orderByMenu({
- ...menuOptions,
- parentKey: "sortDirection"
- }),
- sortByMenu({
- ...menuOptions,
- parentKey: "sortBy"
- }),
- groupByMenu({
- ...menuOptions,
- parentKey: "groupBy"
- })
- ],
- {
- title: "Group & sort"
- }
- );
+ openMenu(menuItems, {
+ title: groupBy ? "Group & sort" : "Sort"
+ });
}}
/>
)}
diff --git a/apps/web/src/components/icon-tag/index.tsx b/apps/web/src/components/icon-tag/index.tsx
index 458faed2a..34e5e5107 100644
--- a/apps/web/src/components/icon-tag/index.tsx
+++ b/apps/web/src/components/icon-tag/index.tsx
@@ -84,7 +84,7 @@ function IconTag(props: IconTagProps) {
>
<Icon
size={11}
- // color={styles?.icon?.color || (highlight ? "primary" : "icon")}
+ color={highlight ? "accent" : "icon"}
sx={{ ...styles?.icon, flexShrink: 0 }}
/>
<Text
diff --git a/apps/web/src/components/reminder/index.tsx b/apps/web/src/components/reminder/index.tsx
index 975479fe5..f49948b6a 100644
--- a/apps/web/src/components/reminder/index.tsx
+++ b/apps/web/src/components/reminder/index.tsx
@@ -85,6 +85,7 @@ function Reminder(props: ReminderProps) {
gap: 1
}}
>
+ {reminder.disabled ? null : <PriorityIcon size={14} />}
{reminder.disabled ? (
<IconTag icon={ReminderOff} text={"Disabled"} testId={"disabled"} />
) : (
@@ -95,7 +96,6 @@ function Reminder(props: ReminderProps) {
testId={"reminder-time"}
/>
)}
- {reminder.disabled ? null : <PriorityIcon size={14} />}
{reminder.mode === "repeat" && reminder.recurringMode && (
<IconTag
icon={Refresh}
diff --git a/apps/web/src/stores/reminder-store.js b/apps/web/src/stores/reminder-store.js
index 1306c2261..04b824085 100644
--- a/apps/web/src/stores/reminder-store.js
+++ b/apps/web/src/stores/reminder-store.js
@@ -37,7 +37,13 @@ class ReminderStore extends BaseStore {
refresh = (reset = true) => {
const reminders = db.reminders.all;
- this.set((state) => (state.reminders = groupReminders(reminders)));
+ this.set(
+ (state) =>
+ (state.reminders = groupReminders(
+ reminders,
+ db.settings.getGroupOptions("reminders")
+ ))
+ );
if (reset) {
resetReminders(reminders);
notestore.refresh();