Fix validation errors were not visible, improve required css

It looks weird if you use et2_required class instead of setting required attribute.
This commit is contained in:
nathan 2022-07-27 11:33:14 -06:00
parent 38721229b0
commit 93167940f8
7 changed files with 41 additions and 15 deletions

View File

@ -22,6 +22,8 @@ export declare class Et2InputWidgetInterface
readonly : boolean; readonly : boolean;
protected value : string | number | Object; protected value : string | number | Object;
public required : boolean;
public set_value(any) : void; public set_value(any) : void;
public get_value() : any; public get_value() : any;
@ -67,6 +69,7 @@ const Et2InputWidgetMixin = <T extends Constructor<LitElement>>(superclass : T)
.input-group__container > .input-group__input ::slotted(.form-control) { .input-group__container > .input-group__input ::slotted(.form-control) {
width: 100%; width: 100%;
} }
` `
]; ];
} }
@ -171,14 +174,11 @@ const Et2InputWidgetMixin = <T extends Constructor<LitElement>>(superclass : T)
// required changed, add / remove validator // required changed, add / remove validator
if(changedProperties.has('required')) if(changedProperties.has('required'))
{ {
// Remove class
this.classList.remove("et2_required")
// Remove all existing Required validators (avoids duplicates) // Remove all existing Required validators (avoids duplicates)
this.validators = (this.validators || []).filter((validator) => validator instanceof Required) this.validators = (this.validators || []).filter((validator) => validator instanceof Required)
if(this.required) if(this.required)
{ {
this.validators.push(new Required()); this.validators.push(new Required());
this.classList.add("et2_required");
} }
} }
} }

View File

@ -82,6 +82,7 @@
display: flex; display: flex;
align-items: center; align-items: center;
gap: 1em; gap: 1em;
flex-wrap: wrap;
} }
::part(form-control-label) { ::part(form-control-label) {
@ -93,6 +94,11 @@
flex: 1 1 auto; flex: 1 1 auto;
} }
::part(form-control-help-text) {
flex-basis: 100%;
position: relative;
}
/* Use .et2-label-fixed class to give fixed label size */ /* Use .et2-label-fixed class to give fixed label size */
.et2-label-fixed::part(form-control-label) { .et2-label-fixed::part(form-control-label) {
width: initial; width: initial;
@ -1982,7 +1988,7 @@ img.vfsMimeIcon[src*="/etemplate/thumbnail.php"] {
/** /**
* Validation * Validation
*/ */
.et2_required, [required] { .et2_required, .et2_required::part(base), [required]::part(base) {
background-color: #ffffd0; background-color: #ffffd0;
} }
@ -2106,6 +2112,11 @@ div.message.floating, lion-validation-feedback[type] {
left: 0px; left: 0px;
} }
lion-validation-feedback[type] {
top: initial;
margin-top: calc(-0.5 * var(--sl-input-height-medium));
}
.message.validation_error, lion-validation-feedback[type="error"] { .message.validation_error, lion-validation-feedback[type="error"] {
color: var(--error-color); color: var(--error-color);
border-color: var(--error-color); border-color: var(--error-color);

View File

@ -603,7 +603,7 @@
* Validation * Validation
*/ */
.et2_required, .et2_required,
[required] { [required]::part(base) {
background-color: #FFDD73; background-color: #FFDD73;
-webkit-border-top-right-radius: 3px; -webkit-border-top-right-radius: 3px;
-webkit-border-bottom-right-radius: 3px; -webkit-border-bottom-right-radius: 3px;
@ -5590,8 +5590,13 @@ span.overlayContainer img.overlay {
#egw_fw_topmenu_info_items #topmenu_info_quick_add .chzn-container .chzn-results { #egw_fw_topmenu_info_items #topmenu_info_quick_add .chzn-container .chzn-results {
max-height: none; max-height: none;
} }
#egw_fw_topmenu_info_items #topmenu_info_quick_add select#quick_add_selectbox { #egw_fw_topmenu_info_items #topmenu_info_quick_add #quick_add_selectbox {
visibility: hidden; height: 0px;
float: left;
display: inline-block;
}
#egw_fw_topmenu_info_items #topmenu_info_quick_add #quick_add_selectbox::part(form-control-input) {
border: none !important;
} }
#egw_fw_topmenu_info_items img#topmenu_info_error { #egw_fw_topmenu_info_items img#topmenu_info_error {
width: 16px; width: 16px;

View File

@ -583,7 +583,7 @@
* Validation * Validation
*/ */
.et2_required, .et2_required,
[required] { [required]::part(base) {
background-color: #FFDD73; background-color: #FFDD73;
-webkit-border-top-right-radius: 3px; -webkit-border-top-right-radius: 3px;
-webkit-border-bottom-right-radius: 3px; -webkit-border-bottom-right-radius: 3px;
@ -5570,8 +5570,13 @@ span.overlayContainer img.overlay {
#egw_fw_topmenu_info_items #topmenu_info_quick_add .chzn-container .chzn-results { #egw_fw_topmenu_info_items #topmenu_info_quick_add .chzn-container .chzn-results {
max-height: none; max-height: none;
} }
#egw_fw_topmenu_info_items #topmenu_info_quick_add select#quick_add_selectbox { #egw_fw_topmenu_info_items #topmenu_info_quick_add #quick_add_selectbox {
visibility: hidden; height: 0px;
float: left;
display: inline-block;
}
#egw_fw_topmenu_info_items #topmenu_info_quick_add #quick_add_selectbox::part(form-control-input) {
border: none !important;
} }
#egw_fw_topmenu_info_items img#topmenu_info_error { #egw_fw_topmenu_info_items img#topmenu_info_error {
width: 16px; width: 16px;

