Added copy as todo (#9884)

This commit is contained in:
Keith Holliday
2018-02-05 09:43:00 -07:00
committed by GitHub
parent 46877fb20c
commit 2d612b655d
2 changed files with 39 additions and 42 deletions

View File

@@ -18,11 +18,9 @@ div
.svg-icon(v-html="icons.like") .svg-icon(v-html="icons.like")
span(v-if='!msg.likes[user._id]') {{ $t('like') }} span(v-if='!msg.likes[user._id]') {{ $t('like') }}
span(v-if='msg.likes[user._id]') {{ $t('liked') }} span(v-if='msg.likes[user._id]') {{ $t('liked') }}
// @TODO make copyAsTodo work in Tavern, guilds, party (inbox can be done later) span.action(v-if='!inbox', @click='copyAsTodo(msg)')
span.action(v-if='!inbox', @click='copyAsTodo(msg)') .svg-icon(v-html="icons.copy")
.svg-icon(v-html="icons.copy") | {{$t('copyAsTodo')}}
| {{$t('copyAsTodo')}}
// @TODO make copyAsTodo work in the inbox
span.action(v-if='!inbox && user.flags.communityGuidelinesAccepted && msg.uuid !== "system"', @click='report(msg)') span.action(v-if='!inbox && user.flags.communityGuidelinesAccepted && msg.uuid !== "system"', @click='report(msg)')
.svg-icon(v-html="icons.report") .svg-icon(v-html="icons.report")
| {{$t('report')}} | {{$t('report')}}
@@ -140,7 +138,6 @@ export default {
mixins: [styleHelper], mixins: [styleHelper],
data () { data () {
return { return {
copyingMessage: {},
icons: Object.freeze({ icons: Object.freeze({
like: likeIcon, like: likeIcon,
copy: copyIcon, copy: copyIcon,
@@ -241,9 +238,7 @@ export default {
this.$emit('messaged-liked', message); this.$emit('messaged-liked', message);
}, },
copyAsTodo (message) { copyAsTodo (message) {
// @TODO: Move to Habitica Event this.$root.$emit('habitica::copy-as-todo', message);
this.copyingMessage = message;
this.$root.$emit('bv::show::modal', 'copyAsTodo');
}, },
async report () { async report () {
this.$root.$emit('habitica::report-chat', { this.$root.$emit('habitica::report-chat', {

View File

@@ -1,64 +1,66 @@
<template lang="pug"> <template lang="pug">
b-modal#copyAsTodo(:title="$t('copyMessageAsToDo')", :hide-footer="true", size='md') b-modal#copyAsTodo(:title="$t('copyMessageAsToDo')", :hide-footer="true", size='md')
.form-group .form-group
input.form-control(type='text', v-model='text') input.form-control(type='text', v-model='task.text')
.form-group .form-group
textarea.form-control(rows='5', v-model='notes' focus-element='true') textarea.form-control(rows='5', v-model='task.notes' focus-element='true')
hr hr
task(v-if='task._id', :isUser="isUser", :task="task")
// @TODO: Implement when tasks are done
//div.task-column.preview
div(v-init='popoverOpen = false', class='task todo uncompleted color-neutral', popover-trigger='mouseenter', data-popover-html="{{popoverOpen ? '' : notes | markdown}}", popover-placement="top")
.task-meta-controls
span(v-if='!obj._locked')
span.task-notes(v-show='notes', @click='popoverOpen = !popoverOpen', popover-trigger='click', data-popover-html="{{notes | markdown}}", popover-placement="top")
span.glyphicon.glyphicon-comment
| &nbsp;
div.task-text
div(v-markdown='text', target='_blank')
.modal-footer .modal-footer
button.btn.btn-secondary(@click='close()') {{ $t('close') }} button.btn.btn-secondary(@click='close()') {{ $t('close') }}
button.btn.btn-primary(@click='saveTodo()') {{ $t('submit') }} button.btn.btn-primary(@click='saveTodo()') {{ $t('submit') }}
</template> </template>
<script> <script>
import { mapActions } from 'client/libs/store';
import markdownDirective from 'client/directives/markdown'; import markdownDirective from 'client/directives/markdown';
import notificationsMixin from 'client/mixins/notifications';
import Task from 'client/components/tasks/task';
import taskDefaults from 'common/script/libs/taskDefaults';
const baseUrl = 'https://habitica.com';
export default { export default {
directives: { directives: {
markdown: markdownDirective, markdown: markdownDirective,
}, },
components: {
Task,
},
mixins: [notificationsMixin],
props: ['copyingMessage', 'groupName', 'groupId'], props: ['copyingMessage', 'groupName', 'groupId'],
data () { data () {
return { return {
text: '', isUser: true,
notes: '', task: {},
}; };
}, },
watch: { mounted () {
copyingMessage () { this.$root.$on('habitica::copy-as-todo', message => {
this.text = this.copyingMessage.text; const notes = `[${message.user}](${baseUrl}/static/home/#?memberId=${message.uuid}) wrote in [${this.groupName}](${baseUrl}/groups/guild/${this.groupId})`;
let baseUrl = 'https://habitica.com'; const newTask = {
this.notes = `[${this.copyingMessage.user}](${baseUrl}/static/home/#?memberId=${this.copyingMessage.uuid}) wrote in [${this.groupName}](${baseUrl}/groups/guild/${this.groupId})`; text: message.text,
}, type: 'todo',
notes,
};
this.task = taskDefaults(newTask);
this.$root.$emit('bv::show::modal', 'copyAsTodo');
});
},
destroyed () {
this.$root.$off('habitica::copy-as-todo');
}, },
methods: { methods: {
...mapActions({
createTask: 'tasks:create',
}),
close () { close () {
this.$root.$emit('bv::hide::modal', 'copyAsTodo'); this.$root.$emit('bv::hide::modal', 'copyAsTodo');
}, },
saveTodo () { saveTodo () {
// let newTask = { this.createTask(this.task);
// text: this.text, this.text(this.$t('messageAddedAsToDo'));
// type: 'todo',
// notes: this.notes,
// };
// @TODO: Add after tasks: User.addTask({body:newTask});
// @TODO: Notification.text(window.env.t('messageAddedAsToDo'));
this.$root.$emit('bv::hide::modal', 'copyAsTodo'); this.$root.$emit('bv::hide::modal', 'copyAsTodo');
}, },
}, },