@autobusal/common 1.35.0 → 1.36.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.36.0 (2026-08-29)
4
+
5
+ - Editors offer Save & Close alongside Save & Stay, so correcting a record no longer bounces you back to its list every time (opt-in per page, editing only). The pair is driven from here (Viewer + Actions).
6
+
3
7
  ## 1.35.0 (2026-08-29)
4
8
 
5
9
  - RouteFeature's compact chip draws a real tooltip on hover AND on focus, so a tap reveals the amenity name; `title` alone was invisible on touch and slow on desktop.
@@ -19,6 +19,25 @@ interface Props {
19
19
  const Actions = ({ id, available, pending, confirm, t, onDelete }: Props): JSX.Element => {
20
20
  const options: ActionData[] = [];
21
21
 
22
+ /**
23
+ * Edited: Claude - Date: 2026-08-29
24
+ *
25
+ * Two ways to save, when the page asks for them (actions={['save',
26
+ * 'save_stay', ...]}): one that returns to the list this record came
27
+ * from, one that keeps it open for another edit. Saving used to always
28
+ * throw you back to the list, so correcting three fields on one record
29
+ * meant three round trips through it.
30
+ *
31
+ * Opt-in per page, because "close" has to mean something: the brand
32
+ * settings, the ticket editors and the notification preferences have no
33
+ * list to go back to and keep their single Save.
34
+ *
35
+ * ONLY WHEN EDITING. On a create form there is nothing to stay on - the
36
+ * record has no id yet, so the form would sit there still full, and the
37
+ * obvious next click would file a duplicate.
38
+ */
39
+ const paired = available.includes('save_stay') && id > 0;
40
+
22
41
  const onAskDelete = (): void => {
23
42
  if (window.confirm(confirm ?? t('table.confirm', { ns: 'common' }))) {
24
43
  if (onDelete) {
@@ -37,7 +56,9 @@ const Actions = ({ id, available, pending, confirm, t, onDelete }: Props): JSX.E
37
56
 
38
57
  if (available.includes('save')) {
39
58
  options.push({
40
- label: t('table.actions.save', { ns: 'common' }),
59
+ // with a second save button beside it, "Save" no longer says what
60
+ // THIS one does
61
+ label: t(paired ? 'table.actions.save_close' : 'table.actions.save', { ns: 'common' }),
41
62
  icon: <RiSave2Line />,
42
63
  type: 'submit'
43
64
  });
@@ -68,12 +89,24 @@ const Actions = ({ id, available, pending, confirm, t, onDelete }: Props): JSX.E
68
89
 
69
90
  if (available.includes('update')) {
70
91
  options.push({
71
- label: t('table.actions.update', { ns: 'common' }),
92
+ label: t(paired ? 'table.actions.save_close' : 'table.actions.update', { ns: 'common' }),
72
93
  icon: <BiEditAlt />,
73
94
  type: 'submit'
74
95
  });
75
96
  }
76
97
 
98
+ // second, so the first submit button - the one Enter presses - stays the
99
+ // one that has always been there
100
+ if (paired) {
101
+ options.push({
102
+ label: t('table.actions.save_stay', { ns: 'common' }),
103
+ icon: <RiSave2Line />,
104
+ type: 'submit',
105
+ name: 'intent',
106
+ value: 'stay'
107
+ });
108
+ }
109
+
77
110
  if (available.includes('approve')) {
78
111
  options.push({
79
112
  label: t('table.actions.approve', { ns: 'common' }),
package/Viewer/Viewer.tsx CHANGED
@@ -21,7 +21,15 @@ interface Props {
21
21
  */
22
22
  confirm?: string
23
23
  t: TFunction<'common'>
24
- onSave?: (data: any) => void
24
+ /**
25
+ * Edited: Claude - Date: 2026-08-29
26
+ *
27
+ * `stay` is true when the editor was saved with "Save & Stay" rather than
28
+ * "Save & Close" - the page keeps the record open instead of returning to
29
+ * its list. Optional, so a form that never navigates anyway (the brand
30
+ * settings, the ticket editors) needs no change and offers one button.
31
+ */
32
+ onSave?: (data: any, stay?: boolean) => void
25
33
  onDelete?: (data?: any) => void
26
34
  // Edited: Ferjolt Ozuni - Date: 2026-07-31
27
35
  // Optional second submit-type action (actions={['save', 'test']}) - e.g.
@@ -62,7 +70,10 @@ const Viewer = ({ id, type, data, fetching, pending, actions, confirm, t, onSave
62
70
  }
63
71
 
64
72
  if (onSave !== undefined) {
65
- onSave(data);
73
+ // 'stay' is set by the second save button (see Actions.tsx); every
74
+ // other submitter - including plain Enter, which fires the FIRST
75
+ // button - leaves it undefined and the page closes as it always has
76
+ onSave(data, submitter?.value === 'stay');
66
77
  }
67
78
  };
68
79
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@autobusal/common",
3
- "version": "1.35.0",
3
+ "version": "1.36.0",
4
4
  "author": "Ferjolt Ozuni",
5
5
  "type": "module",
6
6
  "main": "index.ts"