From 0668729181782cb4619b0b21ffafbbac0873997e Mon Sep 17 00:00:00 2001 From: John Cardinal Date: Tue, 25 Feb 2020 18:18:19 +0000 Subject: [PATCH] --- ayanova/src/components/gz-data-table.vue | 25 +++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/ayanova/src/components/gz-data-table.vue b/ayanova/src/components/gz-data-table.vue index 592978fb..b2047766 100644 --- a/ayanova/src/components/gz-data-table.vue +++ b/ayanova/src/components/gz-data-table.vue @@ -381,19 +381,22 @@ export default { listViewChanged: function() { var vm = this; - console.log("listViewchanged: TOP b4 remove unsaved"); - console.log(vm.pickLists.listViews); - //If listview had changed it can only have changed *away* from the unsaved filter item if it's present so just remove that if it exists - window.$gz._.remove(vm.pickLists.listViews, function(n) { - return n.id == -1; - }); - if (vm.listViewId == -1) { - vm.listViewId = 0; + //If listview had changed it can only have changed *away* from the unsaved filter item if it's present so just remove teh unsaved filter item if it exists + + //DANGER DANGER WARNING: if using lodash to remove item it might mess with vue reactivity + //this example does remove from the array and does update a plain mustache rendition of it on the page but doesn't update the select itself + //whereas using the native javascript array splice function *does* update the select because vue wraps splice and other native methods specifically + //so it can properly update the dom + // window.$gz._.remove(vm.pickLists.listViews, function(n) { + // return n.id == -1; + // }); + + for (var i = vm.pickLists.listViews.length - 1; i >= 0; i--) { + if (vm.pickLists.listViews[i].id === -1) { + vm.pickLists.listViews.splice(i, 1); + } } - // - console.log(vm.pickLists.listViews); - console.log(vm.listViewId); var ShouldGetData = vm.dataTablePagingOptions.page == 1;