Skip to content

Commit

Permalink
add url filter for histories/list_published?f-username=xname
Browse files Browse the repository at this point in the history
- also added the `user-eq` filter for exact match along with existing
  `user` (contains) filter
  • Loading branch information
ahmedhamidawan committed Sep 7, 2023
1 parent 6e57b3c commit 8b41093
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 7 deletions.
24 changes: 18 additions & 6 deletions client/src/components/History/HistoryPublishedList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import StatelessTags from "components/TagsMultiselect/StatelessTags";
import ScrollToTopButton from "components/ToolsList/ScrollToTopButton";
import UtcDate from "components/UtcDate";
import { useAnimationFrameScroll } from "composables/sensors/animationFrameScroll";
import Filtering, { contains, expandNameTag } from "utils/filtering";
import Filtering, { contains, equals, expandNameTag } from "utils/filtering";
import { computed, onMounted, onUnmounted, ref, watch } from "vue";
import { getPublishedHistories, updateTags } from "./services";
Expand All @@ -19,10 +19,19 @@ const validFilters = {
annotation: contains("annotation"),
tag: contains("tags", "tag", expandNameTag),
user: contains("username"),
user_eq: equals("username"),
};
const filters = new Filtering(validFilters, false);
const props = defineProps({
fUsername: {
type: String,
required: false,
default: null,
},
});
const offset = ref({ "-update_time-true": 0 });
const allHistories = ref([]);
const results = ref([]);
Expand Down Expand Up @@ -91,12 +100,12 @@ const scrollToTop = () => {
const sortAndFilterHistories = () => {
allHistories.value = allHistories.value.sort((a, b) => {
const aVal = a[sortBy.value].trim();
const bVal = b[sortBy.value].trim();
const aVal = String(a[sortBy.value]).trim();
const bVal = String(b[sortBy.value]).trim();
if (!sortDesc.value) {
return aVal.localeCompare(bVal);
return aVal - bVal;
} else {
return bVal.localeCompare(aVal);
return bVal - aVal;
}
});
Expand Down Expand Up @@ -180,6 +189,9 @@ async function load() {
}
onMounted(async () => {
if (props.fUsername) {
filterText.value = filters.getFilterText({ "user_eq:": props.fUsername });
}
await load();
useInfiniteScroll(scrollableDiv.value, () => load());
});
Expand Down Expand Up @@ -309,7 +321,7 @@ watch([filterText, sortBy, sortDesc], async () => {
<a
href="#"
class="published-histories-username-link"
@click="setFilter('user', row.item.username)"
@click="setFilter('user_eq', row.item.username)"
>{{ row.item.username }}</a
>
</template>
Expand Down
6 changes: 5 additions & 1 deletion client/src/entry/analysis/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,11 @@ export function getRouter(Galaxy) {
{
path: "histories/list_published",
component: HistoryPublishedList,
props: true,
props: (route) => {
return {
...route.query,
};
},
},
{
path: "histories/archived",
Expand Down

0 comments on commit 8b41093

Please sign in to comment.