100% open-source IoT Platform - Integrate your devices, add intelligence, build custom apps
Java asset-managementbuildingdashboarddataplatformdevice-managementedge-computingenergyenergy-managementenergy-monitorfleet-managementfleet-telematicsiotiot-applicationiot-platformmodbusmqttmqtt-brokerota-updaterules-enginesmartcity
UI update: Added required option to ValueInputProviderOptions (#738)
Rich Turnerea59f9b0a1b0
diff --git a/ui/component/or-attribute-input/src/index.ts b/ui/component/or-attribute-input/src/index.tsindex 1dbdc6cf8..ee3daa148 100644--- a/ui/component/or-attribute-input/src/index.ts+++ b/ui/component/or-attribute-input/src/index.ts@@ -498,6 +498,9 @@ export class OrAttributeInput extends subscribe(manager)(translate(i18next)(LitE@property({type: Boolean})public readonly?: boolean;+ @property({type: Boolean})+ public required?: boolean;+@property()public value?: any;@@ -611,6 +614,7 @@ export class OrAttributeInput extends subscribe(manager)(translate(i18next)(LitEif (this._templateProvider&& (_changedProperties.has("disabled")|| _changedProperties.has("readonly")+ || _changedProperties.has("required")|| _changedProperties.has("label"))) {this._updateTemplate();}@@ -674,6 +678,7 @@ export class OrAttributeInput extends subscribe(manager)(translate(i18next)(LitEconst options: ValueInputProviderOptions = {readonly: this.isReadonly(),+ required: this.required,disabled: this.disabled,compact: this.compact,label: this.getLabel(),diff --git a/ui/component/or-mwc-components/src/or-mwc-input.ts b/ui/component/or-mwc-components/src/or-mwc-input.tsindex cfdd61b0c..ff31db636 100644--- a/ui/component/or-mwc-components/src/or-mwc-input.ts+++ b/ui/component/or-mwc-components/src/or-mwc-input.ts@@ -129,6 +129,7 @@ export enum InputType {export interface ValueInputProviderOptions {label?: string;+ required?: boolean;readonly?: boolean;disabled?: boolean;compact?: boolean;@@ -332,7 +333,7 @@ export const getValueHolderInputTemplateProvider: ValueInputProviderGenerator =if (patternConstraint) {pattern = patternConstraint.regexp;}- if (notNullConstraint || (valueHolderDescriptor && (valueHolderDescriptor as any).optional === false)) {+ if (notNullConstraint) {required = true;}if (notBlankConstraint && !pattern) {@@ -381,6 +382,7 @@ export const getValueHolderInputTemplateProvider: ValueInputProviderGenerator =const supportsLabel = inputTypeSupportsLabel(inputType);const supportsSendButton = inputTypeSupportsButton(inputType);const readonly = options.readonly;+ required = required || options.readonly;const comfortable = options.comfortable;const resizeVertical = options.resizeVertical;const inputRef: Ref<OrMwcInput> = createRef();