當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript form.Form類代碼示例

本文整理匯總了TypeScript中main/app/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<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 }))
        }
      }
    })
開發者ID:hmcts,項目名稱:cmc-citizen-frontend,代碼行數:25,代碼來源:partner.ts

示例2: 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 }))
          }
        }
      }
    })
開發者ID:hmcts,項目名稱:cmc-citizen-frontend,代碼行數:31,代碼來源:will-you-try-mediation.ts

示例3: 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 }))
        }
      }
    }))
開發者ID:hmcts,項目名稱:cmc-citizen-frontend,代碼行數:25,代碼來源:court-offered-set-date.ts

示例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))
            }
          }))
開發者ID:hmcts,項目名稱:cmc-citizen-frontend,代碼行數:14,代碼來源:payment-option.ts

示例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 }))
            }
          }))
開發者ID:hmcts,項目名稱:cmc-citizen-frontend,代碼行數:15,代碼來源:paid-amount.ts

示例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))
          }
        }))
開發者ID:hmcts,項目名稱:cmc-citizen-frontend,代碼行數:15,代碼來源:free-mediation.ts

示例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 }))
      }
    }
開發者ID:hmcts,項目名稱:cmc-citizen-frontend,代碼行數:17,代碼來源:sign-settlement-agreement.ts

示例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 }))
      }
    })
開發者ID:hmcts,項目名稱:cmc-citizen-frontend,代碼行數:18,代碼來源:part-payment-received.ts

示例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 }))
      }
    })
開發者ID:hmcts,項目名稱:cmc-citizen-frontend,代碼行數:19,代碼來源:intention-to-proceed.ts

示例10: renderView

 ErrorHandling.apply(async (req: express.Request, res: express.Response) => {
   renderView(Form.empty(), req, res)
 }))
開發者ID:hmcts,項目名稱:cmc-citizen-frontend,代碼行數:3,代碼來源:repayment-plan-summary.ts


注:本文中的main/app/forms/form.Form類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。