-
Notifications
You must be signed in to change notification settings - Fork 5
/
RedirectDescription.vue
46 lines (41 loc) · 1.32 KB
/
RedirectDescription.vue
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
<docs>
RedirectDescription component.
Display a human readable description of a redirect’s filters.
</docs>
<template>
<ul class="pra-redirect-info-filters">
<li v-for="filter in redirect.filters">
<template v-if="filter.type === 'opt-in'">{{ filter.value ? text('User has opted in') : text('User has not opted in') }}</template>
<template v-else>{{ filterDescription(filter) }}</template>
</li>
</ul>
</template>
<script>
import { OPERATORS } from '@/utils/defaults'
import find from 'lodash/find'
export default {
props: {
redirect: Object,
index: Number
},
methods: {
text (text) {
switch (text) {
case 'User has opted in': return Drupal.t('Supporter has opted in')
case 'User has not opted in': return Drupal.t('Supporter hasn’t opted in')
}
},
/**
* Get a phrase describing the filter, like 'First name does not contain foo'.
* @param {Object} filter - A personalized redirect’s filter.
* @return {string} The filter operator’s translated phrase.
*/
filterDescription (filter) {
const fieldLabel = find(this.$root.$options.settings.fields, { id: filter.field }).label
return Drupal.t(OPERATORS[filter.operator].phrase, { '@attribute': fieldLabel, '@value': filter.value })
}
}
}
</script>
<style lang="css">
</style>