mirror of
https://github.com/EGroupware/egroupware.git
synced 2025-01-01 03:29:05 +01:00
- Deprecate "needed" attribute in favour of standard "required"
- Fix some required CSS
This commit is contained in:
parent
cdcb85f4f3
commit
e048b26235
@ -1,6 +1,6 @@
|
|||||||
import {et2_IInput, et2_IInputNode, et2_ISubmitListener} from "../et2_core_interfaces";
|
import {et2_IInput, et2_IInputNode, et2_ISubmitListener} from "../et2_core_interfaces";
|
||||||
import {Et2Widget} from "../Et2Widget/Et2Widget";
|
import {Et2Widget} from "../Et2Widget/Et2Widget";
|
||||||
import {dedupeMixin, PropertyValues} from "@lion/core";
|
import {css, dedupeMixin, PropertyValues} from "@lion/core";
|
||||||
import {ManualMessage} from "../Validators/ManualMessage";
|
import {ManualMessage} from "../Validators/ManualMessage";
|
||||||
import {Required} from "../Validators/Required";
|
import {Required} from "../Validators/Required";
|
||||||
|
|
||||||
@ -47,7 +47,12 @@ const Et2InputWidgetMixin = (superclass) =>
|
|||||||
static get styles()
|
static get styles()
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
...super.styles
|
super.styles,
|
||||||
|
css`
|
||||||
|
/* Needed so required can show through */
|
||||||
|
::slotted(input), input {
|
||||||
|
background-color: transparent;
|
||||||
|
}`
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -67,11 +72,10 @@ const Et2InputWidgetMixin = (superclass) =>
|
|||||||
type: Boolean
|
type: Boolean
|
||||||
},
|
},
|
||||||
|
|
||||||
needed: {
|
required: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
reflect: true
|
reflect: true
|
||||||
},
|
},
|
||||||
|
|
||||||
onchange: {
|
onchange: {
|
||||||
type: Function
|
type: Function
|
||||||
},
|
},
|
||||||
@ -100,14 +104,13 @@ const Et2InputWidgetMixin = (superclass) =>
|
|||||||
super.updated(changedProperties);
|
super.updated(changedProperties);
|
||||||
|
|
||||||
// Needed changed, add / remove validator
|
// Needed changed, add / remove validator
|
||||||
if(changedProperties.has('needed'))
|
if(changedProperties.has('required'))
|
||||||
{
|
{
|
||||||
// Remove class
|
// Remove class
|
||||||
this.classList.remove("et2_required")
|
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)
|
||||||
this.setAttribute("required", this.needed);
|
if(this.required)
|
||||||
if(this.needed)
|
|
||||||
{
|
{
|
||||||
this.validators.push(new Required());
|
this.validators.push(new Required());
|
||||||
this.classList.add("et2_required");
|
this.classList.add("et2_required");
|
||||||
@ -231,6 +234,7 @@ const Et2InputWidgetMixin = (superclass) =>
|
|||||||
transformAttributes(attrs)
|
transformAttributes(attrs)
|
||||||
{
|
{
|
||||||
super.transformAttributes(attrs);
|
super.transformAttributes(attrs);
|
||||||
|
|
||||||
// Check whether an validation error entry exists
|
// Check whether an validation error entry exists
|
||||||
if(this.id && this.getArrayMgr("validation_errors"))
|
if(this.id && this.getArrayMgr("validation_errors"))
|
||||||
{
|
{
|
||||||
|
@ -19,7 +19,7 @@ export class Et2Textbox extends Et2InputWidget(LionInput)
|
|||||||
static get styles()
|
static get styles()
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
...super.styles,
|
super.styles,
|
||||||
css`
|
css`
|
||||||
:host([type="hidden"]) {
|
:host([type="hidden"]) {
|
||||||
display: none;
|
display: none;
|
||||||
|
@ -1180,8 +1180,15 @@ function transformAttributes(widget, mgr : et2_arrayMgr, attributes)
|
|||||||
// If there is not attribute set, ignore it. Widget sets its own default.
|
// If there is not attribute set, ignore it. Widget sets its own default.
|
||||||
if(typeof attrValue === "undefined")
|
if(typeof attrValue === "undefined")
|
||||||
{
|
{
|
||||||
return;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// "needed" is deprecated, use "required"
|
||||||
|
if(attribute == "needed")
|
||||||
|
{
|
||||||
|
attribute = "required";
|
||||||
|
}
|
||||||
|
|
||||||
const property = widget_class.getPropertyOptions(attribute);
|
const property = widget_class.getPropertyOptions(attribute);
|
||||||
|
|
||||||
switch(typeof property === "object" ? property.type : property)
|
switch(typeof property === "object" ? property.type : property)
|
||||||
|
@ -930,9 +930,9 @@ export class etemplate2
|
|||||||
}
|
}
|
||||||
else if(submit instanceof Promise)
|
else if(submit instanceof Promise)
|
||||||
{
|
{
|
||||||
invalid.push(submit.then(function(sub)
|
invalid.push(submit.then(function(ok)
|
||||||
{
|
{
|
||||||
return sub ? false : this;
|
return ok ? false : this;
|
||||||
}.bind(_widget)));
|
}.bind(_widget)));
|
||||||
}
|
}
|
||||||
}, this, et2_ISubmitListener);
|
}, this, et2_ISubmitListener);
|
||||||
|
Loading…
Reference in New Issue
Block a user