diff options
Diffstat (limited to 'apps/files_reminders/src')
6 files changed, 51 insertions, 27 deletions
diff --git a/apps/files_reminders/src/actions/setReminderCustomAction.ts b/apps/files_reminders/src/actions/setReminderCustomAction.ts index 0c932fa4799..ea21293ee52 100644 --- a/apps/files_reminders/src/actions/setReminderCustomAction.ts +++ b/apps/files_reminders/src/actions/setReminderCustomAction.ts @@ -14,12 +14,21 @@ import { pickCustomDate } from '../services/customPicker' export const action = new FileAction({ id: 'set-reminder-custom', - displayName: () => t('files_reminders', 'Set custom reminder'), - title: () => t('files_reminders', 'Set reminder at custom date & time'), + displayName: () => t('files_reminders', 'Custom reminder'), + title: () => t('files_reminders', 'Reminder at custom date & time'), iconSvgInline: () => CalendarClockSvg, - enabled: (_nodes: Node[], view: View) => { - return view.id !== 'trashbin' + enabled: (nodes: Node[], view: View) => { + if (view.id === 'trashbin') { + return false + } + // Only allow on a single node + if (nodes.length !== 1) { + return false + } + const node = nodes.at(0)! + const dueDate = node.attributes['reminder-due-date'] + return dueDate !== undefined }, parent: SET_REMINDER_MENU_ID, diff --git a/apps/files_reminders/src/actions/setReminderMenuAction.ts b/apps/files_reminders/src/actions/setReminderMenuAction.ts index f42277b055a..d6ddcd90677 100644 --- a/apps/files_reminders/src/actions/setReminderMenuAction.ts +++ b/apps/files_reminders/src/actions/setReminderMenuAction.ts @@ -16,8 +16,17 @@ export const action = new FileAction({ displayName: () => t('files_reminders', 'Set reminder'), iconSvgInline: () => AlarmSvg, - enabled: (_nodes: Node[], view: View) => { - return view.id !== 'trashbin' + enabled: (nodes: Node[], view: View) => { + if (view.id === 'trashbin') { + return false + } + // Only allow on a single node + if (nodes.length !== 1) { + return false + } + const node = nodes.at(0)! + const dueDate = node.attributes['reminder-due-date'] + return dueDate !== undefined }, async exec() { diff --git a/apps/files_reminders/src/actions/setReminderSuggestionActions.scss b/apps/files_reminders/src/actions/setReminderSuggestionActions.scss index 63d875bd56a..1327500c964 100644 --- a/apps/files_reminders/src/actions/setReminderSuggestionActions.scss +++ b/apps/files_reminders/src/actions/setReminderSuggestionActions.scss @@ -10,14 +10,14 @@ &::before { content: ""; - margin: 3px 10px 3px 15px; + margin-block: 3px; + margin-inline: 15px 10px; border-bottom: 1px solid var(--color-border-dark); cursor: default; display: flex; height: 0; position: absolute; - left: 0; - right: 0; + inset-inline: 0; top: -10px; } } diff --git a/apps/files_reminders/src/actions/setReminderSuggestionActions.ts b/apps/files_reminders/src/actions/setReminderSuggestionActions.ts index b5f4425e3cd..f92b2f89108 100644 --- a/apps/files_reminders/src/actions/setReminderSuggestionActions.ts +++ b/apps/files_reminders/src/actions/setReminderSuggestionActions.ts @@ -31,7 +31,7 @@ const laterToday: ReminderOption = { label: t('files_reminders', 'Later today'), ariaLabel: t('files_reminders', 'Set reminder for later today'), dateString: '', - verboseDateString: '' + verboseDateString: '', } const tomorrow: ReminderOption = { @@ -39,7 +39,7 @@ const tomorrow: ReminderOption = { label: t('files_reminders', 'Tomorrow'), ariaLabel: t('files_reminders', 'Set reminder for tomorrow'), dateString: '', - verboseDateString: '' + verboseDateString: '', } const thisWeekend: ReminderOption = { @@ -47,7 +47,7 @@ const thisWeekend: ReminderOption = { label: t('files_reminders', 'This weekend'), ariaLabel: t('files_reminders', 'Set reminder for this weekend'), dateString: '', - verboseDateString: '' + verboseDateString: '', } const nextWeek: ReminderOption = { @@ -55,7 +55,7 @@ const nextWeek: ReminderOption = { label: t('files_reminders', 'Next week'), ariaLabel: t('files_reminders', 'Set reminder for next week'), dateString: '', - verboseDateString: '' + verboseDateString: '', } /** @@ -74,11 +74,17 @@ const generateFileAction = (option: ReminderOption): FileAction|null => { // Empty svg to hide the icon iconSvgInline: () => '<svg></svg>', - enabled: (_nodes: Node[], view: View) => { + enabled: (nodes: Node[], view: View) => { if (view.id === 'trashbin') { return false } - return Boolean(getDateTime(option.dateTimePreset)) + // Only allow on a single node + if (nodes.length !== 1) { + return false + } + const node = nodes.at(0)! + const dueDate = node.attributes['reminder-due-date'] + return dueDate !== undefined && Boolean(getDateTime(option.dateTimePreset)) }, parent: SET_REMINDER_MENU_ID, diff --git a/apps/files_reminders/src/components/SetCustomReminderModal.vue b/apps/files_reminders/src/components/SetCustomReminderModal.vue index 331dc17dbd5..59c0886a009 100644 --- a/apps/files_reminders/src/components/SetCustomReminderModal.vue +++ b/apps/files_reminders/src/components/SetCustomReminderModal.vue @@ -59,11 +59,11 @@ import { emit } from '@nextcloud/event-bus' import { showError, showSuccess } from '@nextcloud/dialogs' import { translate as t } from '@nextcloud/l10n' -import NcButton from '@nextcloud/vue/dist/Components/NcButton.js' -import NcDateTime from '@nextcloud/vue/dist/Components/NcDateTime.js' -import NcDateTimePickerNative from '@nextcloud/vue/dist/Components/NcDateTimePickerNative.js' -import NcDialog from '@nextcloud/vue/dist/Components/NcDialog.js' -import NcNoteCard from '@nextcloud/vue/dist/Components/NcNoteCard.js' +import NcButton from '@nextcloud/vue/components/NcButton' +import NcDateTime from '@nextcloud/vue/components/NcDateTime' +import NcDateTimePickerNative from '@nextcloud/vue/components/NcDateTimePickerNative' +import NcDialog from '@nextcloud/vue/components/NcDialog' +import NcNoteCard from '@nextcloud/vue/components/NcNoteCard' import { getDateString, getInitialCustomDueDate } from '../shared/utils.ts' import { logger } from '../shared/logger.ts' @@ -93,20 +93,20 @@ export default Vue.extend({ }, computed: { - fileId(): number { - return this.node.fileid + fileId(): number|undefined { + return this.node?.fileid }, - fileName(): string { - return this.node.basename + fileName(): string|undefined { + return this.node?.basename }, name() { - return t('files_reminders', 'Set reminder for "{fileName}"', { fileName: this.fileName }) + return this.fileName ? t('files_reminders', 'Set reminder for "{fileName}"', { fileName: this.fileName }) : '' }, label(): string { - return t('files_reminders', 'Set reminder at custom date & time') + return t('files_reminders', 'Reminder at custom date & time') }, clearAriaLabel(): string { diff --git a/apps/files_reminders/src/shared/types.ts b/apps/files_reminders/src/shared/types.ts index 04c29aae147..f8da6f6aed0 100644 --- a/apps/files_reminders/src/shared/types.ts +++ b/apps/files_reminders/src/shared/types.ts @@ -4,7 +4,7 @@ */ export interface FileAttributes { - [key: string]: any + [key: string]: unknown id: number name: string } |