repos
/ timestrap-django master

timestrap-django

mirror archived upstream

Time tracking you can host anywhere, built on Django. Full export support in multiple formats and easily extensible.

djangodockerhandcodedpythonself-hostedtime-trackingtimetracker

1.4 KB · 62 lines · JavaScript Raw History
 1import Vue from 'vue';
 2import Vuex from 'vuex';
 3
 4import entries from './modules/entries';
 5import tasks from './modules/tasks';
 6import clients from './modules/clients';
 7import projects from './modules/projects';
 8import users from './modules/users';
 9import reports from './modules/reports';
10import permissions from './modules/permissions';
11
12
13// Setup Vuex plugin so we can add store to our Vue
14
15Vue.use(Vuex);
16
17
18// Create and export store with all modules for use in main
19
20export default new Vuex.Store({
21  state: {
22    maxLoading: 0,
23    loading: [],
24  },
25  getters: {
26    loadingPercent: (state) => {
27      if (state.loading.length > 0) return (1 - (state.loading.length / state.maxLoading)) * 100;
28      else return 100;
29    },
30    doneLoading: (state) => {
31      if (state.maxLoading === 0) return true;
32      else return false;
33    },
34  },
35  mutations: {
36    addLoading: (state, module) => {
37      state.loading.push(module);
38      state.maxLoading++;
39    },
40    removeLoading: (state, module) => {
41      Vue.delete(
42        state.loading,
43        state.loading.indexOf(module),
44      );
45      if (state.loading.length === 0) {
46        setTimeout(() => {
47          state.maxLoading = 0;
48        }, 500);
49      }
50    },
51  },
52  modules: {
53    entries: entries,
54    tasks: tasks,
55    clients: clients,
56    projects: projects,
57    users: users,
58    reports: reports,
59    permissions: permissions,
60  },
61});