-
Notifications
You must be signed in to change notification settings - Fork 25
Mail: Mail compose as Widget #1609 #1687
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
fa672d7
Added header slot to OcModal
tammi-23 7b5a4bf
wip: rebase and adjustment after rebase
tammi-23 87e7873
wip: revert merged style
tammi-23 c7c5254
fixed test [CI SKIP]
tammi-23 1f4bcf6
wip: adjusted css [CI SKIP]
tammi-23 0c1fe2f
wip: deleted border in mobile view
tammi-23 d299edd
deleted not needed MailCompose
tammi-23 78e2607
wip: changed requested changes
tammi-23 afc9042
update snapshot
tammi-23 0a42145
wip deleted unnecessary code
tammi-23 0b99951
wip: code sorting
tammi-23 1de83fc
wip: mail compose is now scrollable and changed naming in ocmodal
tammi-23 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
140 changes: 140 additions & 0 deletions
140
packages/web-app-mail/src/components/MailComposeForm.vue
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,140 @@ | ||
| <template> | ||
| <div class="px-4"> | ||
| <div class="py-2 mb-2 border-b border-role-outline-variant"> | ||
| <oc-select | ||
| :model-value="modelValue.from" | ||
| :label="`${$gettext('From')}:`" | ||
| :inline-label="true" | ||
| :has-border="false" | ||
| :options="fromOptions" | ||
| option-label="label" | ||
| option-value="value" | ||
| class="w-full" | ||
| @update:model-value="(value: FromOption) => updateField('from', value)" | ||
| /> | ||
| </div> | ||
|
|
||
| <oc-text-input | ||
| :model-value="modelValue.to" | ||
| type="email" | ||
| class="mail-new-message-to-input mb-2 pb-2 border-b border-role-outline-variant" | ||
| :label="`${$gettext('To')}:`" | ||
| :inline-label="true" | ||
| :has-border="false" | ||
| @update:model-value="(value: string) => updateField('to', value)" | ||
| /> | ||
|
|
||
| <oc-text-input | ||
| :model-value="modelValue.cc" | ||
| type="email" | ||
| class="mail-new-message-cc-input mb-2 pb-2 border-b border-role-outline-variant" | ||
| :label="`${$gettext('CC')}:`" | ||
| :inline-label="true" | ||
| :has-border="false" | ||
| @update:model-value="(value: string) => updateField('cc', value)" | ||
| /> | ||
|
|
||
| <oc-text-input | ||
| :model-value="modelValue.bcc" | ||
| type="email" | ||
| class="mail-new-message-bcc-input mb-2 pb-2 border-b border-role-outline-variant" | ||
| :label="`${$gettext('BCC')}:`" | ||
| :inline-label="true" | ||
| :has-border="false" | ||
| @update:model-value="(value: string) => updateField('bcc', value)" | ||
| /> | ||
|
|
||
| <oc-text-input | ||
| :model-value="modelValue.subject" | ||
| class="mail-new-message-to-input pb-2 border-b border-role-outline-variant" | ||
| :label="`${$gettext('Subject')}:`" | ||
| :inline-label="true" | ||
| :has-border="false" | ||
| @update:model-value="(value: string) => updateField('subject', value)" | ||
| /> | ||
|
|
||
| <div class="py-4"> | ||
| <oc-textarea | ||
| :model-value="modelValue.body" | ||
| :label="$gettext('Write email')" | ||
| @update:model-value="(value: string) => updateField('body', value)" | ||
| /> | ||
| </div> | ||
| </div> | ||
| </template> | ||
|
|
||
| <script setup lang="ts"> | ||
| import { computed, unref, watch } from 'vue' | ||
| import { useGettext } from 'vue3-gettext' | ||
| import { useRouteQuery } from '@opencloud-eu/web-pkg' | ||
| import { storeToRefs } from 'pinia' | ||
| import { useAccountsStore } from '../composables/piniaStores/accounts' | ||
|
|
||
| type FromOption = { | ||
| value: string | ||
| label: string | ||
| email: string | ||
| accountId: string | ||
| identityId: string | ||
| } | ||
|
|
||
| export type ComposeFormState = { | ||
| from?: FromOption | ||
| to: string | ||
| cc: string | ||
| bcc: string | ||
| subject: string | ||
| body: string | ||
| } | ||
|
|
||
| const props = defineProps<{ | ||
| modelValue: ComposeFormState | ||
| }>() | ||
|
|
||
| const emit = defineEmits<{ | ||
| (e: 'update:modelValue', value: ComposeFormState): void | ||
| }>() | ||
|
|
||
| const { $gettext } = useGettext() | ||
|
|
||
| const accountsStore = useAccountsStore() | ||
| const { accounts } = storeToRefs(accountsStore) | ||
|
|
||
| const selectedAccountIdQuery = useRouteQuery('accountId') | ||
|
|
||
| const fromOptions = computed<FromOption[]>(() => { | ||
| return ( | ||
| unref(accounts)?.flatMap((account) => | ||
| account.identities?.map((identity) => ({ | ||
| label: identity.name ? `${identity.name} <${identity.email}>` : identity.email, | ||
| value: identity.id, | ||
| email: identity.email, | ||
| accountId: account.accountId, | ||
| identityId: identity.id | ||
| })) | ||
| ) ?? [] | ||
| ) | ||
| }) | ||
|
|
||
| const updateField = <K extends keyof ComposeFormState>(key: K, value: ComposeFormState[K]) => { | ||
| emit('update:modelValue', { ...props.modelValue, [key]: value }) | ||
| } | ||
|
|
||
| watch( | ||
| fromOptions, | ||
| (options) => { | ||
| if (!options.length) { | ||
| return | ||
| } | ||
| const selectedAccountId = unref(selectedAccountIdQuery) | ||
| const defaultFrom = selectedAccountId | ||
| ? (options.find((o) => o.accountId === selectedAccountId) ?? options[0]) | ||
| : options[0] | ||
|
|
||
| if (!props.modelValue.from && defaultFrom) { | ||
| updateField('from', defaultFrom) | ||
| } | ||
| }, | ||
| { immediate: true } | ||
| ) | ||
| </script> | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.