Sessions: Add session category

pull/4020/head
Julio 4 years ago
parent 1322ec43f6
commit 79aad4b561
  1. 27
      assets/vue/components/session/SessionCardList.vue
  2. 6
      assets/vue/components/session/Tabs.vue
  3. 1
      assets/vue/graphql/queries/SessionRelUser.js
  4. 71
      assets/vue/views/user/sessions/List.vue
  5. 2
      src/CoreBundle/DataProvider/Extension/SessionRelUserExtension.php

@ -1,23 +1,18 @@
<template> <template>
<div <div
v-for="session in sessions" v-for="session in sessions"
:key="session.id" :key="session.id"
> >
<div v-if="session.category" <SessionCard
class="text-xl" :session="session"
> />
<v-icon icon="mdi-folder" /> {{ session.category.name }} </div>
</div>
<SessionCard
:session="session"
/>
</div>
</template> </template>
<script> <script>
import SessionCard from './SessionCard.vue'; import SessionCard from './SessionCard.vue';
export default { export default {
name: 'SessionCardList', name: 'SessionCardList',
components: { components: {
@ -32,13 +27,13 @@ export default {
}; };
}, },
methods: { methods: {
isList: function (){ isList: function () {
if (!this.deck) { if (!this.deck) {
return 'primary'; return 'primary';
} }
return 'secondary'; return 'secondary';
}, },
isDeck: function (){ isDeck: function () {
if (this.deck) { if (this.deck) {
return 'primary'; return 'primary';
} }

@ -1,8 +1,8 @@
<template> <template>
<q-tabs align="left" dense inline-label no-caps> <q-tabs align="left" dense inline-label no-caps>
<q-route-tab :to="{name: 'MySessionsPast'}" label="Past"/> <q-route-tab :to="{name: 'MySessionsPast'}" :label="$t('Past')"/>
<q-route-tab :to="{name: 'MySessions'}" label="Current"/> <q-route-tab :to="{name: 'MySessions'}" :label="$t('Current')"/>
<q-route-tab :to="{name: 'MySessionsUpcoming'}" label="Upcoming"/> <q-route-tab :to="{name: 'MySessionsUpcoming'}" :label="$t('Upcoming')"/>
</q-tabs> </q-tabs>
</template> </template>

@ -13,6 +13,7 @@ export const GET_SESSION_REL_USER = gql`
_id _id
name name
category { category {
_id
id id
name name
} }

@ -1,7 +1,18 @@
<template> <template>
<StickyCourses/> <StickyCourses/>
<SessionTabs/> <SessionTabs/>
<SessionListWrapper :sessions="sessions"/> <SessionListWrapper :sessions="sessionList"/>
<div v-if="categories.length" class="grid">
<div v-for="category in categories" >
<div class="text-xl">
<v-icon icon="mdi-folder" /> {{ category.name }} {{category._id}}
</div>
<SessionListWrapper :sessions="getSessionsFromCategory(category)"/>
</div>
</div>
</template> </template>
<script> <script>
@ -13,14 +24,17 @@ import {GET_SESSION_REL_USER} from "../../../graphql/queries/SessionRelUser.js";
import {DateTime} from "luxon"; import {DateTime} from "luxon";
import SessionTabs from '../../../components/session/Tabs'; import SessionTabs from '../../../components/session/Tabs';
import SessionListWrapper from '../../../components/session/SessionListWrapper'; import SessionListWrapper from '../../../components/session/SessionListWrapper';
//import SessionCategoryListWrapper from '../../../components/session/SessionCategoryListWrapper';
import StickyCourses from '../../../views/user/courses/StickyCourses.vue'; import StickyCourses from '../../../views/user/courses/StickyCourses.vue';
import isEmpty from "lodash/isEmpty";
export default { export default {
name: 'SessionList', name: 'SessionList',
components: { components: {
StickyCourses, StickyCourses,
SessionTabs, SessionTabs,
SessionListWrapper SessionListWrapper,
SessionCategoryListWrapper
}, },
setup() { setup() {
const store = useStore(); const store = useStore();
@ -37,10 +51,11 @@ export default {
afterEndDate: end, afterEndDate: end,
}); });
const sessions = useResult(resultSessions, [], ({sessionRelUsers}) => { let sessions = useResult(resultSessions, [], ({sessionRelUsers}) => {
let sessionList = []; let sessionList = [];
sessionRelUsers.edges.map(({node}) => { sessionRelUsers.edges.map(({node}) => {
const sessionExists = sessionList.findIndex(suSession => suSession._id === node.session._id) >= 0; const sessionExists = sessionList.findIndex(suSession => suSession._id === node.session._id) >= 0;
if (!sessionExists) { if (!sessionExists) {
sessionList.push(node.session); sessionList.push(node.session);
} }
@ -51,8 +66,58 @@ export default {
return sessionList; return sessionList;
}); });
let categories = useResult(resultSessions, [], ({sessionRelUsers}) => {
let categoryList = [];
sessionRelUsers.edges.map(({node}) => {
if (isEmpty(node.session.category)) {
return;
}
const categoryExists = categoryList.findIndex(cat => cat._id === node.session.category._id) >= 0;
if (!categoryExists) {
if (!isEmpty(node.session.category)) {
categoryList.push(node.session.category);
}
}
});
return categoryList;
});
const sessionsInCategory = ref([]);
let sessionList = computed(() => sessions.value.filter(function(session) {
if (isEmpty(session.category)) {
//session.category.sessions.push(session.category);
return session;
}
}));
let categoryWithSessions = computed(() => {
let categoriesIn = [];
sessions.value.forEach(function(session) {
if (!isEmpty(session.category)) {
if (categoriesIn[session.category._id] === undefined) {
categoriesIn[session.category._id] = [];
categoriesIn[session.category._id]['sessions'] = [];
}
categoriesIn[session.category._id]['sessions'].push(session);
}
});
return categoriesIn;
});
function getSessionsFromCategory(category) {
return categoryWithSessions.value[category._id]['sessions'];
}
return { return {
getSessionsFromCategory,
sessionList,
sessions, sessions,
sessionsInCategory,categoryWithSessions,
categories,
loadingSessions loadingSessions
} }
} }

@ -45,7 +45,7 @@ final class SessionRelUserExtension implements QueryCollectionExtensionInterface
} }
if (null === $user = $this->security->getUser()) { if (null === $user = $this->security->getUser()) {
throw new AccessDeniedException('Access Denied.'); throw new AccessDeniedException('Access Denied SessionRelUser');
} }
$rootAlias = $queryBuilder->getRootAliases()[0]; $rootAlias = $queryBuilder->getRootAliases()[0];

Loading…
Cancel
Save