@opengeoweb/taf 1.2.0 → 1.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/components/TafForm/TafFormRow/DragHandle.d.ts +8 -0
- package/lib/components/TafForm/TafFormRow/DragHandle.spec.d.ts +1 -0
- package/lib/components/TafForm/TafFormRow/types.d.ts +2 -3
- package/lib/components/TafForm/utils.d.ts +11 -2
- package/package.json +8 -6
- package/taf.esm.js +251 -109
- package/taf.umd.js +253 -112
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export declare const useStyles: (props?: any) => import("@material-ui/styles").ClassNameMap<"dragHandle">;
|
|
3
|
+
interface DragHandleProps {
|
|
4
|
+
isSorting?: boolean;
|
|
5
|
+
isDisabled?: boolean;
|
|
6
|
+
}
|
|
7
|
+
declare const DragHandle: React.FC<DragHandleProps>;
|
|
8
|
+
export default DragHandle;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
+
import { GridProps } from '@material-ui/core';
|
|
2
3
|
import { ArrayField } from 'react-hook-form';
|
|
3
|
-
export interface TafFormRowProps {
|
|
4
|
+
export interface TafFormRowProps extends GridProps {
|
|
4
5
|
isChangeGroup?: boolean;
|
|
5
6
|
disabled?: boolean;
|
|
6
7
|
index?: number;
|
|
7
8
|
lastRow?: boolean;
|
|
8
9
|
onRemoveChangeGroup?: (index: number) => void;
|
|
9
10
|
field?: Partial<ArrayField>;
|
|
10
|
-
onRef?: (node: HTMLElement) => void;
|
|
11
11
|
dragHandle?: React.ReactElement;
|
|
12
|
-
style?: React.CSSProperties;
|
|
13
12
|
}
|
|
14
13
|
export interface FieldNames {
|
|
15
14
|
messageType?: string;
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import Sortable from 'sortablejs';
|
|
2
|
+
import { ArrayField } from 'react-hook-form';
|
|
1
3
|
import { BaseForecast, ChangeGroup, Taf, TafActions } from '../../types';
|
|
2
4
|
import { FieldNames } from './TafFormRow/types';
|
|
3
5
|
export declare const formatIssueTime: (issueDate: string) => string;
|
|
@@ -9,8 +11,15 @@ export declare const getFieldNames: (isChangeGroup: boolean, index: number) => F
|
|
|
9
11
|
export declare const useTACGenerator: (taf: Taf, requestTAC: (postTaf: unknown) => Promise<{
|
|
10
12
|
data: string;
|
|
11
13
|
}>, standardTAC?: string) => [string, (tafToPost: any) => void];
|
|
12
|
-
export declare const
|
|
13
|
-
|
|
14
|
+
export declare const getRange: (min: number, max: number) => number[];
|
|
15
|
+
export declare type SortableField = {
|
|
16
|
+
id: string;
|
|
17
|
+
chosen: boolean;
|
|
18
|
+
};
|
|
19
|
+
export declare const useDragOrder: (trigger: (name?: string | string[]) => Promise<boolean>, move: (oldIndex: number, newIndex: number) => void, fields: Partial<ArrayField<Record<string, unknown>, 'id'>>[]) => {
|
|
20
|
+
onChangeOrder: (event: Sortable.SortableEvent) => void;
|
|
21
|
+
sortedFields: SortableField[];
|
|
22
|
+
setSortedFields: (fields: SortableField[]) => void;
|
|
14
23
|
};
|
|
15
24
|
export declare const getConfirmationDialogTitle: (action: TafActions) => string;
|
|
16
25
|
export declare const getConfirmationDialogContent: (action: TafActions) => string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@opengeoweb/taf",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.2",
|
|
4
4
|
"description": "GeoWeb TAF library for the opengeoweb project",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -14,20 +14,22 @@
|
|
|
14
14
|
"peerDependencies": {
|
|
15
15
|
"react": "16.14.0",
|
|
16
16
|
"@material-ui/core": "^4.11.0",
|
|
17
|
-
"@opengeoweb/theme": "1.2.
|
|
17
|
+
"@opengeoweb/theme": "1.2.2",
|
|
18
18
|
"@material-ui/lab": "^4.0.0-alpha.56",
|
|
19
19
|
"@material-ui/icons": "^4.9.1",
|
|
20
20
|
"react-hook-form": "^6.12.1",
|
|
21
|
-
"
|
|
21
|
+
"react-sortablejs": "^6.0.0",
|
|
22
|
+
"@opengeoweb/form-fields": "1.2.2",
|
|
22
23
|
"@material-ui/pickers": "^3.2.10",
|
|
23
24
|
"@date-io/moment": "^1.3.13",
|
|
24
25
|
"moment": "^2.29.0",
|
|
25
26
|
"moment-timezone": "^0.5.31",
|
|
26
27
|
"lodash": "^4.17.20",
|
|
27
|
-
"@opengeoweb/api": "1.2.
|
|
28
|
+
"@opengeoweb/api": "1.2.2",
|
|
28
29
|
"axios": "^0.21.0",
|
|
29
|
-
"@opengeoweb/shared": "1.2.
|
|
30
|
+
"@opengeoweb/shared": "1.2.2",
|
|
30
31
|
"react-draggable": "^4.4.3",
|
|
31
|
-
"re-resizable": "^6.9.0"
|
|
32
|
+
"re-resizable": "^6.9.0",
|
|
33
|
+
"sortablejs": "^1.14.0"
|
|
32
34
|
}
|
|
33
35
|
}
|
package/taf.esm.js
CHANGED
|
@@ -4,10 +4,11 @@ import { makeStyles, Grid, TextField, IconButton, Tooltip, Chip, SvgIcon, Paper,
|
|
|
4
4
|
import { Skeleton } from '@material-ui/lab';
|
|
5
5
|
import moment from 'moment';
|
|
6
6
|
import { useDraftFormHelpers, useConfirmationDialog, usePreventBrowserClose, StatusTag, AlertBanner, ConfirmationServiceProvider, usePoller, isAxiosError, getAxiosErrorMessage } from '@opengeoweb/shared';
|
|
7
|
-
import { Delete, Close, Add, InfoOutlined, Create, CheckCircle, Schedule, OpenInNew, ExpandMore } from '@material-ui/icons';
|
|
7
|
+
import { Delete, Close, DragIndicator, Add, InfoOutlined, Create, CheckCircle, Schedule, OpenInNew, ExpandMore } from '@material-ui/icons';
|
|
8
8
|
import { useApiContext, useApi, createApiInstance } from '@opengeoweb/api';
|
|
9
9
|
import { getDeepProperty, ReactHookFormHiddenInput, ReactHookFormProvider } from '@opengeoweb/form-fields';
|
|
10
10
|
import { useFormContext, Controller, useFieldArray } from 'react-hook-form';
|
|
11
|
+
import { ReactSortable, Sortable } from 'react-sortablejs';
|
|
11
12
|
|
|
12
13
|
/*! *****************************************************************************
|
|
13
14
|
Copyright (c) Microsoft Corporation.
|
|
@@ -176,80 +177,6 @@ var tafConfig = {
|
|
|
176
177
|
locations: locations
|
|
177
178
|
};
|
|
178
179
|
|
|
179
|
-
/* *
|
|
180
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
181
|
-
* you may not use this file except in compliance with the License.
|
|
182
|
-
* You may obtain a copy of the License at
|
|
183
|
-
*
|
|
184
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
185
|
-
*
|
|
186
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
187
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
188
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
189
|
-
* See the License for the specific language governing permissions and
|
|
190
|
-
* limitations under the License.
|
|
191
|
-
*
|
|
192
|
-
* Copyright 2021 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
|
|
193
|
-
* Copyright 2021 - Finnish Meteorological Institute (FMI)
|
|
194
|
-
* */
|
|
195
|
-
var useStyles$8 = makeStyles(function (theme) {
|
|
196
|
-
return {
|
|
197
|
-
textFieldGridItem: {
|
|
198
|
-
marginRight: 4
|
|
199
|
-
},
|
|
200
|
-
textFieldInput: {
|
|
201
|
-
fontSize: '14px',
|
|
202
|
-
paddingLeft: 1,
|
|
203
|
-
paddingRight: 1,
|
|
204
|
-
color: '#051039',
|
|
205
|
-
WebkitTextFillColor: '#051039' // safari text color fix
|
|
206
|
-
|
|
207
|
-
},
|
|
208
|
-
textFieldLabel: {
|
|
209
|
-
fontSize: '14px'
|
|
210
|
-
},
|
|
211
|
-
textFieldLabelShrink: {
|
|
212
|
-
transform: 'translate(2px, 10px) scale(0.75) !important'
|
|
213
|
-
},
|
|
214
|
-
formRow: {
|
|
215
|
-
marginTop: 8,
|
|
216
|
-
backgroundColor: theme.palette.common.white,
|
|
217
|
-
position: 'relative'
|
|
218
|
-
},
|
|
219
|
-
tacTitle: {
|
|
220
|
-
fontSize: '20px',
|
|
221
|
-
fontWeight: 500
|
|
222
|
-
},
|
|
223
|
-
tacText: {
|
|
224
|
-
fontSize: '14px',
|
|
225
|
-
color: '#000000'
|
|
226
|
-
},
|
|
227
|
-
tacLine: {
|
|
228
|
-
margin: '0',
|
|
229
|
-
padding: '.1em .1em .1em 0.8em',
|
|
230
|
-
textIndent: '-0.7em',
|
|
231
|
-
borderRadius: '3px'
|
|
232
|
-
},
|
|
233
|
-
addButton: {
|
|
234
|
-
marginRight: '38px'
|
|
235
|
-
},
|
|
236
|
-
lifecycleButtons: {
|
|
237
|
-
marginTop: '40px',
|
|
238
|
-
marginBottom: '16px'
|
|
239
|
-
},
|
|
240
|
-
actionButton: {
|
|
241
|
-
marginRight: '16px'
|
|
242
|
-
},
|
|
243
|
-
lastButton: {
|
|
244
|
-
marginRight: '90px'
|
|
245
|
-
},
|
|
246
|
-
backdrop: {
|
|
247
|
-
zIndex: 1500,
|
|
248
|
-
color: '#fff'
|
|
249
|
-
}
|
|
250
|
-
};
|
|
251
|
-
});
|
|
252
|
-
|
|
253
180
|
function _typeof(obj) {
|
|
254
181
|
"@babel/helpers - typeof";
|
|
255
182
|
|
|
@@ -2210,6 +2137,71 @@ var useTACGenerator = function useTACGenerator(taf, requestTAC, standardTAC) {
|
|
|
2210
2137
|
}, [standardTAC]);
|
|
2211
2138
|
return [TAC, retrieveTAC];
|
|
2212
2139
|
};
|
|
2140
|
+
var getRange = function getRange(min, max) {
|
|
2141
|
+
return Array.from({
|
|
2142
|
+
length: max - min + 1
|
|
2143
|
+
}, function (_, i) {
|
|
2144
|
+
return min + i;
|
|
2145
|
+
});
|
|
2146
|
+
};
|
|
2147
|
+
var useDragOrder = function useDragOrder(trigger, move, fields) {
|
|
2148
|
+
// create simple ordered list with hover (chosen) state
|
|
2149
|
+
var _a = __read(React__default.useState([]), 2),
|
|
2150
|
+
sortedFields = _a[0],
|
|
2151
|
+
setSortedFields = _a[1];
|
|
2152
|
+
|
|
2153
|
+
var _b = __read(React__default.useState([null, null]), 2),
|
|
2154
|
+
lastDragOrder = _b[0],
|
|
2155
|
+
onUpdatelastDragOrder = _b[1];
|
|
2156
|
+
|
|
2157
|
+
var onChangeOrder = function onChangeOrder(_a) {
|
|
2158
|
+
var oldIndex = _a.oldIndex,
|
|
2159
|
+
newIndex = _a.newIndex;
|
|
2160
|
+
if (oldIndex === undefined || newIndex === undefined) return;
|
|
2161
|
+
move(oldIndex, newIndex);
|
|
2162
|
+
onUpdatelastDragOrder([oldIndex, newIndex]);
|
|
2163
|
+
};
|
|
2164
|
+
|
|
2165
|
+
React__default.useEffect(function () {
|
|
2166
|
+
setSortedFields(fields.map(function (_a) {
|
|
2167
|
+
var id = _a.id;
|
|
2168
|
+
return {
|
|
2169
|
+
id: id,
|
|
2170
|
+
chosen: false
|
|
2171
|
+
};
|
|
2172
|
+
}));
|
|
2173
|
+
}, [fields]); // triggers validation AFTER render of new sorted elements
|
|
2174
|
+
|
|
2175
|
+
React__default.useEffect(function () {
|
|
2176
|
+
var _a = __read(lastDragOrder, 2),
|
|
2177
|
+
oldIndex = _a[0],
|
|
2178
|
+
newIndex = _a[1];
|
|
2179
|
+
|
|
2180
|
+
if (oldIndex !== null && newIndex !== null) {
|
|
2181
|
+
// trigger validation of moved rows
|
|
2182
|
+
var _b = __read([oldIndex, newIndex].sort(function (a, b) {
|
|
2183
|
+
return a - b;
|
|
2184
|
+
}), 2),
|
|
2185
|
+
start = _b[0],
|
|
2186
|
+
end = _b[1];
|
|
2187
|
+
|
|
2188
|
+
var changedRows = getRange(start, end);
|
|
2189
|
+
var fieldsToValidate = changedRows.reduce(function (list, rowIndex) {
|
|
2190
|
+
var fieldsDict = getFieldNames(true, rowIndex);
|
|
2191
|
+
var fields = Object.keys(fieldsDict).map(function (key) {
|
|
2192
|
+
return fieldsDict[key];
|
|
2193
|
+
});
|
|
2194
|
+
return list.concat(fields);
|
|
2195
|
+
}, []);
|
|
2196
|
+
trigger(fieldsToValidate);
|
|
2197
|
+
}
|
|
2198
|
+
}, [lastDragOrder, trigger]);
|
|
2199
|
+
return {
|
|
2200
|
+
onChangeOrder: onChangeOrder,
|
|
2201
|
+
sortedFields: sortedFields,
|
|
2202
|
+
setSortedFields: setSortedFields
|
|
2203
|
+
};
|
|
2204
|
+
}; // dialog utils
|
|
2213
2205
|
|
|
2214
2206
|
var getConfirmationDialogTitle = function getConfirmationDialogTitle(action) {
|
|
2215
2207
|
if (action === 'DISCARD') return 'Discard TAF';
|
|
@@ -2239,6 +2231,86 @@ var getConfirmationDialogButtonLabel = function getConfirmationDialogButtonLabel
|
|
|
2239
2231
|
}
|
|
2240
2232
|
};
|
|
2241
2233
|
|
|
2234
|
+
/* *
|
|
2235
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
2236
|
+
* you may not use this file except in compliance with the License.
|
|
2237
|
+
* You may obtain a copy of the License at
|
|
2238
|
+
*
|
|
2239
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
2240
|
+
*
|
|
2241
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
2242
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
2243
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2244
|
+
* See the License for the specific language governing permissions and
|
|
2245
|
+
* limitations under the License.
|
|
2246
|
+
*
|
|
2247
|
+
* Copyright 2021 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
|
|
2248
|
+
* Copyright 2021 - Finnish Meteorological Institute (FMI)
|
|
2249
|
+
* */
|
|
2250
|
+
var useStyles$9 = makeStyles(function (theme) {
|
|
2251
|
+
return {
|
|
2252
|
+
textFieldGridItem: {
|
|
2253
|
+
marginRight: 4
|
|
2254
|
+
},
|
|
2255
|
+
textFieldInput: {
|
|
2256
|
+
fontSize: '14px',
|
|
2257
|
+
paddingLeft: 1,
|
|
2258
|
+
paddingRight: 1,
|
|
2259
|
+
color: '#051039',
|
|
2260
|
+
WebkitTextFillColor: '#051039' // safari text color fix
|
|
2261
|
+
|
|
2262
|
+
},
|
|
2263
|
+
textFieldLabel: {
|
|
2264
|
+
fontSize: '14px'
|
|
2265
|
+
},
|
|
2266
|
+
textFieldLabelShrink: {
|
|
2267
|
+
transform: 'translate(2px, 10px) scale(0.75) !important'
|
|
2268
|
+
},
|
|
2269
|
+
formRow: {
|
|
2270
|
+
marginTop: 8,
|
|
2271
|
+
backgroundColor: theme.palette.common.white,
|
|
2272
|
+
position: 'relative',
|
|
2273
|
+
'&.sortable-chosen': {
|
|
2274
|
+
boxShadow: theme.shadows[1]
|
|
2275
|
+
},
|
|
2276
|
+
'&.sortable-ghost': {
|
|
2277
|
+
opacity: 0.5
|
|
2278
|
+
}
|
|
2279
|
+
},
|
|
2280
|
+
tacTitle: {
|
|
2281
|
+
fontSize: '20px',
|
|
2282
|
+
fontWeight: 500
|
|
2283
|
+
},
|
|
2284
|
+
tacText: {
|
|
2285
|
+
fontSize: '14px',
|
|
2286
|
+
color: '#000000'
|
|
2287
|
+
},
|
|
2288
|
+
tacLine: {
|
|
2289
|
+
margin: '0',
|
|
2290
|
+
padding: '.1em .1em .1em 0.8em',
|
|
2291
|
+
textIndent: '-0.7em',
|
|
2292
|
+
borderRadius: '3px'
|
|
2293
|
+
},
|
|
2294
|
+
addButton: {
|
|
2295
|
+
marginRight: '38px'
|
|
2296
|
+
},
|
|
2297
|
+
lifecycleButtons: {
|
|
2298
|
+
marginTop: '40px',
|
|
2299
|
+
marginBottom: '16px'
|
|
2300
|
+
},
|
|
2301
|
+
actionButton: {
|
|
2302
|
+
marginRight: '16px'
|
|
2303
|
+
},
|
|
2304
|
+
lastButton: {
|
|
2305
|
+
marginRight: '90px'
|
|
2306
|
+
},
|
|
2307
|
+
backdrop: {
|
|
2308
|
+
zIndex: 1500,
|
|
2309
|
+
color: '#fff'
|
|
2310
|
+
}
|
|
2311
|
+
};
|
|
2312
|
+
});
|
|
2313
|
+
|
|
2242
2314
|
var getTafErrors = function getTafErrors(name, errors) {
|
|
2243
2315
|
var nameAsArray = name.split('.');
|
|
2244
2316
|
|
|
@@ -2260,7 +2332,7 @@ var getDisplayValue = function getDisplayValue(value, disabled) {
|
|
|
2260
2332
|
return disabled && !value ? '-' : value;
|
|
2261
2333
|
};
|
|
2262
2334
|
var BaseTextField = /*#__PURE__*/React__default.memo(function (props) {
|
|
2263
|
-
var classes = useStyles$
|
|
2335
|
+
var classes = useStyles$9();
|
|
2264
2336
|
return /*#__PURE__*/React__default.createElement(TextField, __assign({
|
|
2265
2337
|
type: "text",
|
|
2266
2338
|
variant: "filled",
|
|
@@ -2299,7 +2371,7 @@ var TafFormTextField = function TafFormTextField(_a) {
|
|
|
2299
2371
|
autoComplete = _h === void 0 ? [] : _h,
|
|
2300
2372
|
_j = _a.autoFocus,
|
|
2301
2373
|
autoFocus = _j === void 0 ? false : _j;
|
|
2302
|
-
var classes = useStyles$
|
|
2374
|
+
var classes = useStyles$9();
|
|
2303
2375
|
|
|
2304
2376
|
var _k = useFormContext(),
|
|
2305
2377
|
control = _k.control,
|
|
@@ -2463,7 +2535,7 @@ var getRequiredCrossFields = function getRequiredCrossFields(fieldNames) {
|
|
|
2463
2535
|
return [[fieldNames.valid, fieldNames.change], [fieldNames.probability], [fieldNames.wind, fieldNames.visibility, fieldNames.weather1, fieldNames.cloud1]];
|
|
2464
2536
|
};
|
|
2465
2537
|
|
|
2466
|
-
var TafFormRow = function
|
|
2538
|
+
var TafFormRow = /*#__PURE__*/React__default.forwardRef(function (_a, ref) {
|
|
2467
2539
|
var _b = _a.isChangeGroup,
|
|
2468
2540
|
isChangeGroup = _b === void 0 ? false : _b,
|
|
2469
2541
|
_c = _a.disabled,
|
|
@@ -2475,28 +2547,23 @@ var TafFormRow = function TafFormRow(_a) {
|
|
|
2475
2547
|
onRemoveChangeGroup = _a.onRemoveChangeGroup,
|
|
2476
2548
|
_f = _a.field,
|
|
2477
2549
|
field = _f === void 0 ? null : _f,
|
|
2478
|
-
_g = _a.
|
|
2479
|
-
|
|
2480
|
-
|
|
2481
|
-
} : _g,
|
|
2482
|
-
_h = _a.dragHandle,
|
|
2483
|
-
dragHandle = _h === void 0 ? null : _h,
|
|
2484
|
-
props = __rest(_a, ["isChangeGroup", "disabled", "index", "lastRow", "onRemoveChangeGroup", "field", "onRef", "dragHandle"]);
|
|
2550
|
+
_g = _a.dragHandle,
|
|
2551
|
+
dragHandle = _g === void 0 ? null : _g,
|
|
2552
|
+
props = __rest(_a, ["isChangeGroup", "disabled", "index", "lastRow", "onRemoveChangeGroup", "field", "dragHandle"]);
|
|
2485
2553
|
|
|
2486
|
-
var classes = useStyles$8();
|
|
2487
2554
|
var namePrefix = !isChangeGroup ? 'baseForecast' : "changeGroups[" + index + "]";
|
|
2488
2555
|
var fieldNames = getFieldNames(isChangeGroup, index);
|
|
2489
2556
|
|
|
2490
|
-
var
|
|
2491
|
-
getValues =
|
|
2492
|
-
trigger =
|
|
2557
|
+
var _h = useFormContext(),
|
|
2558
|
+
getValues = _h.getValues,
|
|
2559
|
+
trigger = _h.trigger;
|
|
2493
2560
|
|
|
2494
2561
|
var isNotRequiredForAction = useDraftFormHelpers().isRequired; // cross-field required validation
|
|
2495
2562
|
|
|
2496
|
-
var
|
|
2497
|
-
mainFields =
|
|
2498
|
-
mainOptionalFields =
|
|
2499
|
-
subFields =
|
|
2563
|
+
var _j = __read(getRequiredCrossFields(fieldNames), 3),
|
|
2564
|
+
mainFields = _j[0],
|
|
2565
|
+
mainOptionalFields = _j[1],
|
|
2566
|
+
subFields = _j[2];
|
|
2500
2567
|
|
|
2501
2568
|
var hasFieldsValue = function hasFieldsValue(fields) {
|
|
2502
2569
|
return fields.map(getValues).find(function (field) {
|
|
@@ -2543,8 +2610,7 @@ var TafFormRow = function TafFormRow(_a) {
|
|
|
2543
2610
|
return /*#__PURE__*/React__default.createElement(Grid, __assign({
|
|
2544
2611
|
"data-testid": "row-" + namePrefix,
|
|
2545
2612
|
container: true,
|
|
2546
|
-
|
|
2547
|
-
ref: onRef
|
|
2613
|
+
ref: ref
|
|
2548
2614
|
}, props), !isChangeGroup && /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement(TafFormTextField, {
|
|
2549
2615
|
label: "Type",
|
|
2550
2616
|
name: fieldNames.messageType,
|
|
@@ -2805,7 +2871,7 @@ var TafFormRow = function TafFormRow(_a) {
|
|
|
2805
2871
|
}, lastRow ? {
|
|
2806
2872
|
tabIndex: '-1'
|
|
2807
2873
|
} : {}), /*#__PURE__*/React__default.createElement(Delete, null))));
|
|
2808
|
-
};
|
|
2874
|
+
});
|
|
2809
2875
|
|
|
2810
2876
|
var getIssuesLabel = function getIssuesLabel(sumOfErrors) {
|
|
2811
2877
|
switch (sumOfErrors) {
|
|
@@ -2891,7 +2957,7 @@ var ThumbsUp = function ThumbsUp(props) {
|
|
|
2891
2957
|
* Copyright 2021 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
|
|
2892
2958
|
* Copyright 2021 - Finnish Meteorological Institute (FMI)
|
|
2893
2959
|
* */
|
|
2894
|
-
var useStyles$
|
|
2960
|
+
var useStyles$8 = makeStyles({
|
|
2895
2961
|
issuesPane: {
|
|
2896
2962
|
display: 'flex',
|
|
2897
2963
|
flexDirection: 'column',
|
|
@@ -2993,7 +3059,7 @@ var IssuesPane = function IssuesPane(_a) {
|
|
|
2993
3059
|
var handleClose = _a.handleClose,
|
|
2994
3060
|
_b = _a.errorList,
|
|
2995
3061
|
errorList = _b === void 0 ? [] : _b;
|
|
2996
|
-
var classes = useStyles$
|
|
3062
|
+
var classes = useStyles$8();
|
|
2997
3063
|
return /*#__PURE__*/React.createElement(Paper, {
|
|
2998
3064
|
elevation: 3,
|
|
2999
3065
|
className: classes.issuesPane
|
|
@@ -3079,7 +3145,7 @@ var filterDuplicateErrors = function filterDuplicateErrors(errors) {
|
|
|
3079
3145
|
var TafFormButtons = function TafFormButtons(_a) {
|
|
3080
3146
|
var tafAction = _a.tafAction,
|
|
3081
3147
|
onTafFormButtonPress = _a.onTafFormButtonPress;
|
|
3082
|
-
var classes = useStyles$
|
|
3148
|
+
var classes = useStyles$9();
|
|
3083
3149
|
var errors = useFormContext().errors;
|
|
3084
3150
|
var errorList = filterDuplicateErrors(getErrors(errors));
|
|
3085
3151
|
|
|
@@ -3179,6 +3245,50 @@ var TafFormButtons = function TafFormButtons(_a) {
|
|
|
3179
3245
|
}));
|
|
3180
3246
|
};
|
|
3181
3247
|
|
|
3248
|
+
/* *
|
|
3249
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
3250
|
+
* you may not use this file except in compliance with the License.
|
|
3251
|
+
* You may obtain a copy of the License at
|
|
3252
|
+
*
|
|
3253
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
3254
|
+
*
|
|
3255
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
3256
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
3257
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
3258
|
+
* See the License for the specific language governing permissions and
|
|
3259
|
+
* limitations under the License.
|
|
3260
|
+
*
|
|
3261
|
+
* Copyright 2021 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
|
|
3262
|
+
* Copyright 2021 - Finnish Meteorological Institute (FMI)
|
|
3263
|
+
* */
|
|
3264
|
+
var useStyles$7 = makeStyles(function () {
|
|
3265
|
+
return {
|
|
3266
|
+
dragHandle: {
|
|
3267
|
+
backgroundColor: 'transparent',
|
|
3268
|
+
'&:hover': {
|
|
3269
|
+
backgroundColor: 'transparent'
|
|
3270
|
+
},
|
|
3271
|
+
cursor: function cursor(isSorting) {
|
|
3272
|
+
return isSorting ? 'grabbing' : 'grab';
|
|
3273
|
+
}
|
|
3274
|
+
}
|
|
3275
|
+
};
|
|
3276
|
+
});
|
|
3277
|
+
|
|
3278
|
+
var DragHandle = function DragHandle(_a) {
|
|
3279
|
+
var _b = _a.isSorting,
|
|
3280
|
+
isSorting = _b === void 0 ? false : _b,
|
|
3281
|
+
_c = _a.isDisabled,
|
|
3282
|
+
isDisabled = _c === void 0 ? false : _c;
|
|
3283
|
+
var classes = useStyles$7(isSorting);
|
|
3284
|
+
return /*#__PURE__*/React__default.createElement(IconButton, {
|
|
3285
|
+
className: classes.dragHandle + " handle",
|
|
3286
|
+
"data-testid": "dragHandle",
|
|
3287
|
+
disableRipple: true,
|
|
3288
|
+
disabled: isDisabled
|
|
3289
|
+
}, /*#__PURE__*/React__default.createElement(DragIndicator, null));
|
|
3290
|
+
};
|
|
3291
|
+
|
|
3182
3292
|
var emptyRow = {
|
|
3183
3293
|
valid: '',
|
|
3184
3294
|
wind: '',
|
|
@@ -3208,7 +3318,7 @@ var TafForm = function TafForm(_a) {
|
|
|
3208
3318
|
onFormAction = _c === void 0 ? function () {
|
|
3209
3319
|
return null;
|
|
3210
3320
|
} : _c;
|
|
3211
|
-
var classes = useStyles$
|
|
3321
|
+
var classes = useStyles$9();
|
|
3212
3322
|
var confirmDialog = useConfirmationDialog();
|
|
3213
3323
|
|
|
3214
3324
|
var _d = useDraftFormHelpers(),
|
|
@@ -3223,7 +3333,8 @@ var TafForm = function TafForm(_a) {
|
|
|
3223
3333
|
handleSubmit = _e.handleSubmit,
|
|
3224
3334
|
watch = _e.watch,
|
|
3225
3335
|
getValues = _e.getValues,
|
|
3226
|
-
errors = _e.errors
|
|
3336
|
+
errors = _e.errors,
|
|
3337
|
+
trigger = _e.trigger;
|
|
3227
3338
|
|
|
3228
3339
|
var hiddenInputFields = ['baseTime', 'issueDate', 'type', 'uuid', 'validDateStart', 'validDateEnd', 'status', 'previousId', 'previousValidDateStart', 'previousValidDateEnd'];
|
|
3229
3340
|
|
|
@@ -3262,7 +3373,8 @@ var TafForm = function TafForm(_a) {
|
|
|
3262
3373
|
}),
|
|
3263
3374
|
fields = _j.fields,
|
|
3264
3375
|
append = _j.append,
|
|
3265
|
-
remove = _j.remove
|
|
3376
|
+
remove = _j.remove,
|
|
3377
|
+
move = _j.move;
|
|
3266
3378
|
|
|
3267
3379
|
var onSubmit = function onSubmit(data) {
|
|
3268
3380
|
// eslint-disable-next-line no-console
|
|
@@ -3320,10 +3432,6 @@ var TafForm = function TafForm(_a) {
|
|
|
3320
3432
|
append(emptyRow);
|
|
3321
3433
|
};
|
|
3322
3434
|
|
|
3323
|
-
var onRemoverow = function onRemoverow(index) {
|
|
3324
|
-
remove(index);
|
|
3325
|
-
};
|
|
3326
|
-
|
|
3327
3435
|
React__default.useEffect(function () {
|
|
3328
3436
|
// set changegroups on mount (if no changegroups - add empty one by default)
|
|
3329
3437
|
if (changeGroups.length > 0) {
|
|
@@ -3335,6 +3443,20 @@ var TafForm = function TafForm(_a) {
|
|
|
3335
3443
|
} // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
3336
3444
|
|
|
3337
3445
|
}, []);
|
|
3446
|
+
|
|
3447
|
+
var _k = useDragOrder(trigger, move, fields),
|
|
3448
|
+
onChangeOrder = _k.onChangeOrder,
|
|
3449
|
+
sortedFields = _k.sortedFields,
|
|
3450
|
+
setSortedFields = _k.setSortedFields;
|
|
3451
|
+
|
|
3452
|
+
var onRemoverow = function onRemoverow(index) {
|
|
3453
|
+
remove(index);
|
|
3454
|
+
var newList = fields.length > 1 ? fields.filter(function (_, fieldIndex) {
|
|
3455
|
+
return fieldIndex === index;
|
|
3456
|
+
}) : [];
|
|
3457
|
+
setSortedFields(newList);
|
|
3458
|
+
};
|
|
3459
|
+
|
|
3338
3460
|
return /*#__PURE__*/React__default.createElement("form", {
|
|
3339
3461
|
onSubmit: handleSubmit(onSubmit),
|
|
3340
3462
|
onChange: onFormChange,
|
|
@@ -3352,17 +3474,37 @@ var TafForm = function TafForm(_a) {
|
|
|
3352
3474
|
}, line);
|
|
3353
3475
|
})), /*#__PURE__*/React__default.createElement(TafFormRow, {
|
|
3354
3476
|
disabled: isDisabled
|
|
3355
|
-
}),
|
|
3477
|
+
}), /*#__PURE__*/React__default.createElement(ReactSortable, {
|
|
3478
|
+
tag: "div",
|
|
3479
|
+
list: sortedFields,
|
|
3480
|
+
setList: setSortedFields,
|
|
3481
|
+
animation: 200,
|
|
3482
|
+
onSort: onChangeOrder,
|
|
3483
|
+
handle: ".handle",
|
|
3484
|
+
direction: "vertical",
|
|
3485
|
+
// hover props
|
|
3486
|
+
forceFallback: true,
|
|
3487
|
+
onStart: function onStart() {
|
|
3488
|
+
Sortable.ghost.style.opacity = '1';
|
|
3489
|
+
}
|
|
3490
|
+
}, sortedFields.map(function (_a, index) {
|
|
3491
|
+
var chosen = _a.chosen;
|
|
3492
|
+
var item = fields[index];
|
|
3356
3493
|
return /*#__PURE__*/React__default.createElement(TafFormRow, {
|
|
3357
3494
|
field: item,
|
|
3495
|
+
className: classes.formRow,
|
|
3358
3496
|
key: item.id,
|
|
3359
3497
|
index: index,
|
|
3360
3498
|
lastRow: fields.length === index + 1,
|
|
3361
3499
|
disabled: isDisabled,
|
|
3362
3500
|
onRemoveChangeGroup: onRemoverow,
|
|
3363
|
-
isChangeGroup: true
|
|
3501
|
+
isChangeGroup: true,
|
|
3502
|
+
dragHandle: /*#__PURE__*/React__default.createElement(DragHandle, {
|
|
3503
|
+
isDisabled: sortedFields.length === 1 || isDisabled,
|
|
3504
|
+
isSorting: chosen
|
|
3505
|
+
})
|
|
3364
3506
|
});
|
|
3365
|
-
}), !isDisabled && /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement(Grid, {
|
|
3507
|
+
})), !isDisabled && /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement(Grid, {
|
|
3366
3508
|
container: true,
|
|
3367
3509
|
item: true,
|
|
3368
3510
|
xs: 12,
|
package/taf.umd.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
(function (global, factory) {
|
|
2
|
-
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('react'), require('@material-ui/core'), require('@material-ui/lab'), require('moment'), require('@opengeoweb/shared'), require('@material-ui/icons'), require('@opengeoweb/api'), require('@opengeoweb/form-fields'), require('react-hook-form')) :
|
|
3
|
-
typeof define === 'function' && define.amd ? define(['exports', 'react', '@material-ui/core', '@material-ui/lab', 'moment', '@opengeoweb/shared', '@material-ui/icons', '@opengeoweb/api', '@opengeoweb/form-fields', 'react-hook-form'], factory) :
|
|
4
|
-
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.Taf = {}, global.React, global.core, global.lab, global.moment, global.shared, global.icons, global.api, global.formFields, global.reactHookForm));
|
|
5
|
-
}(this, (function (exports, React, core, lab, moment, shared, icons, api, formFields, reactHookForm) { 'use strict';
|
|
2
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('react'), require('@material-ui/core'), require('@material-ui/lab'), require('moment'), require('@opengeoweb/shared'), require('@material-ui/icons'), require('@opengeoweb/api'), require('@opengeoweb/form-fields'), require('react-hook-form'), require('react-sortablejs')) :
|
|
3
|
+
typeof define === 'function' && define.amd ? define(['exports', 'react', '@material-ui/core', '@material-ui/lab', 'moment', '@opengeoweb/shared', '@material-ui/icons', '@opengeoweb/api', '@opengeoweb/form-fields', 'react-hook-form', 'react-sortablejs'], factory) :
|
|
4
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.Taf = {}, global.React, global.core, global.lab, global.moment, global.shared, global.icons, global.api, global.formFields, global.reactHookForm, global.reactSortablejs));
|
|
5
|
+
}(this, (function (exports, React, core, lab, moment, shared, icons, api, formFields, reactHookForm, reactSortablejs) { 'use strict';
|
|
6
6
|
|
|
7
7
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
8
8
|
|
|
@@ -197,80 +197,6 @@
|
|
|
197
197
|
locations: locations
|
|
198
198
|
};
|
|
199
199
|
|
|
200
|
-
/* *
|
|
201
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
202
|
-
* you may not use this file except in compliance with the License.
|
|
203
|
-
* You may obtain a copy of the License at
|
|
204
|
-
*
|
|
205
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
206
|
-
*
|
|
207
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
208
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
209
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
210
|
-
* See the License for the specific language governing permissions and
|
|
211
|
-
* limitations under the License.
|
|
212
|
-
*
|
|
213
|
-
* Copyright 2021 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
|
|
214
|
-
* Copyright 2021 - Finnish Meteorological Institute (FMI)
|
|
215
|
-
* */
|
|
216
|
-
var useStyles$8 = core.makeStyles(function (theme) {
|
|
217
|
-
return {
|
|
218
|
-
textFieldGridItem: {
|
|
219
|
-
marginRight: 4
|
|
220
|
-
},
|
|
221
|
-
textFieldInput: {
|
|
222
|
-
fontSize: '14px',
|
|
223
|
-
paddingLeft: 1,
|
|
224
|
-
paddingRight: 1,
|
|
225
|
-
color: '#051039',
|
|
226
|
-
WebkitTextFillColor: '#051039' // safari text color fix
|
|
227
|
-
|
|
228
|
-
},
|
|
229
|
-
textFieldLabel: {
|
|
230
|
-
fontSize: '14px'
|
|
231
|
-
},
|
|
232
|
-
textFieldLabelShrink: {
|
|
233
|
-
transform: 'translate(2px, 10px) scale(0.75) !important'
|
|
234
|
-
},
|
|
235
|
-
formRow: {
|
|
236
|
-
marginTop: 8,
|
|
237
|
-
backgroundColor: theme.palette.common.white,
|
|
238
|
-
position: 'relative'
|
|
239
|
-
},
|
|
240
|
-
tacTitle: {
|
|
241
|
-
fontSize: '20px',
|
|
242
|
-
fontWeight: 500
|
|
243
|
-
},
|
|
244
|
-
tacText: {
|
|
245
|
-
fontSize: '14px',
|
|
246
|
-
color: '#000000'
|
|
247
|
-
},
|
|
248
|
-
tacLine: {
|
|
249
|
-
margin: '0',
|
|
250
|
-
padding: '.1em .1em .1em 0.8em',
|
|
251
|
-
textIndent: '-0.7em',
|
|
252
|
-
borderRadius: '3px'
|
|
253
|
-
},
|
|
254
|
-
addButton: {
|
|
255
|
-
marginRight: '38px'
|
|
256
|
-
},
|
|
257
|
-
lifecycleButtons: {
|
|
258
|
-
marginTop: '40px',
|
|
259
|
-
marginBottom: '16px'
|
|
260
|
-
},
|
|
261
|
-
actionButton: {
|
|
262
|
-
marginRight: '16px'
|
|
263
|
-
},
|
|
264
|
-
lastButton: {
|
|
265
|
-
marginRight: '90px'
|
|
266
|
-
},
|
|
267
|
-
backdrop: {
|
|
268
|
-
zIndex: 1500,
|
|
269
|
-
color: '#fff'
|
|
270
|
-
}
|
|
271
|
-
};
|
|
272
|
-
});
|
|
273
|
-
|
|
274
200
|
function _typeof(obj) {
|
|
275
201
|
"@babel/helpers - typeof";
|
|
276
202
|
|
|
@@ -2231,6 +2157,71 @@
|
|
|
2231
2157
|
}, [standardTAC]);
|
|
2232
2158
|
return [TAC, retrieveTAC];
|
|
2233
2159
|
};
|
|
2160
|
+
var getRange = function getRange(min, max) {
|
|
2161
|
+
return Array.from({
|
|
2162
|
+
length: max - min + 1
|
|
2163
|
+
}, function (_, i) {
|
|
2164
|
+
return min + i;
|
|
2165
|
+
});
|
|
2166
|
+
};
|
|
2167
|
+
var useDragOrder = function useDragOrder(trigger, move, fields) {
|
|
2168
|
+
// create simple ordered list with hover (chosen) state
|
|
2169
|
+
var _a = __read(React__default['default'].useState([]), 2),
|
|
2170
|
+
sortedFields = _a[0],
|
|
2171
|
+
setSortedFields = _a[1];
|
|
2172
|
+
|
|
2173
|
+
var _b = __read(React__default['default'].useState([null, null]), 2),
|
|
2174
|
+
lastDragOrder = _b[0],
|
|
2175
|
+
onUpdatelastDragOrder = _b[1];
|
|
2176
|
+
|
|
2177
|
+
var onChangeOrder = function onChangeOrder(_a) {
|
|
2178
|
+
var oldIndex = _a.oldIndex,
|
|
2179
|
+
newIndex = _a.newIndex;
|
|
2180
|
+
if (oldIndex === undefined || newIndex === undefined) return;
|
|
2181
|
+
move(oldIndex, newIndex);
|
|
2182
|
+
onUpdatelastDragOrder([oldIndex, newIndex]);
|
|
2183
|
+
};
|
|
2184
|
+
|
|
2185
|
+
React__default['default'].useEffect(function () {
|
|
2186
|
+
setSortedFields(fields.map(function (_a) {
|
|
2187
|
+
var id = _a.id;
|
|
2188
|
+
return {
|
|
2189
|
+
id: id,
|
|
2190
|
+
chosen: false
|
|
2191
|
+
};
|
|
2192
|
+
}));
|
|
2193
|
+
}, [fields]); // triggers validation AFTER render of new sorted elements
|
|
2194
|
+
|
|
2195
|
+
React__default['default'].useEffect(function () {
|
|
2196
|
+
var _a = __read(lastDragOrder, 2),
|
|
2197
|
+
oldIndex = _a[0],
|
|
2198
|
+
newIndex = _a[1];
|
|
2199
|
+
|
|
2200
|
+
if (oldIndex !== null && newIndex !== null) {
|
|
2201
|
+
// trigger validation of moved rows
|
|
2202
|
+
var _b = __read([oldIndex, newIndex].sort(function (a, b) {
|
|
2203
|
+
return a - b;
|
|
2204
|
+
}), 2),
|
|
2205
|
+
start = _b[0],
|
|
2206
|
+
end = _b[1];
|
|
2207
|
+
|
|
2208
|
+
var changedRows = getRange(start, end);
|
|
2209
|
+
var fieldsToValidate = changedRows.reduce(function (list, rowIndex) {
|
|
2210
|
+
var fieldsDict = getFieldNames(true, rowIndex);
|
|
2211
|
+
var fields = Object.keys(fieldsDict).map(function (key) {
|
|
2212
|
+
return fieldsDict[key];
|
|
2213
|
+
});
|
|
2214
|
+
return list.concat(fields);
|
|
2215
|
+
}, []);
|
|
2216
|
+
trigger(fieldsToValidate);
|
|
2217
|
+
}
|
|
2218
|
+
}, [lastDragOrder, trigger]);
|
|
2219
|
+
return {
|
|
2220
|
+
onChangeOrder: onChangeOrder,
|
|
2221
|
+
sortedFields: sortedFields,
|
|
2222
|
+
setSortedFields: setSortedFields
|
|
2223
|
+
};
|
|
2224
|
+
}; // dialog utils
|
|
2234
2225
|
|
|
2235
2226
|
var getConfirmationDialogTitle = function getConfirmationDialogTitle(action) {
|
|
2236
2227
|
if (action === 'DISCARD') return 'Discard TAF';
|
|
@@ -2260,6 +2251,86 @@
|
|
|
2260
2251
|
}
|
|
2261
2252
|
};
|
|
2262
2253
|
|
|
2254
|
+
/* *
|
|
2255
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
2256
|
+
* you may not use this file except in compliance with the License.
|
|
2257
|
+
* You may obtain a copy of the License at
|
|
2258
|
+
*
|
|
2259
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
2260
|
+
*
|
|
2261
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
2262
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
2263
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2264
|
+
* See the License for the specific language governing permissions and
|
|
2265
|
+
* limitations under the License.
|
|
2266
|
+
*
|
|
2267
|
+
* Copyright 2021 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
|
|
2268
|
+
* Copyright 2021 - Finnish Meteorological Institute (FMI)
|
|
2269
|
+
* */
|
|
2270
|
+
var useStyles$9 = core.makeStyles(function (theme) {
|
|
2271
|
+
return {
|
|
2272
|
+
textFieldGridItem: {
|
|
2273
|
+
marginRight: 4
|
|
2274
|
+
},
|
|
2275
|
+
textFieldInput: {
|
|
2276
|
+
fontSize: '14px',
|
|
2277
|
+
paddingLeft: 1,
|
|
2278
|
+
paddingRight: 1,
|
|
2279
|
+
color: '#051039',
|
|
2280
|
+
WebkitTextFillColor: '#051039' // safari text color fix
|
|
2281
|
+
|
|
2282
|
+
},
|
|
2283
|
+
textFieldLabel: {
|
|
2284
|
+
fontSize: '14px'
|
|
2285
|
+
},
|
|
2286
|
+
textFieldLabelShrink: {
|
|
2287
|
+
transform: 'translate(2px, 10px) scale(0.75) !important'
|
|
2288
|
+
},
|
|
2289
|
+
formRow: {
|
|
2290
|
+
marginTop: 8,
|
|
2291
|
+
backgroundColor: theme.palette.common.white,
|
|
2292
|
+
position: 'relative',
|
|
2293
|
+
'&.sortable-chosen': {
|
|
2294
|
+
boxShadow: theme.shadows[1]
|
|
2295
|
+
},
|
|
2296
|
+
'&.sortable-ghost': {
|
|
2297
|
+
opacity: 0.5
|
|
2298
|
+
}
|
|
2299
|
+
},
|
|
2300
|
+
tacTitle: {
|
|
2301
|
+
fontSize: '20px',
|
|
2302
|
+
fontWeight: 500
|
|
2303
|
+
},
|
|
2304
|
+
tacText: {
|
|
2305
|
+
fontSize: '14px',
|
|
2306
|
+
color: '#000000'
|
|
2307
|
+
},
|
|
2308
|
+
tacLine: {
|
|
2309
|
+
margin: '0',
|
|
2310
|
+
padding: '.1em .1em .1em 0.8em',
|
|
2311
|
+
textIndent: '-0.7em',
|
|
2312
|
+
borderRadius: '3px'
|
|
2313
|
+
},
|
|
2314
|
+
addButton: {
|
|
2315
|
+
marginRight: '38px'
|
|
2316
|
+
},
|
|
2317
|
+
lifecycleButtons: {
|
|
2318
|
+
marginTop: '40px',
|
|
2319
|
+
marginBottom: '16px'
|
|
2320
|
+
},
|
|
2321
|
+
actionButton: {
|
|
2322
|
+
marginRight: '16px'
|
|
2323
|
+
},
|
|
2324
|
+
lastButton: {
|
|
2325
|
+
marginRight: '90px'
|
|
2326
|
+
},
|
|
2327
|
+
backdrop: {
|
|
2328
|
+
zIndex: 1500,
|
|
2329
|
+
color: '#fff'
|
|
2330
|
+
}
|
|
2331
|
+
};
|
|
2332
|
+
});
|
|
2333
|
+
|
|
2263
2334
|
var getTafErrors = function getTafErrors(name, errors) {
|
|
2264
2335
|
var nameAsArray = name.split('.');
|
|
2265
2336
|
|
|
@@ -2281,7 +2352,7 @@
|
|
|
2281
2352
|
return disabled && !value ? '-' : value;
|
|
2282
2353
|
};
|
|
2283
2354
|
var BaseTextField = /*#__PURE__*/React__default['default'].memo(function (props) {
|
|
2284
|
-
var classes = useStyles$
|
|
2355
|
+
var classes = useStyles$9();
|
|
2285
2356
|
return /*#__PURE__*/React__default['default'].createElement(core.TextField, __assign({
|
|
2286
2357
|
type: "text",
|
|
2287
2358
|
variant: "filled",
|
|
@@ -2320,7 +2391,7 @@
|
|
|
2320
2391
|
autoComplete = _h === void 0 ? [] : _h,
|
|
2321
2392
|
_j = _a.autoFocus,
|
|
2322
2393
|
autoFocus = _j === void 0 ? false : _j;
|
|
2323
|
-
var classes = useStyles$
|
|
2394
|
+
var classes = useStyles$9();
|
|
2324
2395
|
|
|
2325
2396
|
var _k = reactHookForm.useFormContext(),
|
|
2326
2397
|
control = _k.control,
|
|
@@ -2484,7 +2555,7 @@
|
|
|
2484
2555
|
return [[fieldNames.valid, fieldNames.change], [fieldNames.probability], [fieldNames.wind, fieldNames.visibility, fieldNames.weather1, fieldNames.cloud1]];
|
|
2485
2556
|
};
|
|
2486
2557
|
|
|
2487
|
-
var TafFormRow = function
|
|
2558
|
+
var TafFormRow = /*#__PURE__*/React__default['default'].forwardRef(function (_a, ref) {
|
|
2488
2559
|
var _b = _a.isChangeGroup,
|
|
2489
2560
|
isChangeGroup = _b === void 0 ? false : _b,
|
|
2490
2561
|
_c = _a.disabled,
|
|
@@ -2496,28 +2567,23 @@
|
|
|
2496
2567
|
onRemoveChangeGroup = _a.onRemoveChangeGroup,
|
|
2497
2568
|
_f = _a.field,
|
|
2498
2569
|
field = _f === void 0 ? null : _f,
|
|
2499
|
-
_g = _a.
|
|
2500
|
-
|
|
2501
|
-
|
|
2502
|
-
} : _g,
|
|
2503
|
-
_h = _a.dragHandle,
|
|
2504
|
-
dragHandle = _h === void 0 ? null : _h,
|
|
2505
|
-
props = __rest(_a, ["isChangeGroup", "disabled", "index", "lastRow", "onRemoveChangeGroup", "field", "onRef", "dragHandle"]);
|
|
2570
|
+
_g = _a.dragHandle,
|
|
2571
|
+
dragHandle = _g === void 0 ? null : _g,
|
|
2572
|
+
props = __rest(_a, ["isChangeGroup", "disabled", "index", "lastRow", "onRemoveChangeGroup", "field", "dragHandle"]);
|
|
2506
2573
|
|
|
2507
|
-
var classes = useStyles$8();
|
|
2508
2574
|
var namePrefix = !isChangeGroup ? 'baseForecast' : "changeGroups[" + index + "]";
|
|
2509
2575
|
var fieldNames = getFieldNames(isChangeGroup, index);
|
|
2510
2576
|
|
|
2511
|
-
var
|
|
2512
|
-
getValues =
|
|
2513
|
-
trigger =
|
|
2577
|
+
var _h = reactHookForm.useFormContext(),
|
|
2578
|
+
getValues = _h.getValues,
|
|
2579
|
+
trigger = _h.trigger;
|
|
2514
2580
|
|
|
2515
2581
|
var isNotRequiredForAction = shared.useDraftFormHelpers().isRequired; // cross-field required validation
|
|
2516
2582
|
|
|
2517
|
-
var
|
|
2518
|
-
mainFields =
|
|
2519
|
-
mainOptionalFields =
|
|
2520
|
-
subFields =
|
|
2583
|
+
var _j = __read(getRequiredCrossFields(fieldNames), 3),
|
|
2584
|
+
mainFields = _j[0],
|
|
2585
|
+
mainOptionalFields = _j[1],
|
|
2586
|
+
subFields = _j[2];
|
|
2521
2587
|
|
|
2522
2588
|
var hasFieldsValue = function hasFieldsValue(fields) {
|
|
2523
2589
|
return fields.map(getValues).find(function (field) {
|
|
@@ -2564,8 +2630,7 @@
|
|
|
2564
2630
|
return /*#__PURE__*/React__default['default'].createElement(core.Grid, __assign({
|
|
2565
2631
|
"data-testid": "row-" + namePrefix,
|
|
2566
2632
|
container: true,
|
|
2567
|
-
|
|
2568
|
-
ref: onRef
|
|
2633
|
+
ref: ref
|
|
2569
2634
|
}, props), !isChangeGroup && /*#__PURE__*/React__default['default'].createElement(React__default['default'].Fragment, null, /*#__PURE__*/React__default['default'].createElement(TafFormTextField, {
|
|
2570
2635
|
label: "Type",
|
|
2571
2636
|
name: fieldNames.messageType,
|
|
@@ -2826,7 +2891,7 @@
|
|
|
2826
2891
|
}, lastRow ? {
|
|
2827
2892
|
tabIndex: '-1'
|
|
2828
2893
|
} : {}), /*#__PURE__*/React__default['default'].createElement(icons.Delete, null))));
|
|
2829
|
-
};
|
|
2894
|
+
});
|
|
2830
2895
|
|
|
2831
2896
|
var getIssuesLabel = function getIssuesLabel(sumOfErrors) {
|
|
2832
2897
|
switch (sumOfErrors) {
|
|
@@ -2912,7 +2977,7 @@
|
|
|
2912
2977
|
* Copyright 2021 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
|
|
2913
2978
|
* Copyright 2021 - Finnish Meteorological Institute (FMI)
|
|
2914
2979
|
* */
|
|
2915
|
-
var useStyles$
|
|
2980
|
+
var useStyles$8 = core.makeStyles({
|
|
2916
2981
|
issuesPane: {
|
|
2917
2982
|
display: 'flex',
|
|
2918
2983
|
flexDirection: 'column',
|
|
@@ -3014,7 +3079,7 @@
|
|
|
3014
3079
|
var handleClose = _a.handleClose,
|
|
3015
3080
|
_b = _a.errorList,
|
|
3016
3081
|
errorList = _b === void 0 ? [] : _b;
|
|
3017
|
-
var classes = useStyles$
|
|
3082
|
+
var classes = useStyles$8();
|
|
3018
3083
|
return /*#__PURE__*/React__namespace.createElement(core.Paper, {
|
|
3019
3084
|
elevation: 3,
|
|
3020
3085
|
className: classes.issuesPane
|
|
@@ -3100,7 +3165,7 @@
|
|
|
3100
3165
|
var TafFormButtons = function TafFormButtons(_a) {
|
|
3101
3166
|
var tafAction = _a.tafAction,
|
|
3102
3167
|
onTafFormButtonPress = _a.onTafFormButtonPress;
|
|
3103
|
-
var classes = useStyles$
|
|
3168
|
+
var classes = useStyles$9();
|
|
3104
3169
|
var errors = reactHookForm.useFormContext().errors;
|
|
3105
3170
|
var errorList = filterDuplicateErrors(getErrors(errors));
|
|
3106
3171
|
|
|
@@ -3200,6 +3265,50 @@
|
|
|
3200
3265
|
}));
|
|
3201
3266
|
};
|
|
3202
3267
|
|
|
3268
|
+
/* *
|
|
3269
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
3270
|
+
* you may not use this file except in compliance with the License.
|
|
3271
|
+
* You may obtain a copy of the License at
|
|
3272
|
+
*
|
|
3273
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
3274
|
+
*
|
|
3275
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
3276
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
3277
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
3278
|
+
* See the License for the specific language governing permissions and
|
|
3279
|
+
* limitations under the License.
|
|
3280
|
+
*
|
|
3281
|
+
* Copyright 2021 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
|
|
3282
|
+
* Copyright 2021 - Finnish Meteorological Institute (FMI)
|
|
3283
|
+
* */
|
|
3284
|
+
var useStyles$7 = core.makeStyles(function () {
|
|
3285
|
+
return {
|
|
3286
|
+
dragHandle: {
|
|
3287
|
+
backgroundColor: 'transparent',
|
|
3288
|
+
'&:hover': {
|
|
3289
|
+
backgroundColor: 'transparent'
|
|
3290
|
+
},
|
|
3291
|
+
cursor: function cursor(isSorting) {
|
|
3292
|
+
return isSorting ? 'grabbing' : 'grab';
|
|
3293
|
+
}
|
|
3294
|
+
}
|
|
3295
|
+
};
|
|
3296
|
+
});
|
|
3297
|
+
|
|
3298
|
+
var DragHandle = function DragHandle(_a) {
|
|
3299
|
+
var _b = _a.isSorting,
|
|
3300
|
+
isSorting = _b === void 0 ? false : _b,
|
|
3301
|
+
_c = _a.isDisabled,
|
|
3302
|
+
isDisabled = _c === void 0 ? false : _c;
|
|
3303
|
+
var classes = useStyles$7(isSorting);
|
|
3304
|
+
return /*#__PURE__*/React__default['default'].createElement(core.IconButton, {
|
|
3305
|
+
className: classes.dragHandle + " handle",
|
|
3306
|
+
"data-testid": "dragHandle",
|
|
3307
|
+
disableRipple: true,
|
|
3308
|
+
disabled: isDisabled
|
|
3309
|
+
}, /*#__PURE__*/React__default['default'].createElement(icons.DragIndicator, null));
|
|
3310
|
+
};
|
|
3311
|
+
|
|
3203
3312
|
var emptyRow = {
|
|
3204
3313
|
valid: '',
|
|
3205
3314
|
wind: '',
|
|
@@ -3229,7 +3338,7 @@
|
|
|
3229
3338
|
onFormAction = _c === void 0 ? function () {
|
|
3230
3339
|
return null;
|
|
3231
3340
|
} : _c;
|
|
3232
|
-
var classes = useStyles$
|
|
3341
|
+
var classes = useStyles$9();
|
|
3233
3342
|
var confirmDialog = shared.useConfirmationDialog();
|
|
3234
3343
|
|
|
3235
3344
|
var _d = shared.useDraftFormHelpers(),
|
|
@@ -3244,7 +3353,8 @@
|
|
|
3244
3353
|
handleSubmit = _e.handleSubmit,
|
|
3245
3354
|
watch = _e.watch,
|
|
3246
3355
|
getValues = _e.getValues,
|
|
3247
|
-
errors = _e.errors
|
|
3356
|
+
errors = _e.errors,
|
|
3357
|
+
trigger = _e.trigger;
|
|
3248
3358
|
|
|
3249
3359
|
var hiddenInputFields = ['baseTime', 'issueDate', 'type', 'uuid', 'validDateStart', 'validDateEnd', 'status', 'previousId', 'previousValidDateStart', 'previousValidDateEnd'];
|
|
3250
3360
|
|
|
@@ -3283,7 +3393,8 @@
|
|
|
3283
3393
|
}),
|
|
3284
3394
|
fields = _j.fields,
|
|
3285
3395
|
append = _j.append,
|
|
3286
|
-
remove = _j.remove
|
|
3396
|
+
remove = _j.remove,
|
|
3397
|
+
move = _j.move;
|
|
3287
3398
|
|
|
3288
3399
|
var onSubmit = function onSubmit(data) {
|
|
3289
3400
|
// eslint-disable-next-line no-console
|
|
@@ -3341,10 +3452,6 @@
|
|
|
3341
3452
|
append(emptyRow);
|
|
3342
3453
|
};
|
|
3343
3454
|
|
|
3344
|
-
var onRemoverow = function onRemoverow(index) {
|
|
3345
|
-
remove(index);
|
|
3346
|
-
};
|
|
3347
|
-
|
|
3348
3455
|
React__default['default'].useEffect(function () {
|
|
3349
3456
|
// set changegroups on mount (if no changegroups - add empty one by default)
|
|
3350
3457
|
if (changeGroups.length > 0) {
|
|
@@ -3356,6 +3463,20 @@
|
|
|
3356
3463
|
} // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
3357
3464
|
|
|
3358
3465
|
}, []);
|
|
3466
|
+
|
|
3467
|
+
var _k = useDragOrder(trigger, move, fields),
|
|
3468
|
+
onChangeOrder = _k.onChangeOrder,
|
|
3469
|
+
sortedFields = _k.sortedFields,
|
|
3470
|
+
setSortedFields = _k.setSortedFields;
|
|
3471
|
+
|
|
3472
|
+
var onRemoverow = function onRemoverow(index) {
|
|
3473
|
+
remove(index);
|
|
3474
|
+
var newList = fields.length > 1 ? fields.filter(function (_, fieldIndex) {
|
|
3475
|
+
return fieldIndex === index;
|
|
3476
|
+
}) : [];
|
|
3477
|
+
setSortedFields(newList);
|
|
3478
|
+
};
|
|
3479
|
+
|
|
3359
3480
|
return /*#__PURE__*/React__default['default'].createElement("form", {
|
|
3360
3481
|
onSubmit: handleSubmit(onSubmit),
|
|
3361
3482
|
onChange: onFormChange,
|
|
@@ -3373,17 +3494,37 @@
|
|
|
3373
3494
|
}, line);
|
|
3374
3495
|
})), /*#__PURE__*/React__default['default'].createElement(TafFormRow, {
|
|
3375
3496
|
disabled: isDisabled
|
|
3376
|
-
}),
|
|
3497
|
+
}), /*#__PURE__*/React__default['default'].createElement(reactSortablejs.ReactSortable, {
|
|
3498
|
+
tag: "div",
|
|
3499
|
+
list: sortedFields,
|
|
3500
|
+
setList: setSortedFields,
|
|
3501
|
+
animation: 200,
|
|
3502
|
+
onSort: onChangeOrder,
|
|
3503
|
+
handle: ".handle",
|
|
3504
|
+
direction: "vertical",
|
|
3505
|
+
// hover props
|
|
3506
|
+
forceFallback: true,
|
|
3507
|
+
onStart: function onStart() {
|
|
3508
|
+
reactSortablejs.Sortable.ghost.style.opacity = '1';
|
|
3509
|
+
}
|
|
3510
|
+
}, sortedFields.map(function (_a, index) {
|
|
3511
|
+
var chosen = _a.chosen;
|
|
3512
|
+
var item = fields[index];
|
|
3377
3513
|
return /*#__PURE__*/React__default['default'].createElement(TafFormRow, {
|
|
3378
3514
|
field: item,
|
|
3515
|
+
className: classes.formRow,
|
|
3379
3516
|
key: item.id,
|
|
3380
3517
|
index: index,
|
|
3381
3518
|
lastRow: fields.length === index + 1,
|
|
3382
3519
|
disabled: isDisabled,
|
|
3383
3520
|
onRemoveChangeGroup: onRemoverow,
|
|
3384
|
-
isChangeGroup: true
|
|
3521
|
+
isChangeGroup: true,
|
|
3522
|
+
dragHandle: /*#__PURE__*/React__default['default'].createElement(DragHandle, {
|
|
3523
|
+
isDisabled: sortedFields.length === 1 || isDisabled,
|
|
3524
|
+
isSorting: chosen
|
|
3525
|
+
})
|
|
3385
3526
|
});
|
|
3386
|
-
}), !isDisabled && /*#__PURE__*/React__default['default'].createElement(React__default['default'].Fragment, null, /*#__PURE__*/React__default['default'].createElement(core.Grid, {
|
|
3527
|
+
})), !isDisabled && /*#__PURE__*/React__default['default'].createElement(React__default['default'].Fragment, null, /*#__PURE__*/React__default['default'].createElement(core.Grid, {
|
|
3387
3528
|
container: true,
|
|
3388
3529
|
item: true,
|
|
3389
3530
|
xs: 12,
|