-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathHeader.vue
255 lines (216 loc) · 6.36 KB
/
Header.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
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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
<template>
<b-row class="event-header" no-gutters>
<b-col cols="11" md="3">
<b-breadcrumb :items="breadcrumbs" />
</b-col>
<b-col cols="12" md="8">
<b-row>
<b-col class="text-center">
<Spinner v-if="!event.magnitude && !!event.id" />
<h5 v-if="event.magnitude">
<span class="magnitude-type" v-for="item in event.magnitudeType" :key="item[0]">
<span>{{ item[0] }}</span><small>{{ item[1] }}</small>
</span>
( <span class="magnitude">{{ event.magnitude }}</span> )
{{ event.datetime | moment(datetimeFormatUTC) }}
<span class="processing-method">
{{ event.processingMethod.short }}
</span>
<b-badge v-if="agency.title" class="agency" v-b-popover.hover.auto="agency.description">
{{ agency.title }}
</b-badge>
</h5>
</b-col>
</b-row>
<b-row class="event-local-dt-row">
<b-col class="text-center">
<span class="event-datetime"
v-b-popover.hover.auto="'Время землетрясения в вашем часовом поясе'">
{{ localDateTime(event.datetime) }}
</span>
</b-col>
</b-row>
<b-row v-if="event.magnitude">
<b-col class="text-center">
<b-badge
:variant="label.variant"
v-b-popover.hover.auto="label.description">
{{ label.text }}
</b-badge>
</b-col>
</b-row>
<b-row class="event-local-dt-row mt-2">
<b-col class="text-center font-weight-bolder">
<router-link
:to="{ name: 'FeltReportPoll', query: { reportId: event.id } }"
>Ощутили это землетрясение?</router-link>
</b-col>
</b-row>
</b-col>
<b-col cols="1" md="1" class="text-right" v-if="!$root.onMobile">
<b-button-group>
<ExportDropDown v-if="event.id" @export2xls="export2xls" />
</b-button-group>
</b-col>
</b-row>
</template>
<script>
import Spinner from '@/components/Spinner'
import ExportDropDown from '@/components/ExportDropDown'
import { agency, agencyDescription } from '@/helpers/event'
import apiSettings from '@/settings/api'
export default {
components: { Spinner, ExportDropDown },
props: {
event: {}
},
data() {
return {
agency: { title: '', description: '' },
label: {}
}
},
methods: {
setAgency: function(data) {
this.agency.title = agency(data, false)
this.agency.description = agencyDescription(data)
},
localDateTime: function(dt) {
return this.$moment.utc(dt).local().format(this.datetimeFormatLocal)
},
setLabel: function(event) {
if (event.has_delete) {
this.label = {
description: 'Информация о землетрясении удалена из итогового каталога сейсмических событий',
text: 'СОБЫТИЕ УДАЛЕНО',
variant: 'deleted'
}
} else if (event.has_final) {
this.label = {
description: 'Информация о землетрясении проверена и зарегистрирована в итоговом каталоге сейсмических событий',
text: 'ФИНАЛЬНЫЙ РАСЧЁТ',
variant: 'final'
}
} else {
this.label = {
description: 'Информация о землетрясении уточняется',
text: 'РАСЧЁТ ОБНОВЛЯЕТСЯ',
variant: 'processing'
}
}
},
export2xls: function(request) {
request(apiSettings.endpointEvent(this.event.id))
}
},
computed: {
datetimeFormatUTC: function() {
return this.$root.onMobile ? 'L в HH:mm:ss UTC' : 'LL в HH:mm:ss UTC'
},
datetimeFormatLocal: function() {
return this.$root.onMobile ? 'L в HH:mm:ss (UTCZ)' : 'LL в HH:mm:ss (UTCZ)'
},
breadcrumbs: function()
{
let breadcrumbs = []
breadcrumbs.push({
text: 'Главная',
href: this.$router.resolve({ name: 'Mainpage' }).href
})
if (!this.$root.onMobile)
{
let query = JSON.parse(this.$route.query.backUrlQuery || '{}')
breadcrumbs.push({
text: 'События',
href: this.$router.resolve({ name: 'Events', query }).href
})
}
breadcrumbs.push({
text: this.event.id || 'event',
active: true
})
return breadcrumbs
}
},
created() {
this.setLabel(this.event)
},
watch: {
event: function(value)
{
this.breadcrumbs[ this.breadcrumbs.length - 1 ].text = value.id
this.setLabel(value)
this.setAgency(value.agency)
}
}
}
</script>
<style lang="scss">
.popover {
max-width: 450px;
}
</style>
<style lang="scss" scoped>
@import '~scss/_variables';
.event-header {
margin-bottom: 3%;
margin-top: 4%;
.breadcrumb {
background-color: transparent;
padding-left: 0;
padding-top: 0;
.active {
color: $color-gray-dark;
}
}
.agency {
@media screen and (min-width: 768px) {
font-size: 50% !important;
vertical-align: top;
}
}
.badge {
font-size: 70%;
padding: 1%;
text-transform: uppercase;
@media screen and (max-width: 767px) {
padding: 2%;
}
&.agency {
cursor: pointer;
}
}
.badge-deleted {
background-color: $color-red;
color: $color-white;
}
.badge-final {
background-color: $color-green;
color: $color-white;
}
.badge-processing {
background-color: $color-orange;
color: $color-white;
cursor: pointer;
}
.magnitude {
color: $color-orange;
}
.processing-method {
color: $color-blue;
}
.event-local-dt-row
{
margin-bottom: 12px;
.event-datetime
{
border-bottom: 1px dashed;
color: #9E9E9E;
cursor: help;
&:hover {
border-bottom-color: transparent;
}
}
}
}
</style>