-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of github.com:zeroshade/knkpwa
- Loading branch information
Showing
13 changed files
with
265 additions
and
77 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
<template> | ||
<v-edit-dialog | ||
:return-value.sync='saved' | ||
lazy | ||
@open='open' | ||
@save='save' | ||
@cancel='$emit("cancel")' | ||
@close='$emit("close")'> | ||
{{ value }} | ||
<v-combobox slot='input' | ||
:rules='[(v) => !!v || "Cannot be empty"]' | ||
:multiple='multiple' | ||
:chips='chips' | ||
v-model='saved' | ||
:label='label' | ||
:items='items'></v-combobox> | ||
</v-edit-dialog> | ||
</template> | ||
|
||
<script lang='ts'> | ||
import { Prop, Component, Vue, Emit } from 'vue-property-decorator'; | ||
@Component | ||
export default class InlineCombobox extends Vue { | ||
@Prop(String) public value!: string; | ||
@Prop(String) public label!: string; | ||
@Prop(Array) public items!: string[]; | ||
@Prop({default: false}) public multiple!: boolean; | ||
@Prop({default: false}) public chips!: boolean; | ||
public saved: string | string[] = ''; | ||
public save() { | ||
if (this.saved) { | ||
if (this.multiple) { | ||
this.$emit('input', (this.saved as string[]).join(', ')); | ||
} else { | ||
this.$emit('input', this.saved); | ||
} | ||
this.$emit('save'); | ||
} else { | ||
this.$emit('cancel'); | ||
} | ||
} | ||
@Emit() | ||
public open() { | ||
if (this.multiple) { | ||
console.log(this.value, this.value.split(',')); | ||
this.saved = this.value.split(',').map((o) => o.trim()); | ||
} else { | ||
this.saved = this.value; | ||
} | ||
} | ||
} | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,32 @@ | ||
import Vue from 'vue'; | ||
import VueRouter, { Route } from 'vue-router'; | ||
Vue.use(VueRouter); | ||
|
||
export default new VueRouter({ | ||
mode: 'history', | ||
base: process.env.BASE_URL, | ||
routes: [ | ||
{ path: '/', redirect: '/rooms' }, | ||
{ | ||
path: '/rooms', name: 'home', | ||
component: () => import(/* webpackChunkName: "group-app" */ '@/views/RoomGrid.vue'), | ||
}, | ||
{ | ||
path: '/agenda', name: 'agenda', | ||
component: () => import(/* webpackChunkName: "group-app" */ '@/views/Agenda.vue'), | ||
}, | ||
{ | ||
path: '/events', name: 'events', | ||
component: () => import(/* webpackChunkName: "group-app" */ '@/views/Events.vue'), | ||
}, | ||
{ | ||
path: '/callback', component: () => import(/* webpackChunkName: "group-auth" */ '@/views/Auth.vue'), name: 'auth', | ||
}, | ||
], | ||
}); | ||
import Vue from 'vue'; | ||
import VueRouter, { Route } from 'vue-router'; | ||
Vue.use(VueRouter); | ||
|
||
const props = (route: Route) => ({ id: +route.params.id || 3 }); | ||
|
||
export default new VueRouter({ | ||
mode: 'history', | ||
base: process.env.BASE_URL, | ||
routes: [ | ||
{ path: '/', redirect: '/rooms' }, | ||
{ | ||
path: '/rooms/:id?', name: 'rooms', | ||
props, | ||
component: () => import(/* webpackChunkName: "group-app" */ '@/views/RoomGrid.vue'), | ||
}, | ||
{ | ||
path: '/agenda/:id?', name: 'agenda', | ||
props, | ||
component: () => import(/* webpackChunkName: "group-app" */ '@/views/Agenda.vue'), | ||
}, | ||
{ | ||
path: '/events/:id?', name: 'events', | ||
props, | ||
component: () => import(/* webpackChunkName: "group-app" */ '@/views/Events.vue'), | ||
}, | ||
{ | ||
path: '/callback', component: () => import(/* webpackChunkName: "group-auth" */ '@/views/Auth.vue'), | ||
name: 'auth', | ||
}, | ||
], | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
import { AdminState, RootState } from './states'; | ||
import { Module } from 'vuex'; | ||
import sched, { Schedule, ISchedule } from '@/api/schedule'; | ||
import event, { Event } from '@/api/event'; | ||
import colors from 'vuetify/es5/util/colors'; | ||
|
||
function camelCaseToDash(str: string): string { | ||
return str | ||
.replace(/[^a-zA-Z0-9]+/g, '-') | ||
.replace(/([A-Z]+)([A-Z][a-z])/g, '$1-$2') | ||
.replace(/([a-z])([A-Z])/g, '$1-$2') | ||
.replace(/([0-9])([^0-9])/g, '$1-$2') | ||
.replace(/([^0-9])([0-9])/g, '$1-$2') | ||
.replace(/-+/g, '-') | ||
.toLowerCase(); | ||
} | ||
|
||
const adminModule: Module<AdminState, RootState> = { | ||
namespaced: true, | ||
state: { | ||
schedule: null, | ||
events: [], | ||
colorNames: Object.keys(colors).map(camelCaseToDash), | ||
modifierNames: Object.keys(colors.red).map(camelCaseToDash), | ||
}, | ||
getters: { | ||
sched(state) { | ||
return state.schedule; | ||
}, | ||
events(state) { | ||
return state.events; | ||
}, | ||
}, | ||
mutations: { | ||
setSched(state: AdminState, payload: Schedule) { | ||
state.schedule = payload; | ||
}, | ||
setEvents(state: AdminState, payload: Event[]) { | ||
state.events = payload; | ||
}, | ||
updateEvent(state: AdminState, payload: Event) { | ||
const idx = state.events.findIndex((e) => e.id === payload.id); | ||
if (idx !== -1) { | ||
state.events.splice(idx, 1, payload); | ||
} else { | ||
state.events.push(payload); | ||
} | ||
}, | ||
removeEvent(state: AdminState, id: number) { | ||
const idx = state.events.findIndex((e) => e.id === id); | ||
state.events.splice(idx, 1); | ||
}, | ||
}, | ||
actions: { | ||
async loadSchedById({ commit }, id: number) { | ||
const s = await sched.getSchedule(id); | ||
commit('setSched', s); | ||
const e = await event.getEvents(id); | ||
commit('setEvents', e); | ||
}, | ||
async deleteSchedule({ dispatch }, id: number) { | ||
await dispatch('auth/makeAuthedRequest', { | ||
path: `/scheds/${id}`, | ||
method: 'DELETE', | ||
}, { root: true }); | ||
await dispatch('fetchScheds', undefined, { root: true }); | ||
}, | ||
async newSchedule({ dispatch }, payload: ISchedule) { | ||
await dispatch('auth/makeAuthedRequest', { | ||
path: '/scheds', | ||
method: 'POST', | ||
body: payload, | ||
}, { root: true }); | ||
await dispatch('fetchScheds', undefined, { root: true }); | ||
}, | ||
async updateSchedule({ commit, dispatch }, payload: Schedule) { | ||
commit('setSched', payload); | ||
await dispatch('auth/makeAuthedRequest', { | ||
path: `/scheds/${payload.id}`, | ||
method: 'PUT', | ||
body: payload.getISched(), | ||
}, { root: true }); | ||
}, | ||
async updateEvent({ commit, dispatch }, payload: Event) { | ||
commit('updateEvent', payload); | ||
const body = payload.getIEvent(); | ||
let path = '/events'; | ||
let method = 'POST'; | ||
if (payload.id !== 0) { | ||
path += `/${payload.id}`; | ||
method = 'PUT'; | ||
} | ||
|
||
await dispatch('auth/makeAuthedRequest', { | ||
path, method, body, | ||
}, { root: true }); | ||
}, | ||
async delEvent({ commit, dispatch }, id: number) { | ||
commit('removeEvent', id); | ||
await dispatch('auth/makeAuthedRequest', { | ||
path: `/events/${id}`, | ||
method: 'DELETE', | ||
}, { root: true }); | ||
}, | ||
}, | ||
}; | ||
|
||
export default adminModule; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.