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


TypeScript form.Form类代码示例

本文整理汇总了TypeScript中forms/form.Form的典型用法代码示例。如果您正苦于以下问题:TypeScript Form类的具体用法?TypeScript Form怎么用?TypeScript Form使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: DraftService

    ErrorHandling.apply(async (req: express.Request, res: express.Response, next: express.NextFunction) => {
      const form: Form<Disability> = 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.disability = form.model
        if (form.model.option === DisabilityOption.NO) {
          draft.document.statementOfMeans.severeDisability = undefined
        }
        await new DraftService().save(draft, user.bearerToken)

        if (form.model.option === DisabilityOption.YES) {
          res.redirect(StatementOfMeansPaths.severeDisabilityPage.evaluateUri({ externalId: externalId }))
        } else {
          res.redirect(StatementOfMeansPaths.residencePage.evaluateUri({ externalId: externalId }))
        }
      }
    })
开发者ID:hmcts,项目名称:cmc-citizen-frontend,代码行数:23,代码来源:disability.ts

示例2: saveAndRedirect

    ErrorHandling.apply(async (req: express.Request, res: express.Response): Promise<void> => {
      const form: Form<AcceptCourtOffer> = req.body

      if (form.hasErrors()) {
        renderView(form, res)
      } else {
        const draft: Draft<DraftClaimantResponse> = res.locals.claimantResponseDraft

        draft.document.acceptCourtOffer = form.model

        const { externalId } = req.params

        if (form.model.accept.option === YesNoOption.YES.option) {
          draft.document.settlementAgreement = undefined
          draft.document.formaliseRepaymentPlan = undefined
          draft.document.courtDetermination.rejectionReason = undefined

          await saveAndRedirect(res, draft, ClaimantsResponsePaths.taskListPage.evaluateUri({ externalId: externalId }))
        } else {
          await saveAndRedirect(res, draft, ClaimantsResponsePaths.rejectionReasonPage.evaluateUri({ externalId: externalId }))
        }
      }
    }
开发者ID:hmcts,项目名称:cmc-citizen-frontend,代码行数:23,代码来源:court-offered-instalments.ts

示例3: DraftService

    ErrorHandling.apply(async (req: express.Request, res: express.Response, next: express.NextFunction): Promise<void> => {
      const form: Form<AlreadyPaid> = req.body

      if (form.hasErrors()) {
        renderView(form, res)
      } else {
        const draft: Draft<ResponseDraft> = res.locals.responseDraft
        const user: User = res.locals.user

        draft.document.partialAdmission.alreadyPaid = form.model
        draft.document.fullAdmission = draft.document.rejectAllOfClaim = undefined

        if (draft.document.partialAdmission.alreadyPaid.option === YesNoOption.YES) {
          draft.document.partialAdmission.howMuchDoYouOwe = undefined
        } else {
          draft.document.partialAdmission.howMuchHaveYouPaid = undefined
        }

        await new DraftService().save(draft, user.bearerToken)

        const { externalId } = req.params
        res.redirect(Paths.taskListPage.evaluateUri({ externalId: externalId }))
      }
    }))
开发者ID:hmcts,项目名称:cmc-citizen-frontend,代码行数:24,代码来源:already-paid.ts

示例4: DraftService

    ErrorHandling.apply(async (req: express.Request, res: express.Response, next: express.NextFunction): Promise<void> => {
      const form: Form<CanWeUse> = req.body

      if (form.hasErrors()) {
        renderView(form, res)
      } else {
        const claim: Claim = res.locals.claim
        const draft: Draft<MediationDraft> = res.locals.mediationDraft
        const user: User = res.locals.user

        draft.document.canWeUse = form.model

        if (form.model.option === FreeMediationOption.YES) {
          draft.document.canWeUse.mediationPhoneNumber = undefined
        }
        await new DraftService().save(draft, user.bearerToken)

        if (!claim.isResponseSubmitted()) {
          res.redirect(ResponsePaths.taskListPage.evaluateUri({ externalId: claim.externalId }))
        } else {
          res.redirect(ClaimantResponsePaths.taskListPage.evaluateUri({ externalId: claim.externalId }))
        }
      }
    })
开发者ID:hmcts,项目名称:cmc-citizen-frontend,代码行数:24,代码来源:can-we-use.ts

示例5: DraftService

    ErrorHandling.apply(async (req: express.Request, res: express.Response, next: express.NextFunction): Promise<void> => {
      const form: Form<InterestContinueClaiming> = req.body

      if (form.hasErrors()) {
        renderView(form, res)
      } else {
        const draft: Draft<DraftClaim> = res.locals.claimDraft
        const user: User = res.locals.user

        draft.document.interestContinueClaiming = form.model

        if (form.model.option === YesNoOption.NO) {
          draft.document.interestHowMuch = undefined
        }

        await new DraftService().save(draft, user.bearerToken)

        if (form.model.option === YesNoOption.NO) {
          res.redirect(Paths.totalPage.uri)
        } else {
          res.redirect(Paths.interestHowMuchPage.uri)
        }
      }
    }))
