Skip to content

Commit

Permalink
Issue #562: Update searchText query parameter via router
Browse files Browse the repository at this point in the history
Signed-off-by: Florian Heubeck <heubeck@mediamarktsaturn.com>
  • Loading branch information
heubeck committed Jul 31, 2023
1 parent 5a6c486 commit 4724473
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 5 deletions.
13 changes: 13 additions & 0 deletions src/mixins/routerMixin.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
export default {
methods: {
setSearchTextQuery (searchText) {
let queries = JSON.parse(JSON.stringify(this.$route.query));
if (searchText === '') {
delete queries.searchText;
} else {
queries.searchText = searchText;
}
this.$router.replace({query: queries});
}
}
}
6 changes: 5 additions & 1 deletion src/views/policy/PolicyList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import xssFilters from "xss-filters";
import CreatePolicyModal from "./CreatePolicyModal";
import permissionsMixin from "../../mixins/permissionsMixin";
import routerMixin from "../../mixins/routerMixin";
import i18n from "../../i18n";
import ActionableListGroupItem from "../components/ActionableListGroupItem";
import BInputGroupFormInput from "../../forms/BInputGroupFormInput";
Expand All @@ -33,7 +34,7 @@
import { Switch as cSwitch } from '@coreui/vue';
export default {
mixins: [permissionsMixin, bootstrapTableMixin],
mixins: [permissionsMixin, bootstrapTableMixin, routerMixin],
components: {
CreatePolicyModal
},
Expand Down Expand Up @@ -355,6 +356,9 @@
localStorage.setItem("PolicyListPageSize", size.toString())
}
}),
onSearch: ((text) => {
this.setSearchTextQuery(text);
})
}
};
}
Expand Down
6 changes: 5 additions & 1 deletion src/views/portfolio/licenses/LicenseList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,12 @@
import PortfolioWidgetRow from "../../dashboard/PortfolioWidgetRow";
import xssFilters from "xss-filters";
import permissionsMixin from "../../../mixins/permissionsMixin";
import routerMixin from "../../../mixins/routerMixin";
import LicenseAddLicenseModal from "@/views/portfolio/licenses/LicenseAddLicenseModal";
import {loadUserPreferencesForBootstrapTable} from "@/shared/utils";
export default {
mixins: [permissionsMixin],
mixins: [permissionsMixin, routerMixin],
components: {
LicenseAddLicenseModal,
PortfolioWidgetRow
Expand Down Expand Up @@ -132,6 +133,9 @@
localStorage.setItem("LicenseListSortName", name);
localStorage.setItem("LicenseListSortOrder", order);
}
}),
onSearch: ((text) => {
this.setSearchTextQuery(text);
})
}
};
Expand Down
4 changes: 3 additions & 1 deletion src/views/portfolio/projects/ProjectList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,15 @@ import MurmurHash2 from "imurmurhash";
import Vue from 'vue';
import xssFilters from "xss-filters";
import permissionsMixin from "../../../mixins/permissionsMixin";
import routerMixin from "../../../mixins/routerMixin";
import common from "../../../shared/common";
import PolicyViolationProgressBar from "../../components/PolicyViolationProgressBar";
import SeverityProgressBar from "../../components/SeverityProgressBar";
import PortfolioWidgetRow from "../../dashboard/PortfolioWidgetRow";
import ProjectCreateProjectModal from "./ProjectCreateProjectModal";
export default {
mixins: [permissionsMixin],
mixins: [permissionsMixin, routerMixin],
components: {
cSwitch,
ProjectCreateProjectModal,
Expand Down Expand Up @@ -343,6 +344,7 @@ import ProjectCreateProjectModal from "./ProjectCreateProjectModal";
this.showFlatView = false;
}
}
this.setSearchTextQuery(text);
}),
onPageChange: ((number, size) => {
if (localStorage) {
Expand Down
8 changes: 6 additions & 2 deletions src/views/portfolio/vulnerabilities/VulnerabilityList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,13 @@
import $ from "jquery";
import xssFilters from "xss-filters";
import permissionsMixin from "../../../mixins/permissionsMixin";
import routerMixin from "../../../mixins/routerMixin";
import common from "../../../shared/common";
import PortfolioWidgetRow from "../../dashboard/PortfolioWidgetRow";
import VulnerabilityCreateVulnerabilityModal from "./VulnerabilityCreateVulnerabilityModal";
export default {
mixins: [permissionsMixin],
mixins: [permissionsMixin, routerMixin],
components: {
VulnerabilityCreateVulnerabilityModal,
PortfolioWidgetRow
Expand Down Expand Up @@ -164,7 +165,10 @@ import VulnerabilityCreateVulnerabilityModal from "./VulnerabilityCreateVulnerab
localStorage.setItem("VulnerabilityListSortName", name);
localStorage.setItem("VulnerabilityListSortOrder", order);
}
})
}),
onSearch: ((text) => {
this.setSearchTextQuery(text);
}),
}
};
}
Expand Down

0 comments on commit 4724473

Please sign in to comment.