aboutsummaryrefslogtreecommitdiff
path: root/src/components/scope_selector/scope_selector.js
diff options
context:
space:
mode:
authordave <starpumadev@gmail.com>2019-04-02 10:07:36 -0400
committerdave <starpumadev@gmail.com>2019-04-02 10:07:36 -0400
commit8b3f037f877e1bd8a77f925e4d9d06b45addee8b (patch)
tree3cb4e2df8b21c8673971a2f69e4e6588305c2ae7 /src/components/scope_selector/scope_selector.js
parent6482201dc9e54d458bec48794260ffa1749c512b (diff)
parentac28e8c2f981b6584f0103e10b0a5f5b025fcaae (diff)
Merge branch 'develop' of https://git.pleroma.social/pleroma/pleroma-fe into issue-436-mastoapi-notifications
Diffstat (limited to 'src/components/scope_selector/scope_selector.js')
-rw-r--r--src/components/scope_selector/scope_selector.js54
1 files changed, 54 insertions, 0 deletions
diff --git a/src/components/scope_selector/scope_selector.js b/src/components/scope_selector/scope_selector.js
new file mode 100644
index 00000000..8a42ee7b
--- /dev/null
+++ b/src/components/scope_selector/scope_selector.js
@@ -0,0 +1,54 @@
+const ScopeSelector = {
+ props: [
+ 'showAll',
+ 'userDefault',
+ 'originalScope',
+ 'initialScope',
+ 'onScopeChange'
+ ],
+ data () {
+ return {
+ currentScope: this.initialScope
+ }
+ },
+ computed: {
+ showNothing () {
+ return !this.showPublic && !this.showUnlisted && !this.showPrivate && !this.showDirect
+ },
+ showPublic () {
+ return this.originalScope !== 'direct' && this.shouldShow('public')
+ },
+ showUnlisted () {
+ return this.originalScope !== 'direct' && this.shouldShow('unlisted')
+ },
+ showPrivate () {
+ return this.originalScope !== 'direct' && this.shouldShow('private')
+ },
+ showDirect () {
+ return this.shouldShow('direct')
+ },
+ css () {
+ return {
+ public: {selected: this.currentScope === 'public'},
+ unlisted: {selected: this.currentScope === 'unlisted'},
+ private: {selected: this.currentScope === 'private'},
+ direct: {selected: this.currentScope === 'direct'}
+ }
+ }
+ },
+ methods: {
+ shouldShow (scope) {
+ return this.showAll ||
+ this.currentScope === scope ||
+ this.originalScope === scope ||
+ this.userDefault === scope ||
+ scope === 'direct'
+ },
+ changeVis (scope) {
+ this.currentScope = scope
+ this.onScopeChange && this.onScopeChange(scope)
+ }
+ }
+}
+
+export default ScopeSelector