@abgov/nx-adsp 5.8.0-beta.5 → 5.8.1

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abgov/nx-adsp",
3
- "version": "5.8.0-beta.5",
3
+ "version": "5.8.1",
4
4
  "license": "Apache-2.0",
5
5
  "main": "src/index.js",
6
6
  "description": "Government of Alberta - Nx plugin for ADSP apps.",
@@ -0,0 +1,23 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="utf-8" />
5
+ <title><%= projectName %></title>
6
+ <base href="/" />
7
+
8
+ <meta name="viewport" content="width=device-width, initial-scale=1" />
9
+ <link rel="icon" type="image/x-icon" href="favicon.ico" />
10
+
11
+ <script
12
+ type="module"
13
+ src="https://unpkg.com/ionicons@5.5.2/dist/ionicons/ionicons.esm.js"
14
+ ></script>
15
+ <script
16
+ nomodule
17
+ src="https://unpkg.com/ionicons@5.5.2/dist/ionicons/ionicons.js"
18
+ ></script>
19
+ </head>
20
+ <body>
21
+ <div id="root"></div>
22
+ </body>
23
+ </html>
@@ -49,6 +49,7 @@ export interface <%= className %>State {
49
49
  saving: boolean;
50
50
  submitting: boolean;
51
51
  };
52
+ errorMessage: string;
52
53
  }
53
54
 
54
55
  function areSectionsComplete(
@@ -75,7 +76,7 @@ function areSectionsComplete(
75
76
  let completion: SectionCompletion = null;
76
77
  if (!hasError && hasValues.length === requiredValues.length) {
77
78
  completion = 'complete';
78
- } else {
79
+ } else if (hasValues.length > 0) {
79
80
  // This means partial completion.
80
81
  completion = 'incomplete';
81
82
  }
@@ -172,6 +173,11 @@ const formSaved = createAction(
172
173
  (values: <%= className %>) => ({ payload: values })
173
174
  );
174
175
 
176
+ const formSaveRejected = createAction(
177
+ '<%= propertyName %>/save-rejected',
178
+ (message: string) => ({ payload: message })
179
+ );
180
+
175
181
  const queueSaveForm = createAsyncThunk(
176
182
  '<%= propertyName %>/queue-save',
177
183
  debounce(
@@ -181,13 +187,22 @@ const queueSaveForm = createAsyncThunk(
181
187
  const { formId }: <%= className %>State =
182
188
  state[<%= constantName %>_FEATURE_KEY];
183
189
 
184
- await axios.put(
185
- `${FORM_SERVICE_URL}/form/v1/forms/${formId}/data`,
186
- { data: values },
187
- { headers: { Authorization: `Bearer ${user.access_token}` } }
188
- );
189
-
190
- dispatch(formSaved(values));
190
+ try {
191
+ await axios.put(
192
+ `${FORM_SERVICE_URL}/form/v1/forms/${formId}/data`,
193
+ { data: values },
194
+ { headers: { Authorization: `Bearer ${user.access_token}` } }
195
+ );
196
+
197
+ dispatch(formSaved(values));
198
+ } catch (err) {
199
+ let message = 'Unexpected error saving form.';
200
+ if (axios.isAxiosError(err) && err.response?.status === 400) {
201
+ message = err.response?.data?.errorMessage;
202
+ }
203
+
204
+ dispatch(formSaveRejected(message));
205
+ }
191
206
  },
192
207
  2000,
193
208
  { trailing: true, leading: false }
@@ -256,6 +271,7 @@ export const initial<%= className %>State: <%= className %>State = {
256
271
  saving: false,
257
272
  submitting: false,
258
273
  },
274
+ errorMessage: null,
259
275
  };
260
276
 
261
277
  export const <%= propertyName %>Slice = createSlice({
@@ -292,6 +308,10 @@ export const <%= propertyName %>Slice = createSlice({
292
308
  .addCase(formSaved, (state) => {
293
309
  state.busy.saving = false;
294
310
  })
311
+ .addCase(formSaveRejected, (state, action) => {
312
+ state.busy.saving = false;
313
+ state.errorMessage = action.payload;
314
+ })
295
315
  .addCase(queueSaveForm.rejected, (state) => {
296
316
  state.busy.saving = false;
297
317
  })
@@ -122,15 +122,25 @@ const <%= section.className %>FieldSet: FunctionComponent<FieldSetProps> = ({
122
122
  } _%>
123
123
  <%_ } _%>
124
124
  <%_ break;
125
+ case 'integer':
125
126
  case 'number': _%>
126
127
  <GoAInput
127
128
  type="number"
128
129
  disabled={isReadOnly || inReview}
129
130
  error={errors['<%= key %>']}
130
131
  placeholder="<%= value?.examples || []%>"
131
- onChange={(name, updated) => onChange({ ...value, [name]: updated })}
132
+ onChange={(name, updated) => onChange({ ...value, [name]: parseFloat(updated) })}
132
133
  value={`${value.<%= key %> || ''}`}
133
134
  name="<%= key %>"
135
+ <%_ if (value?.maximum !== undefined) { _%>
136
+ max={<%= value.maximum %>}
137
+ <%_ } _%>
138
+ <%_ if (value?.minimum !== undefined) { _%>
139
+ min={<%= value.minimum %>}
140
+ <%_ } _%>
141
+ <%_ if (value?.multipleOf !== undefined) { _%>
142
+ step={<%= value.multipleOf %>}
143
+ <%_ } _%>
134
144
  />
135
145
  <%_ break;
136
146
  case 'boolean': _%>