@@ -12,6 +12,10 @@ import {
12
12
Checkbox ,
13
13
FormControlLabel ,
14
14
IconButton ,
15
+ Table ,
16
+ TableBody ,
17
+ TableCell ,
18
+ TableRow ,
15
19
Typography ,
16
20
} from "@mui/material" ;
17
21
import { useSnackbar } from "notistack" ;
@@ -35,6 +39,80 @@ import { advancedSearchPath, topPath } from "routes/Routes";
35
39
import { AdvancedSerarchResultListParam } from "services/Constants" ;
36
40
import { extractAdvancedSearchParams } from "services/entry/AdvancedSearch" ;
37
41
42
+ function isAttrInfoSet ( info : AdvancedSearchResultAttrInfo ) {
43
+ switch ( info . filterKey ) {
44
+ case AdvancedSearchResultAttrInfoFilterKeyEnum . CLEARED :
45
+ return false ;
46
+ case AdvancedSearchResultAttrInfoFilterKeyEnum . EMPTY :
47
+ case AdvancedSearchResultAttrInfoFilterKeyEnum . NON_EMPTY :
48
+ case AdvancedSearchResultAttrInfoFilterKeyEnum . DUPLICATED :
49
+ case AdvancedSearchResultAttrInfoFilterKeyEnum . DUPLICATED :
50
+ return true ;
51
+ case AdvancedSearchResultAttrInfoFilterKeyEnum . TEXT_CONTAINED :
52
+ return info . keyword !== "" ;
53
+ default :
54
+ return false ;
55
+ }
56
+ }
57
+
58
+ function DeleteAllLabel ( attrinfo : Array < AdvancedSearchResultAttrInfo > ) {
59
+ const renderLabel = ( info : AdvancedSearchResultAttrInfo ) => {
60
+ switch ( info . filterKey ) {
61
+ case AdvancedSearchResultAttrInfoFilterKeyEnum . EMPTY :
62
+ return "(空白)" ;
63
+ case AdvancedSearchResultAttrInfoFilterKeyEnum . NON_EMPTY :
64
+ return "(空白ではない)" ;
65
+ case AdvancedSearchResultAttrInfoFilterKeyEnum . DUPLICATED :
66
+ return "(重複している)" ;
67
+ case AdvancedSearchResultAttrInfoFilterKeyEnum . TEXT_CONTAINED :
68
+ return `「${ info . keyword } 」を含む` ;
69
+ case AdvancedSearchResultAttrInfoFilterKeyEnum . TEXT_NOT_CONTAINED :
70
+ return `「${ info . keyword } 」を含まない` ;
71
+ default :
72
+ return "" ;
73
+ }
74
+ }
75
+
76
+ if ( attrinfo . some ( ( x ) => isAttrInfoSet ( x ) ) ) {
77
+ return (
78
+ < >
79
+ < Typography >
80
+ 以下の条件にマッチする未選択の全てのアイテムを削除する
81
+ </ Typography >
82
+ < Typography variant = "caption" color = "warning" >
83
+ (↑のチェックを入れない場合、一覧で選択したアイテムのみ削除されます)
84
+ </ Typography >
85
+ < Table size = "small" >
86
+ < TableBody >
87
+ { attrinfo . map ( ( info ) => {
88
+ if ( isAttrInfoSet ( info ) ) {
89
+ return (
90
+ < TableRow >
91
+ < TableCell >
92
+ < Typography >
93
+ 属性「{ info . name } 」の値が
94
+ </ Typography >
95
+ </ TableCell >
96
+ < TableCell >
97
+ { renderLabel ( info ) }
98
+ </ TableCell >
99
+ </ TableRow >
100
+ ) ;
101
+ }
102
+ } ) }
103
+ </ TableBody >
104
+ </ Table >
105
+ </ >
106
+ ) ;
107
+ } else {
108
+ return (
109
+ < >
110
+ 未選択の全てのアイテムもまとめて削除する
111
+ </ >
112
+ ) ;
113
+ }
114
+ }
115
+
38
116
export const getIsFiltered = ( filterKey ?: number , keyword ?: string ) => {
39
117
switch ( filterKey ) {
40
118
case AdvancedSearchResultAttrInfoFilterKeyEnum . EMPTY :
@@ -179,7 +257,8 @@ export const AdvancedSearchResultsPage: FC = () => {
179
257
keyword : info . keyword ,
180
258
} ) )
181
259
) ,
182
- isDeleteAllItems
260
+ // disable isDeleteAllItems when join-attrs are specified
261
+ isDeleteAllItems && joinAttrs . length == 0
183
262
) ;
184
263
enqueueSnackbar ( "複数アイテムの削除に成功しました" , {
185
264
variant : "success" ,
@@ -270,12 +349,13 @@ export const AdvancedSearchResultsPage: FC = () => {
270
349
onClickYes = { handleBulkDelete }
271
350
content = {
272
351
bulkOperationEntryIds . length ==
273
- AdvancedSerarchResultListParam . MAX_ROW_COUNT ? (
352
+ AdvancedSerarchResultListParam . MAX_ROW_COUNT && joinAttrs . length == 0 ? (
274
353
< FormControlLabel
354
+ sx = { attrInfo . some ( ( x ) => isAttrInfoSet ( x ) ) ? { alignItems : "flex-start" } : { } }
275
355
control = {
276
356
< Checkbox onChange = { ( ) => setIsDeleteAllItems ( true ) } />
277
357
}
278
- label = "未選択のアイテムもまとめて削除する"
358
+ label = { DeleteAllLabel ( attrInfo ) }
279
359
/>
280
360
) : (
281
361
< > </ >
0 commit comments