Skip to content

Commit

Permalink
Merge pull request #2464 from IDEMSInternational/chore/refactor-text-…
Browse files Browse the repository at this point in the history
…component

chore: refactor text component
  • Loading branch information
jfmcquade authored Oct 10, 2024
2 parents d987c2c + 39e7d2e commit 85d0eab
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 38 deletions.
2 changes: 1 addition & 1 deletion src/app/shared/components/template/components/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ import { TmplTaskCardComponent } from "./task-card/task-card.component";
import { TmplTaskProgressBarComponent } from "./task-progress-bar/task-progress-bar.component";
import { TmplTextAreaComponent } from "./text-area/text-area.component";
import { TmplTextBoxComponent } from "./text-box/text-box.component";
import { TmplTextComponent } from "./text";
import { TmplTextComponent } from "./text/text.component";
import { TmplTileComponent } from "./tile-component/tile-component.component";
import { TmplTitleComponent } from "./title";
import { TmplTimerComponent } from "./timer/timer.component";
Expand Down
37 changes: 0 additions & 37 deletions src/app/shared/components/template/components/text.ts

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
@if (this._row.value) {
<div
class="large standard normal margin-t-large"
[class]="params.style"
[ngStyle]="!hasTextValue ? { display: 'none' } : { display: 'block' }"
[innerHTML]="
params.type === 'numbered'
? (this._row.value | number)
: (this._row.value?.toString() | markdown)
"
[style]="_row.style_list | styleList"
[style.textAlign]="params.textAlign"
></div>
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import { Component, OnInit } from "@angular/core";
import { TemplateBaseComponent } from "../base";
import { getStringParamFromTemplateRow } from "../../../../utils";

interface ITextParams {
style: string | null;
textAlign: string | null;
type: string;
}

@Component({
selector: "plh-tmpl-text",
templateUrl: "./text.component.html",
styleUrls: ["../tmpl-components-common.scss"],
})
export class TmplTextComponent extends TemplateBaseComponent implements OnInit {
params: Partial<ITextParams> = {};
hasTextValue: boolean;

constructor() {
super();
}

ngOnInit() {
this.getParams();
}

getParams() {
this.hasTextValue = !["undefined", "NaN", "null", '""'].includes(this._row.value);
this.params.textAlign = getStringParamFromTemplateRow(this._row, "text_align", null);
this.params.type = this._row.parameter_list?.style?.includes("numbered")
? "numbered"
: "marked";
this.params.style = getStringParamFromTemplateRow(this._row, "style", null);
}
}

0 comments on commit 85d0eab

Please sign in to comment.