Skip to content

Commit 5f04700

Browse files
authored
Merge pull request #1321 from dmm-com/feature/new-ui/advanced_search_result/introduce_is_readonly_flag
Introduce isReadonly flag at the AdvancedSearchResult page
2 parents 184bbc6 + 1305f34 commit 5f04700

File tree

2 files changed

+83
-57
lines changed

2 files changed

+83
-57
lines changed

frontend/src/components/entry/SearchResults.tsx

+20-11
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ interface Props {
6363
joinAttrs: AdvancedSearchJoinAttrInfo[];
6464
disablePaginationFooter: boolean;
6565
setSearchResults: () => void;
66+
isReadonly?: boolean;
6667
}
6768

6869
export const SearchResults: FC<Props> = ({
@@ -80,6 +81,7 @@ export const SearchResults: FC<Props> = ({
8081
joinAttrs,
8182
disablePaginationFooter,
8283
setSearchResults,
84+
isReadonly = false,
8385
}) => {
8486
// NOTE attrTypes are guessed by the first element on the results. So if it has no appropriate attr,
8587
// the type guess doesn't work well. We should improve attr type API if more accurate type is needed.
@@ -109,21 +111,28 @@ export const SearchResults: FC<Props> = ({
109111
searchAllEntities={searchAllEntities}
110112
joinAttrs={joinAttrs}
111113
refreshSearchResults={setSearchResults}
114+
isReadonly={isReadonly}
112115
/>
113116
<TableBody>
114117
{results.values?.map((result) => (
115118
<StyledTableRow key={result.entry.id}>
116-
<TableCell sx={{ padding: 0 }}>
117-
<Checkbox
118-
checked={bulkOperationEntryIds.includes(result.entry.id)}
119-
onChange={(e) =>
120-
handleChangeBulkOperationEntryId(
121-
result.entry.id,
122-
e.target.checked
123-
)
124-
}
125-
/>
126-
</TableCell>
119+
{/* Bulk operation checkbox would be invisible when Readonly mode is true */}
120+
{!isReadonly && (
121+
<TableCell sx={{ padding: 0 }}>
122+
<Checkbox
123+
checked={bulkOperationEntryIds.includes(
124+
result.entry.id
125+
)}
126+
onChange={(e) =>
127+
handleChangeBulkOperationEntryId(
128+
result.entry.id,
129+
e.target.checked
130+
)
131+
}
132+
/>
133+
</TableCell>
134+
)}
135+
127136
<TableCell>
128137
<Box
129138
component={Link}

frontend/src/components/entry/SearchResultsTableHead.tsx

+63-46
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ interface Props {
6161
searchAllEntities: boolean;
6262
joinAttrs: AdvancedSearchJoinAttrInfo[];
6363
refreshSearchResults: () => void;
64+
isReadonly?: boolean;
6465
}
6566

6667
export const SearchResultsTableHead: FC<Props> = ({
@@ -73,6 +74,7 @@ export const SearchResultsTableHead: FC<Props> = ({
7374
searchAllEntities,
7475
joinAttrs,
7576
refreshSearchResults,
77+
isReadonly = false,
7678
}) => {
7779
const location = useLocation();
7880
const navigate = useNavigate();
@@ -187,33 +189,44 @@ export const SearchResultsTableHead: FC<Props> = ({
187189
return (
188190
<TableHead>
189191
<TableRow sx={{ backgroundColor: "primary.dark" }}>
190-
<TableCell sx={{ witdh: "80px" }} />
192+
{/* Bulk operation checkbox would be invisible when Readonly mode is true */}
193+
{!isReadonly && <TableCell sx={{ witdh: "80px" }} />}
191194
<StyledTableCell sx={{ outline: "1px solid #FFFFFF" }}>
192195
<HeaderBox>
193196
<Typography>アイテム名</Typography>
194-
<StyledIconButton
195-
onClick={(e) => {
196-
setEntryMenuEls(e.currentTarget);
197-
}}
198-
>
199-
{defaultEntryFilter ? <FilterAltIcon /> : <FilterListIcon />}
200-
</StyledIconButton>
201-
<SearchResultControlMenuForEntry
202-
entryFilter={entryFilter}
203-
anchorElem={entryMenuEls}
204-
handleClose={() => setEntryMenuEls(null)}
205-
entryFilterDispatcher={entryFilterDispatcher}
206-
handleSelectFilterConditions={handleSelectFilterConditions()}
207-
handleClear={() => handleSelectFilterConditions()(undefined, "")}
208-
/>
197+
198+
{/* SearchControlMenu would be invisible when Readonly Mode is True */}
199+
{!isReadonly && (
200+
<>
201+
<StyledIconButton
202+
onClick={(e) => {
203+
setEntryMenuEls(e.currentTarget);
204+
}}
205+
>
206+
{defaultEntryFilter ? <FilterAltIcon /> : <FilterListIcon />}
207+
</StyledIconButton>
208+
<SearchResultControlMenuForEntry
209+
entryFilter={entryFilter}
210+
anchorElem={entryMenuEls}
211+
handleClose={() => setEntryMenuEls(null)}
212+
entryFilterDispatcher={entryFilterDispatcher}
213+
handleSelectFilterConditions={handleSelectFilterConditions()}
214+
handleClear={() =>
215+
handleSelectFilterConditions()(undefined, "")
216+
}
217+
/>
218+
</>
219+
)}
209220
</HeaderBox>
210221
</StyledTableCell>
211222
{attrNames.map((attrName) => (
212223
<StyledTableCell key={attrName}>
213224
<HeaderBox>
214225
<Typography>{attrName}</Typography>
215226

227+
{/* Bulk operation checkbox would be invisible when Readonly mode is true */}
216228
{(attrTypes[attrName] & EntryAttributeTypeTypeEnum.OBJECT) > 0 &&
229+
!isReadonly &&
217230
attrsFilter[attrName]?.joinedAttrname === undefined && (
218231
<StyledIconButton onClick={() => setJoinAttrname(attrName)}>
219232
<AddIcon />
@@ -229,36 +242,40 @@ export const SearchResultsTableHead: FC<Props> = ({
229242
refreshSearchResults={refreshSearchResults}
230243
/>
231244
)}
232-
<StyledIconButton
233-
onClick={(e) => {
234-
setAttributeMenuEls({
235-
...attributeMenuEls,
236-
[attrName]: e.currentTarget,
237-
});
238-
}}
239-
sx={{ marginLeft: "auto" }}
240-
>
241-
{isFiltered[attrName] ?? false ? (
242-
<FilterAltIcon />
243-
) : (
244-
<FilterListIcon />
245-
)}
246-
</StyledIconButton>
247-
<SearchResultControlMenu
248-
attrFilter={attrsFilter[attrName]}
249-
anchorElem={attributeMenuEls[attrName]}
250-
handleClose={() =>
251-
setAttributeMenuEls({
252-
...attributeMenuEls,
253-
[attrName]: null,
254-
})
255-
}
256-
handleSelectFilterConditions={handleSelectFilterConditions(
257-
attrName
258-
)}
259-
handleUpdateAttrFilter={handleUpdateAttrFilter(attrName)}
260-
attrType={attrTypes[attrName]}
261-
/>
245+
{!isReadonly && (
246+
<>
247+
<StyledIconButton
248+
onClick={(e) => {
249+
setAttributeMenuEls({
250+
...attributeMenuEls,
251+
[attrName]: e.currentTarget,
252+
});
253+
}}
254+
sx={{ marginLeft: "auto" }}
255+
>
256+
{isFiltered[attrName] ?? false ? (
257+
<FilterAltIcon />
258+
) : (
259+
<FilterListIcon />
260+
)}
261+
</StyledIconButton>
262+
<SearchResultControlMenu
263+
attrFilter={attrsFilter[attrName]}
264+
anchorElem={attributeMenuEls[attrName]}
265+
handleClose={() =>
266+
setAttributeMenuEls({
267+
...attributeMenuEls,
268+
[attrName]: null,
269+
})
270+
}
271+
handleSelectFilterConditions={handleSelectFilterConditions(
272+
attrName
273+
)}
274+
handleUpdateAttrFilter={handleUpdateAttrFilter(attrName)}
275+
attrType={attrTypes[attrName]}
276+
/>
277+
</>
278+
)}
262279
</HeaderBox>
263280
</StyledTableCell>
264281
))}

0 commit comments

Comments
 (0)