From 4bf405e3c4111c70a3ca4d88b21ca9b0ac5478e3 Mon Sep 17 00:00:00 2001 From: Kyle Kemp <kyle@seiyria.com> Date: Wed, 24 Apr 2024 09:45:21 -0500 Subject: [PATCH] add externals, add link to rules on card page. closes #9 --- interfaces/product.ts | 3 +++ src/app/card/card.page.html | 5 +++++ src/app/meta.service.ts | 10 ++++++++-- 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/interfaces/product.ts b/interfaces/product.ts index 12f44e2..10245de 100644 --- a/interfaces/product.ts +++ b/interfaces/product.ts @@ -13,4 +13,7 @@ export interface IProduct extends IProductDefinition { filters: IProductFilter[]; subproducts: IProductDefinition[]; cardTemplate: string; + external: { + rules: string; + }; } diff --git a/src/app/card/card.page.html b/src/app/card/card.page.html index 0d1b214..87c7b7e 100644 --- a/src/app/card/card.page.html +++ b/src/app/card/card.page.html @@ -44,6 +44,11 @@ } </ion-label> </ion-item> + + <ion-item [href]="metaService.getRulesByProductId(cardData.product)" target="_blank"> + <ion-icon slot="start" name="link-outline"></ion-icon> + Rules + </ion-item> </ion-list> </ion-card-content> </ion-card> diff --git a/src/app/meta.service.ts b/src/app/meta.service.ts index b9950e7..ad8f942 100644 --- a/src/app/meta.service.ts +++ b/src/app/meta.service.ts @@ -9,6 +9,7 @@ import { environment } from '../environments/environment'; export class MetaService { private allProducts: IProduct[] = []; private templatesByProductId: Record<string, string> = {}; + private rulesByProductId: Record<string, string> = {}; public get products() { return this.allProducts; @@ -20,16 +21,21 @@ export class MetaService { this.allProducts = realData; - this.loadTemplates(); + this.loadExternals(); } - private loadTemplates() { + private loadExternals() { this.allProducts.forEach((product) => { this.templatesByProductId[product.id] = product.cardTemplate; + this.rulesByProductId[product.id] = product.external.rules; }); } public getTemplateByProductId(productId: string): string { return this.templatesByProductId[productId]; } + + public getRulesByProductId(productId: string): string { + return this.rulesByProductId[productId]; + } }