pinafore/routes/_components/dialog/components/PostPrivacyDialog.html

56 lines
1.6 KiB
HTML
Raw Normal View History

2018-04-05 05:33:17 +02:00
<ModalDialog
{id}
{label}
{title}
2018-04-05 05:33:17 +02:00
background="var(--main-bg)"
>
<GenericDialogList selectable={true} {items} on:click="onClick(event)" />
2018-03-03 22:23:26 +01:00
</ModalDialog>
<script>
import ModalDialog from './ModalDialog.html'
import { store } from '../../../_store/store'
import { POST_PRIVACY_OPTIONS } from '../../../_static/statuses'
import { setPostPrivacy } from '../../../_actions/postPrivacy'
2018-03-12 03:40:32 +01:00
import GenericDialogList from './GenericDialogList.html'
import { show } from '../helpers/showDialog'
import { close } from '../helpers/closeDialog'
import { oncreate } from '../helpers/onCreateDialog'
2018-03-03 22:23:26 +01:00
export default {
oncreate,
2018-03-03 22:23:26 +01:00
components: {
2018-03-12 03:40:32 +01:00
ModalDialog,
GenericDialogList
2018-03-03 22:23:26 +01:00
},
store: () => store,
data: () => ({
postPrivacyOptions: POST_PRIVACY_OPTIONS
}),
methods: {
show,
close,
2018-04-20 06:38:01 +02:00
onClick (item) {
let { realm } = this.get()
setPostPrivacy(realm, item.key)
this.close()
2018-03-03 22:23:26 +01:00
}
},
computed: {
composeData: ({ $currentComposeData, realm }) => $currentComposeData[realm] || {},
postPrivacy: ({ postPrivacyKey }) => {
2018-03-03 22:23:26 +01:00
return POST_PRIVACY_OPTIONS.find(_ => _.key === postPrivacyKey)
},
postPrivacyKey: ({ composeData, $currentVerifyCredentials }) => {
2018-03-03 23:15:50 +01:00
return composeData.postPrivacy || $currentVerifyCredentials.source.privacy
2018-03-12 03:40:32 +01:00
},
items: ({ postPrivacy, postPrivacyOptions }) => {
2018-03-12 03:40:32 +01:00
return postPrivacyOptions.map(option => ({
key: option.key,
label: option.label,
icon: option.icon,
selected: postPrivacy.key === option.key
}))
2018-03-03 22:23:26 +01:00
}
}
}
</script>