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

93 lines
1.9 KiB
Vue
Raw Normal View History

2017-09-10 17:25:29 +05:30
<script>
2018-11-08 19:23:39 +05:30
import animateMixin from '../mixins/animate';
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
2018-11-08 19:23:39 +05:30
export default {
directives: {
tooltip,
},
mixins: [animateMixin],
props: {
issuableRef: {
type: [String, Number],
required: true,
2017-09-10 17:25:29 +05:30
},
2018-11-08 19:23:39 +05:30
canUpdate: {
required: false,
type: Boolean,
default: false,
2018-03-17 18:26:18 +05:30
},
2018-11-08 19:23:39 +05:30
titleHtml: {
type: String,
required: true,
2018-03-17 18:26:18 +05:30
},
2018-11-08 19:23:39 +05:30
titleText: {
type: String,
required: true,
2017-09-10 17:25:29 +05:30
},
2018-11-08 19:23:39 +05:30
showInlineEditButton: {
type: Boolean,
required: false,
default: false,
2017-09-10 17:25:29 +05:30
},
2018-11-08 19:23:39 +05:30
},
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
},
2018-11-08 19:23:39 +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('·');
},
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="{
'issue-realtime-pre-pulse': preAnimation,
'issue-realtime-trigger-pulse': pulseAnimation
}"
2018-11-08 19:23:39 +05:30
class="title"
2018-03-17 18:26:18 +05:30
v-html="titleHtml"
>
</h2>
<button
v-if="showInlineEditButton && canUpdate"
2018-12-05 23:21:45 +05:30
v-tooltip
2018-03-17 18:26:18 +05:30
type="button"
2018-12-05 23:21:45 +05:30
class="btn btn-default btn-edit btn-svg js-issuable-edit
qa-edit-button"
2018-03-17 18:26:18 +05:30
title="Edit title and description"
data-placement="bottom"
data-container="body"
@click="edit"
2018-11-08 19:23:39 +05:30
v-html="pencilIcon"
2018-03-17 18:26:18 +05:30
>
</button>
</div>
2017-09-10 17:25:29 +05:30
</template>