Mercurial > gemma
diff client/src/store/application.js @ 1096:aa1f5daf6fc9
refac: centralized stores
author | Thomas Junk <thomas.junk@intevation.de> |
---|---|
date | Tue, 30 Oct 2018 16:55:29 +0100 |
parents | client/src/application/stores/application.js@7ec2133c6404 |
children | 8d12056d602a |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/client/src/store/application.js Tue Oct 30 16:55:29 2018 +0100 @@ -0,0 +1,132 @@ +/* This is Free Software under GNU Affero General Public License v >= 3.0 + * without warranty, see README.md and license for details. + * + * SPDX-License-Identifier: AGPL-3.0-or-later + * License-Filename: LICENSES/AGPL-3.0.txt + * + * Copyright (C) 2018 by via donau + * – Österreichische Wasserstraßen-Gesellschaft mbH + * Software engineering by Intevation GmbH + * + * Author(s): + * Thomas Junk <thomas.junk@intevation.de> + * Markus Kottländer <markus.kottlaender@intevation.de> + * Bernhard E. Reiter <bernhard.reiter@intevation.de> + */ + +import { version } from "../../package.json"; + +const defaultCollapseState = true; + +const initializeSplitScreen = () => { + return { + active: false, + mode: "v" + }; +}; + +const Application = { + namespaced: true, + state: { + appTitle: process.env.VUE_APP_TITLE, + secondaryLogo: process.env.VUE_APP_SECONDARY_LOGO_URL, + sidebar: { + iscollapsed: defaultCollapseState + }, + bottlenecksCollapsed: true, + splitsceen: initializeSplitScreen(), + usermenu: { + iscollapsed: defaultCollapseState + }, + countries: ["AT", "SK", "HU", "HR", "RS", "BiH", "BG", "RO", "UA"], + // there are three states of drawMode: null, "LineString", "Polygon" + drawMode: null, + version + }, + getters: { + countries: state => { + return state.countries; + }, + sidebarCollapsed: state => { + return state.sidebar.iscollapsed; + }, + isUsermenuCollapsed: state => { + return state.usermenu.iscollapsed; + }, + appTitle: state => { + return state.appTitle; + }, + secondaryLogo: state => { + return state.secondaryLogo; + }, + isSplitscreen: state => { + return state.splitsceen.active; + }, + splitMode: state => { + return state.splitsceen.mode; + }, + versionStr: state => { + // version number from package.json + let versionStr = "v" + state.version; + + // hg revision + if ( + process.env.VUE_APP_HGREV && + (state.version.includes("dev") || + state.version.includes("beta") || + state.version.includes("alpha")) + ) + versionStr += " " + process.env.VUE_APP_HGREV; + + return versionStr; + } + }, + mutations: { + toggleSidebar: state => { + state.sidebar.iscollapsed = !state.sidebar.iscollapsed; + }, + toggleBottlenecks: state => { + state.bottlenecksCollapsed = !state.bottlenecksCollapsed; + }, + toggleUserMenu: state => { + state.usermenu.iscollapsed = !state.usermenu.iscollapsed; + }, + toggleSplitScreen: state => { + state.splitsceen.active = !state.splitsceen.active; + }, + openSplitScreen: state => { + state.splitsceen.active = true; + }, + closeSplitScreen: state => { + state.splitsceen.active = false; + }, + resetSidebar: state => { + state.sidebar.iscollapsed = defaultCollapseState; + }, + collapseSidebar: state => { + state.sidebar.iscollapsed = true; + }, + resetUserMenu: state => { + state.usermenu.iscollapsed = defaultCollapseState; + }, + collapseUserMenu: state => { + state.usermenu.iscollapsed = true; + }, + resetSplitScreen: state => { + state.splitsceen = initializeSplitScreen(); + }, + toggleDrawModeLine: state => { + if (state.drawMode) { + state.drawMode = null; + } else { + state.drawMode = "LineString"; + } + }, + activateDrawModePolygon: state => { + state.drawMode = "Polygon"; + } + }, + actions: {} +}; + +export default Application;