Skip to content

Commit

Permalink
updated based on comment
Browse files Browse the repository at this point in the history
  • Loading branch information
mohas22 authored and mohas22 committed Nov 4, 2024
1 parent fa947cb commit 0838ff8
Show file tree
Hide file tree
Showing 4 changed files with 91 additions and 80 deletions.
40 changes: 21 additions & 19 deletions src/components/fields/Currency/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,12 @@ class Currency extends FormComponentBase {
// of any component that's a child of BridgeBase with a call to this.prepareForRender();
this.prepareForRender();

// return if not visible
if (!this.bVisible) {
return nothing;
}
// Handle and return if read only rendering
if (this.bReadonly && this.bVisible) {
if (this.bReadonly) {
const theContent = html`
<lion-input-amount
?readonly=${this.bReadonly}
Expand All @@ -124,24 +128,22 @@ class Currency extends FormComponentBase {

// lion-input-amount options as based on Intl.NumberFormat standard
// NOTE: we set modelValue to parseFloat(this.value). This helps validation.
const theContent = html`${this.bVisible
? html` <lion-input-amount
id=${this.theComponentId}
dataTestId=${this.testId}
.modelValue=${parseFloat(this.value)}
.fieldName=${this.label}
.validators=${this.lionValidatorsArray}
.feedbackCondition=${this.requiredFeedbackCondition.bind(this)}
currency=${this.currencyISOCode}
?readonly=${this.bReadonly}
?disabled=${this.bDisabled}
@click=${this.fieldOnChange}
@blur=${this.fieldOnBlur}
@change=${this.fieldOnChange}
>
<span slot="label">${this.annotatedLabel}</span>
</lion-input-amount>`
: nothing}`;
const theContent = html` <lion-input-amount
id=${this.theComponentId}
dataTestId=${this.testId}
.modelValue=${parseFloat(this.value)}
.fieldName=${this.label}
.validators=${this.lionValidatorsArray}
.feedbackCondition=${this.requiredFeedbackCondition.bind(this)}
currency=${this.currencyISOCode}
?readonly=${this.bReadonly}
?disabled=${this.bDisabled}
@click=${this.fieldOnChange}
@blur=${this.fieldOnBlur}
@change=${this.fieldOnChange}
>
<span slot="label">${this.annotatedLabel}</span>
</lion-input-amount>`;

this.renderTemplates.push(theContent);

Expand Down
45 changes: 24 additions & 21 deletions src/components/fields/Decimal/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,13 @@ class Decimal extends FormComponentBase {
// of any component that's a child of BridgeBase with a call to this.prepareForRender();
this.prepareForRender();

// return if not visible
if (!this.bVisible) {
return nothing;
}

// Handle and return if read only rendering
if (this.bReadonly && this.bVisible) {
if (this.bReadonly) {
const theContent = html`
<lion-input-amount
id=${this.theComponentId}
Expand All @@ -83,26 +88,24 @@ class Decimal extends FormComponentBase {

loadDefaultFeedbackMessages();

const theContent = html`${this.bVisible
? html` <div class="form-group">
<lion-input-amount
id=${this.theComponentId}
name="Amount"
dataTestId=${this.testId}
.modelValue=${this.value}
.fieldName=${this.label}
.validators=${this.lionValidatorsArray}
.feedbackCondition=${this.requiredFeedbackCondition.bind(this)}
?readonly=${this.bReadonly}
?disabled=${this.bDisabled}
@click=${this.fieldOnChange}
@blur=${this.fieldOnBlur}
@change=${this.fieldOnChange}
>
<span slot="label">${this.annotatedLabel}</span>
</lion-input-amount>
</div>`
: nothing}`;
const theContent = html` <div class="form-group">
<lion-input-amount
id=${this.theComponentId}
name="Amount"
dataTestId=${this.testId}
.modelValue=${this.value}
.fieldName=${this.label}
.validators=${this.lionValidatorsArray}
.feedbackCondition=${this.requiredFeedbackCondition.bind(this)}
?readonly=${this.bReadonly}
?disabled=${this.bDisabled}
@click=${this.fieldOnChange}
@blur=${this.fieldOnBlur}
@change=${this.fieldOnChange}
>
<span slot="label">${this.annotatedLabel}</span>
</lion-input-amount>
</div>`;

this.renderTemplates.push(theContent);

Expand Down
47 changes: 25 additions & 22 deletions src/components/fields/Integer/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,13 @@ class Integer extends FormComponentBase {
// of any component that's a child of BridgeBase with a call to this.prepareForRender();
this.prepareForRender();

// return if not visible
if (!this.bVisible) {
return nothing;
}

// Handle and return if read only rendering
if (this.bReadonly && this.bVisible) {
if (this.bReadonly) {
const theContent = html`
<lion-input-amount
id=${this.theComponentId}
Expand All @@ -94,27 +99,25 @@ class Integer extends FormComponentBase {

// lion-input-amount options as based on Intl.NumberFormat standard
// NOTE: we set modelValue to parseInt(this.value) to trim any decimal. This helps validation.
const theContent = html`${this.bVisible
? html` <lion-input-amount
id=${this.theComponentId}
dataTestId=${this.testId}
.fieldName=${this.label}
.formatOptions="${{
minimumFractionDigits: 0,
maximumFractionDigits: 0
}}"
.modelValue=${parseInt(this.value, 10)}
.validators=${this.lionValidatorsArray}
.feedbackCondition=${this.requiredFeedbackCondition.bind(this)}
?readonly=${this.bReadonly}
?disabled=${this.bDisabled}
@click=${this.fieldOnChange}
@blur=${this.fieldOnBlur}
@change=${this.fieldOnChange}
>
<span slot="label">${this.annotatedLabel}</span>
</lion-input-amount>`
: nothing}`;
const theContent = html` <lion-input-amount
id=${this.theComponentId}
dataTestId=${this.testId}
.fieldName=${this.label}
.formatOptions="${{
minimumFractionDigits: 0,
maximumFractionDigits: 0
}}"
.modelValue=${parseInt(this.value, 10)}
.validators=${this.lionValidatorsArray}
.feedbackCondition=${this.requiredFeedbackCondition.bind(this)}
?readonly=${this.bReadonly}
?disabled=${this.bDisabled}
@click=${this.fieldOnChange}
@blur=${this.fieldOnBlur}
@change=${this.fieldOnChange}
>
<span slot="label">${this.annotatedLabel}</span>
</lion-input-amount>`;

this.renderTemplates.push(theContent);

Expand Down
39 changes: 21 additions & 18 deletions src/components/fields/Percentage/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,13 @@ class Percentage extends FormComponentBase {
// of any component that's a child of BridgeBase with a call to this.prepareForRender();
this.prepareForRender();

// return if not visible
if (!this.bVisible) {
return nothing;
}

// Handle and return if read only rendering
if (this.bReadonly && this.bVisible) {
if (this.bReadonly) {
const theContent = html`
<lion-input-amount
id=${this.theComponentId}
Expand All @@ -98,23 +103,21 @@ class Percentage extends FormComponentBase {

// lion-input-amount options as based on Intl.NumberFormat standard
// NOTE: we set modelValue to parseFloat(this.value). This helps validation.
const theContent = html`${this.bVisible
? html` <lion-input-amount
id=${this.theComponentId}
dataTestId=${this.testId}
.fieldName=${this.label}
.formatOptions=${{ style: 'percent', minimumFractionDigits: 0, maximumFractionDigits: 4 }}
.modelValue=${parseFloat(this.value)}
.validators=${this.lionValidatorsArray}
.feedbackCondition=${this.requiredFeedbackCondition.bind(this)}
?readonly=${this.bReadonly}
?disabled=${this.bDisabled}
@blur=${this.fieldOnBlur}
@change=${this.fieldOnChange}
>
<span slot="label">${this.annotatedLabel}</span>
</lion-input-amount>`
: nothing}`;
const theContent = html` <lion-input-amount
id=${this.theComponentId}
dataTestId=${this.testId}
.fieldName=${this.label}
.formatOptions=${{ style: 'percent', minimumFractionDigits: 0, maximumFractionDigits: 4 }}
.modelValue=${parseFloat(this.value)}
.validators=${this.lionValidatorsArray}
.feedbackCondition=${this.requiredFeedbackCondition.bind(this)}
?readonly=${this.bReadonly}
?disabled=${this.bDisabled}
@blur=${this.fieldOnBlur}
@change=${this.fieldOnChange}
>
<span slot="label">${this.annotatedLabel}</span>
</lion-input-amount>`;

this.renderTemplates.push(theContent);

Expand Down

0 comments on commit 0838ff8

Please sign in to comment.