debian-mirror-gitlab/app/assets/javascripts/issue_show/components/title.vue

92 lines
2 KiB
Vue
Raw Normal View History

2017-09-10 17:25:29 +05:30
<script>
import animateMixin from '../mixins/animate';
2018-03-17 18:26:18 +05:30
import eventHub from '../event_hub';
import tooltip from '../../vue_shared/directives/tooltip';
import { spriteIcon } from '../../lib/utils/common_utils';
2017-09-10 17:25:29 +05:30
export default {
2018-03-17 18:26:18 +05:30
directives: {
tooltip,
2017-09-10 17:25:29 +05:30
},
2018-03-17 18:26:18 +05:30
mixins: [animateMixin],
2017-09-10 17:25:29 +05:30
props: {
issuableRef: {
type: String,
required: true,
},
2018-03-17 18:26:18 +05:30
canUpdate: {
required: false,
type: Boolean,
default: false,
},
2017-09-10 17:25:29 +05:30
titleHtml: {
type: String,
required: true,
},
titleText: {
type: String,
required: true,
},
2018-03-17 18:26:18 +05:30
showInlineEditButton: {
type: Boolean,
required: false,
default: false,
},
},
data() {
return {
preAnimation: false,
pulseAnimation: false,
titleEl: document.querySelector('title'),
};
},
computed: {
pencilIcon() {
return spriteIcon('pencil', 'link-highlight');
},
2017-09-10 17:25:29 +05:30
},
watch: {
titleHtml() {
this.setPageTitle();
this.animateChange();
},
},
methods: {
setPageTitle() {
const currentPageTitleScope = this.titleEl.innerText.split('·');
currentPageTitleScope[0] = `${this.titleText} (${this.issuableRef}) `;
this.titleEl.textContent = currentPageTitleScope.join('·');
},
2018-03-17 18:26:18 +05:30
edit() {
eventHub.$emit('open.form');
},
2017-09-10 17:25:29 +05:30
},
};
</script>
<template>
2018-03-17 18:26:18 +05:30
<div class="title-container">
<h2
class="title"
:class="{
'issue-realtime-pre-pulse': preAnimation,
'issue-realtime-trigger-pulse': pulseAnimation
}"
v-html="titleHtml"
>
</h2>
<button
v-tooltip
v-if="showInlineEditButton && canUpdate"
type="button"
class="btn btn-default btn-edit btn-svg js-issuable-edit"
v-html="pencilIcon"
title="Edit title and description"
data-placement="bottom"
data-container="body"
@click="edit"
>
</button>
</div>
2017-09-10 17:25:29 +05:30
</template>