Skip to content

Commit

Permalink
Merge pull request #563 from heubeck/projectlist-searchquery
Browse files Browse the repository at this point in the history
Issue #562: Propagate searchText query to List views
  • Loading branch information
nscuro authored Jul 31, 2023
2 parents bacd9e4 + 4724473 commit 86e9b39
Show file tree
Hide file tree
Showing 5 changed files with 36 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});
}
}
}
7 changes: 6 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 @@ -89,6 +90,7 @@
queryParamsType: 'pageSize',
pageList: '[10, 25, 50, 100]',
pageSize: (localStorage && localStorage.getItem("PolicyListPageSize") !== null) ? Number(localStorage.getItem("PolicyListPageSize")) : 10,
searchText: (this.$route.query.searchText ? this.$route.query.searchText : ''),
icons: {
refresh: 'fa-refresh'
},
Expand Down Expand Up @@ -354,6 +356,9 @@
localStorage.setItem("PolicyListPageSize", size.toString())
}
}),
onSearch: ((text) => {
this.setSearchTextQuery(text);
})
}
};
}
Expand Down
7 changes: 6 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 @@ -107,6 +108,7 @@
pageSize: (localStorage && localStorage.getItem("LicenseListPageSize") !== null) ? Number(localStorage.getItem("LicenseListPageSize")) : 10,
sortName: (localStorage && localStorage.getItem("LicenseListSortName") !== null) ? localStorage.getItem("LicenseListSortName") : undefined,
sortOrder: (localStorage && localStorage.getItem("LicenseListSortOrder") !== null) ? localStorage.getItem("LicenseListSortOrder") : undefined,
searchText: (this.$route.query.searchText ? this.$route.query.searchText : ''),
icons: {
refresh: 'fa-refresh'
},
Expand All @@ -131,6 +133,9 @@
localStorage.setItem("LicenseListSortName", name);
localStorage.setItem("LicenseListSortOrder", order);
}
}),
onSearch: ((text) => {
this.setSearchTextQuery(text);
})
}
};
Expand Down
5 changes: 4 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 @@ -304,6 +305,7 @@ import ProjectCreateProjectModal from "./ProjectCreateProjectModal";
pageSize: (localStorage && localStorage.getItem("ProjectListPageSize") !== null) ? Number(localStorage.getItem("ProjectListPageSize")) : 10,
sortName: (localStorage && localStorage.getItem("ProjectListSortName") !== null) ? localStorage.getItem("ProjectListSortName") : undefined,
sortOrder: (localStorage && localStorage.getItem("ProjectListSortOrder") !== null) ? localStorage.getItem("ProjectListSortOrder") : undefined,
searchText: (this.$route.query.searchText ? this.$route.query.searchText : ''),
icons: {
refresh: 'fa-refresh'
},
Expand Down Expand Up @@ -342,6 +344,7 @@ import ProjectCreateProjectModal from "./ProjectCreateProjectModal";
this.showFlatView = false;
}
}
this.setSearchTextQuery(text);
}),
onPageChange: ((number, size) => {
if (localStorage) {
Expand Down
9 changes: 7 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 @@ -139,6 +140,7 @@ import VulnerabilityCreateVulnerabilityModal from "./VulnerabilityCreateVulnerab
pageSize: (localStorage && localStorage.getItem("VulnerabilityListPageSize") !== null) ? Number(localStorage.getItem("VulnerabilityListPageSize")) : 10,
sortName: (localStorage && localStorage.getItem("VulnerabilityListSortName") !== null) ? localStorage.getItem("VulnerabilityListSortName") : undefined,
sortOrder: (localStorage && localStorage.getItem("VulnerabilityListSortOrder") !== null) ? localStorage.getItem("VulnerabilityListSortOrder") : undefined,
searchText: (this.$route.query.searchText ? this.$route.query.searchText : ''),
icons: {
refresh: 'fa-refresh'
},
Expand All @@ -163,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 86e9b39

Please sign in to comment.