@@ -61,6 +61,7 @@ interface Props {
61
61
searchAllEntities : boolean ;
62
62
joinAttrs : AdvancedSearchJoinAttrInfo [ ] ;
63
63
refreshSearchResults : ( ) => void ;
64
+ isReadonly ?: boolean ;
64
65
}
65
66
66
67
export const SearchResultsTableHead : FC < Props > = ( {
@@ -73,6 +74,7 @@ export const SearchResultsTableHead: FC<Props> = ({
73
74
searchAllEntities,
74
75
joinAttrs,
75
76
refreshSearchResults,
77
+ isReadonly = false ,
76
78
} ) => {
77
79
const location = useLocation ( ) ;
78
80
const navigate = useNavigate ( ) ;
@@ -129,52 +131,52 @@ export const SearchResultsTableHead: FC<Props> = ({
129
131
130
132
const handleSelectFilterConditions =
131
133
( attrName ?: string ) =>
132
- (
133
- attrFilter ?: AttrFilter ,
134
- overwriteEntryName ?: string ,
135
- overwriteReferral ?: string
136
- ) => {
137
- const _attrsFilter =
138
- attrName != null && attrFilter != null
139
- ? { ...attrsFilter , [ attrName ] : attrFilter }
140
- : attrsFilter ;
134
+ (
135
+ attrFilter ?: AttrFilter ,
136
+ overwriteEntryName ?: string ,
137
+ overwriteReferral ?: string
138
+ ) => {
139
+ const _attrsFilter =
140
+ attrName != null && attrFilter != null
141
+ ? { ...attrsFilter , [ attrName ] : attrFilter }
142
+ : attrsFilter ;
141
143
142
- const newParams = formatAdvancedSearchParams ( {
143
- attrsFilter : Object . keys ( _attrsFilter )
144
- . filter ( ( k ) => _attrsFilter [ k ] ?. joinedAttrname === undefined )
145
- . reduce ( ( a , k ) => ( { ...a , [ k ] : _attrsFilter [ k ] } ) , { } ) ,
146
- entryName : overwriteEntryName ?? entryFilter ,
147
- referralName : overwriteReferral ?? referralFilter ,
148
- baseParams : new URLSearchParams ( location . search ) ,
149
- joinAttrs : Object . keys ( _attrsFilter )
150
- . filter ( ( k ) => _attrsFilter [ k ] ?. joinedAttrname !== undefined )
151
- . map ( ( k ) => ( {
152
- name : _attrsFilter [ k ] ?. baseAttrname ?? "" ,
153
- attrinfo : Object . keys ( _attrsFilter )
154
- . filter (
155
- ( j ) =>
156
- _attrsFilter [ j ] . baseAttrname === _attrsFilter [ k ] . baseAttrname
157
- )
158
- . map ( ( j ) => ( {
159
- name : _attrsFilter [ j ] ?. joinedAttrname ?? "" ,
160
- filterKey : _attrsFilter [ j ] . filterKey ,
161
- keyword : _attrsFilter [ j ] . keyword ,
162
- } ) ) ,
163
- } ) )
164
- // This removes duplicates
165
- . filter ( ( v , i , a ) => a . findIndex ( ( t ) => t . name === v . name ) === i ) ,
166
- } ) ;
144
+ const newParams = formatAdvancedSearchParams ( {
145
+ attrsFilter : Object . keys ( _attrsFilter )
146
+ . filter ( ( k ) => _attrsFilter [ k ] ?. joinedAttrname === undefined )
147
+ . reduce ( ( a , k ) => ( { ...a , [ k ] : _attrsFilter [ k ] } ) , { } ) ,
148
+ entryName : overwriteEntryName ?? entryFilter ,
149
+ referralName : overwriteReferral ?? referralFilter ,
150
+ baseParams : new URLSearchParams ( location . search ) ,
151
+ joinAttrs : Object . keys ( _attrsFilter )
152
+ . filter ( ( k ) => _attrsFilter [ k ] ?. joinedAttrname !== undefined )
153
+ . map ( ( k ) => ( {
154
+ name : _attrsFilter [ k ] ?. baseAttrname ?? "" ,
155
+ attrinfo : Object . keys ( _attrsFilter )
156
+ . filter (
157
+ ( j ) =>
158
+ _attrsFilter [ j ] . baseAttrname === _attrsFilter [ k ] . baseAttrname
159
+ )
160
+ . map ( ( j ) => ( {
161
+ name : _attrsFilter [ j ] ?. joinedAttrname ?? "" ,
162
+ filterKey : _attrsFilter [ j ] . filterKey ,
163
+ keyword : _attrsFilter [ j ] . keyword ,
164
+ } ) ) ,
165
+ } ) )
166
+ // This removes duplicates
167
+ . filter ( ( v , i , a ) => a . findIndex ( ( t ) => t . name === v . name ) === i ) ,
168
+ } ) ;
167
169
168
- if ( getIsFiltered ( attrFilter ?. filterKey , attrFilter ?. keyword ) ) {
169
- refreshSearchResults ( ) ;
170
- }
170
+ if ( getIsFiltered ( attrFilter ?. filterKey , attrFilter ?. keyword ) ) {
171
+ refreshSearchResults ( ) ;
172
+ }
171
173
172
- // simply reload with the new params
173
- navigate ( {
174
- pathname : location . pathname ,
175
- search : "?" + newParams . toString ( ) ,
176
- } ) ;
177
- } ;
174
+ // simply reload with the new params
175
+ navigate ( {
176
+ pathname : location . pathname ,
177
+ search : "?" + newParams . toString ( ) ,
178
+ } ) ;
179
+ } ;
178
180
179
181
const handleUpdateAttrFilter =
180
182
( attrName : string ) => ( attrFilter : AttrFilter ) => {
@@ -187,33 +189,43 @@ export const SearchResultsTableHead: FC<Props> = ({
187
189
return (
188
190
< TableHead >
189
191
< TableRow sx = { { backgroundColor : "primary.dark" } } >
190
- < TableCell sx = { { witdh : "80px" } } />
192
+ { /* Bulk operation checkbox would be invisible when Readonly mode is true */ }
193
+ { ! isReadonly && (
194
+ < TableCell sx = { { witdh : "80px" } } />
195
+ ) }
191
196
< StyledTableCell sx = { { outline : "1px solid #FFFFFF" } } >
192
197
< HeaderBox >
193
198
< 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
- />
199
+
200
+ { /* SearchControlMenu would be invisible when Readonly Mode is True */ }
201
+ { ! isReadonly && (
202
+ < >
203
+ < StyledIconButton
204
+ onClick = { ( e ) => {
205
+ setEntryMenuEls ( e . currentTarget ) ;
206
+ } }
207
+ >
208
+ { defaultEntryFilter ? < FilterAltIcon /> : < FilterListIcon /> }
209
+ </ StyledIconButton >
210
+ < SearchResultControlMenuForEntry
211
+ entryFilter = { entryFilter }
212
+ anchorElem = { entryMenuEls }
213
+ handleClose = { ( ) => setEntryMenuEls ( null ) }
214
+ entryFilterDispatcher = { entryFilterDispatcher }
215
+ handleSelectFilterConditions = { handleSelectFilterConditions ( ) }
216
+ handleClear = { ( ) => handleSelectFilterConditions ( ) ( undefined , "" ) }
217
+ />
218
+ </ >
219
+ ) }
209
220
</ HeaderBox >
210
221
</ StyledTableCell >
211
222
{ attrNames . map ( ( attrName ) => (
212
223
< StyledTableCell key = { attrName } >
213
224
< HeaderBox >
214
225
< Typography > { attrName } </ Typography >
215
226
216
- { ( attrTypes [ attrName ] & EntryAttributeTypeTypeEnum . OBJECT ) > 0 &&
227
+ { /* Bulk operation checkbox would be invisible when Readonly mode is true */ }
228
+ { ( attrTypes [ attrName ] & EntryAttributeTypeTypeEnum . OBJECT ) > 0 && ! isReadonly &&
217
229
attrsFilter [ attrName ] ?. joinedAttrname === undefined && (
218
230
< StyledIconButton onClick = { ( ) => setJoinAttrname ( attrName ) } >
219
231
< AddIcon />
@@ -229,36 +241,40 @@ export const SearchResultsTableHead: FC<Props> = ({
229
241
refreshSearchResults = { refreshSearchResults }
230
242
/>
231
243
) }
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
- />
244
+ { ! isReadonly && (
245
+ < >
246
+ < StyledIconButton
247
+ onClick = { ( e ) => {
248
+ setAttributeMenuEls ( {
249
+ ...attributeMenuEls ,
250
+ [ attrName ] : e . currentTarget ,
251
+ } ) ;
252
+ } }
253
+ sx = { { marginLeft : "auto" } }
254
+ >
255
+ { isFiltered [ attrName ] ?? false ? (
256
+ < FilterAltIcon />
257
+ ) : (
258
+ < FilterListIcon />
259
+ ) }
260
+ </ StyledIconButton >
261
+ < SearchResultControlMenu
262
+ attrFilter = { attrsFilter [ attrName ] }
263
+ anchorElem = { attributeMenuEls [ attrName ] }
264
+ handleClose = { ( ) =>
265
+ setAttributeMenuEls ( {
266
+ ...attributeMenuEls ,
267
+ [ attrName ] : null ,
268
+ } )
269
+ }
270
+ handleSelectFilterConditions = { handleSelectFilterConditions (
271
+ attrName
272
+ ) }
273
+ handleUpdateAttrFilter = { handleUpdateAttrFilter ( attrName ) }
274
+ attrType = { attrTypes [ attrName ] }
275
+ />
276
+ </ >
277
+ ) }
262
278
</ HeaderBox >
263
279
</ StyledTableCell >
264
280
) ) }
0 commit comments