From 1ad5246fba095ed5e732dd1d174981e72ff8dd27 Mon Sep 17 00:00:00 2001 From: John Cardinal Date: Tue, 22 Dec 2020 15:35:24 +0000 Subject: [PATCH] --- ayanova/src/api/gzmenu.js | 4 ++-- ayanova/src/api/gzutil.js | 12 ++++++++++++ ayanova/src/views/home-review.vue | 12 +++++++----- ayanova/src/views/home-reviews.vue | 17 ++++++++++++----- 4 files changed, 33 insertions(+), 12 deletions(-) diff --git a/ayanova/src/api/gzmenu.js b/ayanova/src/api/gzmenu.js index 7aca31cf..ef03f4b8 100644 --- a/ayanova/src/api/gzmenu.js +++ b/ayanova/src/api/gzmenu.js @@ -305,8 +305,8 @@ export default { vm.$router.push({ name: "home-reviews", params: { - objectType: Number.parseInt(item.data.ayaType, 10), - objectId: Number.parseInt(item.data.recordId, 10), + objectType: window.$gz.util.stringToIntOrNull(item.data.ayaType), + objectId: window.$gz.util.stringToIntOrNull(item.data.recordId), name: objName } }); diff --git a/ayanova/src/api/gzutil.js b/ayanova/src/api/gzutil.js index 85994d15..a8017dd2 100644 --- a/ayanova/src/api/gzutil.js +++ b/ayanova/src/api/gzutil.js @@ -607,6 +607,18 @@ export default { return obj === true || obj === false || typeof variable === "boolean"; }, /////////////////////////////////////////////// + // parse to number or null if not a number + // used because route params can turn into strings + // on their own + // + stringToIntOrNull: function(n) { + const ret = Number.parseInt(n, 10); + if (Number.isNaN(ret)) { + return null; + } + return ret; + }, + /////////////////////////////////////////////// // Use geolocation api to attempt to get current location // try high accuracy first and downgrade if unavailable //https://www.openstreetmap.org/?mlat=48.3911&mlon=-124.7353#map=12/48.3910/-124.7353 diff --git a/ayanova/src/views/home-review.vue b/ayanova/src/views/home-review.vue index c9dced9f..71208896 100644 --- a/ayanova/src/views/home-review.vue +++ b/ayanova/src/views/home-review.vue @@ -218,9 +218,13 @@ export default { } else { //New record so there has to be a object type and objectId in route // path: "/home-reviews/:recordid/:objectType?/:objectId?", + vm.obj.objectId = window.$gz.util.stringToIntOrNull( + vm.$route.params.objectId + ); + vm.obj.objectType = window.$gz.util.stringToIntOrNull( + vm.$route.params.objectType + ); - vm.obj.objectId = vm.$route.params.objectId; - vm.obj.objectType = vm.$route.params.objectType; if (!vm.obj.objectId || !vm.obj.objectType) { throw "ObjectType and ObjectId are required to set a reminder"; } @@ -346,9 +350,7 @@ export default { }, iconForType() { - return window.$gz.util.iconForType( - Number.parseInt(this.obj.objectType, 10) - ); + return window.$gz.util.iconForType(this.obj.objectType); }, hasSupervisorRole: function() { //mirrored from ReviewBiz.cs validation rule at server diff --git a/ayanova/src/views/home-reviews.vue b/ayanova/src/views/home-reviews.vue index 17c42ed7..12d2b3a2 100644 --- a/ayanova/src/views/home-reviews.vue +++ b/ayanova/src/views/home-reviews.vue @@ -35,8 +35,15 @@ export default { vm.rights = window.$gz.role.getRights(window.$gz.type.Review); window.$gz.eventBus.$on("menu-click", clickHandler); - vm.objectId = vm.$route.params.objectId; - vm.objectType = vm.$route.params.objectType; + vm.objectId = window.$gz.util.stringToIntOrNull(vm.$route.params.objectId); + vm.objectType = window.$gz.util.stringToIntOrNull( + vm.$route.params.objectType + ); + + console.log("route params ingested as: ", { + id: vm.objectId, + type: vm.objectType + }); if (vm.objectId && vm.objectType) { //pre-filter @@ -44,13 +51,13 @@ export default { { fld: "metareviewobjectid", filter: { - items: [{ op: "=", value: Number.parseInt(vm.objectId, 10) }] //oddly still need this to turn it from a string even when it wasn't a string + items: [{ op: "=", value: vm.objectId }] } }, { fld: "AyaType", filter: { - items: [{ op: "=", value: Number.parseInt(vm.objectType, 10) }] + items: [{ op: "=", value: vm.objectType }] } } ]); @@ -94,7 +101,7 @@ export default { this.selectedItems = selected; }, iconForType() { - return window.$gz.util.iconForType(Number.parseInt(this.objectType, 10)); + return window.$gz.util.iconForType(this.objectType, 10); } } };