From 15daaebab9d4e6a76d3757f41c46894fcc8ba002 Mon Sep 17 00:00:00 2001 From: John Cardinal Date: Tue, 13 Nov 2018 22:31:57 +0000 Subject: [PATCH] --- app/ayanova/package-lock.json | 21 +++++++++++++++++++++ app/ayanova/package.json | 3 ++- app/ayanova/src/api/locale.js | 20 ++------------------ app/ayanova/src/store.js | 2 ++ app/ayanova/src/utils/roles.js | 5 ----- devdocs/todo.txt | 3 ++- devdocs/tools.txt | 16 +--------------- 7 files changed, 30 insertions(+), 40 deletions(-) diff --git a/app/ayanova/package-lock.json b/app/ayanova/package-lock.json index 93ff9b8c..e3ade940 100644 --- a/app/ayanova/package-lock.json +++ b/app/ayanova/package-lock.json @@ -13512,6 +13512,11 @@ "integrity": "sha512-vFwSUfQvqybiICwZY5+DAWIPLKsWO31Q91JSKl3UYv+K5c2QRPzn0qzec6QPu1Qc9eHYItiP3NdJqNVqetYAww==", "dev": true }, + "shvl": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/shvl/-/shvl-1.3.1.tgz", + "integrity": "sha512-+rRPP46hloYUAEImJcqprUgXu+05Ikqr4h4V+w5i2zJy37nAqtkQKufs3+3S2fDq6JNRrHMIQhB/Vaex+jgAAw==" + }, "sigmund": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/sigmund/-/sigmund-1.0.1.tgz", @@ -15334,6 +15339,22 @@ "resolved": "https://registry.npmjs.org/vuex/-/vuex-3.0.1.tgz", "integrity": "sha512-wLoqz0B7DSZtgbWL1ShIBBCjv22GV5U+vcBFox658g6V0s4wZV9P4YjCNyoHSyIBpj1f29JBoNQIqD82cR4O3w==" }, + "vuex-persistedstate": { + "version": "2.5.4", + "resolved": "https://registry.npmjs.org/vuex-persistedstate/-/vuex-persistedstate-2.5.4.tgz", + "integrity": "sha512-XYJhKIwO+ZVlTaXyxKxnplrJ88Fnvk5aDw753bxzRw5/yMKLQ6lq9CDCBex2fwZaQcLibhtgJOxGCHjy9GLSlQ==", + "requires": { + "deepmerge": "^2.1.0", + "shvl": "^1.3.0" + }, + "dependencies": { + "deepmerge": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/deepmerge/-/deepmerge-2.2.1.tgz", + "integrity": "sha512-R9hc1Xa/NOBi9WRVUWg19rl1UB7Tt4kuPd+thNJgFZoxXsTz7ncaPaeIm+40oSGuP33DfMb4sZt1QIGiJzC4EA==" + } + } + }, "w3c-hr-time": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/w3c-hr-time/-/w3c-hr-time-1.0.1.tgz", diff --git a/app/ayanova/package.json b/app/ayanova/package.json index f6267655..3bd64edb 100644 --- a/app/ayanova/package.json +++ b/app/ayanova/package.json @@ -16,7 +16,8 @@ "vue": "^2.5.17", "vue-router": "^3.0.1", "vuetify": "^1.3.0", - "vuex": "^3.0.1" + "vuex": "^3.0.1", + "vuex-persistedstate": "^2.5.4" }, "devDependencies": { "@cypress/webpack-preprocessor": "^3.0.0", diff --git a/app/ayanova/src/api/locale.js b/app/ayanova/src/api/locale.js index 03efcab5..2c771421 100644 --- a/app/ayanova/src/api/locale.js +++ b/app/ayanova/src/api/locale.js @@ -3,24 +3,8 @@ import config from "../utils/config"; import api from "./apiutil"; import _ from "../utils/libs/core.min.js"; -/* -Locale: -Methods - - This module is responsible for handling all localized text operations - - It stores a local in memory cache of the keys and returns them from cache whenever possible - - Method: Get keys one at a time or in an array - - a method that accepts lt keys and returns their text - - If a key is not in the cache here then it returns an obvious error string - - Method: pre-fetch / Cache keys - - Used to pre-fetch a bunch of keys at once if necessary - - A caller will call this with the list of keys it will need in advance, the ones that are not present in the cache will be fetched from the server and the cache populated - - No text is actually returned at this point, it's just a pre-setup kind of thing to ensure better perf later - - Method: Clear cache - - Clear the local cache entirely - - -*/ - +//Keep the localized text keys here temporarily +//TODO: rehydrate on page refresh / put in sessionstorage var lt = {}; export default { diff --git a/app/ayanova/src/store.js b/app/ayanova/src/store.js index de84d19b..a7ce28e8 100644 --- a/app/ayanova/src/store.js +++ b/app/ayanova/src/store.js @@ -1,9 +1,11 @@ import Vue from "vue"; import Vuex from "vuex"; +import createPersistedState from "vuex-persistedstate"; Vue.use(Vuex); export default new Vuex.Store({ + plugins: [createPersistedState()], state: { authenticated: false, apiUrl: "http://localhost:7575/api/v8.0/", diff --git a/app/ayanova/src/utils/roles.js b/app/ayanova/src/utils/roles.js index 74b009da..6aae7f22 100644 --- a/app/ayanova/src/utils/roles.js +++ b/app/ayanova/src/utils/roles.js @@ -39,10 +39,5 @@ export default { return false; } return role === (store.state.roles & role); - //https://stackoverflow.com/questions/39359740/what-are-enum-flags-in-typescript - //https://stackoverflow.com/questions/15551652/javascript-enum-flag-check - // if ((role & flags.ERROR) == flags.ERROR) { - // alert("ERROR IS SET"); - // } } }; diff --git a/devdocs/todo.txt b/devdocs/todo.txt index 4b1651d3..eea31a31 100644 --- a/devdocs/todo.txt +++ b/devdocs/todo.txt @@ -31,9 +31,10 @@ WEEK OF 2018-11-12 - RAVEN shell start work. YAY! NEXT UP / CURRENTLY WORKING ON: - + - lookup naming guidelines for javascript functions (capitalized?) and fixup the code and stick to it. - Look over the (now two) api calls and look for optimization and code shrinkage / de-duplication + - Handle refresh with session storage and how to rehydrate stuff - Move on to the next thing (build and post?) diff --git a/devdocs/tools.txt b/devdocs/tools.txt index 21918f1b..dee37d85 100644 --- a/devdocs/tools.txt +++ b/devdocs/tools.txt @@ -79,23 +79,9 @@ https://vuex.vuejs.org/guide/structure.html VUEX STATE PERSISTENCE = VUEX-PERSISTEDSTATE =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- - https://github.com/robinvdvleuten/vuex-persistedstate - - Some stuff should probably be persisted like auth, maybe other stuff? - - Is this app an online only app? - - Store enough stuff to keep working locally? - - Fill out a workorder offline? - - Create a new one offline? - - enter labour only, no parts or other lengthy lookup stuff?? - - If recreating AyaNova 7 essentially, then that app is always online as well so maybe don't even consider offline work? + - Many things need to be persisted and survive a refresh so this is how it will be done -LOCALSTORAGE = Built in -=-=-=-=-=-=-=-=-=-=-=-= - - All modern browsers should support it and less libs the better - - Fallback if find it doesn't work: - - = STORE.JS Very widely used and I don't necessarily need a VUE specific one, this is the one used for pecklist and rockfish - - https://github.com/marcuswestin/store.js/ - - SERVICEWORKER = WORKBOX =-=-=-=-=-=-=-=-=-=-=-= For offsite PWA use, works well and is simple to implement