-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(Description) adding new example for new FieldInteractionAPI func…
…tionality
- Loading branch information
John Sullivan
committed
Jul 28, 2022
1 parent
b5f69ba
commit 480b688
Showing
7 changed files
with
69 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
...ects/novo-examples/src/utils/field-interactions/fi-description/fi-description-example.css
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/** No CSS for this example */ |
11 changes: 11 additions & 0 deletions
11
...cts/novo-examples/src/utils/field-interactions/fi-description/fi-description-example.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<novo-form [form]="form" layout="vertical"> | ||
<div class="novo-form-row"> | ||
<novo-control [form]="form" [control]="controls.descriptionControl"></novo-control> | ||
</div> | ||
<div class="novo-form-row"> | ||
<novo-control [form]="form" [control]="controls.toggleControl"></novo-control> | ||
</div> | ||
</novo-form> | ||
<div class="final-value">Form Value - {{ form.value | json }}</div> | ||
<div class="final-value">Form Dirty - {{ form.dirty | json }}</div> | ||
<div class="final-value">Is Form Valid? - {{ form.valid | json }}</div> |
46 changes: 46 additions & 0 deletions
46
projects/novo-examples/src/utils/field-interactions/fi-description/fi-description-example.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import { Component } from '@angular/core'; | ||
// Vendor | ||
import { CheckboxControl, FieldInteractionApi, FormUtils, TextBoxControl } from 'novo-elements'; | ||
|
||
/** | ||
* @title Fi Required Example | ||
*/ | ||
@Component({ | ||
selector: 'fi-required-example', | ||
templateUrl: 'fi-description-example.html', | ||
styleUrls: ['fi-description-example.css'], | ||
}) | ||
export class FiDescriptionExample { | ||
public form: any = {}; | ||
public controls: any = {}; | ||
|
||
constructor(formUtils: FormUtils) { | ||
const standardDescription = 'Toggle the checkbox below to toggle between an HTML description and a plain text description!'; | ||
const htmlDescription = '<span><b>BOLD</b> description with a <a target="_blank" href="https://www.google.com">Google</a> Link</span>'; | ||
|
||
const descriptionFunction = (API: FieldInteractionApi) => { | ||
console.log('[FieldInteractionDemo] - descriptionFunction'); // tslint:disable-line | ||
const activeValue = API.getActiveValue(); | ||
|
||
if (activeValue) { | ||
API.setDescription('description', htmlDescription); | ||
} else { | ||
API.setDescription('description', standardDescription); | ||
} | ||
}; | ||
|
||
// Required Field Interactions | ||
this.controls.descriptionControl = new TextBoxControl({ | ||
type: 'text', | ||
key: 'description', | ||
label: 'Test', | ||
description: standardDescription, | ||
}); | ||
this.controls.toggleControl = new CheckboxControl({ | ||
key: 'toggle', | ||
label: 'Description has HTML?', | ||
interactions: [{ event: 'change', script: descriptionFunction }], | ||
}); | ||
this.form = formUtils.toFormGroup([this.controls.descriptionControl, this.controls.toggleControl]); | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
projects/novo-examples/src/utils/field-interactions/fi-description/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './fi-description-example'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters