Skip to content

Commit

Permalink
add externals, add link to rules on card page. closes #9
Browse files Browse the repository at this point in the history
  • Loading branch information
seiyria committed Apr 24, 2024
1 parent e5e1fce commit 4bf405e
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
3 changes: 3 additions & 0 deletions interfaces/product.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,7 @@ export interface IProduct extends IProductDefinition {
filters: IProductFilter[];
subproducts: IProductDefinition[];
cardTemplate: string;
external: {
rules: string;
};
}
5 changes: 5 additions & 0 deletions src/app/card/card.page.html
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
10 changes: 8 additions & 2 deletions src/app/meta.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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];
}
}

0 comments on commit 4bf405e

Please sign in to comment.