当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript FormValidator.requestHandler方法代码示例

本文整理汇总了TypeScript中main/app/forms/validation/formValidator.FormValidator.requestHandler方法的典型用法代码示例。如果您正苦于以下问题:TypeScript FormValidator.requestHandler方法的具体用法?TypeScript FormValidator.requestHandler怎么用?TypeScript FormValidator.requestHandler使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在main/app/forms/validation/formValidator.FormValidator的用法示例。


在下文中一共展示了FormValidator.requestHandler方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: Form

/* tslint:disable:no-default-export */
export default express.Router()
  .get(
    page.uri,
    StatementOfMeansStateGuard.requestHandler(),
    (req: express.Request, res: express.Response) => {
      const draft: Draft<ResponseDraft> = res.locals.responseDraft
      res.render(page.associatedView, {
        form: new Form(draft.document.statementOfMeans.partnerPension)
      })
    })
  .post(
    page.uri,
    StatementOfMeansStateGuard.requestHandler(),
    FormValidator.requestHandler(PartnerPension),
    ErrorHandling.apply(async (req: express.Request, res: express.Response, next: express.NextFunction) => {
      const form: Form<PartnerPension> = 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.partnerPension = form.model
        await new DraftService().save(draft, user.bearerToken)

        if (draft.document.statementOfMeans.disability && draft.document.statementOfMeans.disability.option === DisabilityOption.YES) {
          res.redirect(StatementOfMeansPaths.partnerDisabilityPage.evaluateUri({ externalId: externalId }))
开发者ID:hmcts,项目名称:cmc-citizen-frontend,代码行数:30,代码来源:partner-pension.ts

示例2: renderView

  })
}

/* tslint:disable:no-default-export */
export default express.Router()
  .get(
    Paths.courtOfferedSetDatePage.uri,
    ErrorHandling.apply(async (req: express.Request, res: express.Response, next: express.NextFunction) => {
      const draft: Draft<DraftClaimantResponse> = res.locals.claimantResponseDraft

      renderView(new Form(draft.document.acceptCourtOffer), res)
    }))

  .post(
    Paths.courtOfferedSetDatePage.uri,
    FormValidator.requestHandler(AcceptCourtOffer, AcceptCourtOffer.fromObject),
    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
开发者ID:hmcts,项目名称:cmc-citizen-frontend,代码行数:31,代码来源:court-offered-set-date.ts

示例3: Form

/* tslint:disable:no-default-export */
export default express.Router()
  .get(
    page.uri,
    StatementOfMeansStateGuard.requestHandler(),
    (req: express.Request, res: express.Response) => {
      const draft: Draft<ResponseDraft> = res.locals.responseDraft
      res.render(page.associatedView, {
        form: new Form(draft.document.statementOfMeans.cohabiting)
      })
    })
  .post(
    page.uri,
    StatementOfMeansStateGuard.requestHandler(),
    FormValidator.requestHandler(Cohabiting),
    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
开发者ID:hmcts,项目名称:cmc-citizen-frontend,代码行数:30,代码来源:partner.ts

示例4: catch

    })
  } catch (err) {
    next(err)
  }
}

/* tslint:disable:no-default-export */
export default express.Router()
  .get(
    Paths.signSettlementAgreement.uri,
    ErrorHandling.apply(async (req: express.Request, res: express.Response, next: express.NextFunction) => {
      renderView(new Form(new DefendantSettlementResponse()), res, next)
    }))
  .post(
    Paths.signSettlementAgreement.uri,
    FormValidator.requestHandler(DefendantSettlementResponse),
    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 }))
开发者ID:hmcts,项目名称:cmc-citizen-frontend,代码行数:31,代码来源:sign-settlement-agreement.ts

示例5: renderView

    form: form,
    totalAmount: StatesPaidHelper.getAlreadyPaidAmount(claim),
    paidInFull: !StatesPaidHelper.isAlreadyPaidLessThanAmount(claim)
  })
}

