Fixed #739 - Closed event for Message

pull/800/head
Cagatay Civici 2020-12-09 17:11:02 +03:00
parent 1c5fac7abe
commit c7b2d74c97
3 changed files with 35 additions and 8 deletions

View File

@ -6,7 +6,7 @@
<div class="p-message-text"> <div class="p-message-text">
<slot></slot> <slot></slot>
</div> </div>
<button class="p-message-close p-link" @click="visible = false" v-if="closable" type="button" v-ripple> <button class="p-message-close p-link" @click="close($event)" v-if="closable" type="button" v-ripple>
<i class="p-message-close-icon pi pi-times"></i> <i class="p-message-close-icon pi pi-times"></i>
</button> </button>
</div> </div>
@ -18,6 +18,7 @@
import Ripple from '../ripple/Ripple'; import Ripple from '../ripple/Ripple';
export default { export default {
emits: ['close'],
props: { props: {
severity: { severity: {
type: String, type: String,
@ -49,6 +50,12 @@ export default {
}, this.life); }, this.life);
} }
}, },
methods: {
close(event) {
this.visible = false;
this.$emit('close', event);
}
},
computed: { computed: {
containerClass() { containerClass() {
return 'p-message p-component p-message-' + this.severity; return 'p-message p-component p-message-' + this.severity;

View File

@ -11,7 +11,7 @@
<div class="content-section implementation"> <div class="content-section implementation">
<div class="card"> <div class="card">
<h5>Basic</h5> <h5>Basic</h5>
<Dropdown v-model="selectedCity1" :options="cities" optionLabel="name" placeholder="Select a City" /> <Dropdown v-model="selectedCity1" :options="cities" optionLabel="name" optionValue="code" placeholder="Select a City" />
<h5>Editable</h5> <h5>Editable</h5>
<Dropdown v-model="selectedCity2" :options="cities" optionLabel="name" :editable="true"/> <Dropdown v-model="selectedCity2" :options="cities" optionLabel="name" :editable="true"/>
@ -47,15 +47,15 @@ import DropdownDoc from './DropdownDoc';
export default { export default {
data() { data() {
return { return {
selectedCity1: null, selectedCity1: 0,
selectedCity2: null, selectedCity2: null,
selectedCountry: null, selectedCountry: null,
cities: [ cities: [
{name: 'New York', code: 'NY'}, {name: 'New York', code: 1},
{name: 'Rome', code: 'RM'}, {name: 'Rome', code: 2},
{name: 'London', code: 'LDN'}, {name: 'London', code: 0},
{name: 'Istanbul', code: 'IST'}, {name: 'Istanbul', code: 4},
{name: 'Paris', code: 'PRS'} {name: 'Paris', code: 5}
], ],
countries: [ countries: [
{name: 'Australia', code: 'AU'}, {name: 'Australia', code: 'AU'},

View File

@ -144,6 +144,26 @@ import InlineMessage from 'primevue/inlinemessage';
</table> </table>
</div> </div>
<h5>Events of Message</h5>
<div class="doc-tablewrapper">
<table class="doc-table">
<thead>
<tr>
<th>Name</th>
<th>Parameters</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>close</td>
<td>event: Browser event</td>
<td>Callback to invoke when a message is closed.</td>
</tr>
</tbody>
</table>
</div>
<h5>Styling</h5> <h5>Styling</h5>
<p>Following is the list of structural style classes, for theming classes visit <router-link to="/theming">theming</router-link> page.</p> <p>Following is the list of structural style classes, for theming classes visit <router-link to="/theming">theming</router-link> page.</p>