Skip to content

Commit d84e76c

Browse files
committed
Merge branch 'master' of github.com:dmm-com/airone into feature/frontend-core-module
2 parents e8b803d + 9d20a36 commit d84e76c

16 files changed

+1659
-583
lines changed

frontend/src/AppBase.tsx

+13-11
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import { ThemeProvider } from "@mui/material/styles";
2-
import React, { FC } from "react";
2+
import React, { FC, StrictMode } from "react";
33

44
import { AironeSnackbarProvider } from "AironeSnackbarProvider";
5-
import { CheckTermsService } from "CheckTermsService";
65
import { ErrorHandler } from "ErrorHandler";
76
import { theme } from "Theme";
7+
import { CheckTerms } from "components/common/CheckTerms";
88
import { AppRouter } from "routes/AppRouter";
99
import "i18n/config";
1010

@@ -17,14 +17,16 @@ interface Props {
1717

1818
export const AppBase: FC<Props> = ({ customRoutes }) => {
1919
return (
20-
<ThemeProvider theme={theme}>
21-
<AironeSnackbarProvider>
22-
<ErrorHandler>
23-
<CheckTermsService>
24-
<AppRouter customRoutes={customRoutes} />
25-
</CheckTermsService>
26-
</ErrorHandler>
27-
</AironeSnackbarProvider>
28-
</ThemeProvider>
20+
<StrictMode>
21+
<ThemeProvider theme={theme}>
22+
<AironeSnackbarProvider>
23+
<ErrorHandler>
24+
<CheckTerms>
25+
<AppRouter customRoutes={customRoutes} />
26+
</CheckTerms>
27+
</ErrorHandler>
28+
</AironeSnackbarProvider>
29+
</ThemeProvider>
30+
</StrictMode>
2931
);
3032
};

frontend/src/CheckTermsService.tsx frontend/src/components/common/CheckTerms.tsx

+2-5
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,13 @@
11
import React, { FC } from "react";
22

3-
import { NonTermsServiceAgreement } from "./services/Exceptions";
4-
3+
import { NonTermsServiceAgreement } from "services/Exceptions";
54
import { ServerContext } from "services/ServerContext";
65

76
function getCookieValue(key: string) {
87
return ((document.cookie + ";").match(key + "=([^¥S;]*)") || [])[1];
98
}
109

11-
export const CheckTermsService: FC<{ children: React.ReactNode }> = ({
12-
children,
13-
}) => {
10+
export const CheckTerms: FC<{ children: React.ReactNode }> = ({ children }) => {
1411
const serverContext = ServerContext.getInstance();
1512

1613
if (

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
))}

frontend/src/components/entry/entryForm/AttributeValueField.tsx

+28-2
Original file line numberDiff line numberDiff line change
@@ -24,23 +24,32 @@ interface Props {
2424
setValue: UseFormSetValue<Schema>;
2525
type: number;
2626
schemaId: number;
27+
isDisabled?: boolean;
2728
}
2829

2930
export const AttributeValueField: FC<Props> = ({
3031
control,
3132
setValue,
3233
type,
3334
schemaId,
35+
isDisabled = false,
3436
}) => {
3537
switch (type) {
3638
case EntryAttributeTypeTypeEnum.STRING:
37-
return <StringAttributeValueField control={control} attrId={schemaId} />;
39+
return (
40+
<StringAttributeValueField
41+
control={control}
42+
attrId={schemaId}
43+
isDisabled={isDisabled}
44+
/>
45+
);
3846

3947
case EntryAttributeTypeTypeEnum.TEXT:
4048
return (
4149
<StringAttributeValueField
4250
control={control}
4351
attrId={schemaId}
52+
isDisabled={isDisabled}
4453
multiline
4554
/>
4655
);
@@ -51,6 +60,7 @@ export const AttributeValueField: FC<Props> = ({
5160
attrId={schemaId}
5261
control={control}
5362
setValue={setValue}
63+
isDisabled={isDisabled}
5464
/>
5565
);
5666

@@ -60,18 +70,26 @@ export const AttributeValueField: FC<Props> = ({
6070
attrId={schemaId}
6171
control={control}
6272
setValue={setValue}
73+
isDisabled={isDisabled}
6374
/>
6475
);
6576

6677
case EntryAttributeTypeTypeEnum.BOOLEAN:
67-
return <BooleanAttributeValueField attrId={schemaId} control={control} />;
78+
return (
79+
<BooleanAttributeValueField
80+
attrId={schemaId}
81+
control={control}
82+
isDisabled={isDisabled}
83+
/>
84+
);
6885

6986
case EntryAttributeTypeTypeEnum.OBJECT:
7087
return (
7188
<ObjectAttributeValueField
7289
attrId={schemaId}
7390
control={control}
7491
setValue={setValue}
92+
isDisabled={isDisabled}
7593
/>
7694
);
7795

@@ -81,6 +99,7 @@ export const AttributeValueField: FC<Props> = ({
8199
attrId={schemaId}
82100
control={control}
83101
setValue={setValue}
102+
isDisabled={isDisabled}
84103
/>
85104
);
86105

@@ -90,6 +109,7 @@ export const AttributeValueField: FC<Props> = ({
90109
attrId={schemaId}
91110
control={control}
92111
setValue={setValue}
112+
isDisabled={isDisabled}
93113
/>
94114
);
95115

@@ -99,6 +119,7 @@ export const AttributeValueField: FC<Props> = ({
99119
attrId={schemaId}
100120
control={control}
101121
setValue={setValue}
122+
isDisabled={isDisabled}
102123
/>
103124
);
104125

@@ -108,6 +129,7 @@ export const AttributeValueField: FC<Props> = ({
108129
attrId={schemaId}
109130
control={control}
110131
setValue={setValue}
132+
isDisabled={isDisabled}
111133
multiple
112134
/>
113135
);
@@ -118,6 +140,7 @@ export const AttributeValueField: FC<Props> = ({
118140
attrId={schemaId}
119141
control={control}
120142
setValue={setValue}
143+
isDisabled={isDisabled}
121144
multiple
122145
/>
123146
);
@@ -128,6 +151,7 @@ export const AttributeValueField: FC<Props> = ({
128151
attrId={schemaId}
129152
control={control}
130153
setValue={setValue}
154+
isDisabled={isDisabled}
131155
multiple
132156
/>
133157
);
@@ -143,6 +167,7 @@ export const AttributeValueField: FC<Props> = ({
143167
attrId={schemaId}
144168
control={control}
145169
setValue={setValue}
170+
isDisabled={isDisabled}
146171
/>
147172
);
148173

@@ -152,6 +177,7 @@ export const AttributeValueField: FC<Props> = ({
152177
attrId={schemaId}
153178
control={control}
154179
setValue={setValue}
180+
isDisabled={isDisabled}
155181
withBoolean
156182
/>
157183
);

0 commit comments

Comments
 (0)