-
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: Message when field values are invalid for field or missing fiel…
…d. (#218) When the editor is trying to show a field but the value is not able to be used for the field it will show a message that the value is not editable in the editor UI. When a field type is not recognized and `Unknown` field will be used that shows a message that the field type needs to be updated. fixes #154 fixes #94
- Loading branch information
Showing
16 changed files
with
219 additions
and
32 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
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 |
---|---|---|
@@ -1,6 +1,28 @@ | ||
.selective | ||
margin: $le-space-medium | ||
|
||
.selective__error, | ||
.selective__info, | ||
.selective__warning | ||
align-items: center | ||
column-gap: $le-space-medium | ||
line-height: $le-line-height-paragraph | ||
display: flex | ||
flex-flow: row | ||
padding: $le-space-medium | ||
|
||
.selective__error | ||
border: $le-border-size-medium dashed var(--color-error) | ||
color: var(--color-error) | ||
|
||
.selective__info | ||
border: $le-border-size-medium dashed var(--color-info) | ||
color: var(--color-info) | ||
|
||
.selective__warning | ||
border: $le-border-size-medium dashed var(--color-warning) | ||
color: var(--color-warning) | ||
|
||
@import './field' | ||
@import './fields' | ||
@import './mixins' |
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,2 @@ | ||
.selective__field__type__unknown | ||
line-height: $le-line-height-paragraph |
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,8 @@ | ||
.le__info | ||
align-items: center | ||
border: $le-border-size-medium dashed var(--color-info) | ||
color: var(--color-info) | ||
column-gap: $le-space-medium | ||
display: flex | ||
flex-flow: row | ||
padding: $le-space-medium |
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,8 @@ | ||
.le__warning | ||
align-items: center | ||
border: $le-border-size-medium dashed var(--color-warning) | ||
color: var(--color-warning) | ||
column-gap: $le-space-medium | ||
display: flex | ||
flex-flow: row | ||
padding: $le-space-medium |
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
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,58 @@ | ||
import { | ||
DeepObject, | ||
Field, | ||
FieldConfig, | ||
SelectiveEditor, | ||
TemplateResult, | ||
Types, | ||
html, | ||
} from '@blinkk/selective-edit'; | ||
import {LiveEditorGlobalConfig} from '../editor'; | ||
import {templateInfo} from '../template'; | ||
|
||
export type UnknownFieldConfig = FieldConfig; | ||
|
||
export class UnknownField extends Field { | ||
config: UnknownFieldConfig; | ||
|
||
constructor( | ||
types: Types, | ||
config: UnknownFieldConfig, | ||
globalConfig: LiveEditorGlobalConfig, | ||
fieldType = 'unknown' | ||
) { | ||
super(types, config, globalConfig, fieldType); | ||
this.config = config; | ||
} | ||
|
||
/** | ||
* Template for determining how to render the field. | ||
* | ||
* @param editor Selective editor used to render the template. | ||
* @param data Data provided to render the template. | ||
*/ | ||
template(editor: SelectiveEditor, data: DeepObject): TemplateResult { | ||
return this.templateWrapper(editor, data); | ||
} | ||
|
||
/** | ||
* Template for rendering the field structure. | ||
* | ||
* Used for controlling the order that parts of the field are rendered. | ||
* | ||
* @param editor Selective editor used to render the template. | ||
* @param data Data provided to render the template. | ||
*/ | ||
templateInputStructure( | ||
// eslint-disable-next-line @typescript-eslint/no-unused-vars | ||
editor: SelectiveEditor, | ||
// eslint-disable-next-line @typescript-eslint/no-unused-vars | ||
data: DeepObject | ||
): TemplateResult { | ||
return html`<div class="selective__field__input__structure"> | ||
${templateInfo(html`Unable to display this field that is using the | ||
<code>${this.config.type}</code> field type. Please contact the | ||
developer to update the editor configuration to use a valid field type.`)} | ||
</div>`; | ||
} | ||
} |
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
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
Oops, something went wrong.