2018-08-26 14:39:02 +00:00
|
|
|
<template>
|
|
|
|
<div>
|
|
|
|
<div ref="comment-input"></div>
|
|
|
|
<div class="level">
|
|
|
|
<div class="level-left">
|
|
|
|
<span class="text-muted">{{ __('Ctrl + Enter to submit') }}</span>
|
|
|
|
</div>
|
|
|
|
<div class="level-right">
|
|
|
|
<button class="btn btn-primary btn-xs" @click="submit_input">{{ __('Submit') }}</button>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
<script>
|
|
|
|
export default {
|
|
|
|
mounted() {
|
|
|
|
this.make_input();
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
make_input() {
|
2018-09-30 15:38:46 +00:00
|
|
|
this.message_input = frappe.ui.form.make_control({
|
2018-08-26 14:39:02 +00:00
|
|
|
parent: this.$refs['comment-input'],
|
|
|
|
on_submit: (message) => {
|
|
|
|
this.message_input.reset();
|
|
|
|
this.$emit('change', message);
|
|
|
|
},
|
2018-09-30 15:38:46 +00:00
|
|
|
only_input: true,
|
2018-08-26 14:39:02 +00:00
|
|
|
no_wrapper: true
|
|
|
|
});
|
|
|
|
},
|
|
|
|
submit_input() {
|
|
|
|
if (!this.message_input) return;
|
2018-09-30 15:38:46 +00:00
|
|
|
const value = this.message_input.get_value();
|
2018-08-26 14:39:02 +00:00
|
|
|
if (!value) return;
|
|
|
|
this.message_input.submit();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|