Repository navigation
Notices with the code of an error, and a loading that never gets stuck
New features
-
Common. Every message is a notice.
IDEAMessageServiceno longer usesion-toast: a new component (idea-notices) takes its look from the app's Ionic tokens, dark mode included.- Notices are stacked at the bottom, at the bottom-right corner on a wide screen, at most 3 at a time.
- They close by themselves after 3, 5 or 10 seconds, pausing while pointed or focused.
- Refinable with
--idea-notice-background,--idea-notice-border-radius,--idea-notice-width.
-
Common. The code of an unhandled back-end error. The error
IDEAApiServicethrows carries therequestIdthe back-end adds to the errors it didn't handle (IDEAApiError.requestId, idea-aws >= 4.8.0). Pass it to the message, and the user sees the whole code, with a button to copy it and a sentence asking to report it: the code leads to the log line with the real cause.this._message.error('COMMON.OPERATION_FAILED', { requestId: error.requestId });
-
Common. Messages that stay. With
persistent, a message stays until the user closes it, with its owncloseTextand anonClosecallback. The app-status announcements use it instead of their own toast. -
Common. A loading that blocks at once, never flashes, never gets stuck.
IDEALoadingServicekeeps its API but counts the waits, so the app is free at the lasthide():- nested
show()/hide()work, and ahide()that comes early cancels the wait; - the app is blocked from the call, but the wait shows only after 250 ms and stays at least 500 ms;
- from 8.14.1, a notice that comes during the wait, or once it is over, takes its place: the wait doesn't stay its 500 ms next to it (e.g. a quick save and its success);
- after 8 seconds, a second line says it's taking longer than usual.
- nested
-
Common. The panel of a long task.
show(options)returns a task that shows its steps (step(), with their duration), its progress (progress()), an error with the code to copy (fail()), and a Cancel button. Cancel triggerstask.cancelled, anAbortSignalthatIDEAApiServicenow accepts assignal.
Behaviour changes for older versions
No code change is required, but:
- messages and waits look different, and the module no longer uses
ion-toastandion-loading: app CSS aimed at them (e.g.ion-toast.toastWithServerMessage) no longer applies; - the waits are counted: an extra
hide()inside a nested block now closes the outer wait early, where it used to leave an overlay on screen; IDEAAppStatusService.check()'stoastColorandtoastPositionare deprecated and ignored;- a cancelled request (
signal) doesn't count as a back-end failure for the app status.
How to adopt the new version
-
Update
@idea-ionic/commonto 8.14.0 and copy theIDEA_COMMONtranslations again: there are new terms inMESSAGE.*andLOADING.*. -
Wherever you show the error of an API request, pass
requestId: error.requestId. KeepserverMessageonly where the back-end explains something the user can act on: with arequestIdit isn't shown, being the back-end's generic message. -
Optional. Show long tasks with the panel:
const task = await this._loading.show({ message: 'IMPORT.TITLE', steps: ['IMPORT.READ', 'IMPORT.SAVE'], cancelable: true }); try { task.step(0); const rows = await this._api.getResource(['imports', id], { signal: task.cancelled }); task.step(1); // ... } catch (error) { if (!task.cancelled.aborted) task.fail('COMMON.OPERATION_FAILED', { requestId: error.requestId }); } finally { await this._loading.hide(); }
Notes
- The code appears only with a back-end on
idea-aws>= 4.8.0: with an older one there's norequestId, and errors look as before, in the new style. - The legacy
IDEAAWSAPIService(uncommon) carries therequestIdtoo, and the module's own components (common, uncommon, teams, agenda) pass it in their errors. - The notices' icons come from
ionicons, already installed with@ionic/angular.