2017-09-10 17:25:29 +05:30
|
|
|
<script>
|
2018-05-09 12:01:36 +05:30
|
|
|
import $ from 'jquery';
|
2017-09-10 17:25:29 +05:30
|
|
|
import animateMixin from '../mixins/animate';
|
|
|
|
import TaskList from '../../task_list';
|
2018-03-17 18:26:18 +05:30
|
|
|
import recaptchaModalImplementor from '../../vue_shared/mixins/recaptcha_modal_implementor';
|
2017-09-10 17:25:29 +05:30
|
|
|
|
|
|
|
export default {
|
2018-03-17 18:26:18 +05:30
|
|
|
mixins: [
|
|
|
|
animateMixin,
|
|
|
|
recaptchaModalImplementor,
|
|
|
|
],
|
|
|
|
|
2017-09-10 17:25:29 +05:30
|
|
|
props: {
|
|
|
|
canUpdate: {
|
|
|
|
type: Boolean,
|
|
|
|
required: true,
|
|
|
|
},
|
|
|
|
descriptionHtml: {
|
|
|
|
type: String,
|
|
|
|
required: true,
|
|
|
|
},
|
|
|
|
descriptionText: {
|
|
|
|
type: String,
|
|
|
|
required: true,
|
|
|
|
},
|
|
|
|
taskStatus: {
|
|
|
|
type: String,
|
|
|
|
required: false,
|
|
|
|
default: '',
|
|
|
|
},
|
2018-03-17 18:26:18 +05:30
|
|
|
issuableType: {
|
|
|
|
type: String,
|
|
|
|
required: false,
|
|
|
|
default: 'issue',
|
|
|
|
},
|
|
|
|
updateUrl: {
|
|
|
|
type: String,
|
|
|
|
required: false,
|
|
|
|
default: null,
|
|
|
|
},
|
2017-09-10 17:25:29 +05:30
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
preAnimation: false,
|
|
|
|
pulseAnimation: false,
|
|
|
|
};
|
|
|
|
},
|
|
|
|
watch: {
|
|
|
|
descriptionHtml() {
|
|
|
|
this.animateChange();
|
|
|
|
|
|
|
|
this.$nextTick(() => {
|
|
|
|
this.renderGFM();
|
|
|
|
});
|
|
|
|
},
|
|
|
|
taskStatus() {
|
|
|
|
this.updateTaskStatusText();
|
|
|
|
},
|
|
|
|
},
|
2018-03-17 18:26:18 +05:30
|
|
|
mounted() {
|
|
|
|
this.renderGFM();
|
|
|
|
this.updateTaskStatusText();
|
|
|
|
},
|
2017-09-10 17:25:29 +05:30
|
|
|
methods: {
|
|
|
|
renderGFM() {
|
|
|
|
$(this.$refs['gfm-content']).renderGFM();
|
|
|
|
|
|
|
|
if (this.canUpdate) {
|
|
|
|
// eslint-disable-next-line no-new
|
|
|
|
new TaskList({
|
2018-03-17 18:26:18 +05:30
|
|
|
dataType: this.issuableType,
|
2017-09-10 17:25:29 +05:30
|
|
|
fieldName: 'description',
|
|
|
|
selector: '.detail-page-description',
|
2018-03-17 18:26:18 +05:30
|
|
|
onSuccess: this.taskListUpdateSuccess.bind(this),
|
2017-09-10 17:25:29 +05:30
|
|
|
});
|
|
|
|
}
|
|
|
|
},
|
2018-03-17 18:26:18 +05:30
|
|
|
|
|
|
|
taskListUpdateSuccess(data) {
|
|
|
|
try {
|
|
|
|
this.checkForSpam(data);
|
2018-03-27 19:54:05 +05:30
|
|
|
this.closeRecaptcha();
|
2018-03-17 18:26:18 +05:30
|
|
|
} catch (error) {
|
|
|
|
if (error && error.name === 'SpamError') this.openRecaptcha();
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2017-09-10 17:25:29 +05:30
|
|
|
updateTaskStatusText() {
|
|
|
|
const taskRegexMatches = this.taskStatus.match(/(\d+) of ((?!0)\d+)/);
|
|
|
|
const $issuableHeader = $('.issuable-meta');
|
|
|
|
const $tasks = $('#task_status', $issuableHeader);
|
|
|
|
const $tasksShort = $('#task_status_short', $issuableHeader);
|
|
|
|
|
|
|
|
if (taskRegexMatches) {
|
|
|
|
$tasks.text(this.taskStatus);
|
2018-03-17 18:26:18 +05:30
|
|
|
$tasksShort.text(
|
|
|
|
`${taskRegexMatches[1]}/${taskRegexMatches[2]} task${taskRegexMatches[2] > 1 ?
|
|
|
|
's' :
|
|
|
|
''}`,
|
|
|
|
);
|
2017-09-10 17:25:29 +05:30
|
|
|
} else {
|
|
|
|
$tasks.text('');
|
|
|
|
$tasksShort.text('');
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<template>
|
|
|
|
<div
|
|
|
|
v-if="descriptionHtml"
|
|
|
|
:class="{
|
|
|
|
'js-task-list-container': canUpdate
|
2018-03-17 18:26:18 +05:30
|
|
|
}"
|
2018-11-08 19:23:39 +05:30
|
|
|
class="description"
|
2018-03-17 18:26:18 +05:30
|
|
|
>
|
2017-09-10 17:25:29 +05:30
|
|
|
<div
|
2018-11-08 19:23:39 +05:30
|
|
|
ref="gfm-content"
|
2017-09-10 17:25:29 +05:30
|
|
|
:class="{
|
|
|
|
'issue-realtime-pre-pulse': preAnimation,
|
|
|
|
'issue-realtime-trigger-pulse': pulseAnimation
|
|
|
|
}"
|
2018-11-08 19:23:39 +05:30
|
|
|
class="wiki"
|
|
|
|
v-html="descriptionHtml">
|
2017-09-10 17:25:29 +05:30
|
|
|
</div>
|
|
|
|
<textarea
|
|
|
|
v-if="descriptionText"
|
2018-03-17 18:26:18 +05:30
|
|
|
v-model="descriptionText"
|
|
|
|
:data-update-url="updateUrl"
|
2018-11-08 19:23:39 +05:30
|
|
|
class="hidden js-task-list-field"
|
2018-03-17 18:26:18 +05:30
|
|
|
>
|
2017-09-10 17:25:29 +05:30
|
|
|
</textarea>
|
2018-03-17 18:26:18 +05:30
|
|
|
|
|
|
|
<recaptcha-modal
|
|
|
|
v-show="showRecaptcha"
|
|
|
|
:html="recaptchaHTML"
|
|
|
|
@close="closeRecaptcha"
|
|
|
|
/>
|
2017-09-10 17:25:29 +05:30
|
|
|
</div>
|
|
|
|
</template>
|