CitySettings.vue
5.63 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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
<template>
<div>
<h2 class="mt-12 font-bold text-2xl">Cities</h2>
<div v-if="cities.length" class="mt-4 flex flex-wrap">
<select-input v-model="city" class="pr-6">
<option v-for="city in cities" :value="city.id">
{{ city.name }}
</option>
</select-input>
<button class="btn-indigo hover:underline"
tabindex="-1"
type="button"
@click="cityAdd"
>
Add
</button>
</div>
<div class="mt-6 bg-white rounded shadow">
<table class="w-full whitespace-nowrap">
<tr class="text-left font-bold">
<th class="px-6 pt-6 pb-4" colspan="5">Name</th>
<th class="px-6 pt-6 pb-4"></th>
</tr>
<template v-for="city in token.cities">
<tr :key="city.id" class="hover:bg-gray-100 focus-within:bg-gray-100">
<td colspan="5" class="border-t">
<div class="px-6 py-4">
{{ city.name }}
</div>
</td>
<td class="border-t w-px">
<div class="px-6 py-4">
<button class="px-4 flex items-center"
tabindex="-1"
@click="cityDelete(city.id)"
>
<icon name="trash" class="block w-6 h-6 fill-gray-400"/>
</button>
</div>
</td>
</tr>
<tr v-if="city.dictionary_campaigns.length">
<th class="px-6 pt-6 pb-4"></th>
<th class="px-6 pt-6 pb-4">Кампания</th>
<th class="px-6 pt-6 pb-4">Обновлять?</th>
<th class="px-6 pt-6 pb-4">Синхронизировать?</th>
<th class="px-6 pt-6 pb-4">Включено?</th>
<th class="px-6 pt-6 pb-4"></th>
</tr>
<tr v-if="city.dictionary_campaigns.length" :key="dictionary_campaign.id" v-for="dictionary_campaign in city.dictionary_campaigns">
<td class="border-t"></td>
<td class="border-t">
<span class="px-6 py-4 flex items-center focus:text-indigo-500">
<inertia-link class="hover:text-indigo-500 focus:text-indigo-500"
:href="route('token.campaign.variables', [token.id, city.id, dictionary_campaign.campaign_id])"
>
{{ dictionary_campaign.name }}
</inertia-link>
</span>
</td>
<td class="border-t text-center">
<div class="px-6 py-4">
<input :checked="dictionary_campaign.updated"
@change="updated(city.id, dictionary_campaign.campaign_id, !dictionary_campaign.updated)"
type="checkbox"
>
</div>
</td>
<td class="border-t text-center">
<input :checked="dictionary_campaign.synced"
@change="synced(city.id, dictionary_campaign.campaign_id, !dictionary_campaign.synced)"
type="checkbox"
>
</td>
<td class="border-t text-center">
<input :checked="dictionary_campaign.enabled"
disabled="disabled"
@change="enabled(city.id, dictionary_campaign.campaign_id, !dictionary_campaign.enabled)"
type="checkbox"
>
</td>
<td class="border-t"></td>
</tr>
</template>
<tr v-if="token.cities.length === 0">
<td class="border-t px-6 py-4" colspan="4">No City found.</td>
</tr>
</table>
</div>
</div>
</template>
<script>
import SelectInput from "../../Shared/SelectInput";
import Icon from "../../Shared/Icon";
export default {
components: {Icon, SelectInput},
props: {
cities: Array,
token: Object,
main_token_campaigns: Array,
},
data() {
return {
city: false
}
},
watch: {},
mounted() {
},
methods: {
cityAdd() {
this.$emit('add', this.city)
},
cityDelete(id) {
this.$emit('delete', id)
},
synced(city_id, campaign_id, synced) {
this.$emit('synced', city_id, campaign_id, synced)
},
updated(city_id, campaign_id, updated) {
this.$emit('updated', city_id, campaign_id, updated)
},
enabled(city_id, campaign_id, updated) {
this.$emit('enabled', city_id, campaign_id, updated)
},
}
}
</script>