@zeniai/client-epic-state 5.2.48 → 5.2.49-betaAK0
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/esm/view/expenseAutomationView/reducers/reconciliationViewReducer.js +80 -53
- package/lib/esm/view/invoicing/editInvoicingCatalogItemDetailView/editInvoicingCatalogItemDetailViewReducer.js +19 -11
- package/lib/esm/view/invoicing/editInvoicingCatalogItemDetailView/editInvoicingCatalogItemDetailViewSelector.js +4 -1
- package/lib/esm/view/invoicing/editInvoicingCatalogItemDetailView/saveInvoicingCatalogItemEpic.js +3 -2
- package/lib/esm/view/invoicing/editInvoicingCatalogItemDetailView/seedInvoicingCatalogItemFormDraftEpic.js +18 -9
- package/lib/esm/view/invoicing/editInvoicingCouponDetailView/editInvoicingCouponDetailViewReducer.js +19 -11
- package/lib/esm/view/invoicing/editInvoicingCouponDetailView/editInvoicingCouponDetailViewSelector.js +3 -1
- package/lib/esm/view/invoicing/editInvoicingCouponDetailView/saveInvoicingCouponEpic.js +1 -1
- package/lib/esm/view/invoicing/editInvoicingCouponDetailView/seedInvoicingCouponFormDraftEpic.js +16 -7
- package/lib/esm/view/invoicing/editInvoicingCustomerDetailView/editInvoicingCustomerDetailViewReducer.js +19 -11
- package/lib/esm/view/invoicing/editInvoicingCustomerDetailView/editInvoicingCustomerDetailViewSelector.js +4 -2
- package/lib/esm/view/invoicing/editInvoicingCustomerDetailView/saveInvoicingCustomerEpic.js +1 -1
- package/lib/esm/view/invoicing/editInvoicingSubscriptionDetailView/editInvoicingSubscriptionDetailViewReducer.js +21 -13
- package/lib/esm/view/invoicing/editInvoicingSubscriptionDetailView/editInvoicingSubscriptionDetailViewSelector.js +3 -2
- package/lib/esm/view/invoicing/editInvoicingSubscriptionDetailView/fetchInvoicingSubscriptionFormPageEpic.js +4 -1
- package/lib/esm/view/invoicing/editInvoicingSubscriptionDetailView/saveInvoicingSubscriptionEpic.js +1 -1
- package/lib/esm/view/invoicing/editInvoicingSubscriptionDetailView/seedInvoicingSubscriptionFormDraftEpic.js +18 -9
- package/lib/esm/view/invoicing/invoicingFormDraft.js +56 -0
- package/lib/view/expenseAutomationView/reducers/reconciliationViewReducer.js +80 -53
- package/lib/view/invoicing/editInvoicingCatalogItemDetailView/editInvoicingCatalogItemDetailViewReducer.d.ts +3 -1
- package/lib/view/invoicing/editInvoicingCatalogItemDetailView/editInvoicingCatalogItemDetailViewReducer.js +19 -11
- package/lib/view/invoicing/editInvoicingCatalogItemDetailView/editInvoicingCatalogItemDetailViewSelector.d.ts +10 -0
- package/lib/view/invoicing/editInvoicingCatalogItemDetailView/editInvoicingCatalogItemDetailViewSelector.js +4 -1
- package/lib/view/invoicing/editInvoicingCatalogItemDetailView/editInvoicingCatalogItemDetailViewState.d.ts +2 -1
- package/lib/view/invoicing/editInvoicingCatalogItemDetailView/saveInvoicingCatalogItemEpic.js +3 -2
- package/lib/view/invoicing/editInvoicingCatalogItemDetailView/seedInvoicingCatalogItemFormDraftEpic.d.ts +10 -6
- package/lib/view/invoicing/editInvoicingCatalogItemDetailView/seedInvoicingCatalogItemFormDraftEpic.js +17 -8
- package/lib/view/invoicing/editInvoicingCouponDetailView/editInvoicingCouponDetailViewReducer.d.ts +3 -1
- package/lib/view/invoicing/editInvoicingCouponDetailView/editInvoicingCouponDetailViewReducer.js +19 -11
- package/lib/view/invoicing/editInvoicingCouponDetailView/editInvoicingCouponDetailViewSelector.d.ts +13 -0
- package/lib/view/invoicing/editInvoicingCouponDetailView/editInvoicingCouponDetailViewSelector.js +3 -1
- package/lib/view/invoicing/editInvoicingCouponDetailView/editInvoicingCouponDetailViewState.d.ts +2 -1
- package/lib/view/invoicing/editInvoicingCouponDetailView/saveInvoicingCouponEpic.js +1 -1
- package/lib/view/invoicing/editInvoicingCouponDetailView/seedInvoicingCouponFormDraftEpic.d.ts +10 -6
- package/lib/view/invoicing/editInvoicingCouponDetailView/seedInvoicingCouponFormDraftEpic.js +15 -6
- package/lib/view/invoicing/editInvoicingCustomerDetailView/editInvoicingCustomerDetailViewReducer.d.ts +3 -1
- package/lib/view/invoicing/editInvoicingCustomerDetailView/editInvoicingCustomerDetailViewReducer.js +19 -11
- package/lib/view/invoicing/editInvoicingCustomerDetailView/editInvoicingCustomerDetailViewSelector.d.ts +9 -0
- package/lib/view/invoicing/editInvoicingCustomerDetailView/editInvoicingCustomerDetailViewSelector.js +4 -2
- package/lib/view/invoicing/editInvoicingCustomerDetailView/editInvoicingCustomerDetailViewState.d.ts +2 -1
- package/lib/view/invoicing/editInvoicingCustomerDetailView/saveInvoicingCustomerEpic.js +1 -1
- package/lib/view/invoicing/editInvoicingSubscriptionDetailView/editInvoicingSubscriptionDetailViewReducer.d.ts +3 -1
- package/lib/view/invoicing/editInvoicingSubscriptionDetailView/editInvoicingSubscriptionDetailViewReducer.js +21 -13
- package/lib/view/invoicing/editInvoicingSubscriptionDetailView/editInvoicingSubscriptionDetailViewSelector.d.ts +9 -0
- package/lib/view/invoicing/editInvoicingSubscriptionDetailView/editInvoicingSubscriptionDetailViewSelector.js +3 -2
- package/lib/view/invoicing/editInvoicingSubscriptionDetailView/editInvoicingSubscriptionDetailViewState.d.ts +2 -1
- package/lib/view/invoicing/editInvoicingSubscriptionDetailView/fetchInvoicingSubscriptionFormPageEpic.js +4 -1
- package/lib/view/invoicing/editInvoicingSubscriptionDetailView/saveInvoicingSubscriptionEpic.js +1 -1
- package/lib/view/invoicing/editInvoicingSubscriptionDetailView/seedInvoicingSubscriptionFormDraftEpic.d.ts +10 -6
- package/lib/view/invoicing/editInvoicingSubscriptionDetailView/seedInvoicingSubscriptionFormDraftEpic.js +17 -8
- package/lib/view/invoicing/invoicingFormDraft.d.ts +50 -0
- package/lib/view/invoicing/invoicingFormDraft.js +63 -0
- package/package.json +1 -1
|
@@ -7,15 +7,24 @@ const editInvoicingSubscriptionDetailViewReducer_1 = require("./editInvoicingSub
|
|
|
7
7
|
const invoicingSubscriptionDetailHelper_1 = require("./invoicingSubscriptionDetailHelper");
|
|
8
8
|
const invoicingSubscriptionFormConfig_1 = require("./invoicingSubscriptionFormConfig");
|
|
9
9
|
/**
|
|
10
|
-
* Seeds the edit draft from the record the
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
10
|
+
* Seeds the edit draft from the record, so the form has its values before it
|
|
11
|
+
* mounts. The reducer ignores a seed once the draft holds the record, which is
|
|
12
|
+
* what stops a background refetch from overwriting edits in progress.
|
|
13
|
+
*
|
|
14
|
+
* Opening the page counts as a trigger, not just the detail response: the page
|
|
15
|
+
* fetch is cache-guarded, so re-opening a form for a record already loaded this
|
|
16
|
+
* session issues no request at all — and a draft cleared in between (by a save
|
|
17
|
+
* or a cancel) would have nothing left to seed it.
|
|
14
18
|
*/
|
|
15
|
-
const seedInvoicingSubscriptionFormDraftEpic = (actions$, state$) => actions$.pipe((0, operators_1.filter)(editInvoicingSubscriptionDetailViewReducer_1.updateInvoicingSubscriptionDetail.match
|
|
16
|
-
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
+
const seedInvoicingSubscriptionFormDraftEpic = (actions$, state$) => actions$.pipe((0, operators_1.filter)((action) => editInvoicingSubscriptionDetailViewReducer_1.updateInvoicingSubscriptionDetail.match(action) ||
|
|
20
|
+
editInvoicingSubscriptionDetailViewReducer_1.fetchInvoicingSubscriptionFormPage.match(action)), (0, operators_1.withLatestFrom)(state$), (0, operators_1.mergeMap)(([action, state]) => {
|
|
21
|
+
const id = editInvoicingSubscriptionDetailViewReducer_1.updateInvoicingSubscriptionDetail.match(action)
|
|
22
|
+
? action.payload.id
|
|
23
|
+
: action.payload.subscriptionId;
|
|
24
|
+
// Nothing to seed from on a cold open; the detail response triggers this
|
|
25
|
+
// again once it lands.
|
|
26
|
+
const subscription = id != null ? (0, invoicingSubscriptionDetailHelper_1.getInvoicingSubscriptionById)(state, id) : undefined;
|
|
27
|
+
if (id == null || subscription == null) {
|
|
19
28
|
return rxjs_1.EMPTY;
|
|
20
29
|
}
|
|
21
30
|
return (0, rxjs_1.of)((0, editInvoicingSubscriptionDetailViewReducer_1.seedInvoicingSubscriptionFormDraft)({
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { FetchState, ID } from '../../commonStateTypes/common';
|
|
2
|
+
/**
|
|
3
|
+
* A create/edit form's draft, plus where its values came from.
|
|
4
|
+
*
|
|
5
|
+
* The status is what lets an edit form tell "these are the record's values"
|
|
6
|
+
* from "these are whatever the form had at first render". It cannot be read off
|
|
7
|
+
* the presence of a draft, because the form writes drafts too: it pushes its
|
|
8
|
+
* whole state back on every change, so a change made before the record landed
|
|
9
|
+
* leaves a draft that looks seeded but holds nothing.
|
|
10
|
+
*
|
|
11
|
+
* `Not-Started` — written by the form, never filled from a record.
|
|
12
|
+
* `Completed` — filled from the loaded record; the form may have edited it since.
|
|
13
|
+
* `Error` — the record's fetch failed, so the form starts blank and a
|
|
14
|
+
* later successful fetch is still allowed to seed it.
|
|
15
|
+
*/
|
|
16
|
+
export interface InvoicingFormDraft<TLocalData> {
|
|
17
|
+
fetchState: FetchState;
|
|
18
|
+
localData: TLocalData;
|
|
19
|
+
}
|
|
20
|
+
export type InvoicingFormDraftById<TLocalData> = Record<ID, InvoicingFormDraft<TLocalData>>;
|
|
21
|
+
/**
|
|
22
|
+
* The form's own write. Keeps the status: an edit on top of a seeded draft is
|
|
23
|
+
* still the record's draft, and an edit made before the record arrived must not
|
|
24
|
+
* pass for one.
|
|
25
|
+
*/
|
|
26
|
+
export declare function applyInvoicingFormDraftEdit<TLocalData>(draftById: InvoicingFormDraftById<TLocalData>, id: ID, localData: TLocalData): void;
|
|
27
|
+
/**
|
|
28
|
+
* Fill the draft from the loaded record, once. A second seed is ignored so a
|
|
29
|
+
* late refetch cannot overwrite edits in progress — but a draft the form wrote
|
|
30
|
+
* before the record landed is replaced, since it was never the record's.
|
|
31
|
+
*/
|
|
32
|
+
export declare function applyInvoicingFormDraftSeed<TLocalData>(draftById: InvoicingFormDraftById<TLocalData>, id: ID, localData: TLocalData): void;
|
|
33
|
+
/**
|
|
34
|
+
* Stand the draft up blank when the record's fetch fails, so the form renders
|
|
35
|
+
* instead of waiting behind a skeleton that will never resolve. A draft that
|
|
36
|
+
* already exists is left alone: a background refetch failing is no reason to
|
|
37
|
+
* discard what the user has.
|
|
38
|
+
*/
|
|
39
|
+
export declare function applyInvoicingFormDraftFailure<TLocalData>(draftById: InvoicingFormDraftById<TLocalData>, id: ID, blankLocalData: TLocalData): void;
|
|
40
|
+
/** The draft's values, or the blank form when nothing is drafted yet. */
|
|
41
|
+
export declare function getInvoicingFormDraftLocalData<TLocalData>(draftById: InvoicingFormDraftById<TLocalData>, id: ID | undefined, blankLocalData: TLocalData): TLocalData;
|
|
42
|
+
/**
|
|
43
|
+
* Whether the form should still be showing its skeleton — the record has
|
|
44
|
+
* neither reached the draft nor failed trying.
|
|
45
|
+
*
|
|
46
|
+
* Settles once and stays settled, which is what keeps a later refetch from
|
|
47
|
+
* swapping a form the user is typing into back for a skeleton. Create mode
|
|
48
|
+
* (no id) has no record to wait for.
|
|
49
|
+
*/
|
|
50
|
+
export declare function isInvoicingFormDraftPending<TLocalData>(draftById: InvoicingFormDraftById<TLocalData>, id: ID | undefined): boolean;
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.applyInvoicingFormDraftEdit = applyInvoicingFormDraftEdit;
|
|
4
|
+
exports.applyInvoicingFormDraftSeed = applyInvoicingFormDraftSeed;
|
|
5
|
+
exports.applyInvoicingFormDraftFailure = applyInvoicingFormDraftFailure;
|
|
6
|
+
exports.getInvoicingFormDraftLocalData = getInvoicingFormDraftLocalData;
|
|
7
|
+
exports.isInvoicingFormDraftPending = isInvoicingFormDraftPending;
|
|
8
|
+
/**
|
|
9
|
+
* The form's own write. Keeps the status: an edit on top of a seeded draft is
|
|
10
|
+
* still the record's draft, and an edit made before the record arrived must not
|
|
11
|
+
* pass for one.
|
|
12
|
+
*/
|
|
13
|
+
function applyInvoicingFormDraftEdit(draftById, id, localData) {
|
|
14
|
+
draftById[id] = {
|
|
15
|
+
fetchState: draftById[id]?.fetchState ?? 'Not-Started',
|
|
16
|
+
localData,
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Fill the draft from the loaded record, once. A second seed is ignored so a
|
|
21
|
+
* late refetch cannot overwrite edits in progress — but a draft the form wrote
|
|
22
|
+
* before the record landed is replaced, since it was never the record's.
|
|
23
|
+
*/
|
|
24
|
+
function applyInvoicingFormDraftSeed(draftById, id, localData) {
|
|
25
|
+
if (draftById[id]?.fetchState === 'Completed') {
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
draftById[id] = { fetchState: 'Completed', localData };
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Stand the draft up blank when the record's fetch fails, so the form renders
|
|
32
|
+
* instead of waiting behind a skeleton that will never resolve. A draft that
|
|
33
|
+
* already exists is left alone: a background refetch failing is no reason to
|
|
34
|
+
* discard what the user has.
|
|
35
|
+
*/
|
|
36
|
+
function applyInvoicingFormDraftFailure(draftById, id, blankLocalData) {
|
|
37
|
+
if (draftById[id] != null) {
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
draftById[id] = { fetchState: 'Error', localData: blankLocalData };
|
|
41
|
+
}
|
|
42
|
+
/** The draft's values, or the blank form when nothing is drafted yet. */
|
|
43
|
+
function getInvoicingFormDraftLocalData(draftById, id, blankLocalData) {
|
|
44
|
+
if (id == null) {
|
|
45
|
+
return blankLocalData;
|
|
46
|
+
}
|
|
47
|
+
return draftById[id]?.localData ?? blankLocalData;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Whether the form should still be showing its skeleton — the record has
|
|
51
|
+
* neither reached the draft nor failed trying.
|
|
52
|
+
*
|
|
53
|
+
* Settles once and stays settled, which is what keeps a later refetch from
|
|
54
|
+
* swapping a form the user is typing into back for a skeleton. Create mode
|
|
55
|
+
* (no id) has no record to wait for.
|
|
56
|
+
*/
|
|
57
|
+
function isInvoicingFormDraftPending(draftById, id) {
|
|
58
|
+
if (id == null) {
|
|
59
|
+
return false;
|
|
60
|
+
}
|
|
61
|
+
const fetchState = draftById[id]?.fetchState;
|
|
62
|
+
return fetchState !== 'Completed' && fetchState !== 'Error';
|
|
63
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zeniai/client-epic-state",
|
|
3
|
-
"version": "5.2.
|
|
3
|
+
"version": "5.2.49-betaAK0",
|
|
4
4
|
"description": "Shared module between Web & Mobile containing required abstractions for state management, async network communication. ",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"module": "lib/esm/index.js",
|