/* tslint:disable:no-default-export */
export default express.Router()
  .get(Paths.settleClaimPage.uri,
    ErrorHandling.apply(async (req: express.Request, res: express.Response, next: express.NextFunction) => {
      const draft: Draft<DraftClaimantResponse> = res.locals.claimantResponseDraft
      renderView(new Form(draft.document.accepted), res)
    }))
  .post(
    Paths.settleClaimPage.uri,
    FormValidator.requestHandler(ClaimSettled, ClaimSettled.fromObject),
    ErrorHandling.apply(async (req: express.Request, res: express.Response): Promise<void> => {
      const form: Form<ClaimSettled> = req.body
      if (form.hasErrors()) {
        renderView(form, res)
      } else {
        const draft: Draft<DraftClaimantResponse> = res.locals.claimantResponseDraft
        draft.document.accepted = form.model

        if (form.model.accepted.option === YesNoOption.YES.option) {
          draft.document.rejectionReason = undefined
          draft.document.freeMediation = undefined
        }

        await new DraftService().save(draft, res.locals.user.bearerToken)
开发者ID:hmcts,项目名称:cmc-citizen-frontend,代码行数:30,代码来源:settle-claim.ts

示例6: Form

/* tslint:disable:no-default-export */
export default express.Router()
  .get(
    page.uri,
    StatementOfMeansStateGuard.requestHandler(),
    (req: express.Request, res: express.Response) => {
      const draft: Draft<ResponseDraft> = res.locals.responseDraft
      res.render(page.associatedView, {
        form: new Form(draft.document.statementOfMeans.partnerAge)
      })
    })
  .post(
    page.uri,
    StatementOfMeansStateGuard.requestHandler(),
    FormValidator.requestHandler(PartnerAge),
    ErrorHandling.apply(async (req: express.Request, res: express.Response, next: express.NextFunction) => {
      const form: Form<PartnerAge> = 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.partnerAge = form.model
        if (form.model.option === PartnerAgeOption.NO) {
          draft.document.statementOfMeans.partnerPension = undefined
        }
        await new DraftService().save(draft, user.bearerToken)
开发者ID:hmcts,项目名称:cmc-citizen-frontend,代码行数:30,代码来源:partner-age.ts

示例7: Form

/* tslint:disable:no-default-export */
export default express.Router()
  .get(
    page.uri,
    StatementOfMeansStateGuard.requestHandler(),
    (req: express.Request, res: express.Response) => {
      const draft: Draft<ResponseDraft> = res.locals.responseDraft
      res.render(page.associatedView, {
        form: new Form(draft.document.statementOfMeans.partnerDisability)
      })
    })
  .post(
    page.uri,
    StatementOfMeansStateGuard.requestHandler(),
    FormValidator.requestHandler(PartnerDisability),
    ErrorHandling.apply(async (req: express.Request, res: express.Response, next: express.NextFunction) => {
      const form: Form<PartnerDisability> = 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.partnerDisability = form.model
        if (form.model.option === PartnerDisabilityOption.NO) {
          draft.document.statementOfMeans.partnerSevereDisability = undefined
        }
        await new DraftService().save(draft, user.bearerToken)
开发者ID:hmcts,项目名称:cmc-citizen-frontend,代码行数:30,代码来源:partner-disability.ts

示例8: renderView

function renderView (form: Form<IntentionToProceed>, res: express.Response): void {
  res.render(Paths.intentionToProceedPage.associatedView,{
    form: form
  })
}

/* tslint:disable:no-default-export */
export default express.Router()
  .get(Paths.intentionToProceedPage.uri,
    ErrorHandling.apply(async (req: express.Request, res: express.Response, next: express.NextFunction) => {
      const draft: Draft<DraftClaimantResponse> = res.locals.claimantResponseDraft
      renderView(new Form(draft.document.intentionToProceed), res)
    }))
  .post(
    Paths.intentionToProceedPage.uri,
    FormValidator.requestHandler(IntentionToProceed, IntentionToProceed.fromObject),
    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)
开发者ID:hmcts,项目名称:cmc-citizen-frontend,代码行数:31,代码来源:intention-to-proceed.ts

示例9: async

  })
}

/* tslint:disable:no-default-export */
export default express.Router()
  .get(
    Paths.willYouTryMediation.uri,
    async (req: express.Request, res: express.Response, next: express.NextFunction) => {
      const draft: Draft<MediationDraft> = res.locals.mediationDraft

      renderView(new Form(draft.document.willYouTryMediation), res)
    }
  )
  .post(
    Paths.willYouTryMediation.uri,
    FormValidator.requestHandler(FreeMediation),
    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
        }
开发者ID:hmcts,项目名称:cmc-citizen-frontend,代码行数:31,代码来源:will-you-try-mediation.ts

示例10: renderView

    paidAmount: StatesPaidHelper.getAlreadyPaidAmount(claim)
  })
}

/* tslint:disable:no-default-export */
export default express.Router()
  .get(Paths.partPaymentReceivedPage.uri,
    stateGuardRequestHandler,
    ErrorHandling.apply(async (req: express.Request, res: express.Response, next: express.NextFunction) => {
      const draft: Draft<DraftClaimantResponse> = res.locals.claimantResponseDraft
      renderView(new Form(draft.document.partPaymentReceived), res)
    }))
  .post(
    Paths.partPaymentReceivedPage.uri,
    stateGuardRequestHandler,
    FormValidator.requestHandler(PartPaymentReceived, PartPaymentReceived.fromObject),
    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)
开发者ID:hmcts,项目名称:cmc-citizen-frontend,代码行数:31,代码来源:part-payment-received.ts


注:本文中的main/app/forms/validation/formValidator.FormValidator.requestHandler方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。