mirror of
https://github.com/hcengineering/platform.git
synced 2025-06-05 15:24:22 +00:00
EQMS-1411: Fixed the approval-to-effective status transition in QMS documents (#8598)
Some checks are pending
CI / build (push) Waiting to run
CI / svelte-check (push) Blocked by required conditions
CI / formatting (push) Blocked by required conditions
CI / test (push) Blocked by required conditions
CI / uitest (push) Waiting to run
CI / uitest-pg (push) Waiting to run
CI / uitest-qms (push) Waiting to run
CI / uitest-workspaces (push) Waiting to run
CI / docker-build (push) Blocked by required conditions
CI / dist-build (push) Blocked by required conditions
Some checks are pending
CI / build (push) Waiting to run
CI / svelte-check (push) Blocked by required conditions
CI / formatting (push) Blocked by required conditions
CI / test (push) Blocked by required conditions
CI / uitest (push) Waiting to run
CI / uitest-pg (push) Waiting to run
CI / uitest-qms (push) Waiting to run
CI / uitest-workspaces (push) Waiting to run
CI / docker-build (push) Blocked by required conditions
CI / dist-build (push) Blocked by required conditions
Signed-off-by: Victor Ilyushchenko <alt13ri@gmail.com>
This commit is contained in:
parent
fe23a72d6e
commit
9e916670e1
@ -870,12 +870,16 @@ export async function getFirstRank (
|
|||||||
/**
|
/**
|
||||||
* @public
|
* @public
|
||||||
*/
|
*/
|
||||||
export function getEffectiveDocUpdate (): DocumentUpdate<ControlledDocument> {
|
export function getEffectiveDocUpdates (): DocumentUpdate<ControlledDocument>[] {
|
||||||
return {
|
return [
|
||||||
state: DocumentState.Effective,
|
{
|
||||||
effectiveDate: Date.now(),
|
state: DocumentState.Effective,
|
||||||
controlledState: undefined
|
effectiveDate: Date.now()
|
||||||
}
|
},
|
||||||
|
{
|
||||||
|
$unset: { controlledState: true }
|
||||||
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -31,7 +31,7 @@ import documents, {
|
|||||||
DocumentApprovalRequest,
|
DocumentApprovalRequest,
|
||||||
DocumentState,
|
DocumentState,
|
||||||
DocumentTemplate,
|
DocumentTemplate,
|
||||||
getEffectiveDocUpdate,
|
getEffectiveDocUpdates,
|
||||||
type DocumentRequest,
|
type DocumentRequest,
|
||||||
type DocumentTraining
|
type DocumentTraining
|
||||||
} from '@hcengineering/controlled-documents'
|
} from '@hcengineering/controlled-documents'
|
||||||
@ -58,8 +58,9 @@ async function getDocs (
|
|||||||
return allDocs.filter(predicate)
|
return allDocs.filter(predicate)
|
||||||
}
|
}
|
||||||
|
|
||||||
function makeDocEffective (doc: ControlledDocument, txFactory: TxFactory): Tx {
|
function makeDocEffective (doc: ControlledDocument, txFactory: TxFactory): Tx[] {
|
||||||
return txFactory.createTxUpdateDoc(doc._class, doc.space, doc._id, getEffectiveDocUpdate())
|
const updates = getEffectiveDocUpdates()
|
||||||
|
return updates.map((u) => txFactory.createTxUpdateDoc(doc._class, doc.space, doc._id, u))
|
||||||
}
|
}
|
||||||
|
|
||||||
function archiveDocs (docs: ControlledDocument[], txFactory: TxFactory): Tx[] {
|
function archiveDocs (docs: ControlledDocument[], txFactory: TxFactory): Tx[] {
|
||||||
@ -358,7 +359,7 @@ export async function OnDocPlannedEffectiveDateChanged (
|
|||||||
if (tx.operations.plannedEffectiveDate === 0 && doc.controlledState === ControlledDocumentState.Approved) {
|
if (tx.operations.plannedEffectiveDate === 0 && doc.controlledState === ControlledDocumentState.Approved) {
|
||||||
// Create with not derived tx factory in order for notifications to work
|
// Create with not derived tx factory in order for notifications to work
|
||||||
const factory = new TxFactory(control.txFactory.account)
|
const factory = new TxFactory(control.txFactory.account)
|
||||||
await control.apply(control.ctx, [makeDocEffective(doc, factory)])
|
await control.apply(control.ctx, makeDocEffective(doc, factory))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -383,7 +384,7 @@ export async function OnDocApprovalRequestApproved (
|
|||||||
|
|
||||||
// Create with not derived tx factory in order for notifications to work
|
// Create with not derived tx factory in order for notifications to work
|
||||||
const factory = new TxFactory(control.txFactory.account)
|
const factory = new TxFactory(control.txFactory.account)
|
||||||
await control.apply(control.ctx, [makeDocEffective(doc, factory)])
|
await control.apply(control.ctx, makeDocEffective(doc, factory))
|
||||||
// make doc effective immediately
|
// make doc effective immediately
|
||||||
}
|
}
|
||||||
return result
|
return result
|
||||||
|
Loading…
Reference in New Issue
Block a user