@devix-tecnologia/timeline-vue 1.0.2 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +138 -11
- package/dist/style.css +1 -1
- package/dist/timeline-vue.es.js +293 -256
- package/dist/types/components/timeline/atomos/AvatarTimeline.vue.d.ts +0 -1
- package/dist/types/components/timeline/atomos/BoxData.vue.d.ts +0 -1
- package/dist/types/components/timeline/atomos/Destaque.vue.d.ts +0 -1
- package/dist/types/components/timeline/atomos/Hora.vue.d.ts +0 -2
- package/dist/types/components/timeline/atomos/IconeCategoria.vue.d.ts +2 -3
- package/dist/types/components/timeline/atomos/IconeStatus.vue.d.ts +0 -1
- package/dist/types/components/timeline/atomos/SubtituloEvento.vue.d.ts +0 -1
- package/dist/types/components/timeline/atomos/TituloEvento.vue.d.ts +0 -1
- package/dist/types/components/timeline/moleculas/DescricaoEvento.vue.d.ts +0 -1
- package/dist/types/components/timeline/moleculas/EventoTimeline.vue.d.ts +84 -5
- package/dist/types/components/timeline/moleculas/HoraEvento.vue.d.ts +5 -3
- package/dist/types/components/timeline/moleculas/PerfilTimeline.vue.d.ts +0 -2
- package/dist/types/components/timeline/moleculas/SeparadorPeriodo.vue.d.ts +3 -7
- package/dist/types/components/timeline/moleculas/Topo.vue.d.ts +0 -1
- package/dist/types/components/timeline/organismos/Timeline.vue.d.ts +2 -5
- package/dist/types/components/timeline/type.d.ts +10 -7
- package/package.json +1 -1
- package/src/components/timeline/atomos/Destaque.vue +3 -3
- package/src/components/timeline/atomos/Hora.vue +7 -10
- package/src/components/timeline/atomos/IconeCategoria.vue +6 -6
- package/src/components/timeline/atomos/IconeStatus.vue +17 -16
- package/src/components/timeline/moleculas/DescricaoEvento.vue +5 -5
- package/src/components/timeline/moleculas/EventoTimeline.stories.ts +49 -49
- package/src/components/timeline/moleculas/EventoTimeline.vue +82 -26
- package/src/components/timeline/moleculas/HoraEvento.vue +5 -4
- package/src/components/timeline/moleculas/PerfilTimeline.vue +2 -3
- package/src/components/timeline/moleculas/SeparadorPeriodo.vue +26 -27
- package/src/components/timeline/organismos/Timeline.mock.ts +87 -57
- package/src/components/timeline/organismos/Timeline.stories.ts +22 -5
- package/src/components/timeline/organismos/Timeline.vue +97 -73
- package/src/components/timeline/type.ts +11 -7
|
@@ -1,30 +1,34 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<div>
|
|
3
|
-
<
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
</div>
|
|
11
|
-
|
|
12
|
-
<div
|
|
13
|
-
v-for="evento in eventosPorTipo"
|
|
14
|
-
:key="evento.key"
|
|
15
|
-
class="areaTimeline"
|
|
16
|
-
>
|
|
2
|
+
<div class="areaTimeline">
|
|
3
|
+
<PerfilTimeline
|
|
4
|
+
v-if="perfilTimeline !== null"
|
|
5
|
+
:nomePerfil="perfilTimeline.nome"
|
|
6
|
+
:imagemPerfil="perfilTimeline.imagem"
|
|
7
|
+
:iconePerfil="perfilTimeline.icone"
|
|
8
|
+
/>
|
|
9
|
+
<section class="timeline">
|
|
17
10
|
<!-- SEPARADOR -->
|
|
18
|
-
<div v-
|
|
19
|
-
<SeparadorPeriodo
|
|
11
|
+
<div v-for="evento in eventosPorTipo" :key="evento.key">
|
|
12
|
+
<SeparadorPeriodo
|
|
13
|
+
v-if="evento.tipo === 'dia'"
|
|
14
|
+
:dataSeparador="evento.valor"
|
|
15
|
+
/>
|
|
16
|
+
<!--loop-->
|
|
17
|
+
<EventoTimeline
|
|
18
|
+
v-if="evento.tipo === 'evento'"
|
|
19
|
+
:status="evento.valor.status"
|
|
20
|
+
:criticidade="evento.valor.criticidade"
|
|
21
|
+
:previsto="evento.valor.previsto"
|
|
22
|
+
:realizado="evento.valor.realizado"
|
|
23
|
+
:categoria="evento.valor.categoria"
|
|
24
|
+
:titulo="evento.valor.titulo"
|
|
25
|
+
:subtitulo="evento.valor.subtitulo"
|
|
26
|
+
:destaque="evento.valor.destaque"
|
|
27
|
+
:ehAtual="evento.valor.atual"
|
|
28
|
+
:aoCLicar="evento.valor.aoCLicar"
|
|
29
|
+
/>
|
|
20
30
|
</div>
|
|
21
|
-
|
|
22
|
-
<section class="timeline">
|
|
23
|
-
<!--loop-->
|
|
24
|
-
<EventoTimeline :dadosEvento="evento" />
|
|
25
|
-
</section>
|
|
26
|
-
</div>
|
|
27
|
-
</div>
|
|
31
|
+
</section>
|
|
28
32
|
</div>
|
|
29
33
|
</template>
|
|
30
34
|
|
|
@@ -37,11 +41,9 @@ import { Evento } from "../type";
|
|
|
37
41
|
|
|
38
42
|
type TipoEventoTimeline =
|
|
39
43
|
| { tipo: "dia"; valor: Date; key: number }
|
|
40
|
-
| { tipo: "evento"; valor: Evento; key: number
|
|
44
|
+
| { tipo: "evento"; valor: Evento; key: number }
|
|
41
45
|
| { tipo: "eventos"; valor: Evento[]; key: number };
|
|
42
46
|
|
|
43
|
-
// type Ordem = 'ascendente' | 'descendente';
|
|
44
|
-
|
|
45
47
|
export default defineComponent({
|
|
46
48
|
props: {
|
|
47
49
|
perfilTimeline: {
|
|
@@ -52,10 +54,6 @@ export default defineComponent({
|
|
|
52
54
|
required: true,
|
|
53
55
|
type: Object,
|
|
54
56
|
},
|
|
55
|
-
// ordem: {
|
|
56
|
-
// required: false,
|
|
57
|
-
// type: Ordem,
|
|
58
|
-
// },
|
|
59
57
|
},
|
|
60
58
|
components: {
|
|
61
59
|
PerfilTimeline,
|
|
@@ -66,12 +64,29 @@ export default defineComponent({
|
|
|
66
64
|
const dadosEventosTimeline: Evento[] = reactive(
|
|
67
65
|
props.eventosTimeline as Array<Evento>
|
|
68
66
|
);
|
|
67
|
+
let dadosEventosTimelineClone: Evento[] = reactive(dadosEventosTimeline);
|
|
68
|
+
|
|
69
|
+
function carregarListaEventos() {
|
|
70
|
+
dadosEventosTimelineClone = dadosEventosTimeline;
|
|
71
|
+
const resultado: Evento[] = filtraEventoAtual(dadosEventosTimelineClone);
|
|
72
|
+
dadosEventosTimelineClone.map((resp) => {
|
|
73
|
+
if (resultado[0].id === resp.id) {
|
|
74
|
+
resp.atual = true;
|
|
75
|
+
resp.scroll = true;
|
|
76
|
+
void scrollParaItemAtual();
|
|
77
|
+
} else {
|
|
78
|
+
resp.atual = false;
|
|
79
|
+
resp.scroll = false;
|
|
80
|
+
}
|
|
81
|
+
return {
|
|
82
|
+
evento: resp,
|
|
83
|
+
};
|
|
84
|
+
});
|
|
85
|
+
}
|
|
69
86
|
|
|
70
|
-
const
|
|
71
|
-
(
|
|
72
|
-
|
|
73
|
-
}
|
|
74
|
-
);
|
|
87
|
+
const atualizarEventoAtual = () => {
|
|
88
|
+
setInterval(carregarListaEventos, 60000);
|
|
89
|
+
};
|
|
75
90
|
|
|
76
91
|
const verifica_mesmo_dia = (a: Date, b: Date) => {
|
|
77
92
|
const mesmo_dia = a.getDay() === b.getDay();
|
|
@@ -81,85 +96,94 @@ export default defineComponent({
|
|
|
81
96
|
};
|
|
82
97
|
|
|
83
98
|
//verifica qual evento está mais próximo da hora atual e coloca ele numa nova lista na primeira posição
|
|
84
|
-
|
|
99
|
+
const filtraEventoAtual = (eventos: Evento[]) => {
|
|
85
100
|
if (eventos) {
|
|
86
101
|
const agora = Date.now();
|
|
87
|
-
let minDiff = null;
|
|
102
|
+
let minDiff: number | null = null;
|
|
88
103
|
let listaEventos = [];
|
|
89
104
|
for (const e of eventos) {
|
|
90
105
|
const t = e.data.getTime();
|
|
91
|
-
const diff = Math.abs(agora - t);
|
|
92
|
-
if (minDiff === null || (diff < minDiff && t <= agora)) {
|
|
93
|
-
minDiff = diff;
|
|
94
|
-
listaEventos.length = 0;
|
|
95
|
-
}
|
|
96
|
-
//se o evento já estiver marcado como realizado, cancelado ou adiado, ele pula para o próximo da lista.
|
|
97
106
|
if (e.status === "planejado" || e.status === "atrasado") {
|
|
107
|
+
const diff: number = Math.abs(agora - e.data.getTime());
|
|
108
|
+
if (minDiff === null || (diff < minDiff && t <= agora)) {
|
|
109
|
+
minDiff = diff;
|
|
110
|
+
listaEventos.length = 0;
|
|
111
|
+
} else if (diff > minDiff) {
|
|
112
|
+
continue;
|
|
113
|
+
}
|
|
98
114
|
listaEventos.push(e);
|
|
99
115
|
}
|
|
100
116
|
}
|
|
101
117
|
return listaEventos;
|
|
102
118
|
} else {
|
|
103
|
-
console.log("vazio.. ", []);
|
|
104
119
|
return [];
|
|
105
120
|
}
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
// lista de eventos por tipo
|
|
124
|
+
const eventosTimeline = computed(() => {
|
|
125
|
+
void atualizarEventoAtual();
|
|
126
|
+
|
|
127
|
+
const eventosOrdenados = dadosEventosTimelineClone.sort(
|
|
128
|
+
(a: Evento, b: Evento) => {
|
|
129
|
+
return a.data.getTime() - b.data.getTime();
|
|
130
|
+
}
|
|
131
|
+
);
|
|
132
|
+
if (eventosOrdenados) {
|
|
133
|
+
let resultado: Array<TipoEventoTimeline> = [];
|
|
116
134
|
let dataAtual: Date | null = null;
|
|
117
135
|
let idx = 0;
|
|
136
|
+
let statusEvento;
|
|
118
137
|
|
|
119
138
|
for (const evento of eventosOrdenados) {
|
|
139
|
+
const agora = new Date();
|
|
120
140
|
const dataEvento = evento.data;
|
|
121
|
-
|
|
141
|
+
statusEvento = evento.status;
|
|
142
|
+
const toleranciaEvento = evento.tolerancia * 60 * 1000;
|
|
143
|
+
|
|
144
|
+
//altera status para atrasado
|
|
145
|
+
if (
|
|
146
|
+
statusEvento === "planejado" &&
|
|
147
|
+
dataEvento.getTime() + toleranciaEvento < agora.getTime()
|
|
148
|
+
) {
|
|
149
|
+
evento.status = "atrasado";
|
|
150
|
+
}
|
|
122
151
|
if (!dataAtual || !verifica_mesmo_dia(dataAtual, dataEvento)) {
|
|
123
152
|
dataAtual = dataEvento;
|
|
124
|
-
|
|
153
|
+
resultado.push({
|
|
125
154
|
tipo: "dia",
|
|
126
155
|
valor: evento.data,
|
|
127
156
|
key: ++idx,
|
|
128
157
|
});
|
|
129
158
|
}
|
|
130
|
-
|
|
131
|
-
result.push({
|
|
159
|
+
resultado.push({
|
|
132
160
|
tipo: "evento",
|
|
133
161
|
valor: evento,
|
|
134
162
|
key: ++idx,
|
|
135
|
-
atual:
|
|
136
|
-
eventoAtual === null
|
|
137
|
-
? false
|
|
138
|
-
: evento.id === eventoAtual.id
|
|
139
|
-
? true
|
|
140
|
-
: false,
|
|
141
163
|
});
|
|
142
164
|
}
|
|
143
|
-
return
|
|
165
|
+
return resultado;
|
|
144
166
|
} else {
|
|
145
167
|
return [];
|
|
146
168
|
}
|
|
147
169
|
});
|
|
148
170
|
|
|
149
|
-
|
|
150
|
-
eventosPorTipo,
|
|
151
|
-
};
|
|
152
|
-
},
|
|
153
|
-
methods: {
|
|
154
|
-
scrollParaItemAtual() {
|
|
171
|
+
const scrollParaItemAtual = () => {
|
|
155
172
|
const itemAtual = document.querySelector(".atual");
|
|
156
173
|
itemAtual?.scrollIntoView({
|
|
157
174
|
behavior: "smooth",
|
|
158
175
|
block: "center",
|
|
159
176
|
});
|
|
160
|
-
}
|
|
177
|
+
};
|
|
178
|
+
|
|
179
|
+
carregarListaEventos();
|
|
180
|
+
return {
|
|
181
|
+
eventosPorTipo: eventosTimeline,
|
|
182
|
+
scrollParaItemAtual,
|
|
183
|
+
};
|
|
161
184
|
},
|
|
162
185
|
mounted() {
|
|
186
|
+
// Aguardando a renderização para fazer scroll
|
|
163
187
|
this.scrollParaItemAtual();
|
|
164
188
|
},
|
|
165
189
|
});
|
|
@@ -4,20 +4,22 @@ export type Perfil = {
|
|
|
4
4
|
icone: string | null;
|
|
5
5
|
};
|
|
6
6
|
|
|
7
|
+
export type Categoria = {
|
|
8
|
+
nome: string;
|
|
9
|
+
icone: string;
|
|
10
|
+
};
|
|
11
|
+
|
|
7
12
|
export type Evento = {
|
|
8
13
|
id: string;
|
|
9
14
|
data: Date;
|
|
10
15
|
previsto: Date;
|
|
11
16
|
duracao: number | null;
|
|
12
17
|
realizado: Date | null;
|
|
13
|
-
tolerancia: number
|
|
18
|
+
tolerancia: number;
|
|
14
19
|
titulo: string;
|
|
15
20
|
subtitulo: string;
|
|
16
21
|
destaque: string;
|
|
17
|
-
categoria:
|
|
18
|
-
nome: string;
|
|
19
|
-
icone: string;
|
|
20
|
-
};
|
|
22
|
+
categoria: Categoria;
|
|
21
23
|
status:
|
|
22
24
|
| "atrasado"
|
|
23
25
|
| "adiantado"
|
|
@@ -25,6 +27,8 @@ export type Evento = {
|
|
|
25
27
|
| "realizado"
|
|
26
28
|
| "planejado"
|
|
27
29
|
| "cancelado";
|
|
28
|
-
criticidade:
|
|
29
|
-
|
|
30
|
+
criticidade: "baixa" | "media" | "alta";
|
|
31
|
+
aoCLicar?: VoidFunction;
|
|
32
|
+
atual: boolean;
|
|
33
|
+
scroll: boolean;
|
|
30
34
|
};
|