@openremote/or-asset-viewer 1.2.0 → 1.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/umd/index.js +9 -8
- package/dist/umd/index.orbundle.js +12 -11
- package/lib/index.js +1 -0
- package/lib/index.js.map +1 -1
- package/lib/or-edit-asset-panel.js +13 -13
- package/lib/or-edit-asset-panel.js.map +1 -1
- package/package.json +15 -15
package/dist/umd/index.js
CHANGED
|
@@ -368,7 +368,7 @@
|
|
|
368
368
|
${this.icon?$`<or-icon class="mdc-icon-button__icon" aria-hidden="true" icon="${this.icon}"></or-icon>`:""}
|
|
369
369
|
${this.iconOn?$`<or-icon class="mdc-icon-button__icon mdc-icon-button__icon--on" aria-hidden="true" icon="${this.iconOn}"></or-icon>`:""}
|
|
370
370
|
</button>
|
|
371
|
-
`;case Zi.BUTTON:case Zi.BUTTON_MOMENTARY:{const e=e=>{this.disabled&&e.stopPropagation(),i&&this.dispatchEvent(new Ji(!0,null))},t=e=>{this.disabled&&e.stopPropagation(),i&&this.dispatchEvent(new Ji(!1,!0))},n=e=>{this.disabled&&e.stopPropagation(),i||this.dispatchEvent(new Ji(!0,null))},i=this.type===Zi.BUTTON_MOMENTARY,a=!this.action&&!this.label;
|
|
371
|
+
`;case Zi.BUTTON:case Zi.BUTTON_MOMENTARY:{const e=e=>{this.disabled&&e.stopPropagation(),i&&this.dispatchEvent(new Ji(!0,null))},t=e=>{this.disabled&&e.stopPropagation(),i&&this.dispatchEvent(new Ji(!1,!0))},n=e=>{this.disabled&&e.stopPropagation(),i||this.dispatchEvent(new Ji(!0,null))},i=this.type===Zi.BUTTON_MOMENTARY,a=!this.action&&!this.label;!a||this.iconTrailing||this.icon||(this.icon="circle");const r={"mdc-icon-button":a,"mdc-fab":!a&&this.action,"mdc-fab--extended":!a&&this.action&&!!this.label,"mdc-fab--mini":!a&&this.action&&(this.compact||this.comfortable),"mdc-button":!a&&!this.action,"mdc-button--raised":!a&&!this.action&&this.raised,"mdc-button--unelevated":!a&&!this.action&&this.unElevated,"mdc-button--outlined":!a&&!this.action&&(this.outlined||i),"mdc-button--rounded":!a&&!this.action&&this.rounded,"mdc-button--fullwidth":this.fullWidth};return $`
|
|
372
372
|
<button id="component" class="${Ce(r)}"
|
|
373
373
|
?readonly="${this.readonly}"
|
|
374
374
|
?disabled="${this.disabled}"
|
|
@@ -1356,25 +1356,25 @@
|
|
|
1356
1356
|
<div id="edit-wrapper">
|
|
1357
1357
|
${as("0",{type:"info",title:"properties"},$`${t}`)||""}
|
|
1358
1358
|
${as("1",{type:"info",title:"attribute_plural"},$`${i}`)||""}
|
|
1359
|
-
</div>`}_getAttributeTemplate(e,t){const
|
|
1359
|
+
</div>`}_getAttributeTemplate(e,t){var n;const i=Qa.AssetModelUtil.getAttributeDescriptor(t.name,e),a=!i||i.optional,r=Ye(),o=t.meta?Object.entries(t.meta).sort(gi.Util.sortByString((([e,t])=>e))).map((([e,n])=>this._getMetaItemTemplate(t,gi.Util.getMetaItemNameValueHolder(e,n)))):[],s=t.meta&&(t.meta.hasOwnProperty("momentary")||t.meta.hasOwnProperty("format")&&(null===(n=t.meta.format)||void 0===n?void 0:n.asMomentary));return{template:$`
|
|
1360
1360
|
<tr class="mdc-data-table__row">
|
|
1361
1361
|
<td class="padded-cell mdc-data-table__cell expander-cell"><or-icon icon="chevron-right"></or-icon><span>${t.name}</span></td>
|
|
1362
1362
|
<td class="padded-cell mdc-data-table__cell">${gi.Util.getValueDescriptorLabel(t.type)}</td>
|
|
1363
1363
|
<td class="padded-cell overflow-visible mdc-data-table__cell">
|
|
1364
|
-
<or-attribute-input ${Ae(
|
|
1364
|
+
<or-attribute-input ${Ae(r)}
|
|
1365
1365
|
.comfortable="${!0}" .assetType="${e}" .label=${null}
|
|
1366
|
-
.readonly="${
|
|
1366
|
+
.readonly="${s}" .attribute="${t}" .assetId="${this.asset.id}"
|
|
1367
1367
|
disableWrite disableSubscribe disableButton compact
|
|
1368
1368
|
@or-attribute-input-changed="${e=>this._onAttributeModified(t,e.detail.value)}"></or-attribute-input>
|
|
1369
1369
|
</td>
|
|
1370
|
-
<td class="padded-cell mdc-data-table__cell actions-cell">${
|
|
1370
|
+
<td class="padded-cell mdc-data-table__cell actions-cell">${a?$`<or-mwc-input type="${Zi.BUTTON}" icon="delete" @click="${()=>{delete this.asset.attributes[t.name],this._onModified()}}">`:""}</td>
|
|
1371
1371
|
</tr>
|
|
1372
1372
|
<tr class="attribute-meta-row">
|
|
1373
1373
|
<td colspan="4">
|
|
1374
1374
|
<div class="meta-item-container">
|
|
1375
1375
|
<div>
|
|
1376
1376
|
<div>
|
|
1377
|
-
${
|
|
1377
|
+
${o.map((e=>e.template))}
|
|
1378
1378
|
</div>
|
|
1379
1379
|
<div class="item-add">
|
|
1380
1380
|
<or-mwc-input .type="${Zi.BUTTON}" label="addMetaItems" icon="plus" @or-mwc-input-changed="${()=>this._addMetaItems(t)}"></or-mwc-input>
|
|
@@ -1383,7 +1383,7 @@
|
|
|
1383
1383
|
</div>
|
|
1384
1384
|
</td>
|
|
1385
1385
|
</tr>
|
|
1386
|
-
`,validator:()=>{let e=!1;return
|
|
1386
|
+
`,validator:()=>{let e=!1;return r.value&&(e=r.value.checkValidity()),{name:t.name,valid:e,metaResults:o.map((e=>e.validator()))}}}}_onModified(){this.dispatchEvent(new go(this.validate())),this.requestUpdate()}validate(){return this.attributeTemplatesAndValidators.map((e=>e.validator()))}_onAttributeModified(e,t){const n=this.changedAttributes.indexOf(e.name);n>-1?this.changedAttributes.splice(n,1):(e.value=t,e.timestamp=void 0,this._onModified())}_onMetaItemModified(e,t,n){t.value=n?n.value:void 0,e.meta[t.name]=t.value,this._onModified()}_getMetaItemTemplate(e,t){const n=Qa.AssetModelUtil.getMetaItemDescriptor(t.name),i=n?Qa.AssetModelUtil.getValueDescriptor(n.type):void 0;let a=$``,r=()=>({name:t.name,valid:!0});if(i){const o={label:gi.Util.getMetaLabel(t,n,this.asset.type,!0),resizeVertical:!0},s=((e,t,n,i,a,r)=>{let o,s,d,l,c,m,u,p,h=r.inputType;const f={},_="string"==typeof e?e:e.name,g=(t&&t.meta||i&&i.meta?gi.Util.getAttributeValueConstraints(t,n,_):gi.Util.getMetaValueConstraints(t,n,_))||[],b=t&&t.meta||i&&i.meta?gi.Util.getAttributeValueFormat(t,n,_):gi.Util.getMetaValueFormat(t,n,_);if(!h){switch(i.name){case"text":case"email":case"UUID":case"assetID":case"hostOrIPAddress":case"IPAddress":h=!0===gi.Util.getMetaValue("multiline",t,n)?Zi.TEXTAREA:Zi.TEXT;break;case"boolean":if(b&&b.asNumber){h=Zi.NUMBER,o=1,d=0,l=1,p=e=>!!e;break}h=b&&(b.asOnOff||b.asOpenClosed)?Zi.SWITCH:Zi.CHECKBOX,(b&&b.asMomentary||!0===gi.Util.getMetaValue("momentary",t,n))&&(h=Zi.BUTTON_MOMENTARY);break;case"bigNumber":case"number":case"positiveInteger":case"positiveNumber":case"long":case"integer":case"byte":case"integerByte":case"direction":case"TCP_IPPortNumber":"byte"===i.name||"integerByte"===i.name?(d=0,l=255,o=1):"integer"!==i.name&&"long"!==i.name||(o=1),b&&b.asDate?h=Zi.DATETIME:b&&b.asBoolean?(h=Zi.CHECKBOX,p=e=>e?1:0):h=b&&b.asSlider?Zi.RANGE:Zi.NUMBER;break;case"bigInteger":h=Zi.BIG_INT,o=1;break;case"colourRGB":h=Zi.COLOUR;break;case"dateAndTime":case"timestamp":case"timestampISO8601":h=Zi.DATETIME;break;case"CRONExpression":h=Zi.CRON;break;case"timeDurationISO8601":h=Zi.DURATION_TIME;break;case"periodDurationISO8601":h=Zi.DURATION_PERIOD;break;case"timeAndPeriodDurationISO8601":h=Zi.DURATION;break;case"JSONObject":h=Zi.JSON_OBJECT}i.arrayDimensions&&i.arrayDimensions>0&&(h=Zi.JSON)}if(!h)switch(i.jsonType){case"number":case"bigint":h=Zi.NUMBER;break;case"boolean":h=Zi.CHECKBOX;break;case"string":h=Zi.TEXT;break;case"date":h=Zi.DATETIME}h||(h=Zi.JSON);const y=g&&g.find((e=>"size"===e.type)),v=g&&g.find((e=>"pattern"===e.type)),x=g&&g.find((e=>"min"===e.type)),k=g&&g.find((e=>"max"===e.type)),w=g&&g.find((e=>"allowedValues"===e.type)),M=g&&g.find((e=>"past"===e.type)),L=g&&g.find((e=>"pastOrPresent"===e.type)),T=g&&g.find((e=>"future"===e.type)),E=g&&g.find((e=>"futureOrPresent"===e.type)),Y=g&&g.find((e=>"notEmpty"===e.type)),S=g&&g.find((e=>"notBlank"===e.type)),D=g&&g.find((e=>"notNull"===e.type));if(y&&(d=y.min,l=y.max),y&&(d=y.min,l=y.max),x&&(d=x.min),k&&(l=k.max),v&&(s=v.regexp),D&&(m=!0),S&&!s?s="\\S+":Y&&!s&&(s=".+"),w&&w.allowedValues){const e=w.allowedValueNames&&w.allowedValueNames.length===w.allowedValues.length?w.allowedValueNames:void 0;u=w.allowedValues.map(((t,n)=>{let i=e?e[n]:""+t;return i=gi.Util.getAllowedValueLabel(i),[t,i||""+t]})),h=Zi.SELECT,i.arrayDimensions&&i.arrayDimensions>0&&(c=!0)}h===Zi.DATETIME&&(M||L?(d=void 0,l=new Date):(T||E)&&(d=new Date,l=void 0),b&&(b.timeStyle&&!b.dateStyle?h=Zi.TIME:b.dateStyle&&!b.timeStyle&&(h=Zi.DATE))),h===Zi.NUMBER&&b&&b.resolution&&(o=b.resolution),h===Zi.COLOUR&&(f.marginLeft="24px");const A=ta(h),C=function(e){return ta(e)||e===Zi.CHECKBOX||e===Zi.BUTTON_MOMENTARY}(h),I=ea(h),O=r.readonly;m=m||r.required;const R=r.comfortable,H=r.resizeVertical,N=Ye();return{templateFunction:(e,t,n,i,_,g)=>{const y=r.disabled||n||i,v=C?r.label:void 0;return $`<or-mwc-input ${Ae(N)} id="input" style="${xi(f)}" .type="${h}" .label="${v}" .value="${e}" .pattern="${s}"
|
|
1387
1387
|
.min="${d}" .max="${l}" .format="${b}" .focused="${t}" .required="${m}" .multiple="${c}"
|
|
1388
1388
|
.options="${u}" .comfortable="${R}" .readonly="${O}" .disabled="${y}" .step="${o}"
|
|
1389
1389
|
.helperText="${g}" .helperPersistent="${!0}" .resizeVertical="${H}"
|
|
@@ -1470,7 +1470,7 @@
|
|
|
1470
1470
|
<or-mwc-input type="button" class="mdc-button mdc-snackbar__action" label="${this.buttonText}">
|
|
1471
1471
|
</or-mwc-input>
|
|
1472
1472
|
</div>
|
|
1473
|
-
`:$``}
|
|
1473
|
+
`:$``}
|
|
1474
1474
|
</div>
|
|
1475
1475
|
</div>
|
|
1476
1476
|
`}updated(e){super.updated(e),e.has("_open")&&this._open&&this.open()}onClose(e){this.buttonAction&&this.buttonAction(),this.dispatchChangedEvent({opened:!1,closeReason:e})}onOpen(){this.dispatchChangedEvent({opened:!0})}dispatchChangedEvent(e){this.dispatchEvent(new Bo(e))}};Fo([he({type:String,attribute:!1})],Wo.prototype,"text",void 0),Fo([he({type:String})],Wo.prototype,"buttonText",void 0),Fo([he({type:Object,attribute:!1})],Wo.prototype,"buttonAction",void 0),Fo([he({type:Number})],Wo.prototype,"timeout",void 0),Fo([he({type:Boolean})],Wo.prototype,"_open",void 0),Fo([_e("#mdc-snackbar")],Wo.prototype,"_mdcElem",void 0),Wo=Fo([me("or-mwc-snackbar")],Wo);const Vo=o`
|
|
@@ -1649,6 +1649,7 @@
|
|
|
1649
1649
|
flex: 0;
|
|
1650
1650
|
margin: 0 0 10px 0;
|
|
1651
1651
|
position: unset;
|
|
1652
|
+
z-index: 1;
|
|
1652
1653
|
}
|
|
1653
1654
|
|
|
1654
1655
|
#attribute-picker > or-mwc-input {
|