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

56 lines
1.6 KiB
HTML
Raw Normal View History

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