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


TypeScript FeatureToggles.hasAnyAuthorisedFeature方法代碼示例

本文整理匯總了TypeScript中utils/featureToggles.FeatureToggles.hasAnyAuthorisedFeature方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript FeatureToggles.hasAnyAuthorisedFeature方法的具體用法?TypeScript FeatureToggles.hasAnyAuthorisedFeature怎麽用?TypeScript FeatureToggles.hasAnyAuthorisedFeature使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在utils/featureToggles.FeatureToggles的用法示例。


在下文中一共展示了FeatureToggles.hasAnyAuthorisedFeature方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: renderView

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

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

        draft.document.response = form.model

        if (draft.document.response.type === ResponseType.FULL_ADMISSION) {
          if (!draft.document.fullAdmission) {
            draft.document.fullAdmission = new FullAdmission()
          }
          delete draft.document.partialAdmission
          delete draft.document.freeMediation
        } else if (draft.document.response.type === ResponseType.PART_ADMISSION) {
          if (!draft.document.partialAdmission) {
            draft.document.partialAdmission = new PartialAdmission()
          }
          delete draft.document.fullAdmission
          delete draft.document.rejectAllOfClaim
          delete draft.document.freeMediation
        } else {
          delete draft.document.fullAdmission
          delete draft.document.partialAdmission
          delete draft.document.statementOfMeans
        }

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

        switch (draft.document.response.type) {
          case ResponseType.DEFENCE:
            res.redirect(Paths.defenceRejectAllOfClaimPage.evaluateUri({ externalId: externalId }))
            break

          case ResponseType.PART_ADMISSION:
            if (FeatureToggles.hasAnyAuthorisedFeature(claim.features, 'admissions')) {
              res.redirect(PartAdmissionPaths.alreadyPaidPage.evaluateUri({ externalId: externalId }))
            } else {
              res.redirect(Paths.sendYourResponseByEmailPage.evaluateUri({ externalId: externalId }))
            }
            break

          case ResponseType.FULL_ADMISSION:
            if (FeatureToggles.hasAnyAuthorisedFeature(claim.features, 'admissions')) {
              res.redirect(Paths.taskListPage.evaluateUri({ externalId: claim.externalId }))
            } else {
              res.redirect(Paths.sendYourResponseByEmailPage.evaluateUri({ externalId: externalId }))
            }
            break

          default:
            next(new Error(`Unknown response type: ${draft.document.response.type}`))
        }
      }
    }))
開發者ID:hmcts,項目名稱:cmc-citizen-frontend,代碼行數:60,代碼來源:response-type.ts

示例2: isFeatureEnabledOnClaim

 static isFeatureEnabledOnClaim (claim: Claim, feature: string = 'admissions'): boolean {
   return FeatureToggles.hasAnyAuthorisedFeature(claim.features, feature)
 }
開發者ID:hmcts,項目名稱:cmc-citizen-frontend,代碼行數:3,代碼來源:claimFeatureToggles.ts

示例3:

 (res: express.Response) => FeatureToggles.hasAnyAuthorisedFeature(res.locals.claim.features, feature),
開發者ID:hmcts,項目名稱:cmc-citizen-frontend,代碼行數:1,代碼來源:optInFeatureToggleGuard.ts


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