mirror of
https://github.com/lingble/chatwoot.git
synced 2025-11-02 12:08:01 +00:00
feat: Add ability to sort canned responses (#9330)
Co-authored-by: jeffOtano <jeff@rinsed.com>
This commit is contained in:
@@ -32,9 +32,25 @@
|
||||
<th
|
||||
v-for="thHeader in $t('CANNED_MGMT.LIST.TABLE_HEADER')"
|
||||
:key="thHeader"
|
||||
class="last:text-right"
|
||||
class="last:text-right first:m-0 first:p-0"
|
||||
>
|
||||
{{ thHeader }}
|
||||
<p v-if="thHeader !== $t('CANNED_MGMT.LIST.TABLE_HEADER[0]')">
|
||||
{{ thHeader }}
|
||||
</p>
|
||||
|
||||
<button
|
||||
v-if="thHeader === $t('CANNED_MGMT.LIST.TABLE_HEADER[0]')"
|
||||
class="cursor-pointer flex items-center p-0"
|
||||
@click="toggleSort"
|
||||
>
|
||||
<p class="uppercase">
|
||||
{{ thHeader }}
|
||||
</p>
|
||||
<fluent-icon
|
||||
class="mb-2 ml-2"
|
||||
:icon="sortOrder === 'asc' ? 'chevron-up' : 'chevron-down'"
|
||||
/>
|
||||
</button>
|
||||
</th>
|
||||
</thead>
|
||||
<tbody>
|
||||
@@ -132,6 +148,7 @@ export default {
|
||||
cannedResponseAPI: {
|
||||
message: '',
|
||||
},
|
||||
sortOrder: 'asc',
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
@@ -156,9 +173,20 @@ export default {
|
||||
},
|
||||
mounted() {
|
||||
// Fetch API Call
|
||||
this.$store.dispatch('getCannedResponse');
|
||||
this.$store.dispatch('getCannedResponse').then(() => {
|
||||
this.toggleSort();
|
||||
});
|
||||
},
|
||||
methods: {
|
||||
toggleSort() {
|
||||
this.records.sort((a, b) => {
|
||||
if (this.sortOrder === 'asc') {
|
||||
return a.short_code.localeCompare(b.short_code);
|
||||
}
|
||||
return b.short_code.localeCompare(a.short_code);
|
||||
});
|
||||
this.sortOrder = this.sortOrder === 'asc' ? 'desc' : 'asc';
|
||||
},
|
||||
showAlert(message) {
|
||||
// Reset loading, current selected agent
|
||||
this.loading[this.selectedResponse.id] = false;
|
||||
|
||||
Reference in New Issue
Block a user