DomainSession
Defined in: js-api/src/ui/domains/domains-session.ts:79
A set of editors that save as ONE transaction.
const session = new DG.DomainSession([parent, children]);
const draft = parent.addRow({name: 'Study 7'}); // id = '~new:…'
children.addRow({study_id: parent.dataFrame.get('id', draft)});
await session.save(); // one /transaction, the ref resolved server-side
isDirty / changeCount / isSaving aggregate over the editors; the
signals mirror theirs. editors is live — add / remove
resubscribe — so a page can grow its session as widgets appear.
Implements
Constructors
Constructor
new DomainSession(
editors?,options?):DomainSession
Defined in: js-api/src/ui/domains/domains-session.ts:98
Parameters
| Parameter | Type |
|---|---|
editors? | DomainFrameEditor[] |
options? | DomainSessionOptions |
Returns
DomainSession
Properties
| Property | Modifier | Type | Default value | Description | Defined in |
|---|---|---|---|---|---|
editors | readonly | DomainFrameEditor[] | [] | Every editor whose pending changes this object answers for. Read on demand: an editor that appears after the widget was constructed must show up here. | js-api/src/ui/domains/domains-session.ts:84 |
CELL_ERRORS | readonly | "Fix the cell errors first" | 'Fix the cell errors first' | What lastRefusal says when an editor refused its own batch: the blocking cells name themselves, and prepareSave has already ballooned the first of them. | js-api/src/ui/domains/domains-session.ts:82 |
Accessors
changeCount
Get Signature
get changeCount():
number
Defined in: js-api/src/ui/domains/domains-session.ts:114
Sum of the editors' pending cell changes.
Returns
number
isDirty
Get Signature
get isDirty():
boolean
Defined in: js-api/src/ui/domains/domains-session.ts:111
Whether any editor has a pending change.
Returns
boolean
isSaving
Get Signature
get isSaving():
boolean
Defined in: js-api/src/ui/domains/domains-session.ts:117
Whether a transaction is in flight (every editor is closed while it is).
Returns
boolean
lastRefusal
Get Signature
get lastRefusal():
DomainSessionRefusal|null
Defined in: js-api/src/ui/domains/domains-session.ts:122
Why the last save did not land; null after a successful save or before the first one. A host that shows the refusal in its own words (a status line, a form footer) reads the sentence here instead of intercepting the balloon.
Returns
DomainSessionRefusal | null
onChanged
Get Signature
get onChanged():
Observable<DomainSession>
Defined in: js-api/src/ui/domains/domains-session.ts:125
Fires on every service-state write of any editor.
Returns
Observable<DomainSession>
onDirtyChanged
Get Signature
get onDirtyChanged():
Observable<boolean>
Defined in: js-api/src/ui/domains/domains-session.ts:127
Fires when the aggregate isDirty flips.
Returns
Observable<boolean>
onSaved
Get Signature
get onSaved():
Observable<DomainSaveResult>
Defined in: js-api/src/ui/domains/domains-session.ts:132
Fires after a successful save with the counters summed over the editors and every draft id the server assigned.
Returns
Observable<DomainSaveResult>
onSavingChanged
Get Signature
get onSavingChanged():
Observable<boolean>
Defined in: js-api/src/ui/domains/domains-session.ts:129
Fires when the aggregate isSaving flips.
Returns
Observable<boolean>
quiet
Get Signature
get quiet():
boolean
Defined in: js-api/src/ui/domains/domains-session.ts:108
Returns
boolean
schema
Get Signature
get schema():
string|undefined
Defined in: js-api/src/ui/domains/domains-session.ts:106
The transaction's URL schema (see DomainSessionOptions.schema).
Returns
string | undefined
Methods
add()
add(
editor):void
Defined in: js-api/src/ui/domains/domains-session.ts:134
Parameters
| Parameter | Type |
|---|---|
editor | DomainFrameEditor |
Returns
void
buildOps()
buildOps():
DomainSessionPart[] |null
Defined in: js-api/src/ui/domains/domains-session.ts:161
Every editor's batch (prepareSave), in editor order — what save
concatenates; null when any editor refused (a blocking cell error, already
reported).
Returns
DomainSessionPart[] | null
discard()
discard():
void
Defined in: js-api/src/ui/domains/domains-session.ts:281
Drops every editor's pending batch.
Returns
void
dispose()
dispose():
void
Defined in: js-api/src/ui/domains/domains-session.ts:275
Releases every editor: the session's subscriptions go, the editors stay. An ad-hoc session —
DomainFrameEditor.save, one saveAll — MUST be disposed when its transaction is done,
or its subscriptions accumulate on the editors for the life of the frame.
Returns
void
remove()
remove(
editor):void
Defined in: js-api/src/ui/domains/domains-session.ts:146
Parameters
| Parameter | Type |
|---|---|
editor | DomainFrameEditor |
Returns
void
save()
save():
Promise<boolean>
Defined in: js-api/src/ui/domains/domains-session.ts:187
Writes every editor's pending batch as ONE /transaction: audit rows share
a tx_id, and any failure rolls all of it back. Resolves to whether the
batch landed.
Blocking cell errors refuse the save (naming the first one). A version
conflict goes through the platform's standard reload/overwrite dialog on
the editor that owns the failing row, and the WHOLE batch is rebuilt and
retried. A server validation error — a business-key clash included, which the
onDuplicate: 'error' of every insert makes an atomic refusal — lands on the
offending editor's cells and everything stays pending. Every editor is
CLOSED while this runs (see
DomainFrameEditor.isSaving). Every unsuccessful return leaves its reason in
lastRefusal.
Returns
Promise<boolean>