View File

@ -593,7 +593,7 @@
* Validation * Validation
*/ */
.et2_required, .et2_required,
[required] { [required]::part(base) {
background-color: #FFDD73; background-color: #FFDD73;
-webkit-border-top-right-radius: 3px; -webkit-border-top-right-radius: 3px;
-webkit-border-bottom-right-radius: 3px; -webkit-border-bottom-right-radius: 3px;

View File

@ -437,7 +437,7 @@ div.et2_file input.et2_file_upload{
/** /**
* Validation * Validation
*/ */
.et2_required, [required] { .et2_required, [required]::part(base) {
background-color: @egw_color_1_e; background-color: @egw_color_1_e;
.border_radius (3px, 3px ,3px ,3px ); .border_radius (3px, 3px ,3px ,3px );
} }

View File

@ -614,7 +614,7 @@
* Validation * Validation
*/ */
.et2_required, .et2_required,
[required] { [required]::part(base) {
background-color: #FFDD73; background-color: #FFDD73;
-webkit-border-top-right-radius: 3px; -webkit-border-top-right-radius: 3px;
-webkit-border-bottom-right-radius: 3px; -webkit-border-bottom-right-radius: 3px;
@ -5601,8 +5601,13 @@ span.overlayContainer img.overlay {
#egw_fw_topmenu_info_items #topmenu_info_quick_add .chzn-container .chzn-results { #egw_fw_topmenu_info_items #topmenu_info_quick_add .chzn-container .chzn-results {
max-height: none; max-height: none;
} }
#egw_fw_topmenu_info_items #topmenu_info_quick_add select#quick_add_selectbox { #egw_fw_topmenu_info_items #topmenu_info_quick_add #quick_add_selectbox {
visibility: hidden; height: 0px;
float: left;
display: inline-block;
}
#egw_fw_topmenu_info_items #topmenu_info_quick_add #quick_add_selectbox::part(form-control-input) {
border: none !important;
} }
#egw_fw_topmenu_info_items img#topmenu_info_error { #egw_fw_topmenu_info_items img#topmenu_info_error {
width: 16px; width: 16px;