@olenbetong/synergi-react 5.1.0 → 5.3.0

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.
Files changed (76) hide show
  1. package/dist/styles/styles.css +1 -1
  2. package/dist/styles/styles.css.map +1 -1
  3. package/es/components/Checkbox/index.css +1 -1
  4. package/es/components/ColorCard/index.css +17 -28
  5. package/es/components/DateNavigator/index.css +5 -7
  6. package/es/components/ImageEditor/ImageEditor.css +10 -10
  7. package/es/components/ImageEditor/ImageEditor.d.ts +18 -1
  8. package/es/components/ImageEditor/ImageEditor.js +30 -13
  9. package/es/components/ImageEditor/ResponsiveButton.js +2 -2
  10. package/es/components/ImageEditor/encodeImage.d.ts +33 -0
  11. package/es/components/ImageEditor/encodeImage.js +60 -0
  12. package/es/components/ImageEditor/index.d.ts +2 -0
  13. package/es/components/ImageEditor/index.js +1 -0
  14. package/es/components/ImageEditor/plugins/cropPlugin/CropToolbar.js +1 -1
  15. package/es/components/ImageEditor/plugins/cropPlugin/useCropTool.js +3 -9
  16. package/es/components/ImageEditor/plugins/redactPlugin/RedactToolbar.js +1 -1
  17. package/es/components/ImageEditor/plugins/redactPlugin/useRedactTool.js +3 -4
  18. package/es/components/ImageEditor/plugins/rotatePlugin.js +2 -1
  19. package/es/components/MergeProgressDialog/MergeProgressDialogDs.js +3 -3
  20. package/es/components/PageBanner/index.css +1 -1
  21. package/es/components/PdfViewer/PdfViewer.js +1 -1
  22. package/es/components/Spinner/index.css +1 -1
  23. package/es/components/SplitContainer/index.css +1 -1
  24. package/es/components/ValueToggleGroup/index.css +2 -2
  25. package/es/elements/ElementLookupDialog/BarcodeScanner/BarcodeScanner.css +7 -7
  26. package/es/elements-ds/ElementLookupDialog.js +1 -1
  27. package/es/improve/ReportIssueAttachments.d.ts +6 -0
  28. package/es/improve/ReportIssueAttachments.js +45 -0
  29. package/es/improve/ReportIssueForm.css +133 -0
  30. package/es/improve/ReportIssueForm.d.ts +18 -0
  31. package/es/improve/ReportIssueForm.js +71 -0
  32. package/es/improve/data/dsReportIssueAreas.d.ts +8 -0
  33. package/es/improve/data/dsReportIssueAreas.js +37 -0
  34. package/es/improve/data/dsReportIssueFiles.d.ts +15 -0
  35. package/es/improve/data/dsReportIssueFiles.js +55 -0
  36. package/es/improve/data/index.d.ts +3 -0
  37. package/es/improve/data/index.js +3 -0
  38. package/es/improve/data/procReportIssue.d.ts +16 -0
  39. package/es/improve/data/procReportIssue.js +44 -0
  40. package/es/improve/index.d.ts +3 -0
  41. package/es/improve/index.js +3 -0
  42. package/es/index.css +1 -1
  43. package/package.json +7 -3
  44. package/src/components/Checkbox/index.scss +2 -2
  45. package/src/components/ColorCard/index.css +17 -28
  46. package/src/components/DateNavigator/index.css +5 -7
  47. package/src/components/ImageEditor/ImageEditor.browser.test.tsx +30 -5
  48. package/src/components/ImageEditor/ImageEditor.css +10 -10
  49. package/src/components/ImageEditor/ImageEditor.test.tsx +4 -3
  50. package/src/components/ImageEditor/ImageEditor.tsx +47 -14
  51. package/src/components/ImageEditor/ResponsiveButton.tsx +2 -2
  52. package/src/components/ImageEditor/encodeImage.browser.test.ts +88 -0
  53. package/src/components/ImageEditor/encodeImage.ts +80 -0
  54. package/src/components/ImageEditor/index.ts +2 -0
  55. package/src/components/ImageEditor/plugins/cropPlugin/CropToolbar.tsx +2 -8
  56. package/src/components/ImageEditor/plugins/cropPlugin/useCropTool.ts +3 -10
  57. package/src/components/ImageEditor/plugins/plugins.browser.test.ts +20 -2
  58. package/src/components/ImageEditor/plugins/redactPlugin/RedactToolbar.tsx +3 -3
  59. package/src/components/ImageEditor/plugins/redactPlugin/useRedactTool.ts +3 -4
  60. package/src/components/ImageEditor/plugins/rotatePlugin.ts +2 -1
  61. package/src/components/MergeProgressDialog/MergeProgressDialogDs.tsx +3 -3
  62. package/src/components/PageBanner/index.scss +10 -10
  63. package/src/components/PdfViewer/PdfViewer.tsx +1 -1
  64. package/src/components/Spinner/index.css +1 -1
  65. package/src/components/SplitContainer/index.scss +5 -1
  66. package/src/components/ValueToggleGroup/index.css +2 -2
  67. package/src/elements/ElementLookupDialog/BarcodeScanner/BarcodeScanner.css +7 -7
  68. package/src/elements-ds/ElementLookupDialog.tsx +1 -3
  69. package/src/improve/ReportIssueAttachments.tsx +138 -0
  70. package/src/improve/ReportIssueForm.css +133 -0
  71. package/src/improve/ReportIssueForm.tsx +218 -0
  72. package/src/improve/data/dsReportIssueAreas.ts +45 -0
  73. package/src/improve/data/dsReportIssueFiles.ts +66 -0
  74. package/src/improve/data/index.ts +3 -0
  75. package/src/improve/data/procReportIssue.ts +58 -0
  76. package/src/improve/index.ts +3 -0
