CampaignsSettings.vue
3.24 KB
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
<template>
<div>
<h2 class="mt-12 font-bold text-2xl">Campaigns</h2>
<div v-if="campaigns.length" class="mt-4 flex flex-wrap">
<select-input v-model="campaign_id"
:readonly="campaign_id"
class="pr-6"
>
<option v-for="campaign in campaigns" :value="campaign.id">
{{ campaign.name }}
</option>
</select-input>
<button class="btn-indigo hover:underline"
tabindex="-1"
type="button"
@click="add"
>
Add
</button>
</div>
<div class="mt-4 flex flex-wrap">
</div>
<div class="mt-6 bg-white rounded shadow overflow-x-auto">
<table class="w-full whitespace-nowrap">
<tr class="text-left font-bold">
<th class="px-6 pt-6 pb-4">Name</th>
<th class="px-6 pt-6 pb-4">Action</th>
</tr>
<tr v-for="campaign in token.campaigns" :key="campaign.id"
class="hover:bg-gray-100 focus-within:bg-gray-100">
<td class="border-t px-6 py-3">
{{ campaign.name }}
</td>
<td class="border-t px-6 py-3">
<input :id="'campaign-enabled-' + campaign.id" :checked="campaign.enabled"
@change="enabled(campaign.id, !campaign.enabled)"
type="checkbox"
>
<label :for="'campaign-enabled-' + campaign.id">Enabled</label>
<button class="text-red-600 hover:underline"
tabindex="-1"
type="button"
@click="destroy(campaign.id)"
>
Delete Campaign
</button>
</td>
</tr>
<tr v-if="token.campaigns.length === 0">
<td class="border-t px-6 py-4" colspan="5">No campaigns found.</td>
</tr>
</table>
</div>
</div>
</template>
<script>
import Icon from "../../Shared/Icon";
import SelectInput from "../../Shared/SelectInput";
import LoadingButton from "../../Shared/LoadingButton";
export default {
components: {
Icon,
SelectInput,
LoadingButton,
},
props: {
campaigns: Array,
token: Object,
},
data() {
return {
campaign_id: null,
}
},
watch: {},
mounted() {
},
methods: {
add() {
if (!this.campaign_id) {
return;
}
this.$emit('add', this.campaign_id)
},
enabled(campaign_id, enabled) {
this.$emit('enabled', campaign_id, enabled)
},
destroy(campaign_id) {
this.$emit('delete', campaign_id)
},
}
}
</script>