-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(uip-bool-setting): implement uip-setting interface
- Loading branch information
Showing
6 changed files
with
52 additions
and
47 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
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,41 @@ | ||
import {UIPSetting} from '../setting'; | ||
import {attr} from "@exadel/esl/modules/esl-base-element/core"; | ||
|
||
export class UIPBoolSetting extends UIPSetting { | ||
public static is = 'uip-bool-setting'; | ||
protected $field: HTMLInputElement; | ||
|
||
@attr({defaultValue: null}) value: string; | ||
@attr({defaultValue: 'replace'}) mode: 'replace' | 'append'; | ||
|
||
protected render() { | ||
this.$field = document.createElement('input'); | ||
this.$field.type = 'checkbox'; | ||
this.$field.name = this.label || ''; | ||
} | ||
|
||
protected getDisplayedValue(): string | boolean { | ||
return this.value ? this.value : this.$field.checked; | ||
} | ||
|
||
protected setValue(value: string | null): void { | ||
if (this.value) { | ||
if (this.mode === 'append') { | ||
this.$field.checked = (value || '').search(new RegExp(/\b/.source + this.value + /\b/.source)) !== -1; | ||
} else { | ||
this.$field.checked = value === this.value; | ||
} | ||
} else { | ||
this.$field.checked = value !== null; | ||
} | ||
} | ||
|
||
protected setInconsistency(): void { | ||
|
||
} | ||
|
||
protected isValid(): boolean { | ||
return true; | ||
} | ||
} | ||
|
This file was deleted.
Oops, something went wrong.
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
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