mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-09-30 18:39:43 +00:00
remove unused files
This commit is contained in:
@@ -1,114 +0,0 @@
|
||||
import {makeFetch, fetchResults} from 'ChillMainAssets/lib/api/apiMethods';
|
||||
import {fetchCalendarRangeForUser} from 'ChillCalendarAssets/vuejs/Calendar/api';
|
||||
import {ActionContext} from 'vuex';
|
||||
import {State} from './index';
|
||||
|
||||
type Context = ActionContext<State, State>;
|
||||
|
||||
const actions = {
|
||||
setCurrentDatesView(, {start, end}) {
|
||||
commit('setCurrentDatesView', {start, end});
|
||||
dispatch('fetchRanges');
|
||||
},
|
||||
fetchRanges({commit, state}, payload = null) {
|
||||
if (state.me === null) {
|
||||
console.log('me is not there');
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
if (state.currentView.start === null || state.currentView.end === null) {
|
||||
console.log('current view dates are null');
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
if (getters.isRangeLoaded) {
|
||||
console.log('range already loaded');
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
commit('addLoaded', {start: state.currentView.start, end: state.currentView.end});
|
||||
|
||||
return fetchCalendarRangeForUser(state.me, state.currentView.start, state.currentView.end)
|
||||
.then(ranges => {
|
||||
commit('setRanges', ranges);
|
||||
return Promise.resolve();
|
||||
})
|
||||
.catch(err => {
|
||||
console.error(err);
|
||||
return Promise.resolve();
|
||||
})
|
||||
;
|
||||
},
|
||||
postRange({commit}, payload) {
|
||||
const url = `/api/1.0/calendar/calendar-range.json?`;
|
||||
makeFetch('POST', url, payload)
|
||||
.then((response) => {
|
||||
const newRange =
|
||||
{
|
||||
start: response.startDate.datetime,
|
||||
end: response.endDate.datetime,
|
||||
calendarRangeId: response.id,
|
||||
toDelete: false
|
||||
}
|
||||
commit('addRange', newRange)
|
||||
})
|
||||
.catch((error) => {
|
||||
console.log(error);
|
||||
})
|
||||
},
|
||||
deleteRange({commit}, payload) {
|
||||
const url = `/api/1.0/calendar/calendar-range/${payload}.json`;
|
||||
makeFetch('DELETE', url)
|
||||
.then((response) => {
|
||||
if (response == 200) {
|
||||
commit('removeRange', payload);
|
||||
}
|
||||
})
|
||||
.catch((error) => {
|
||||
console.log(error);
|
||||
})
|
||||
},
|
||||
patchRange({commit}, payload) {
|
||||
const url = `/api/1.0/calendar/calendar-range/${payload.extendedProps.calendarRangeId}.json`;
|
||||
const body = {
|
||||
startDate: {
|
||||
datetime: `${payload.start.toISOString().split('.')[0]}+0000`, //should be like "2021-08-20T15:00:00+0200",
|
||||
},
|
||||
endDate: {
|
||||
datetime: `${payload.end.toISOString().split('.')[0]}+0000`, // TODO check if OK with time zone
|
||||
},
|
||||
}
|
||||
makeFetch('PATCH', url, body)
|
||||
.then((response) => {
|
||||
console.log('response', response);
|
||||
})
|
||||
.catch((error) => {
|
||||
console.log(error);
|
||||
})
|
||||
},
|
||||
fetchAppointments({commit}, payload) {
|
||||
const url = `/api/1.0/calendar/calendar.json?main_user=${payload}&item_per_page=1000`
|
||||
makeFetch('GET', url)
|
||||
.then((response) => {
|
||||
const appointments = response.results.map(a => (
|
||||
{
|
||||
myCalendar: true,
|
||||
calendarId: a.id,
|
||||
start: a.startDate.datetime,
|
||||
end: a.endDate.datetime,
|
||||
user: a.user,
|
||||
mainUser: a.mainUser,
|
||||
persons: a.persons,
|
||||
professionals: a.professionals,
|
||||
comment: a.comment
|
||||
})
|
||||
);
|
||||
commit('setAppointments', appointments)
|
||||
})
|
||||
.catch((error) => {
|
||||
console.log(error);
|
||||
})
|
||||
},
|
||||
};
|
||||
|
||||
export default actions;
|
@@ -1,33 +0,0 @@
|
||||
const getters = {
|
||||
rangeSource(state) {
|
||||
return {
|
||||
events: state.ranges,
|
||||
borderColor: "#3788d8",
|
||||
backgroundColor: '#ffffff',
|
||||
textColor: '#444444',
|
||||
}
|
||||
},
|
||||
appointmentSource(state) {
|
||||
if (state.appointmentsShown) {
|
||||
return {
|
||||
events: state.appointments,
|
||||
color: "darkblue",
|
||||
id: 1000,
|
||||
editable: false
|
||||
}
|
||||
} else {
|
||||
return null
|
||||
}
|
||||
},
|
||||
isRangeLoaded: (state) => (start, end) => {
|
||||
for (let {rStart, rEnd} of state.rangesLoaded) {
|
||||
if (start === rStart && end === rEnd) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
},
|
||||
};
|
||||
|
||||
export default getters;
|
@@ -1,39 +0,0 @@
|
||||
import {State} from './index';
|
||||
import {CalendarRange, Calendar, User} from 'ChillCalendarAssets/types';
|
||||
|
||||
const mutations = {
|
||||
setCurrentDatesView(state: State, payload: {start: Date, end: Date}) {
|
||||
state.currentView.start = payload.start;
|
||||
state.currentView.end = payload.end;
|
||||
},
|
||||
addRanges(state: State, ranges: CalendarRange[]) {
|
||||
console.log('addRanges', ranges);
|
||||
|
||||
const toAdd = ranges.filter(r => !state.rangesIndex.has(r.id));
|
||||
state.ranges.push(...toAdd);
|
||||
toAdd.forEach((r) => {state.rangesIndex.add(r.id)});
|
||||
},
|
||||
addLoaded(state: State, payload: {start: Date, end: Date}) {
|
||||
state.rangesLoaded.push({start: payload.start, end: payload.end});
|
||||
},/*
|
||||
setRangesToCopy(state: State, payload: CalendarRange[]) {
|
||||
state.rangesToCopy = payload
|
||||
},*/
|
||||
addRange(state: State, payload: CalendarRange) {
|
||||
state.ranges = [...state.ranges, payload];
|
||||
},
|
||||
removeRange(state: State, payload: CalendarRange) {
|
||||
const filteredCollection = state.ranges.filter(
|
||||
(r) => r.calendarRangeId !== payload
|
||||
)
|
||||
state.ranges = filteredCollection;
|
||||
},
|
||||
setAppointments(state: State, payload: Calendar) {
|
||||
state.appointments = payload;
|
||||
},
|
||||
setAppointmentShown(state: State, payload: boolean) {
|
||||
state.appointmentsShown = payload
|
||||
}
|
||||
};
|
||||
|
||||
export default mutations;
|
Reference in New Issue
Block a user