开发者ID:hmcts,项目名称:cmc-citizen-frontend,代码行数:24,代码来源:interest-continue-claiming.ts

示例6: ValidationError

    ErrorHandling.apply(async (req: express.Request, res: express.Response, next: express.NextFunction) => {
      const form: Form<HowMuchOwed> = req.body
      const claim: Claim = res.locals.claim
      const user: User = res.locals.user

      if (form.model.amount > claim.totalAmountTillToday) {
        let totalAmount: string = NumberFormatter.formatMoney(claim.totalAmountTillToday)
        let error = new ValidationError()
        error.property = 'amount'
        error.constraints = { amount: 'Enter a valid amount between ÂŁ1 and ' + totalAmount }
        form.errors.push(new FormValidationError(error))
      }

      if (form.hasErrors()) {
        await renderView(form, res, next)
      } else {
        const draft: Draft<ResponseDraft> = res.locals.responseDraft

        draft.document.howMuchOwed = form.model
        await new DraftService().save(draft, user.bearerToken)

        res.redirect(Paths.timelinePage.evaluateUri({ externalId: claim.externalId }))
      }
    })
开发者ID:hmcts,项目名称:cmc-citizen-frontend,代码行数:24,代码来源:how-much-owed.ts

示例7: DraftService

    ErrorHandling.apply(async (req: express.Request, res: express.Response, next: express.NextFunction) => {
      const form: Form<InterestDate> = req.body

      if (form.hasErrors()) {
        renderView(form, res)
      } else {
        const draft: Draft<DraftClaim> = res.locals.claimDraft
        const user: User = res.locals.user

        draft.document.interestDate = form.model
        if (form.model.type === InterestDateType.SUBMISSION) {
          draft.document.interestStartDate = undefined
          draft.document.interestEndDate = undefined
        }
        await new DraftService().save(draft, user.bearerToken)

        if (form.model.type === InterestDateType.SUBMISSION) {
          res.redirect(Paths.totalPage.uri)
        } else {
          res.redirect(Paths.interestStartDatePage.uri)
        }

      }
    }))
开发者ID:hmcts,项目名称:cmc-citizen-frontend,代码行数:24,代码来源:interest-date.ts

示例8: DraftService

    ErrorHandling.apply(async (req: express.Request, res: express.Response) => {
      const form: Form<OtherDependants> = 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.otherDependants = form.model

        // skip if any dependants are disabled, or if defendant and partner are both disabled, or if defendant is severely disabled
        const anyDisabledDependants: boolean =
          (draft.document.statementOfMeans.dependantsDisability && draft.document.statementOfMeans.dependantsDisability.option === DependantsDisabilityOption.YES)
          || (draft.document.statementOfMeans.otherDependantsDisability && draft.document.statementOfMeans.otherDependantsDisability.option === OtherDependantsDisabilityOption.YES)
        const defendantIsDisabled: boolean = draft.document.statementOfMeans.disability.option === DisabilityOption.YES
        const partnerIsDisabled: boolean = draft.document.statementOfMeans.cohabiting.option === CohabitingOption.YES
          && draft.document.statementOfMeans.partnerDisability.option === PartnerDisabilityOption.YES
        const defendantIsSeverelyDisabled: boolean = draft.document.statementOfMeans.severeDisability
          && draft.document.statementOfMeans.severeDisability.option === SevereDisabilityOption.YES

        const skipCarerPage: boolean = anyDisabledDependants || (defendantIsDisabled && partnerIsDisabled) || defendantIsSeverelyDisabled

        if (skipCarerPage) {
          draft.document.statementOfMeans.carer = undefined
        }

        await new DraftService().save(draft, user.bearerToken)
        if (skipCarerPage) {
          res.redirect(Paths.employmentPage.evaluateUri({ externalId: externalId }))
        } else {
          res.redirect(Paths.carerPage.evaluateUri({ externalId: externalId }))
        }
      }
    })
开发者ID:hmcts,项目名称:cmc-citizen-frontend,代码行数:36,代码来源:other-dependants.ts

示例9: it

 it('should return value if value associated with given field exists', () => {
   const form: Form<any> = new Form({ address: { city: 'London' } })
   expect(form.valueFor('address[city]')).to.equal('London')
 })
开发者ID:hmcts,项目名称:cmc-citizen-frontend,代码行数:4,代码来源:form.ts

示例10: renderView

 ErrorHandling.apply(async (req: express.Request, res: express.Response): Promise<void> => {
   renderView(Form.empty<ClaimReference>(), res)
 })
开发者ID:hmcts,项目名称:cmc-citizen-frontend,代码行数:3,代码来源:enter-claim-number.ts


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