Skip to content

Commit

Permalink
Issue #14: fix saving/restoring state
Browse files Browse the repository at this point in the history
  • Loading branch information
jarrah42 committed Apr 13, 2021
1 parent 3852650 commit 2754965
Show file tree
Hide file tree
Showing 6 changed files with 115 additions and 102 deletions.
6 changes: 6 additions & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#
# NOTICE: this is an auto-generated file
#
# This file sets the default parameters for manual `pnpm install`.
#
shamefully-hoist=true
2 changes: 2 additions & 0 deletions .settings/org.springframework.ide.eclipse.boot.prefs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
eclipse.preferences.version=1
spring.boot.launch.profile.history=production;
1 change: 1 addition & 0 deletions frontend/generated/vaadin.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
import '../../target/index';
170 changes: 93 additions & 77 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,136 +5,152 @@
"@polymer/polymer": "3.2.0",
"@vaadin/flow-frontend": "./target/flow-frontend",
"@vaadin/router": "1.7.2",
"@vaadin/vaadin-grid": "5.7.4",
"@vaadin/vaadin-icons": "4.3.1",
"@vaadin/vaadin-grid": "6.0.1",
"@vaadin/vaadin-icons": "4.3.2",
"@vaadin/vaadin-split-layout": "4.3.0",
"@vaadin/vaadin-combo-box": "5.3.0",
"@vaadin/vaadin-core-shrinkwrap": "17.0.7",
"@vaadin/vaadin-upload": "4.4.0",
"@vaadin/vaadin-combo-box": "6.0.1",
"@vaadin/vaadin-core-shrinkwrap": "19.0.4",
"@vaadin/vaadin-upload": "5.0.0",
"@vaadin/vaadin-dialog": "2.5.2",
"@vaadin/vaadin-select": "2.3.0",
"@vaadin/vaadin-select": "3.0.0",
"@vaadin/vaadin-app-layout": "2.2.0",
"@vaadin/vaadin-item": "2.3.0",
"@vaadin/vaadin-notification": "1.6.0",
"@vaadin/vaadin-item": "3.0.0",
"@vaadin/vaadin-notification": "1.6.1",
"@vaadin/vaadin-progress-bar": "1.3.0",
"@vaadin/vaadin-ordered-layout": "1.4.0",
"@vaadin/vaadin-login": "1.2.0",
"@vaadin/vaadin-login": "2.0.0",
"@vaadin/vaadin-button": "2.4.0",
"@vaadin/vaadin-date-picker": "4.3.0",
"@vaadin/vaadin-text-field": "2.7.1",
"@vaadin/vaadin-menu-bar": "1.2.0",
"@vaadin/vaadin-custom-field": "1.2.0",
"@vaadin/vaadin-date-picker": "5.0.0",
"@vaadin/vaadin-text-field": "3.0.2",
"@vaadin/vaadin-menu-bar": "2.0.0",
"@vaadin/vaadin-custom-field": "2.0.0",
"@vaadin/vaadin-form-layout": "2.3.0",
"@polymer/iron-list": "3.1.0",
"@vaadin/vaadin-accordion": "1.2.0",
"@vaadin/vaadin-list-box": "1.4.0",
"@vaadin/vaadin-checkbox": "2.4.0",
"@vaadin/vaadin-list-box": "2.0.0",
"@vaadin/vaadin-checkbox": "3.0.0",
"@vaadin/vaadin-details": "1.2.0",
"@polymer/iron-icon": "3.0.1",
"@vaadin/vaadin-time-picker": "2.3.0",
"@vaadin/vaadin-context-menu": "4.5.0",
"@vaadin/vaadin-tabs": "3.2.0",
"@vaadin/vaadin-radio-button": "1.4.1",
"@vaadin/vaadin-lumo-styles": "1.6.0",
"@vaadin/vaadin-time-picker": "3.0.0",
"@vaadin/vaadin-context-menu": "5.0.0",
"@vaadin/vaadin-tabs": "4.0.0",
"@vaadin/vaadin-radio-button": "1.5.1",
"@vaadin/vaadin-lumo-styles": "1.6.1",
"@vaadin/vaadin-material-styles": "1.3.2",
"apexcharts": "3.17.0",
"onecolor": "3.1.0",
"@vaadin/vaadin-date-time-picker": "1.3.0",
"@vaadin/vaadin-date-time-picker": "2.0.0",
"lit-element": "2.3.1",
"@vaadin/form": "./target/flow-frontend/form"
"@vaadin/form": "./target/flow-frontend/form",
"@vaadin/vaadin-avatar": "2.0.2"
},
"devDependencies": {
"webpack": "4.42.0",
"webpack": "4.46.0",
"webpack-cli": "3.3.11",
"webpack-dev-server": "3.10.3",
"webpack-babel-multi-target-plugin": "2.3.3",
"copy-webpack-plugin": "5.1.1",
"webpack-dev-server": "3.11.0",
"webpack-merge": "4.2.2",
"raw-loader": "4.0.0",
"compression-webpack-plugin": "4.0.1",
"html-webpack-plugin": "3.2.0",
"script-ext-html-webpack-plugin": "2.1.4",
"typescript": "3.8.3",
"awesome-typescript-loader": "5.2.1",
"terser": "4.6.7",
"progress-webpack-plugin": "0.0.24",
"chokidar": "^3.4.0",
"validator": "12.0.0",
"lit-html": "1.2.1",
"@types/validator": "10.11.3",
"lit-element": "2.3.1"
"html-webpack-plugin": "4.5.1",
"typescript": "4.0.3",
"chokidar": "^3.5.0",
"validator": "13.1.17",
"lit-html": "1.3.0",
"@types/validator": "13.1.0",
"lit-element": "2.4.0",
"css-loader": "4.2.1",
"file-loader": "6.2.0",
"extra-watch-webpack-plugin": "1.0.3",
"glob": "7.1.6",
"lit-css-loader": "0.0.4",
"loader-utils": "2.0.0",
"construct-style-sheets-polyfill": "2.4.16",
"ts-loader": "8.0.12",
"workbox-webpack-plugin": "5.1.4",
"idb": "5.0.6",
"workbox-core": "5.1.4",
"workbox-precaching": "5.1.4",
"webpack-manifest-plugin": "3.0.0",
"extract-loader": "5.1.0"
},
"vaadin": {
"dependencies": {
"@vaadin/router": "1.7.2",
"@polymer/polymer": "3.2.0",
"@webcomponents/webcomponentsjs": "^2.2.10",
"@vaadin/vaadin-crud": "1.1.0",
"@vaadin/vaadin-grid": "5.7.4",
"@vaadin/vaadin-icons": "4.3.1",
"@vaadin/vaadin-grid": "6.0.1",
"@vaadin/vaadin-icons": "4.3.2",
"@vaadin/vaadin-split-layout": "4.3.0",
"@vaadin/vaadin-combo-box": "5.3.0",
"@vaadin/vaadin-combo-box": "6.0.1",
"@vaadin/vaadin-cookie-consent": "1.1.2",
"@vaadin/vaadin-core-shrinkwrap": "17.0.7",
"@vaadin/vaadin-upload": "4.4.0",
"@vaadin/vaadin-core-shrinkwrap": "19.0.4",
"@vaadin/vaadin-upload": "5.0.0",
"@vaadin/vaadin-dialog": "2.5.2",
"@vaadin/vaadin-select": "2.3.0",
"@vaadin/vaadin-select": "3.0.0",
"@vaadin/vaadin-app-layout": "2.2.0",
"@vaadin/vaadin-item": "2.3.0",
"@vaadin/vaadin-item": "3.0.0",
"@vaadin/vaadin-board": "2.1.1",
"@vaadin/vaadin-notification": "1.6.0",
"@vaadin/vaadin-notification": "1.6.1",
"@vaadin/vaadin-charts": "6.2.4",
"@vaadin/vaadin-grid-pro": "2.0.7",
"@vaadin/vaadin-progress-bar": "1.3.0",
"@vaadin/vaadin-shrinkwrap": "15.0.4",
"@vaadin/vaadin-ordered-layout": "1.4.0",
"@vaadin/vaadin-login": "1.2.0",
"@vaadin/vaadin-login": "2.0.0",
"@vaadin/vaadin-button": "2.4.0",
"@vaadin/vaadin-date-picker": "4.3.0",
"@vaadin/vaadin-text-field": "2.7.1",
"@vaadin/vaadin-menu-bar": "1.2.0",
"@vaadin/vaadin-custom-field": "1.2.0",
"@vaadin/vaadin-date-picker": "5.0.0",
"@vaadin/vaadin-text-field": "3.0.2",
"@vaadin/vaadin-menu-bar": "2.0.0",
"@vaadin/vaadin-custom-field": "2.0.0",
"@vaadin/vaadin-form-layout": "2.3.0",
"@vaadin/vaadin-confirm-dialog": "1.1.6",
"@polymer/iron-list": "3.1.0",
"@vaadin/vaadin-accordion": "1.2.0",
"@vaadin/vaadin-list-box": "1.4.0",
"@vaadin/vaadin-checkbox": "2.4.0",
"@vaadin/vaadin-list-box": "2.0.0",
"@vaadin/vaadin-checkbox": "3.0.0",
"@vaadin/vaadin-details": "1.2.0",
"@polymer/iron-icon": "3.0.1",
"@vaadin/vaadin-time-picker": "2.3.0",
"@vaadin/vaadin-context-menu": "4.5.0",
"@vaadin/vaadin-tabs": "3.2.0",
"@vaadin/vaadin-radio-button": "1.4.1",
"@vaadin/vaadin-lumo-styles": "1.6.0",
"@vaadin/vaadin-time-picker": "3.0.0",
"@vaadin/vaadin-context-menu": "5.0.0",
"@vaadin/vaadin-tabs": "4.0.0",
"@vaadin/vaadin-radio-button": "1.5.1",
"@vaadin/vaadin-lumo-styles": "1.6.1",
"@vaadin/vaadin-material-styles": "1.3.2",
"@vaadin/vaadin-rich-text-editor": "1.1.1",
"apexcharts": "3.17.0",
"onecolor": "3.1.0",
"@vaadin/vaadin-date-time-picker": "1.3.0",
"lit-element": "2.3.1"
"@vaadin/vaadin-date-time-picker": "2.0.0",
"lit-element": "2.3.1",
"@vaadin/vaadin-avatar": "2.0.2"
},
"devDependencies": {
"webpack-babel-multi-target-plugin": "2.3.3",
"copy-webpack-plugin": "5.1.1",
"compression-webpack-plugin": "4.0.1",
"raw-loader": "4.0.0",
"webpack-cli": "3.3.11",
"webpack": "4.42.0",
"html-webpack-plugin": "3.2.0",
"script-ext-html-webpack-plugin": "2.1.4",
"awesome-typescript-loader": "5.2.1",
"typescript": "3.8.3",
"webpack": "4.46.0",
"html-webpack-plugin": "4.5.1",
"typescript": "4.0.3",
"webpack-merge": "4.2.2",
"webpack-dev-server": "3.10.3",
"terser": "4.6.7",
"progress-webpack-plugin": "0.0.24",
"chokidar": "^3.4.0",
"validator": "12.0.0",
"lit-html": "1.2.1",
"@types/validator": "10.11.3",
"lit-element": "2.3.1"
"webpack-dev-server": "3.11.0",
"chokidar": "^3.5.0",
"validator": "13.1.17",
"lit-html": "1.3.0",
"@types/validator": "13.1.0",
"lit-element": "2.4.0",
"css-loader": "4.2.1",
"file-loader": "6.2.0",
"extra-watch-webpack-plugin": "1.0.3",
"glob": "7.1.6",
"lit-css-loader": "0.0.4",
"loader-utils": "2.0.0",
"construct-style-sheets-polyfill": "2.4.16",
"ts-loader": "8.0.12",
"workbox-webpack-plugin": "5.1.4",
"idb": "5.0.6",
"workbox-core": "5.1.4",
"workbox-precaching": "5.1.4",
"webpack-manifest-plugin": "3.0.0",
"extract-loader": "5.1.0"
},
"hash": "d6b263dfb4954fd591b30231fd01efb20c902a47ff627bcba641f81c08bf598c"
"hash": "37498f9a177dc06c4e43a7d2ff720f2dee5daceb02332d9f22703e999ae55d25"
}
}
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
<maven.clean.plugin.version>3.0.0</maven.clean.plugin.version>
<maven.surefire.plugin.version>2.21.0</maven.surefire.plugin.version>

