-
-
Notifications
You must be signed in to change notification settings - Fork 145
Expand file tree
/
Copy pathEventList.vue
More file actions
167 lines (150 loc) · 3.96 KB
/
EventList.vue
File metadata and controls
167 lines (150 loc) · 3.96 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
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
<template lang="pug">
div
// TODO: Make event-editor a global component backed by a Vuex store
// Currently, more than one event-editor on the same view can lead to multiple event-editors opening.
event-editor(
v-if="editable"
:event="editableEvent", :bucket_id="bucket_id",
@save="(e) => $emit('save', e)", @delete="removeEvent"
)
b-card.event-container(no-block=true)
span(slot="header")
h4.card-title Events
span.pagination-header
| Showing {{ displayed_events.length }} events #[span(v-if="events.length > displayed_events.length") (out of {{ events.length }})]
b-button(@click="expandList", size="sm", style="float: right;")
span(v-if="!isListExpanded")
| Expand list
span(v-else)
| Condense list
ul.event-list(:class="{ 'expand': isListExpanded }")
li(v-for="event in displayed_events")
span.event
span.field(:title="event.timestamp")
icon(name="calendar")
| {{ event.timestamp | friendlytime }}
span.field
icon(name="clock")
| {{ event.duration | friendlyduration }}
span(v-for="(val, key) in event.data").field
icon(name="tags")
// TODO: Add some kind of highlighting to key
| {{ key }}: {{ val }}
span(v-if="editable")
b-btn.field(@click="() => {editEvent(event)}" variant="outline-dark" size="sm" style="padding: 0 0.2em 0 0.2em")
icon(name="edit")
| Edit
</template>
<style scoped lang="scss">
$border-color: #ddd;
.card {
margin-bottom: 1em;
.card-title {
display: inline-block;
margin-bottom: 0;
margin-right: 1em;
}
.card-body {
padding: 0;
}
}
.event-list {
list-style-type: none;
padding: 0;
border-radius: 3px;
height: 25em;
overflow-y: auto;
white-space: nowrap;
margin-bottom: 0px;
li {
border: 0 solid $border-color;
border-width: 0 0 1px 0;
border-radius: 4px;
padding: 2px;
&:last-child {
border-width: 0;
}
}
&.expand {
height: 100%;
}
}
.event {
display: inline-block;
padding: 0.3em;
clear: both;
}
.pagination-header {
font-size: 12pt;
color: #666;
margin-bottom: 10px;
}
.field {
margin: 0 5px 0 0;
font-size: 11pt;
padding: 3px 5px 3px 5px;
background-color: #ddd;
border: 1px solid #ccc;
border-radius: 2px;
&:last-child {
margin-right: 0;
}
}
/* Flips the outer element once, then all direct children once,
leaving the scrollbar in the first flipped yet the content correct */
.scrollbar-flipped,
.scrollbar-flipped > * {
transform: rotateX(180deg);
-ms-transform: rotateX(180deg); /* IE 9 */
-webkit-transform: rotateX(180deg); /* Safari and Chrome */
}
</style>
<script lang="ts">
import 'vue-awesome/icons/edit';
import 'vue-awesome/icons/tags';
import 'vue-awesome/icons/clock';
import 'vue-awesome/icons/calendar';
import EventEditor from '~/components/EventEditor.vue';
export default {
name: 'EventList',
components: {
'event-editor': EventEditor,
},
props: {
bucket_id: String,
events: Array,
editable: {
default: false,
type: Boolean,
},
},
data: function () {
return {
isListExpanded: false,
limit: 100,
editableEvent: null,
};
},
computed: {
displayed_events: function () {
return (this.events || []).slice(0, this.limit);
},
},
methods: {
editEvent: function (event) {
this.editableEvent = event;
this.$nextTick(() => {
this.$bvModal.show('edit-modal-' + event.id);
});
},
expandList: function () {
this.isListExpanded = !this.isListExpanded;
console.log('List should be expanding: ', this.isListExpanded);
},
removeEvent: function (_event) {
// FIXME: Illegal mutation of prop, need to propagate upwards or move into vuex.
//this.events = this.events.filter(e => e.id != event.id);
},
},
};
</script>