本文整理匯總了TypeScript中main/app/forms/form.Form.hasErrors方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript Form.hasErrors方法的具體用法?TypeScript Form.hasErrors怎麽用?TypeScript Form.hasErrors使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類main/app/forms/form.Form
的用法示例。
在下文中一共展示了Form.hasErrors方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: DraftService
ErrorHandling.apply(async (req: express.Request, res: express.Response, next: express.NextFunction): Promise<void> => {
const form: Form<AcceptCourtOffer> = req.body
if (form.hasErrors()) {
renderView(form, res)
} else {
const draft: Draft<DraftClaimantResponse> = res.locals.claimantResponseDraft
const user: User = res.locals.user
const { externalId } = req.params
draft.document.acceptCourtOffer = form.model
if (draft.document.courtDetermination.rejectionReason || draft.document.formaliseRepaymentPlan) {
delete draft.document.courtDetermination.rejectionReason
delete draft.document.formaliseRepaymentPlan
delete draft.document.settlementAgreement
}
await new DraftService().save(draft, user.bearerToken)
if (form.model.accept.option === YesNoOption.YES.option) {
res.redirect(Paths.taskListPage.evaluateUri({ externalId: externalId }))
} else {
res.redirect(Paths.rejectionReasonPage.evaluateUri({ externalId: externalId }))
}
}
}))
示例2: DraftService
ErrorHandling.apply(async (req: express.Request, res: express.Response, next: express.NextFunction) => {
const form: Form<Cohabiting> = req.body
const { externalId } = req.params
if (form.hasErrors()) {
res.render(page.associatedView, { form: form })
} else {
const draft: Draft<ResponseDraft> = res.locals.responseDraft
const user: User = res.locals.user
draft.document.statementOfMeans.cohabiting = form.model
if (form.model.option === CohabitingOption.NO) {
draft.document.statementOfMeans.partnerAge = draft.document.statementOfMeans.partnerDisability =
draft.document.statementOfMeans.partnerSevereDisability = draft.document.statementOfMeans.partnerPension =
undefined
}
await new DraftService().save(draft, user.bearerToken)
if (form.model.option === CohabitingOption.YES) {
res.redirect(StatementOfMeansPaths.partnerAgePage.evaluateUri({ externalId: externalId }))
} else {
res.redirect(StatementOfMeansPaths.dependantsPage.evaluateUri({ externalId: externalId }))
}
}
})
示例3: DraftService
ErrorHandling.apply(async (req: express.Request, res: express.Response, next: express.NextFunction) => {
const form: Form<FreeMediation> = req.body
if (form.hasErrors()) {
renderView(form, res)
} else {
const draft: Draft<MediationDraft> = res.locals.mediationDraft
const user: User = res.locals.user
draft.document.willYouTryMediation = form.model
if (form.model.option === FreeMediationOption.NO) {
draft.document.youCanOnlyUseMediation = undefined
draft.document.canWeUse = undefined
draft.document.canWeUseCompany = undefined
}
await new DraftService().save(draft, user.bearerToken)
const externalId: string = req.params.externalId
if (form.model.option === FreeMediationOption.YES) {
res.redirect(Paths.mediationAgreementPage.evaluateUri({ externalId: externalId }))
} else {
const claim: Claim = res.locals.claim
if (!claim.isResponseSubmitted()) {
res.redirect(ResponsePaths.taskListPage.evaluateUri({ externalId: externalId }))
} else {
res.redirect(ClaimantResponsePaths.taskListPage.evaluateUri({ externalId: externalId }))
}
}
}
})
示例4: async
async (req: express.Request, res: express.Response): Promise<void> => {
const form: Form<PaymentOption> = req.body
if (form.hasErrors()) {
this.renderView(form, res)
} else {
this.createModelAccessor().patch(res.locals.draft.document, model => model.paymentOption = form.model)
this.deleteRedundantData(res, req)
await this.saveDraft(res.locals)
res.redirect(this.buildPostSubmissionUri(path, req, res))
}
}))
示例5: async
async (req: express.Request, res: express.Response): Promise<void> => {
const form: Form<PaidAmount> = req.body
if (form.hasErrors()) {
this.renderView(form, res)
} else {
this.paidAmount().set(res.locals.draft.document, form.model)
const user: User = res.locals.user
await new DraftService().save(res.locals.draft, user.bearerToken)
const { externalId } = req.params
res.redirect(new RoutablePath(path + Paths.paidAmountSummaryPage.uri).evaluateUri({ externalId: externalId }))
}
}))
示例6: DraftService
ErrorHandling.apply(async (req: express.Request, res: express.Response) => {
const form: Form<FreeMediation> = req.body
if (form.hasErrors()) {
this.renderView(form, res)
} else {
const draft: Draft<any> = res.locals.draft
const user: User = res.locals.user
draft.document.freeMediation = form.model
await new DraftService().save(draft, user.bearerToken)
res.redirect(this.buildRedirectUri(req, res))
}
}))
示例7: renderView
ErrorHandling.apply(async (req: express.Request, res: express.Response, next: express.NextFunction): Promise<void> => {
const form: Form<DefendantSettlementResponse> = req.body
if (form.hasErrors()) {
renderView(form, res, next)
} else {
const claim: Claim = res.locals.claim
const user: User = res.locals.user
if (form.model.option === YesNoOption.YES.option) {
await settlementAgreementClient.countersignSettlementAgreement(claim.externalId, user)
} else {
await settlementAgreementClient.rejectSettlementAgreement(claim.externalId, user)
}
res.redirect(Paths.settlementAgreementConfirmation.evaluateUri({ externalId: claim.externalId }))
}
}
示例8: DraftService
ErrorHandling.apply(async (req: express.Request, res: express.Response): Promise<void> => {
const form: Form<PartPaymentReceived> = req.body
if (form.hasErrors()) {
renderView(form, res)
} else {
const draft: Draft<DraftClaimantResponse> = res.locals.claimantResponseDraft
draft.document.partPaymentReceived = form.model
if (form.model.received.option === YesNoOption.NO.option) {
draft.document.accepted = undefined
draft.document.rejectionReason = undefined
}
await new DraftService().save(draft, res.locals.user.bearerToken)
res.redirect(Paths.taskListPage.evaluateUri({ externalId: res.locals.claim.externalId }))
}
})
示例9: DraftService
ErrorHandling.apply(async (req: express.Request, res: express.Response): Promise<void> => {
const form: Form<IntentionToProceed> = req.body
if (form.hasErrors()) {
renderView(form, res)
} else {
const draft: Draft<DraftClaimantResponse> = res.locals.claimantResponseDraft
const mediationDraft: Draft<MediationDraft> = res.locals.mediationDraft
const user: User = res.locals.user
if (form.model.proceed === YesNoOption.NO.option && mediationDraft) {
await new DraftService().delete(mediationDraft.id, user.bearerToken)
}
draft.document.intentionToProceed = form.model
await new DraftService().save(draft, user.bearerToken)
res.redirect(Paths.taskListPage.evaluateUri({ externalId: res.locals.claim.externalId }))
}
})