Skip to content

Commit

Permalink
fix(Isefac): list header include date
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexays committed Mar 11, 2018
1 parent d64f832 commit 34e30db
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 12 deletions.
4 changes: 2 additions & 2 deletions src/components/cards/Isefac/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
<i class="material-icons md-48">error_outline</i>
<h2 class="subheading">You must be logged to Isefac to use this card.</h2>
</div>
<div v-else-if="loaded">
<div v-else-if="!loading">
<div class="text-xs-center">
<h3>{{user.name}}</h3>
</div>
<v-list class="dates" three-line dense>
<template v-for="(date, index) of dates">
<v-subheader v-if="index === 0 || (dates[index - 1].header !== date.header && !compareDate(dates[index - 1].start, date.start))" :key="date.header">{{ date.header }}</v-subheader>
<v-subheader v-if="index === 0 || (dates[index - 1].header !== date.header)" :key="index">{{ date.header }}</v-subheader>
<v-list-tile :key="date">
<v-list-tile-content>
<v-list-tile-title>{{date.title}}</v-list-tile-title>
Expand Down
14 changes: 5 additions & 9 deletions src/components/cards/Isefac/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,14 @@ export default {
return {
API: 'https://nantes.campus-isefac.fr/bachelor/',
is_logged: true,
loaded: false,
loading: true,
dates: [],
user: {
name: '',
},
};
},
methods: {
compareDate(a, b) {
if (!a || !b) return false;
a.setHours(0, 0, 0, 0);
b.setHours(0, 0, 0, 0);
return a === b;
},
getCalendar() {
return this.axios.get(`${this.API}index.php/apps/planning/`)
.then((res) => {
Expand All @@ -44,7 +38,9 @@ export default {
.map((f) => {
f.startString = `${f.start.getHours()}h${(`0${f.start.getMinutes()}`).substr(-2)}`;
f.endString = `${f.end.getHours()}h${(`0${f.end.getMinutes()}`).substr(-2)}`;
f.header = f.start.toLocaleDateString('en-Us', { weekday: 'long' });
f.header = `${f.start.toLocaleDateString('en-Us', {
weekday: 'long',
})} ${f.start.getDate()}/${f.start.getMonth() + 1}`;
return f;
})
.sort((a, b) => a.start - b.start);
Expand All @@ -54,7 +50,7 @@ export default {
mounted() {
Promise.all([this.getCalendar()])
.finally(() => {
this.loaded = true;
this.loading = false;
this.$emit('init', this.$data);
});
},
Expand Down
4 changes: 3 additions & 1 deletion src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import directives from 'vuetify/es5/directives';
import axios from 'axios';
import VueAxios from 'vue-axios';
import VueLazyload from 'vue-lazyload';
import pick from 'lodash/pick';
import App from '@/App';
import router from '@/router';
import store from '@/helpers/store';
Expand Down Expand Up @@ -85,7 +86,8 @@ Vue.directive('init', {
isLiteral: true,
bind: (el, binding, vnode) => {
if (!binding.value) return;
Object.assign(vnode.componentInstance.$data, JSON.parse(localStorage.getItem(`cache_${binding.value}`)) || {});
const keys = Object.keys(vnode.componentInstance.$data);
Object.assign(vnode.componentInstance.$data, pick(JSON.parse(localStorage.getItem(`cache_${binding.value}`)) || {}, keys));
},
});
Vue.filter('bytes', (nb) => {
Expand Down

0 comments on commit 34e30db

Please sign in to comment.