Skip to content

Commit

Permalink
Allow properties in search
Browse files Browse the repository at this point in the history
  • Loading branch information
Max Frederiksen authored and Max Frederiksen committed Jan 3, 2025
1 parent d81065b commit 1c57afd
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 9 deletions.
4 changes: 2 additions & 2 deletions src/api/ologApi.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,11 @@ export const ologApi = createApi({
keepUnusedDataFor: 0, // Don't cache anything
endpoints: builder => ({
searchLogs: builder.query({
query: ({query, title, desc, start, end, level, logbooks, tags, owner, attachments, from, size, sort}) => {
query: ({query, title, desc, properties, start, end, level, logbooks, tags, owner, attachments, from, size, sort}) => {
return {
url: '/logs/search',
params: {
query, title, desc, start, end, level, logbooks, tags, owner, attachments, from, size, sort
query, title, desc, properties, start, end, level, logbooks, tags, owner, attachments, from, size, sort
}
}
}
Expand Down
8 changes: 7 additions & 1 deletion src/beta/components/search/AdvancedSearchDrawer.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import WizardDateInput from "components/shared/input/WizardDateInput";
import EntryTypeSelect from "components/shared/input/managed/EntryTypeSelect";
import LogbooksMultiSelect from "components/shared/input/managed/LogbooksMultiSelect";
import TagsMultiSelect from "components/shared/input/managed/TagsMultiSelect";
import { useForm, useWatch } from "react-hook-form";
import { useForm } from "react-hook-form";
import {
defaultSearchParams,
updateSearchParams,
Expand Down Expand Up @@ -77,6 +77,12 @@ export const AdvancedSearchDrawer = ({
control={control}
defaultValue=""
/>
<TextInput
name="properties"
label="Properties"
control={control}
defaultValue=""
/>
<EntryTypeSelect control={control} />
<LogbooksMultiSelect control={control} />
<TagsMultiSelect control={control} />
Expand Down
26 changes: 24 additions & 2 deletions src/beta/components/search/SearchParamsBadges.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,18 @@ export const SearchParamsBadges = () => {
const dispatch = useDispatch();
const onSearch = (vals) => dispatch(updateSearchParams(vals));

const { title, level, desc, owner, attachments, start, end, tags, logbooks } =
searchParams;
const {
title,
level,
desc,
properties,
owner,
attachments,
start,
end,
tags,
logbooks,
} = searchParams;

return (
<Stack flexDirection="row" gap={0.5} flexWrap="wrap" padding={0.5}>
Expand Down Expand Up @@ -85,6 +95,18 @@ export const SearchParamsBadges = () => {
}
/>
) : null}
{properties ? (
<TextChip
name="properties"
value={properties}
onDelete={() =>
onSearch({
...searchParams,
properties: defaultSearchParams.properties,
})
}
/>
) : null}
{owner ? (
<TextChip
name="author"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,6 @@ export const SearchResultSingleItem = ({
whiteSpace="nowrap"
variant="body2"
fontSize=".75rem"
fontWeight="bold"
color="#0090AD"
sx={{ opacity: 0.8, marginRight: "2px" }}
/>
</Stack>
<Stack
Expand All @@ -93,7 +90,10 @@ export const SearchResultSingleItem = ({
</Typography>
<Box>
{log?.attachments?.length > 0 ? (
<AttachFileIcon fontSize="small" />
<AttachFileIcon
fontSize="small"
sx={{ fontSize: "1.2rem", marginRight: "-2px", marginTop: "4px" }}
/>
) : null}
</Box>
</Stack>
Expand Down
1 change: 1 addition & 0 deletions src/features/advancedSearchReducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export const advancedSearchSlice = createSlice({
searchParams?.logbooks?.length > 0 && activeFieldCount++;
searchParams?.tags?.length > 0 && activeFieldCount++;
searchParams.owner && activeFieldCount++;
searchParams.properties && activeFieldCount++;

// If any of the advanced-only fields have values
// then advanced search is active
Expand Down
1 change: 1 addition & 0 deletions src/features/searchParamsReducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export const defaultSearchParams = {
query: "",
title: "",
desc: "",
properties: "",
owner: "",
level: undefined,
start: undefined,
Expand Down

0 comments on commit 1c57afd

Please sign in to comment.