forked from AkkomaGang/akkoma-fe
Make scope options optional, refactoring.
This commit is contained in:
parent
ee1b60c9c5
commit
d64293506c
5 changed files with 40 additions and 21 deletions
|
@ -29,4 +29,6 @@ npm run build
|
||||||
npm run unit
|
npm run unit
|
||||||
```
|
```
|
||||||
|
|
||||||
For detailed explanation on how things work, checkout the [guide](http://vuejs-templates.github.io/webpack/) and [docs for vue-loader](http://vuejs.github.io/vue-loader).
|
# Configuration
|
||||||
|
|
||||||
|
Edit config.json for configuration. scopeOptionsEnabled gives you input fields for CWs and the scope settings.
|
||||||
|
|
|
@ -46,20 +46,23 @@ const PostStatusForm = {
|
||||||
error: null,
|
error: null,
|
||||||
posting: false,
|
posting: false,
|
||||||
highlighted: 0,
|
highlighted: 0,
|
||||||
vis: {
|
|
||||||
public: { icon: 'icon-globe', big: true, selected: true },
|
|
||||||
unlisted: { icon: 'icon-lock-open-alt', big: true, selected: false },
|
|
||||||
private: { icon: 'icon-lock', big: true, selected: false },
|
|
||||||
direct: { icon: 'icon-mail-alt', big: true, selected: false }
|
|
||||||
},
|
|
||||||
newStatus: {
|
newStatus: {
|
||||||
status: statusText,
|
status: statusText,
|
||||||
files: []
|
files: [],
|
||||||
|
visibility: 'public'
|
||||||
},
|
},
|
||||||
caret: 0
|
caret: 0
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
|
vis () {
|
||||||
|
return {
|
||||||
|
public: { selected: this.newStatus.visibility === 'public' },
|
||||||
|
unlisted: { selected: this.newStatus.visibility === 'unlisted' },
|
||||||
|
private: { selected: this.newStatus.visibility === 'private' },
|
||||||
|
direct: { selected: this.newStatus.visibility === 'direct' }
|
||||||
|
}
|
||||||
|
},
|
||||||
candidates () {
|
candidates () {
|
||||||
const firstchar = this.textAtCaret.charAt(0)
|
const firstchar = this.textAtCaret.charAt(0)
|
||||||
if (firstchar === '@') {
|
if (firstchar === '@') {
|
||||||
|
@ -124,6 +127,9 @@ const PostStatusForm = {
|
||||||
},
|
},
|
||||||
isOverLengthLimit () {
|
isOverLengthLimit () {
|
||||||
return this.hasStatusLengthLimit && (this.statusLength > this.statusLengthLimit)
|
return this.hasStatusLengthLimit && (this.statusLength > this.statusLengthLimit)
|
||||||
|
},
|
||||||
|
scopeOptionsEnabled () {
|
||||||
|
return this.$store.state.config.scopeOptionsEnabled
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
@ -200,15 +206,13 @@ const PostStatusForm = {
|
||||||
if (!data.error) {
|
if (!data.error) {
|
||||||
this.newStatus = {
|
this.newStatus = {
|
||||||
status: '',
|
status: '',
|
||||||
files: []
|
files: [],
|
||||||
|
visibility: newStatus.visibility
|
||||||
}
|
}
|
||||||
this.$emit('posted')
|
this.$emit('posted')
|
||||||
let el = this.$el.querySelector('textarea')
|
let el = this.$el.querySelector('textarea')
|
||||||
el.style.height = '16px'
|
el.style.height = '16px'
|
||||||
this.error = null
|
this.error = null
|
||||||
|
|
||||||
for (key in Object.keys(this.vis)) { this.vis[key].selected = false }
|
|
||||||
this.vis.public.selected = true
|
|
||||||
} else {
|
} else {
|
||||||
this.error = data.error
|
this.error = data.error
|
||||||
}
|
}
|
||||||
|
@ -250,6 +254,7 @@ const PostStatusForm = {
|
||||||
e.dataTransfer.dropEffect = 'copy'
|
e.dataTransfer.dropEffect = 'copy'
|
||||||
},
|
},
|
||||||
resize (e) {
|
resize (e) {
|
||||||
|
if (!e.target) { return }
|
||||||
const vertPadding = Number(window.getComputedStyle(e.target)['padding-top'].substr(0, 1)) +
|
const vertPadding = Number(window.getComputedStyle(e.target)['padding-top'].substr(0, 1)) +
|
||||||
Number(window.getComputedStyle(e.target)['padding-bottom'].substr(0, 1))
|
Number(window.getComputedStyle(e.target)['padding-bottom'].substr(0, 1))
|
||||||
e.target.style.height = 'auto'
|
e.target.style.height = 'auto'
|
||||||
|
@ -262,8 +267,6 @@ const PostStatusForm = {
|
||||||
this.error = null
|
this.error = null
|
||||||
},
|
},
|
||||||
changeVis (visibility) {
|
changeVis (visibility) {
|
||||||
console.log(visibility)
|
|
||||||
Object.keys(this.vis).forEach(function (x) { this.vis[x].selected = x === visibility })
|
|
||||||
this.newStatus.visibility = visibility
|
this.newStatus.visibility = visibility
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
<form @submit.prevent="postStatus(newStatus)">
|
<form @submit.prevent="postStatus(newStatus)">
|
||||||
<div class="form-group" >
|
<div class="form-group" >
|
||||||
<input
|
<input
|
||||||
|
v-if="scopeOptionsEnabled"
|
||||||
type="text"
|
type="text"
|
||||||
:placeholder="$t('post_status.content_warning')"
|
:placeholder="$t('post_status.content_warning')"
|
||||||
v-model="newStatus.spoilerText"
|
v-model="newStatus.spoilerText"
|
||||||
|
@ -23,11 +24,11 @@
|
||||||
@input="resize"
|
@input="resize"
|
||||||
@paste="paste">
|
@paste="paste">
|
||||||
</textarea>
|
</textarea>
|
||||||
<div class="visibility-tray">
|
<div v-if="scopeOptionsEnabled" class="visibility-tray">
|
||||||
<i v-on:click="changeVis('direct')" v-bind:class="vis.direct"></i>
|
<i v-on:click="changeVis('direct')" class="icon-mail-alt" :class="vis.direct"></i>
|
||||||
<i v-on:click="changeVis('private')" v-bind:class="vis.private"></i>
|
<i v-on:click="changeVis('private')" class="icon-lock" :class="vis.private"></i>
|
||||||
<i v-on:click="changeVis('unlisted')" v-bind:class="vis.unlisted"></i>
|
<i v-on:click="changeVis('unlisted')" class="icon-lock-open-alt" :class="vis.unlisted"></i>
|
||||||
<i v-on:click="changeVis('public')" v-bind:class="vis.public"></i>
|
<i v-on:click="changeVis('public')" class="icon-globe" :class="vis.public"></i>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div style="position:relative;" v-if="candidates">
|
<div style="position:relative;" v-if="candidates">
|
||||||
|
@ -90,6 +91,17 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.post-status-form .visibility-tray {
|
||||||
|
font-size: 1.2em;
|
||||||
|
padding: 3px;
|
||||||
|
cursor: pointer;
|
||||||
|
|
||||||
|
.selected {
|
||||||
|
color: $fallback--lightFg;
|
||||||
|
color: var(--lightFg, $fallback--lightFg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
.post-status-form, .login {
|
.post-status-form, .login {
|
||||||
.form-bottom {
|
.form-bottom {
|
||||||
display: flex;
|
display: flex;
|
||||||
|
|
|
@ -88,7 +88,7 @@ window.fetch('/api/statusnet/config.json')
|
||||||
window.fetch('/static/config.json')
|
window.fetch('/static/config.json')
|
||||||
.then((res) => res.json())
|
.then((res) => res.json())
|
||||||
.then((data) => {
|
.then((data) => {
|
||||||
const {theme, background, logo, showWhoToFollowPanel, whoToFollowProvider, whoToFollowLink, showInstanceSpecificPanel} = data
|
const {theme, background, logo, showWhoToFollowPanel, whoToFollowProvider, whoToFollowLink, showInstanceSpecificPanel, scopeOptionsEnabled} = data
|
||||||
store.dispatch('setOption', { name: 'theme', value: theme })
|
store.dispatch('setOption', { name: 'theme', value: theme })
|
||||||
store.dispatch('setOption', { name: 'background', value: background })
|
store.dispatch('setOption', { name: 'background', value: background })
|
||||||
store.dispatch('setOption', { name: 'logo', value: logo })
|
store.dispatch('setOption', { name: 'logo', value: logo })
|
||||||
|
@ -96,6 +96,7 @@ window.fetch('/static/config.json')
|
||||||
store.dispatch('setOption', { name: 'whoToFollowProvider', value: whoToFollowProvider })
|
store.dispatch('setOption', { name: 'whoToFollowProvider', value: whoToFollowProvider })
|
||||||
store.dispatch('setOption', { name: 'whoToFollowLink', value: whoToFollowLink })
|
store.dispatch('setOption', { name: 'whoToFollowLink', value: whoToFollowLink })
|
||||||
store.dispatch('setOption', { name: 'showInstanceSpecificPanel', value: showInstanceSpecificPanel })
|
store.dispatch('setOption', { name: 'showInstanceSpecificPanel', value: showInstanceSpecificPanel })
|
||||||
|
store.dispatch('setOption', { name: 'scopeOptionsEnabled', value: scopeOptionsEnabled })
|
||||||
if (data['chatDisabled']) {
|
if (data['chatDisabled']) {
|
||||||
store.dispatch('disableChat')
|
store.dispatch('disableChat')
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,5 +10,6 @@
|
||||||
"whoToFollowProviderDummy2": "https://followlink.osa-p.net/api/get_recommend.json?acct=@{{user}}@{{host}}",
|
"whoToFollowProviderDummy2": "https://followlink.osa-p.net/api/get_recommend.json?acct=@{{user}}@{{host}}",
|
||||||
"whoToFollowLink": "https://vinayaka.distsn.org/?{{host}}+{{user}}",
|
"whoToFollowLink": "https://vinayaka.distsn.org/?{{host}}+{{user}}",
|
||||||
"whoToFollowLinkDummy2": "https://followlink.osa-p.net/recommend.html",
|
"whoToFollowLinkDummy2": "https://followlink.osa-p.net/recommend.html",
|
||||||
"showInstanceSpecificPanel": false
|
"showInstanceSpecificPanel": false,
|
||||||
|
"scopeOptionsEnabled": false
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue