From d3639b2df4fece251e7cbac6920607ce7dacb302 Mon Sep 17 00:00:00 2001 From: syuilo Date: Tue, 27 Feb 2018 02:10:52 +0900 Subject: [PATCH] #372 --- src/api/models/messaging-message.ts | 2 +- .../views/components/messaging-room.form.vue | 36 ++++-- .../components/messaging-room.message.vue | 107 +++++++++++------- 3 files changed, 91 insertions(+), 54 deletions(-) diff --git a/src/api/models/messaging-message.ts b/src/api/models/messaging-message.ts index 90cf1cd71..fcb356c5c 100644 --- a/src/api/models/messaging-message.ts +++ b/src/api/models/messaging-message.ts @@ -67,7 +67,7 @@ export const pack = ( // Populate user _message.user = await packUser(_message.user_id, me); - if (_message.file) { + if (_message.file_id) { // Populate file _message.file = await packFile(_message.file_id); } diff --git a/src/web/app/common/views/components/messaging-room.form.vue b/src/web/app/common/views/components/messaging-room.form.vue index 9b5f1522f..48ccaa4d2 100644 --- a/src/web/app/common/views/components/messaging-room.form.vue +++ b/src/web/app/common/views/components/messaging-room.form.vue @@ -8,18 +8,18 @@ placeholder="%i18n:common.input-message-here%" v-autocomplete="'text'" > -
{{ file.name }}
- - - - + @@ -39,6 +39,9 @@ export default Vue.extend({ computed: { draftId(): string { return this.user.id; + }, + canSend(): boolean { + return (this.text != null && this.text != '') || this.file != null; } }, watch: { @@ -88,15 +91,24 @@ export default Vue.extend({ }); }, - upload() { - // TODO + onChangeFile() { + this.upload((this.$refs.file as any).files[0]); + }, + + upload(file) { + (this.$refs.uploader as any).upload(file); + }, + + onUploaded(file) { + this.file = file; }, send() { this.sending = true; (this as any).api('messaging/messages/create', { user_id: this.user.id, - text: this.text + text: this.text ? this.text : undefined, + file_id: this.file ? this.file.id : undefined }).then(message => { this.clear(); }).catch(err => { @@ -158,13 +170,18 @@ export default Vue.extend({ box-shadow none background transparent + > .file + padding 8px + color #444 + background #eee + cursor pointer + > .send position absolute bottom 0 right 0 margin 0 padding 10px 14px - line-height 1em font-size 1em color #aaa transition color 0.1s ease @@ -222,7 +239,6 @@ export default Vue.extend({ .attach-from-drive margin 0 padding 10px 14px - line-height 1em font-size 1em font-weight normal text-decoration none diff --git a/src/web/app/common/views/components/messaging-room.message.vue b/src/web/app/common/views/components/messaging-room.message.vue index 9772c7c0d..56854ca2f 100644 --- a/src/web/app/common/views/components/messaging-room.message.vue +++ b/src/web/app/common/views/components/messaging-room.message.vue @@ -3,23 +3,27 @@ -
-
+
+

%i18n:common.tags.mk-messaging-message.is-read%

- -

%i18n:common.tags.mk-messaging-message.deleted%

+
+