@@ -0,0 +1,138 @@
1
+ import { Alert, Button, Heading, Paragraph } from "@digdir/designsystemet-react";
2
+ import { FileIcon, TrashIcon, UploadIcon } from "@navikt/aksel-icons";
3
+ import { useData, useDragAndDropUpload, useFilter } from "@olenbetong/appframe-react";
4
+
5
+ import clsx from "clsx";
6
+ import { useRef, useState } from "react";
7
+
8
+ import { getLocalizedString } from "../i18n.js";
9
+ import { dsReportIssueFiles, type ReportIssueFilesRecord } from "./data/dsReportIssueFiles.js";
10
+
11
+ const IMAGE_EXTENSIONS = ["jpg", "jpeg", "png", "gif", "svg", "webp", "avif"];
12
+
13
+ function isImage(file: ReportIssueFilesRecord) {
14
+ let extension = (file.Extension ?? file.FileName?.split(".").pop() ?? "").replace(/^\./, "").toLowerCase();
15
+
16
+ return IMAGE_EXTENSIONS.includes(extension);
17
+ }
18
+
19
+ /**
20
+ * File upload is broken in the old Synergi iOS app's webview, which Apple will not let us replace,
21
+ * so the form says to open the site in Safari instead.
22
+ */
23
+ function isIosWebview() {
24
+ return /(iPad|iPhone)/.test(navigator.userAgent) && !navigator.userAgent.includes("Safari");
25
+ }
26
+
27
+ function WebViewWarning() {
28
+ return (
29
+ <Paragraph data-size="sm">
30
+ {getLocalizedString(
31
+ "File upload is unfortunately broken in the Synergi iOS application, and Apple's policies prevent us from publishing a new version to fix it.",
32
+ )}{" "}
33
+ {getLocalizedString("To upload attachments, please open")}{" "}
34
+ <a href="https://synergi.olenbetong.no" target="_blank" rel="noopener noreferrer">
35
+ s.obet.no
36
+ </a>{" "}
37
+ {getLocalizedString("in Safari instead")}.{" "}
38
+ {getLocalizedString(
39
+ "You can also add the website to your home screen using the share dialog in Safari for easy access.",
40
+ )}
41
+ </Paragraph>
42
+ );
43
+ }
44
+
45
+ /**
46
+ * The attachments of an issue that is still being written. They are uploaded at once, to the
47
+ * user's temp files, and the report moves them onto the issue. Files left there from a report that
48
+ * was never sent show up again the next time.
49
+ */
50
+ export function ReportIssueAttachments() {
51
+ let files = useData(dsReportIssueFiles);
52
+ let { dragProps, dragOver, removeStatus, status, upload } = useDragAndDropUpload<ReportIssueFilesRecord>({
53
+ dataObject: dsReportIssueFiles,
54
+ });
55
+ let inputRef = useRef<HTMLInputElement>(null);
56
+ let [webview] = useState(isIosWebview);
57
+
58
+ useFilter(dsReportIssueFiles, `[CreatedBy] = '${af.userSession.login.replace(/'/g, "''")}'`, "whereClause");
59
+
60
+ let uploading = status.filter((item) => !item.error && !item.complete);
61
+ let failed = status.filter((item) => item.error);
62
+
63
+ return (
64
+ <section className="ObReportIssue-attachments" aria-labelledby="ObReportIssue-attachments-heading">
65
+ <Heading level={2} data-size="xs" id="ObReportIssue-attachments-heading">
66
+ {getLocalizedString("Attachments")}
67
+ </Heading>
68
+
69
+ {webview ? (
70
+ <WebViewWarning />
71
+ ) : (
72
+ <div className={clsx("ObReportIssue-dropzone", dragOver && "ObReportIssue-dropzone--over")} {...dragProps}>
73
+ {files.length > 0 && (
74
+ <ul className="ObReportIssue-files">
75
+ {files.map((file, index) => (
76
+ <li className="ObReportIssue-file" key={file.PrimKey}>
77
+ <div className="ObReportIssue-thumbnail">
78
+ {isImage(file) ? (
79
+ <img src={dsReportIssueFiles.getFileStoreURL(file)} alt="" />
80
+ ) : (
81
+ <FileIcon aria-hidden />
82
+ )}
83
+ </div>
84
+ <span className="ObReportIssue-fileName">{file.FileName}</span>
85
+ <Button
86
+ variant="tertiary"
87
+ data-size="sm"
88
+ icon
89
+ aria-label={`${getLocalizedString("Delete")} ${file.FileName ?? ""}`}
90
+ onClick={() => dsReportIssueFiles.deleteRow(index)}
91
+ >
92
+ <TrashIcon aria-hidden />
93
+ </Button>
94
+ </li>
95
+ ))}
96
+ </ul>
97
+ )}
98
+ <div className="ObReportIssue-uploadActions">
99
+ <Button variant="secondary" onClick={() => inputRef.current?.click()}>
100
+ <UploadIcon aria-hidden />
101
+ {getLocalizedString("Upload File")}
102
+ </Button>
103
+ <span className="ObReportIssue-dropHint">{getLocalizedString("or drag and drop from your computer")}</span>
104
+ </div>
105
+ <input
106
+ tabIndex={-1}
107
+ type="file"
108
+ multiple
109
+ className="ObReportIssue-fileInput"
110
+ ref={inputRef}
111
+ onChange={(event) => {
112
+ let selected = event.currentTarget.files;
113
+ if (selected && selected.length > 0) upload(Array.from(selected));
114
+ event.currentTarget.value = "";
115
+ }}
116
+ />
117
+ </div>
118
+ )}
119
+
120
+ {uploading.map((item) => (
121
+ <div className="ObReportIssue-progress" key={item.index}>
122
+ <span>{item.name}</span>
123
+ <progress max={item.progress.total} value={item.progress.loaded} />
124
+ </div>
125
+ ))}
126
+ {failed.map((item) => (
127
+ <Alert data-color="danger" data-size="sm" key={item.index} className="ObReportIssue-uploadError">
128
+ <span>
129
+ {getLocalizedString("Failed to upload")} {`'${item.name}'`}: {item.error}
130
+ </span>
131
+ <Button variant="tertiary" data-size="sm" onClick={() => removeStatus(item.index)}>
132
+ {getLocalizedString("Close")}
133
+ </Button>
134
+ </Alert>
135
+ ))}
136
+ </section>
137
+ );
138
+ }
@@ -0,0 +1,133 @@
1
+ .ObReportIssue {
2
+ display: flex;
3
+ flex-direction: column;
4
+ gap: var(--ds-size-6, 1.5rem);
5
+ }
6
+
7
+ .ObReportIssue-checklist {
8
+ margin: var(--ds-size-2, 0.5rem) 0 0;
9
+ padding-inline-start: 1.5rem;
10
+ }
11
+
12
+ .ObReportIssue-actions {
13
+ display: flex;
14
+ flex-wrap: wrap;
15
+ gap: var(--ds-size-2, 0.5rem);
16
+ }
17
+
18
+ .ObReportIssue-submit {
19
+ flex-grow: 1;
20
+ }
21
+
22
+ .ObReportIssue-attachments {
23
+ display: flex;
24
+ flex-direction: column;
25
+ gap: var(--ds-size-3, 0.75rem);
26
+ }
27
+
28
+ .ObReportIssue-dropzone {
29
+ border-radius: var(--ds-border-radius-md, 0.25rem);
30
+ outline: 0 dashed var(--ds-color-neutral-border-default, rgba(0, 0, 0, 0.24));
31
+ outline-offset: 0.25rem;
32
+ transition: outline-width 50ms ease-out;
33
+ }
34
+
35
+ .ObReportIssue-dropzone--over {
36
+ outline-width: 0.125rem;
37
+ background-color: var(--ds-color-accent-surface-tinted);
38
+ }
39
+
40
+ .ObReportIssue-files {
41
+ display: grid;
42
+ grid-template-columns: repeat(auto-fill, minmax(8rem, 1fr));
43
+ gap: var(--ds-size-3, 0.75rem);
44
+ margin: 0 0 var(--ds-size-3, 0.75rem);
45
+ padding: 0;
46
+ list-style: none;
47
+ }
48
+
49
+ .ObReportIssue-file {
50
+ display: grid;
51
+ grid-template-columns: 1fr auto;
52
+ align-items: center;
53
+ gap: var(--ds-size-1, 0.25rem);
54
+ }
55
+
56
+ .ObReportIssue-thumbnail {
57
+ grid-column: 1 / -1;
58
+ display: grid;
59
+ place-items: center;
60
+ height: 6rem;
61
+ border-radius: var(--ds-border-radius-md, 0.25rem);
62
+ background-color: var(--ds-color-neutral-background-tinted);
63
+ overflow: hidden;
64
+
65
+ img {
66
+ width: 100%;
67
+ height: 100%;
68
+ object-fit: cover;
69
+ }
70
+
71
+ svg {
72
+ width: 2.5rem;
73
+ height: 2.5rem;
74
+ }
75
+ }
76
+
77
+ .ObReportIssue-fileName {
78
+ overflow: hidden;
79
+ text-overflow: ellipsis;
80
+ white-space: nowrap;
81
+ font-size: var(--ds-font-size-2, 0.875rem);
82
+ }
83
+
84
+ .ObReportIssue-uploadActions {
85
+ display: flex;
86
+ flex-wrap: wrap;
87
+ align-items: center;
88
+ gap: var(--ds-size-3, 0.75rem);
89
+ }
90
+
91
+ .ObReportIssue-dropHint {
92
+ color: var(--ds-color-neutral-text-subtle);
93
+ font-size: var(--ds-font-size-2, 0.875rem);
94
+ }
95
+
96
+ /* Touch devices have nothing to drag files from. */
97
+ @media (pointer: coarse) {
98
+ .ObReportIssue-dropHint {
99
+ display: none;
100
+ }
101
+ }
102
+
103
+ .ObReportIssue-fileInput {
104
+ position: absolute;
105
+ width: 1px;
106
+ height: 1px;
107
+ padding: 0;
108
+ margin: -1px;
109
+ overflow: hidden;
110
+ clip: rect(0, 0, 0, 0);
111
+ white-space: nowrap;
112
+ border: 0;
113
+ }
114
+
115
+ .ObReportIssue-progress {
116
+ display: flex;
117
+ align-items: center;
118
+ justify-content: space-between;
119
+ gap: var(--ds-size-4, 1rem);
120
+ font-size: var(--ds-font-size-2, 0.875rem);
121
+
122
+ progress {
123
+ flex-basis: 25%;
124
+ accent-color: var(--ds-color-accent-base-default);
125
+ }
126
+ }
127
+
128
+ .ObReportIssue-uploadError {
129
+ display: flex;
130
+ align-items: center;
131
+ justify-content: space-between;
132
+ gap: var(--ds-size-2, 0.5rem);
133
+ }
@@ -0,0 +1,218 @@
1
+ import "./ReportIssueForm.css";
2
+
3
+ import {
4
+ Alert,
5
+ Button,
6
+ Divider,
7
+ Field,
8
+ Fieldset,
9
+ Heading,
10
+ Label,
11
+ Radio,
12
+ Select,
13
+ Textfield,
14
+ } from "@digdir/designsystemet-react";
15
+ import { logError, startActivity } from "@olenbetong/appframe-core";
16
+ import { useData, useLoading } from "@olenbetong/appframe-react";
17
+
18
+ import clsx from "clsx";
19
+ import { type FormEvent, useEffect, useId, useState } from "react";
20
+
21
+ import { getLocalizedString } from "../i18n.js";
22
+ import { dsReportIssueAreas } from "./data/dsReportIssueAreas.js";
23
+ import { procReportIssue } from "./data/procReportIssue.js";
24
+ import { ReportIssueAttachments } from "./ReportIssueAttachments.js";
25
+
26
+ export type ReportIssueType = "Issue" | "Suggestion";
27
+
28
+ export type ReportIssueFormProps = {
29
+ /** The type chosen when the form opens. The user can change it. Defaults to `Issue`. */
30
+ defaultType?: ReportIssueType;
31
+ /** Called with the new issue's number once it has been reported. */
32
+ onCreated: (issueId: number) => void;
33
+ /** Shows a Cancel button beside Send, for a form in a dialog. */
34
+ onCancel?: () => void;
35
+ className?: string;
36
+ };
37
+
38
+ /** Today at 08:00, as a `datetime-local` value: most incidents are reported the same day. */
39
+ function defaultIncidentDate() {
40
+ let now = new Date();
41
+ let pad = (value: number) => String(value).padStart(2, "0");
42
+
43
+ return `${now.getFullYear()}-${pad(now.getMonth() + 1)}-${pad(now.getDate())}T08:00`;
44
+ }
45
+
46
+ /**
47
+ * The form for reporting an issue or a suggestion to Improve: the type, what happened, the area it
48
+ * belongs to and any attachments. It is the report-issue app's page, and the issue tracker opens it
49
+ * in a dialog. The form creates the issue itself and hands its number to `onCreated`; where to go
50
+ * from there is up to the app.
51
+ */
52
+ export function ReportIssueForm({ defaultType = "Issue", onCreated, onCancel, className }: ReportIssueFormProps) {
53
+ let areas = useData(dsReportIssueAreas);
54
+ let areasLoading = useLoading(dsReportIssueAreas);
55
+ let [issueType, setIssueType] = useState<ReportIssueType>(defaultType);
56
+ let [incidentDate, setIncidentDate] = useState(defaultIncidentDate);
57
+ let [description, setDescription] = useState("");
58
+ let [cause, setCause] = useState("");
59
+ let [area, setArea] = useState("");
60
+ let [sending, setSending] = useState(false);
61
+ let [error, setError] = useState<string | null>(null);
62
+ let areaId = useId();
63
+
64
+ useEffect(() => {
65
+ if (!dsReportIssueAreas.isDataLoaded()) dsReportIssueAreas.refreshDataSource();
66
+ }, []);
67
+
68
+ let isIssue = issueType === "Issue";
69
+
70
+ async function submit(event: FormEvent<HTMLFormElement>) {
71
+ event.preventDefault();
72
+ if (sending) return;
73
+
74
+ let logActivity = startActivity("ReportIssue");
75
+ try {
76
+ setSending(true);
77
+ setError(null);
78
+ let result = await procReportIssue.execute({
79
+ IssueType: issueType,
80
+ Area: area,
81
+ Description: description,
82
+ IncidentDate: isIssue ? incidentDate : null,
83
+ CauseAnalysis: isIssue && cause.trim() ? cause : null,
84
+ SubmitFiles: true,
85
+ });
86
+ let issueId = result.Table?.[0]?.IssueID;
87
+ if (!issueId) throw new Error(getLocalizedString("The issue was not created. Please try again."));
88
+
89
+ logActivity({ Area: area, IssueID: issueId });
90
+ onCreated(issueId);
91
+ } catch (reason) {
92
+ logError(reason);
93
+ setError(reason instanceof Error ? reason.message : String(reason));
94
+ } finally {
95
+ setSending(false);
96
+ }
97
+ }
98
+
99
+ return (
100
+ <form
101
+ className={clsx("ObReportIssue", className)}
102
+ aria-label={getLocalizedString("Report Issue")}
103
+ onSubmit={submit}
104
+ >
105
+ <Fieldset>
106
+ <Fieldset.Legend>
107
+ <Heading level={2} data-size="xs">
108
+ {getLocalizedString("Issue type")}
109
+ </Heading>
110
+ </Fieldset.Legend>
111
+ <Radio
112
+ name="IssueType"
113
+ value="Issue"
114
+ checked={isIssue}
115
+ onChange={() => setIssueType("Issue")}
116
+ label={getLocalizedString("Report a non-conformity or RUH")}
117
+ description={getLocalizedString(
118
+ "If something has happened that we should document and learn from, please tell us.",
119
+ )}
120
+ />
121
+ <Radio
122
+ name="IssueType"
123
+ value="Suggestion"
124
+ checked={!isIssue}
125
+ onChange={() => setIssueType("Suggestion")}
126
+ label={getLocalizedString("Make a suggestion")}
127
+ description={getLocalizedString(
128
+ "Make a suggestion and contribute to Ølen Betong’s best practices. It could be something new or something you think should be done differently.",
129
+ )}
130
+ />
131
+ </Fieldset>
132
+
133
+ {isIssue && (
134
+ <>
135
+ <div>
136
+ <Heading level={2} data-size="xs">
137
+ {getLocalizedString("Remember to enter the following")}:
138
+ </Heading>
139
+ <ul className="ObReportIssue-checklist">
140
+ <li>{getLocalizedString("Where the event occured, and if there are any witnesses")}</li>
141
+ <li>{getLocalizedString("Write in a few words - Your observation")}</li>
142
+ <li>{getLocalizedString("Why did it happen?")}</li>
143
+ <li>{getLocalizedString("Immediate measures performed")}</li>
144
+ <li>{getLocalizedString("If possible - recommend measures")}</li>
145
+ </ul>
146
+ </div>
147
+ <Textfield
148
+ type="datetime-local"
149
+ required
150
+ name="IncidentDate"
151
+ value={incidentDate}
152
+ onChange={(event) => setIncidentDate(event.target.value)}
153
+ label={getLocalizedString("Incident date and time")}
154
+ />
155
+ </>
156
+ )}
157
+
158
+ <Textfield
159
+ required
160
+ multiline
161
+ rows={6}
162
+ name="Description"
163
+ value={description}
164
+ onChange={(event) => setDescription(event.target.value)}
165
+ label={getLocalizedString("Description")}
166
+ />
167
+
168
+ {isIssue && (
169
+ <Textfield
170
+ multiline
171
+ rows={3}
172
+ name="CauseAnalysis"
173
+ value={cause}
174
+ onChange={(event) => setCause(event.target.value)}
175
+ label={getLocalizedString("Cause - Describe why the incident occurred")}
176
+ description={getLocalizedString(
177
+ "Try to find the root cause of the incident. Why did it happen? What were the contributing factors? This will help us find good measures to prevent similar incidents in the future. If the cause is unknown, leave the field blank.",
178
+ )}
179
+ />
180
+ )}
181
+
182
+ <Field>
183
+ <Label htmlFor={areaId}>
184
+ {getLocalizedString("Area")} / {getLocalizedString("Department")}
185
+ </Label>
186
+ <Select id={areaId} name="Area" required value={area} onChange={(event) => setArea(event.target.value)}>
187
+ <Select.Option value="">{areasLoading ? getLocalizedString("Loading...") : ""}</Select.Option>
188
+ {areas.map((row) => (
189
+ <Select.Option key={row.Area} value={row.Area}>
190
+ {row.Area}
191
+ </Select.Option>
192
+ ))}
193
+ </Select>
194
+ </Field>
195
+
196
+ <Divider />
197
+ <ReportIssueAttachments />
198
+ <Divider />
199
+
200
+ {error && (
201
+ <Alert data-color="danger" data-size="sm" role="alert">
202
+ {error}
203
+ </Alert>
204
+ )}
205
+
206
+ <div className="ObReportIssue-actions">
207
+ <Button type="submit" loading={sending} className="ObReportIssue-submit">
208
+ {isIssue ? getLocalizedString("Send issue") : getLocalizedString("Send suggestion")}
209
+ </Button>
210
+ {onCancel && (
211
+ <Button type="button" variant="secondary" onClick={onCancel} disabled={sending}>
212
+ {getLocalizedString("Cancel")}
213
+ </Button>
214
+ )}
215
+ </div>
216
+ </form>
217
+ );
218
+ }
@@ -0,0 +1,45 @@
1
+ import { generateApiDataObject, SortOrder } from "@olenbetong/appframe-data";
2
+
3
+ export type ReportIssueAreasRecord = {
4
+ Area: string;
5
+ Responsible: string;
6
+ SortOrder: string | null;
7
+ CompanySort: number;
8
+ };
9
+
10
+ /** The areas an issue can be reported to: the user's areas that are not archived. */
11
+ export const dsReportIssueAreas = generateApiDataObject<ReportIssueAreasRecord>({
12
+ resource: "aviw_Improve_MyAreas",
13
+ id: "dsReportIssueAreas",
14
+ allowUpdate: false,
15
+ allowInsert: false,
16
+ allowDelete: false,
17
+ dynamicLoading: false,
18
+ fields: [
19
+ {
20
+ name: "Area",
21
+ type: "string",
22
+ nullable: false,
23
+ },
24
+ {
25
+ name: "Responsible",
26
+ type: "string",
27
+ nullable: false,
28
+ },
29
+ {
30
+ name: "SortOrder",
31
+ type: "string",
32
+ nullable: true,
33
+ },
34
+ {
35
+ name: "CompanySort",
36
+ type: "number",
37
+ nullable: false,
38
+ },
39
+ ],
40
+ parameters: {
41
+ maxRecords: -1,
42
+ whereClause: "[Archived] IS NULL",
43
+ sortOrder: [{ CompanySort: SortOrder.Asc }, { SortOrder: SortOrder.Asc }, { Area: SortOrder.Asc }],
44
+ },
45
+ });
@@ -0,0 +1,66 @@
1
+ import { generateApiDataObject } from "@olenbetong/appframe-data";
2
+
3
+ export type ReportIssueFilesRecord = {
4
+ PrimKey: string;
5
+ Created: Date;
6
+ CreatedBy: string;
7
+ FileName: string | null;
8
+ FileSize: number | null;
9
+ FileRef: string | null;
10
+ Extension: string | null;
11
+ };
12
+
13
+ /**
14
+ * Attachments uploaded before the issue exists. They wait in a temp table, one set per user, until
15
+ * the issue is reported, and the report moves them onto the new issue. The form filters this on
16
+ * the user's login: users with access to the table see everyone's.
17
+ */
18
+ export const dsReportIssueFiles = generateApiDataObject<ReportIssueFilesRecord>({
19
+ resource: "atbv_Improve_IssuesFiles_Temp",
20
+ uniqueName: "atbv_Improve_IssuesFiles_Temp",
21
+ id: "dsReportIssueFiles",
22
+ allowUpdate: false,
23
+ allowInsert: true,
24
+ allowDelete: true,
25
+ dynamicLoading: false,
26
+ fields: [
27
+ {
28
+ name: "PrimKey",
29
+ type: "string",
30
+ nullable: false,
31
+ },
32
+ {
33
+ name: "Created",
34
+ type: "datetime",
35
+ nullable: false,
36
+ },
37
+ {
38
+ name: "CreatedBy",
39
+ type: "string",
40
+ nullable: false,
41
+ },
42
+ {
43
+ name: "FileName",
44
+ type: "string",
45
+ nullable: true,
46
+ },
47
+ {
48
+ name: "FileSize",
49
+ type: "number",
50
+ nullable: true,
51
+ },
52
+ {
53
+ name: "FileRef",
54
+ type: "string",
55
+ nullable: true,
56
+ },
57
+ {
58
+ name: "Extension",
59
+ type: "string",
60
+ nullable: true,
61
+ },
62
+ ],
63
+ parameters: {
64
+ maxRecords: -1,
65
+ },
66
+ });
@@ -0,0 +1,3 @@
1
+ export * from "./dsReportIssueAreas.js";
2
+ export * from "./dsReportIssueFiles.js";
3
+ export * from "./procReportIssue.js";
@@ -0,0 +1,58 @@
1
+ import { ProcedureAPI } from "@olenbetong/appframe-data";
2
+
3
+ export type ReportIssueParams = {
4
+ IssueType: "Issue" | "Suggestion";
5
+ Area?: string | null;
6
+ Description: string;
7
+ IncidentDate?: string | null;
8
+ SubmitFiles?: boolean | null;
9
+ CauseAnalysis?: string | null;
10
+ };
11
+
12
+ export type ReportIssueResult = {
13
+ Table: { IssueID: number }[];
14
+ };
15
+
16
+ /** Creates the issue and moves the user's uploaded attachments onto it. */
17
+ export const procReportIssue = new ProcedureAPI<ReportIssueParams, ReportIssueResult>({
18
+ procedureId: "astp_Improve_CreateNewIssue2",
19
+ parameters: [
20
+ {
21
+ name: "IssueType",
22
+ type: "string",
23
+ hasDefault: false,
24
+ required: true,
25
+ },
26
+ {
27
+ name: "Area",
28
+ type: "string",
29
+ hasDefault: true,
30
+ required: false,
31
+ },
32
+ {
33
+ name: "Description",
34
+ type: "string",
35
+ hasDefault: false,
36
+ required: true,
37
+ },
38
+ {
39
+ name: "IncidentDate",
40
+ type: "datetime",
41
+ hasDefault: true,
42
+ required: false,
43
+ },
44
+ {
45
+ name: "SubmitFiles",
46
+ type: "boolean",
47
+ hasDefault: true,
48
+ required: false,
49
+ },
50
+ {
51
+ name: "CauseAnalysis",
52
+ type: "string",
53
+ hasDefault: true,
54
+ required: false,
55
+ },
56
+ ],
57
+ timeout: 30000,
58
+ });
@@ -0,0 +1,3 @@
1
+ export * from "./data/index.js";
2
+ export * from "./ReportIssueAttachments.js";
3
+ export * from "./ReportIssueForm.js";