[Client] Resolve #2225

This commit is contained in:
syuilo 2018-12-02 15:26:56 +09:00
parent 6f92d601ec
commit bb14895fd8
No known key found for this signature in database
GPG key ID: BDC4C49D06AB9D69
5 changed files with 56 additions and 5 deletions

View file

@ -1628,6 +1628,9 @@ mobile/views/pages/user.vue:
block: "ブロック" block: "ブロック"
unblock: "ブロック解除" unblock: "ブロック解除"
years-old: "{age}歳" years-old: "{age}歳"
push-to-list: "リストに追加"
select-list: "リストを選択してください"
list-pushed: "{user}を{list}に追加しました"
mobile/views/pages/user/home.vue: mobile/views/pages/user/home.vue:
recent-notes: "最近の投稿" recent-notes: "最近の投稿"

View file

@ -2,9 +2,12 @@
<div class="felqjxyj" :class="{ splash }"> <div class="felqjxyj" :class="{ splash }">
<div class="bg" ref="bg" @click="onBgClick"></div> <div class="bg" ref="bg" @click="onBgClick"></div>
<div class="main" ref="main"> <div class="main" ref="main">
<div class="icon" :class="type"><fa :icon="icon"/></div> <div class="icon" v-if="type" :class="type"><fa :icon="icon"/></div>
<header v-if="title" v-html="title"></header> <header v-if="title" v-html="title"></header>
<div class="body" v-if="text" v-html="text"></div> <div class="body" v-if="text" v-html="text"></div>
<ui-select v-if="select" v-model="selectedValue">
<option v-for="item in select.items" :value="item.value">{{ item.text }}</option>
</ui-select>
<ui-horizon-group no-grow class="buttons fit-bottom" v-if="!splash"> <ui-horizon-group no-grow class="buttons fit-bottom" v-if="!splash">
<ui-button @click="ok" primary autofocus>OK</ui-button> <ui-button @click="ok" primary autofocus>OK</ui-button>
<ui-button @click="cancel" v-if="showCancelButton">Cancel</ui-button> <ui-button @click="cancel" v-if="showCancelButton">Cancel</ui-button>
@ -33,6 +36,9 @@ export default Vue.extend({
type: String, type: String,
required: false required: false
}, },
select: {
required: false
},
showCancelButton: { showCancelButton: {
type: Boolean, type: Boolean,
default: false default: false
@ -43,6 +49,12 @@ export default Vue.extend({
} }
}, },
data() {
return {
selectedValue: null
};
},
computed: { computed: {
icon(): any { icon(): any {
switch (this.type) { switch (this.type) {
@ -83,7 +95,8 @@ export default Vue.extend({
methods: { methods: {
ok() { ok() {
this.$emit('ok'); const result = this.select ? this.selectedValue : true;
this.$emit('ok', result);
this.close(); this.close();
}, },
@ -180,8 +193,11 @@ export default Vue.extend({
display block display block
margin 0 auto margin 0 auto
& + header
margin-top 16px
> header > header
margin 16px 0 8px 0 margin 0 0 8px 0
font-weight bold font-weight bold
font-size 20px font-size 20px

View file

@ -109,8 +109,12 @@ export default Vue.extend({
userId: this.user.id userId: this.user.id
}); });
this.$root.alert({ this.$root.alert({
type: 'success',
title: 'Done!', title: 'Done!',
text: this.$t('list-pushed').replace('{user}', this.user.name).replace('{list}', list.title) text: this.$t('list-pushed', {
user: this.user.name,
list: list.title
})
}); });
}); });
} }

View file

@ -460,7 +460,7 @@ export default (callback: (launch: (router: VueRouter) => [Vue, MiOS]) => void,
alert(opts) { alert(opts) {
return new Promise((res) => { return new Promise((res) => {
const vm = this.new(Alert, opts); const vm = this.new(Alert, opts);
vm.$once('ok', () => res(true)); vm.$once('ok', result => res(result));
vm.$once('cancel', () => res(false)); vm.$once('cancel', () => res(false));
}); });
} }

View file

@ -116,6 +116,34 @@ export default Vue.extend({
menu() { menu() {
let menu = [{ let menu = [{
icon: ['far', 'list'],
text: this.$t('push-to-list'),
action: async () => {
const lists = await this.$root.api('users/lists/list');
const listId = await this.$root.alert({
type: null,
title: this.$t('select-list'),
select: {
items: lists.map(list => ({
value: list.id, text: list.title
}))
},
showCancelButton: true
});
if (listId == null) return;
await this.$root.api('users/lists/push', {
listId: listId,
userId: this.user.id
});
this.$root.alert({
type: 'success',
text: this.$t('list-pushed', {
user: this.user.name,
list: lists.find(l => l.id === listId).title
})
});
}
}, null, {
icon: this.user.isMuted ? ['fas', 'eye'] : ['far', 'eye-slash'], icon: this.user.isMuted ? ['fas', 'eye'] : ['far', 'eye-slash'],
text: this.user.isMuted ? this.$t('unmute') : this.$t('mute'), text: this.user.isMuted ? this.$t('unmute') : this.$t('mute'),
action: () => { action: () => {