# Pull Request Template ## Description This PR adds new eslint rules to the code base. **Error rules** | Rule name | Type | Files updated | | ----------------- | --- | - | | `vue/block-order` | error | ✅ | | `vue/component-name-in-template-casing` | error | ✅ | | `vue/component-options-name-casing` | error | ✅ | | `vue/custom-event-name-casing` | error | ✅ | | `vue/define-emits-declaration` | error | ✅ | | `vue/no-unused-properties` | error | ✅ | | `vue/define-macros-order` | error | ✅ | | `vue/define-props-declaration` | error | ✅ | | `vue/match-component-import-name` | error | ✅ | | `vue/next-tick-style` | error | ✅ | | `vue/no-bare-strings-in-template` | error | ✅ | | `vue/no-empty-component-block` | error | ✅ | | `vue/no-multiple-objects-in-class` | error | ✅ | | `vue/no-required-prop-with-default` | error | ✅ | | `vue/no-static-inline-styles` | error | ✅ | | `vue/no-template-target-blank` | error | ✅ | | `vue/no-this-in-before-route-enter` | error | ✅ | | `vue/no-undef-components` | error | ✅ | | `vue/no-unused-emit-declarations` | error | ✅ | | `vue/no-unused-refs` | error | ✅ | | `vue/no-use-v-else-with-v-for` | error | ✅ | | `vue/no-useless-v-bind` | error | ✅ | | `vue/no-v-text` | error | ✅ | | `vue/padding-line-between-blocks` | error | ✅ | | ~`vue/prefer-prop-type-boolean-first`~ | ~error~ | ❌ (removed this rule, cause a bug in displaying custom attributes) | | `vue/prefer-separate-static-class` | error | ✅ | | `vue/prefer-true-attribute-shorthand` | error | ✅ | | `vue/require-explicit-slots` | error | ✅ | | `vue/require-macro-variable-name` | error | ✅ | **Warn rules** | Rule name | Type | Files updated | | ---- | ------------- | ------------- | | `vue/no-root-v-if` | warn | ❎ | Fixes https://linear.app/chatwoot/issue/CW-3492/vue-eslint-rules ## Type of change - [x] New feature (non-breaking change which adds functionality) ## Checklist: - [x] My code follows the style guidelines of this project - [x] I have performed a self-review of my code - [x] I have commented on my code, particularly in hard-to-understand areas - [ ] I have made corresponding changes to the documentation - [x] My changes generate no new warnings - [x] I have added tests that prove my fix is effective or that my feature works - [x] New and existing unit tests pass locally with my changes - [ ] Any dependent changes have been merged and published in downstream modules --------- Co-authored-by: Fayaz Ahmed <fayazara@gmail.com> Co-authored-by: Muhsin Keloth <muhsinkeramam@gmail.com> Co-authored-by: Shivam Mishra <scm.mymail@gmail.com> Co-authored-by: Pranav <pranav@chatwoot.com>
142 lines
3.9 KiB
Vue
142 lines
3.9 KiB
Vue
<script>
|
|
// TODO: Remove this when we support all formats
|
|
const formatsToRemove = ['DOCUMENT', 'IMAGE', 'VIDEO'];
|
|
|
|
export default {
|
|
props: {
|
|
inboxId: {
|
|
type: Number,
|
|
default: undefined,
|
|
},
|
|
},
|
|
data() {
|
|
return {
|
|
query: '',
|
|
};
|
|
},
|
|
computed: {
|
|
whatsAppTemplateMessages() {
|
|
// TODO: Remove the last filter when we support all formats
|
|
return this.$store.getters['inboxes/getWhatsAppTemplates'](this.inboxId)
|
|
.filter(template => template.status.toLowerCase() === 'approved')
|
|
.filter(template => {
|
|
return template.components.every(component => {
|
|
return !formatsToRemove.includes(component.format);
|
|
});
|
|
});
|
|
},
|
|
filteredTemplateMessages() {
|
|
return this.whatsAppTemplateMessages.filter(template =>
|
|
template.name.toLowerCase().includes(this.query.toLowerCase())
|
|
);
|
|
},
|
|
},
|
|
methods: {
|
|
getTemplatebody(template) {
|
|
return template.components.find(component => component.type === 'BODY')
|
|
.text;
|
|
},
|
|
},
|
|
};
|
|
</script>
|
|
|
|
<template>
|
|
<div class="w-full">
|
|
<div class="gap-1 templates__list-search">
|
|
<fluent-icon icon="search" class="search-icon" size="16" />
|
|
<input
|
|
v-model="query"
|
|
type="search"
|
|
:placeholder="$t('WHATSAPP_TEMPLATES.PICKER.SEARCH_PLACEHOLDER')"
|
|
class="templates__search-input"
|
|
/>
|
|
</div>
|
|
<div class="template__list-container">
|
|
<div v-for="(template, i) in filteredTemplateMessages" :key="template.id">
|
|
<button
|
|
class="template__list-item"
|
|
@click="$emit('onSelect', template)"
|
|
>
|
|
<div>
|
|
<div class="flex items-center justify-between mb-2.5">
|
|
<p class="label-title">
|
|
{{ template.name }}
|
|
</p>
|
|
<span
|
|
class="inline-block px-2 py-1 text-xs leading-none bg-white rounded-sm cursor-default dark:bg-slate-700 text-slate-800 dark:text-slate-100"
|
|
>
|
|
{{ $t('WHATSAPP_TEMPLATES.PICKER.LABELS.LANGUAGE') }} :
|
|
{{ template.language }}
|
|
</span>
|
|
</div>
|
|
<div>
|
|
<p class="strong">
|
|
{{ $t('WHATSAPP_TEMPLATES.PICKER.LABELS.TEMPLATE_BODY') }}
|
|
</p>
|
|
<p class="label-body">{{ getTemplatebody(template) }}</p>
|
|
</div>
|
|
<div class="label-category">
|
|
<p class="strong">
|
|
{{ $t('WHATSAPP_TEMPLATES.PICKER.LABELS.CATEGORY') }}
|
|
</p>
|
|
<p>{{ template.category }}</p>
|
|
</div>
|
|
</div>
|
|
</button>
|
|
<hr v-if="i != filteredTemplateMessages.length - 1" :key="`hr-${i}`" />
|
|
</div>
|
|
<div v-if="!filteredTemplateMessages.length">
|
|
<p>
|
|
{{ $t('WHATSAPP_TEMPLATES.PICKER.NO_TEMPLATES_FOUND') }}
|
|
<strong>{{ query }}</strong>
|
|
</p>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</template>
|
|
|
|
<style scoped lang="scss">
|
|
.templates__list-search {
|
|
@apply items-center flex bg-slate-25 dark:bg-slate-900 mb-2.5 py-0 px-2.5 rounded-md border border-solid border-slate-100 dark:border-slate-700;
|
|
|
|
.search-icon {
|
|
@apply text-slate-400 dark:text-slate-300;
|
|
}
|
|
|
|
.templates__search-input {
|
|
@apply bg-transparent border-0 text-xs h-9 m-0;
|
|
}
|
|
}
|
|
.template__list-container {
|
|
@apply bg-slate-25 dark:bg-slate-900 rounded-md max-h-[18.75rem] overflow-y-auto p-2.5;
|
|
|
|
.template__list-item {
|
|
@apply rounded-lg cursor-pointer block p-2.5 text-left w-full hover:bg-woot-50 dark:hover:bg-slate-800;
|
|
|
|
.label-title {
|
|
@apply text-sm;
|
|
}
|
|
|
|
.label-category {
|
|
@apply mt-5;
|
|
|
|
span {
|
|
@apply text-sm font-semibold;
|
|
}
|
|
}
|
|
|
|
.label-body {
|
|
font-family: monospace;
|
|
}
|
|
}
|
|
}
|
|
|
|
.strong {
|
|
@apply text-xs font-semibold;
|
|
}
|
|
|
|
hr {
|
|
@apply border-b border-solid border-slate-100 dark:border-slate-700 my-2.5 mx-auto max-w-[95%];
|
|
}
|
|
</style>
|