pinafore/routes/_components/dialog/PostPrivacyDialog.html

54 lines
1.5 KiB
HTML
Raw Normal View History

2018-04-05 03:33:17 +00:00
<ModalDialog
:label
:shown
:closed
:title
background="var(--main-bg)"
on:destroyDialog="destroy()"
>
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'
2018-03-03 22:15:50 +00:00
import { setPostPrivacy } from '../../_actions/postPrivacy'
2018-03-12 02:40:32 +00:00
import GenericDialogList from './GenericDialogList.html'
2018-03-03 21:23:26 +00:00
export default {
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: {
async show() {
this.set({shown: true})
},
2018-03-12 02:40:32 +00:00
onClick(item) {
setPostPrivacy(this.get('realm'), item.key)
2018-03-03 21:23:26 +00:00
this.set({closed: true})
}
},
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>