mirror of
https://github.com/hcengineering/platform.git
synced 2025-05-31 04:38:02 +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
|
||||
*/
|
||||
export function getEffectiveDocUpdate (): DocumentUpdate<ControlledDocument> {
|
||||
return {
|
||||
state: DocumentState.Effective,
|
||||
effectiveDate: Date.now(),
|
||||
controlledState: undefined
|
||||
}
|
||||
export function getEffectiveDocUpdates (): DocumentUpdate<ControlledDocument>[] {
|
||||
return [
|
||||
{
|
||||
state: DocumentState.Effective,
|
||||
effectiveDate: Date.now()
|
||||
},
|
||||
{
|
||||
$unset: { controlledState: true }
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -31,7 +31,7 @@ import documents, {
|
||||
DocumentApprovalRequest,
|
||||
DocumentState,
|
||||
DocumentTemplate,
|
||||
getEffectiveDocUpdate,
|
||||
getEffectiveDocUpdates,
|
||||
type DocumentRequest,
|
||||
type DocumentTraining
|
||||
} from '@hcengineering/controlled-documents'
|
||||
@ -58,8 +58,9 @@ async function getDocs (
|
||||
return allDocs.filter(predicate)
|
||||
}
|
||||
|
||||
function makeDocEffective (doc: ControlledDocument, txFactory: TxFactory): Tx {
|
||||
return txFactory.createTxUpdateDoc(doc._class, doc.space, doc._id, getEffectiveDocUpdate())
|
||||
function makeDocEffective (doc: ControlledDocument, txFactory: TxFactory): Tx[] {
|
||||
const updates = getEffectiveDocUpdates()
|
||||
return updates.map((u) => txFactory.createTxUpdateDoc(doc._class, doc.space, doc._id, u))
|
||||
}
|
||||
|
||||
function archiveDocs (docs: ControlledDocument[], txFactory: TxFactory): Tx[] {
|
||||
@ -358,7 +359,7 @@ export async function OnDocPlannedEffectiveDateChanged (
|
||||
if (tx.operations.plannedEffectiveDate === 0 && doc.controlledState === ControlledDocumentState.Approved) {
|
||||
// Create with not derived tx factory in order for notifications to work
|
||||
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
|
||||
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
|
||||
}
|
||||
return result
|
||||
|
Loading…
Reference in New Issue
Block a user