<vaadin.version>17.0.7</vaadin.version>
<vaadin.version>19.0.4</vaadin.version>
<jetty.version>9.4.15.v20190215</jetty.version>
</properties>

Expand Down
36 changes: 12 additions & 24 deletions src/main/java/io/bssw/psip/ui/views/Assessment.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,6 @@
*******************************************************************************/
package io.bssw.psip.ui.views;

import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
Expand Down Expand Up @@ -215,15 +211,12 @@ private String generateSaveUrl(Activity activity) {
Iterator<Item> itemIter = category.getItems().iterator();
while (itemIter.hasNext()) {
Item item = itemIter.next();
nested.append(item.getPath() + "=" + item.getScore().orElse(0));
nested.append(item.getPath() + ":" + item.getScore().orElse(0));
if (itemIter.hasNext()) {
nested.append("&");
nested.append("+");
}
}
try {
query.append(URLEncoder.encode(nested.toString(), StandardCharsets.UTF_8.toString()));
} catch (UnsupportedEncodingException e1) {
}
query.append(nested.toString());
if (categoryIter.hasNext()) {
query.append("&");
}
Expand All @@ -242,23 +235,18 @@ private void restoreSaveUrl(Activity activity, Map<String, List<String>> paramet
List<String> values = parameters.get(categoryPath);
if (!values.isEmpty()) {
// Only use the first value
try {
String subQuery = URLDecoder.decode(values.get(0), StandardCharsets.UTF_8.toString());
for (String itemScore : subQuery.split("&")) {
String[] kv = itemScore.split("=");
if (kv.length == 2) {
Item item = activityService.getItem("assessment/" + categoryPath + "/" + kv[0]);
if (item != null) {
try {
item.setScore(Integer.parseInt(kv[1]));
} catch (NumberFormatException e) {
// Skip it
}
for (String itemScore : values.get(0).split("\\+")) {
String[] kv = itemScore.split(":");
if (kv.length == 2) {
Item item = activityService.getItem("assessment/" + categoryPath + "/" + kv[0]);
if (item != null) {
try {
item.setScore(Integer.parseInt(kv[1]));
} catch (NumberFormatException e) {
// Skip it
}
}
}
} catch (UnsupportedEncodingException e) {
// Skip it
}
}
}
Expand Down

0 comments on commit 2754965

Please sign in to comment.