Skip to content

Commit

Permalink
corrected BlockOperation
Browse files Browse the repository at this point in the history
  • Loading branch information
Standarduser committed Feb 2, 2024
1 parent caa397e commit bc0b43f
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 125 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@ The widgets are designed for VIS 1.x.
Placeholder for the next version (at the beginning of the line):
### **WORK IN PROGRESS**
-->

### **WORK IN PROGRESS**

* (Standarduser) corrected block operation. ATTENTION! You may have to delete and reinsert your widgets, if you used a different Object ID for blocking operation! Of cause only these widgets, where you used this function ;)

### 0.0.7 (2023-12-26)

* (Standarduser) CSS adjustments
Expand Down
133 changes: 16 additions & 117 deletions widgets/vis-homekittiles.html
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@
</div>'
data-vis-attrs="description/custom,vis-homekittiles.infoText,hktRadiobuttons;oid;numberOfButtons[3]/slider,2,10,1;directionHorizontal/checkbox;"
data-vis-attrs0="group.buttons;valueButton_(1-numberOfButtons);labelButton_(1-numberOfButtons)[Button];iconButton_(1-numberOfButtons)/image;"
data-vis-attrs1="group.blockOperation;blockOperationIfTrue/checkbox;blockOperationIfFalse/checkbox;blockOperationShowIcon/checkbox;blockOperationIcon/image;blockOperationIconNotInEditor/checkbox;blockOperationUseDifferentOID/checkbox;blockOperationOID/id;"
data-vis-attrs1="group.blockOperation;blockOperationIfTrue/checkbox;blockOperationIfFalse/checkbox;blockOperationShowIcon/checkbox;blockOperationIcon/image;blockOperationIconNotInEditor/checkbox;blockOperationUseDifferentOID/checkbox;oidBlockOperation/id;"
data-vis-attrs2="group.acknowledge;ackShowIcon/checkbox;ackIcon/image;ackUseSpin/checkbox;ackInvertFunction/checkbox;ackIconNotInEditor/checkbox;"
>
<div class="homekitTiles radiobuttons vis-widget <%== this.data.attr('class') %>" style="width:110px; height:235px;" id="<%= this.data.attr('wid') %>">
Expand Down Expand Up @@ -237,42 +237,8 @@
<span><%= text %></span>

<div class="ackIcon" <%= (el) -> vis.binds['vis-homekittiles'].addAckIcon(el, data) %>></div>

<div class="blockOperation">
<%
var blockOperationIfTrue = this.data.attr('blockOperationIfTrue');
var blockOperationIfFalse = this.data.attr('blockOperationIfFalse');
var blockOperationShowIcon = this.data.attr('blockOperationShowIcon');
var currentState = false;
var showBlockedIcon = false;

//get value for blocked
if (this.data.attr('blockOperationUseDifferentOID')) {
var currentState = vis.states.attr(this.data['blockOperationOID'] + '.val');
} else {
var currentState = vis.states.attr(this.data['oid'] + '.val');
}

//add blocked div
if (blockOperationIfTrue && currentState == true || blockOperationIfFalse && currentState != true) { %>
<div class="blocked" style="width: 100%; height:100%; position: absolute; top: 0; left: 0;">

<%
//add icon
if (blockOperationShowIcon) {
if (vis.editMode && !this.data.attr('blockOperationIconNotInEditor')) {
showBlockedIcon = true;
} else if (!vis.editMode && (blockOperationIfTrue && currentState || blockOperationIfFalse && !currentState)) {
showBlockedIcon = true;
}
if (showBlockedIcon) { %>
<img class="blockedIcon" src="<%= this.data.attr('blockOperationIcon') %>">
<% }
} %>
</div>
<% } %>
</div>
</label>
<div class="blockOperation" <%= (el) -> vis.binds['vis-homekittiles'].addBlockOperation(el, data) %>></div>
</div>
<%

Expand Down Expand Up @@ -304,7 +270,7 @@
data-vis-attrs0="group.labelGroup1;label[Datepicker];"
data-vis-attrs1="group.labelGroup2;label3pre;label3oid/id;label3unit;label3post;label3decimals[1];label3factor[1];label3comma[true]/checkbox;label3tdp/checkbox;label4pre;label4oid/id;label4unit;label4post;label4decimals[1];label4factor[1];label4comma[true]/checkbox;label4tdp/checkbox;label5pre;label5oid/id;label5unit;label5post;label5decimals[1];label5factor[1];label5comma[true]/checkbox;label5tdp/checkbox;"
data-vis-attrs2="group.increment;incrementOid/id;incrementPlusShow/checkbox;incrementMinusShow/checkbox;incrementPlusValue[1];incrementMinusValue[-1];incrementValueMax[100];incrementValueMin[0];incrementShowOnlyIfTrue/checkbox;"
data-vis-attrs3="group.blockOperation;blockOperationIfTrue/checkbox;blockOperationIfFalse/checkbox;blockOperationShowIcon/checkbox;blockOperationIcon/image;blockOperationIconNotInEditor/checkbox;blockOperationUseDifferentOID/checkbox;blockOperationOID/id;"
data-vis-attrs3="group.blockOperation;blockOperationIfTrue/checkbox;blockOperationIfFalse/checkbox;blockOperationShowIcon/checkbox;blockOperationIcon/image;blockOperationIconNotInEditor/checkbox;blockOperationUseDifferentOID/checkbox;oidBlockOperation/id;"
data-vis-attrs4="group.acknowledge;ackShowIcon/checkbox;ackIcon/image;ackUseSpin/checkbox;ackInvertFunction/checkbox;ackIconNotInEditor/checkbox;"
>
<div class="homekitTiles tile datepicker vis-widget <%= this.data.attr('showLikeActive') ? 'state-active' : 'state-default' %> <%== this.data.attr('class') %>" style="width: 110px; height: 110px;" id="<%= this.data.attr('wid') %>">
Expand Down Expand Up @@ -351,7 +317,7 @@
data-vis-attrs0="group.labelGroup1;label[Switch];label2pre;label2oid/id;label2unit;label2post;label2decimals[1];label2factor[1];label2comma[true]/checkbox;label2tdp/checkbox;"
data-vis-attrs1="group.labelGroup2;label3pre;label3oid/id;label3unit;label3post;label3decimals[1];label3factor[1];label3comma[true]/checkbox;label3tdp/checkbox;label4pre;label4oid/id;label4unit;label4post;label4decimals[1];label4factor[1];label4comma[true]/checkbox;label4tdp/checkbox;label5pre;label5oid/id;label5unit;label5post;label5decimals[1];label5factor[1];label5comma[true]/checkbox;label5tdp/checkbox;"
data-vis-attrs2="group.increment;incrementOid/id;incrementPlusShow/checkbox;incrementMinusShow/checkbox;incrementPlusValue[1];incrementMinusValue[-1];incrementValueMax[100];incrementValueMin[0];incrementShowOnlyIfTrue/checkbox;"
data-vis-attrs3="group.blockOperation;blockOperationIfTrue/checkbox;blockOperationIfFalse/checkbox;blockOperationShowIcon/checkbox;blockOperationIcon/image;blockOperationIconNotInEditor/checkbox;blockOperationUseDifferentOID/checkbox;blockOperationOID/id;"
data-vis-attrs3="group.blockOperation;blockOperationIfTrue/checkbox;blockOperationIfFalse/checkbox;blockOperationShowIcon/checkbox;blockOperationIcon/image;blockOperationIconNotInEditor/checkbox;blockOperationUseDifferentOID/checkbox;oidBlockOperation/id;"
data-vis-attrs4="group.acknowledge;ackShowIcon/checkbox;ackIcon/image;ackUseSpin/checkbox;ackInvertFunction/checkbox;ackIconNotInEditor/checkbox;"
>
<div class="homekitTiles tile vis-widget <%= vis.states.attr(this.data['oid'] + '.val') ? 'state-active' : 'state-default' %> <%== this.data.attr('class') %>" style="width:110px; height:110px;" id="<%= this.data.attr('wid') %>">
Expand All @@ -363,41 +329,7 @@

<div class="ackIcon" <%= (el) -> vis.binds['vis-homekittiles'].addAckIcon(el, data) %>></div>
<div class="increment" <%= (el) -> vis.binds['vis-homekittiles'].addIncrement(el, data) %>></div>

<div class="blockOperation">
<%
var blockOperationIfTrue = this.data.attr('blockOperationIfTrue');
var blockOperationIfFalse = this.data.attr('blockOperationIfFalse');
var blockOperationShowIcon = this.data.attr('blockOperationShowIcon');
var currentState = false;
var showBlockedIcon = false;

//get value for blocked
if (this.data.attr('blockOperationUseDifferentOID')) {
var currentState = vis.states.attr(this.data['blockOperationOID'] + '.val');
} else {
var currentState = vis.states.attr(this.data['oid'] + '.val');
}

//add blocked div
if (blockOperationIfTrue && currentState == true || blockOperationIfFalse && currentState != true) { %>
<div class="blocked" style="width: 100%; height:100%; position: absolute; top: 0; left: 0;">

<%
//add icon
if (blockOperationShowIcon) {
if (vis.editMode && !this.data.attr('blockOperationIconNotInEditor')) {
showBlockedIcon = true;
} else if (!vis.editMode && (blockOperationIfTrue && currentState || blockOperationIfFalse && !currentState)) {
showBlockedIcon = true;
}
if (showBlockedIcon) { %>
<img class="blockedIcon" src="<%= this.data.attr('blockOperationIcon') %>">
<% }
} %>
</div>
<% } %>
</div>
<div class="blockOperation" <%= (el) -> vis.binds['vis-homekittiles'].addBlockOperation(el, data) %>></div>
</div>
</script>

Expand Down Expand Up @@ -431,7 +363,8 @@
<div class="ackIcon" <%= (el) -> vis.binds['vis-homekittiles'].addAckIcon(el, data) %>></div>
<div class="increment" <%= (el) -> vis.binds['vis-homekittiles'].addIncrement(el, data) %>></div>

<div class="blockOperation">
<div class="blockOperation" data-oid="<%= this.data.attr('oidBlockOperation') %>">
<span class="blockOperationHelper"><%= vis.states.attr(this.data['oidBlockOperation'] + '.val') %></span>
<%
var blockOperationIfTrue = this.data.attr('blockOperationIfTrue');
var blockOperationIfFalse = this.data.attr('blockOperationIfFalse');
Expand All @@ -441,7 +374,7 @@

//get value for blocked
if (this.data.attr('blockOperationUseDifferentOID')) {
var currentState = vis.states.attr(this.data['blockOperationOID'] + '.val');
var currentState = vis.states.attr(this.data['oidBlockOperation'] + '.val');
} else {
var currentState = vis.states.attr(this.data['oid'] + '.val');
}
Expand Down Expand Up @@ -487,7 +420,7 @@
data-vis-attrs0="group.labelGroup1;label[Dialog];label2pre;label2oid/id;label2unit;label2post;label2decimals[1];label2factor[1];label2comma[true]/checkbox;label2tdp/checkbox;"
data-vis-attrs1="group.labelGroup2;label3pre;label3oid/id;label3unit;label3post;label3decimals[1];label3factor[1];label3comma[true]/checkbox;label3tdp/checkbox;label4pre;label4oid/id;label4unit;label4post;label4decimals[1];label4factor[1];label4comma[true]/checkbox;label4tdp/checkbox;label5pre;label5oid/id;label5unit;label5post;label5decimals[1];label5factor[1];label5comma[true]/checkbox;label5tdp/checkbox;"
data-vis-attrs2="group.increment;incrementOid/id;incrementPlusShow/checkbox;incrementMinusShow/checkbox;incrementPlusValue[1];incrementMinusValue[-1];incrementValueMax[100];incrementValueMin[0];incrementShowOnlyIfTrue/checkbox;"
data-vis-attrs3="group.blockOperation;blockOperationIfTrue/checkbox;blockOperationIfFalse/checkbox;blockOperationShowIcon/checkbox;blockOperationIcon/image;blockOperationIconNotInEditor/checkbox;blockOperationUseDifferentOID/checkbox;blockOperationOID/id;"
data-vis-attrs3="group.blockOperation;blockOperationIfTrue/checkbox;blockOperationIfFalse/checkbox;blockOperationShowIcon/checkbox;blockOperationIcon/image;blockOperationIconNotInEditor/checkbox;blockOperationUseDifferentOID/checkbox;oidBlockOperation/id;"
data-vis-attrs4="group.dialog;contains_view/views;title;autoclose/slider,0,30000,100;modal/checkbox;dialog_width;dialog_height;dialog_top;dialog_left;overflowX/nselect,,visible,hidden,scroll,auto,initial,inherit;overflowY/nselect,,visible,hidden,scroll,auto,initial,inherit;arrowDirection/nselect,,top,right,bottom,left;setIdOnOpenClose/id;setValueOnOpen;setValueOnClose;"
>
<div class="homekitTiles tile dialog vis-widget <%= this.data.attr('showLikeActive') ? 'state-active' : 'state-default' %> <%== this.data.attr('class') %>" style="width: 110px; height: 110px;" id="<%= this.data.attr('wid') %>">
Expand All @@ -503,41 +436,7 @@
</div>

<div class="increment" <%= (el) -> vis.binds['vis-homekittiles'].addIncrement(el, data) %>></div>

<div class="blockOperation">
<%
var blockOperationIfTrue = this.data.attr('blockOperationIfTrue');
var blockOperationIfFalse = this.data.attr('blockOperationIfFalse');
var blockOperationShowIcon = this.data.attr('blockOperationShowIcon');
var currentState = false;
var showBlockedIcon = false;

//get value for blocked
if (this.data.attr('blockOperationUseDifferentOID')) {
var currentState = vis.states.attr(this.data['blockOperationOID'] + '.val');
} else {
var currentState = vis.states.attr(this.data['oid'] + '.val');
}

//add blocked div
if (blockOperationIfTrue && currentState == true || blockOperationIfFalse && currentState != true) { %>
<div class="blocked" style="width: 100%; height:100%; position: absolute; top: 0; left: 0;">

<%
//add icon
if (blockOperationShowIcon) {
if (vis.editMode && !this.data.attr('blockOperationIconNotInEditor')) {
showBlockedIcon = true;
} else if (!vis.editMode && (blockOperationIfTrue && currentState || blockOperationIfFalse && !currentState)) {
showBlockedIcon = true;
}
if (showBlockedIcon) { %>
<img class="blockedIcon" src="<%= this.data.attr('blockOperationIcon') %>">
<% }
} %>
</div>
<% } %>
</div>
<div class="blockOperation" <%= (el) -> vis.binds['vis-homekittiles'].addBlockOperation(el, data) %>></div>

<div class="popup-helper" <%= (el) -> vis.binds['vis-homekittiles'].dialogContainer(el, data) %> />
<div class="popup-helper" <%= (el) -> vis.binds.jqueryui.dialogAutoClose(el, data.attr('autoclose')) %> />
Expand All @@ -560,7 +459,7 @@
</div>
</div>'
data-vis-attrs="description/custom,vis-homekittiles.infoText,hktSettingsBool;oid/id;label[Switch];"
data-vis-attrs0="group.blockOperation;blockOperationIfTrue/checkbox;blockOperationIfFalse/checkbox;blockOperationShowIcon/checkbox;blockOperationIcon/image;blockOperationIconNotInEditor/checkbox;blockOperationUseDifferentOID/checkbox;blockOperationOID/id;"
data-vis-attrs0="group.blockOperation;blockOperationIfTrue/checkbox;blockOperationIfFalse/checkbox;blockOperationShowIcon/checkbox;blockOperationIcon/image;blockOperationIconNotInEditor/checkbox;blockOperationUseDifferentOID/checkbox;oidBlockOperation/id;"
>
<div class="homekitTiles settings bool vis-widget <%= vis.states.attr(this.data['oid'] + '.val') ? 'state-active' : 'state-default' %> <%== this.data.attr('class') %>" style="width:230px; height:17px;" id="<%= this.data.attr('wid') %>">

Expand All @@ -569,7 +468,7 @@
<div class="toggle"></div>
</div>

<div class="invisible-helper" data-oid="<%= this.data.attr('blockOperationOID') %>"></div>
<div class="invisible-helper" data-oid="<%= this.data.attr('oidBlockOperation') %>"></div>
<%
var blockOperationIfTrue = this.data.attr('blockOperationIfTrue');
var blockOperationIfFalse = this.data.attr('blockOperationIfFalse');
Expand All @@ -579,7 +478,7 @@

//get value for blocked
if (this.data.attr('blockOperationUseDifferentOID')) {
var currentState = vis.states.attr(this.data['blockOperationOID'] + '.val');
var currentState = vis.states.attr(this.data['oidBlockOperation'] + '.val');
} else {
var currentState = vis.states.attr(this.data['oid'] + '.val');
}
Expand Down Expand Up @@ -622,7 +521,7 @@
</div>'
data-vis-attrs="description/custom,vis-homekittiles.infoText,hktSettingsValue;oid/id;label[Value];unit;"
data-vis-attrs0="group.increment;incrementPlusShow[true]/checkbox;incrementMinusShow[true]/checkbox;incrementPlusValue[1];incrementMinusValue[-1];incrementValueMax[100];incrementValueMin[0];"
data-vis-attrs1="group.blockOperation;blockOperationIfTrue/checkbox;blockOperationIfFalse/checkbox;blockOperationShowIcon/checkbox;blockOperationIcon/image;blockOperationIconNotInEditor/checkbox;blockOperationUseDifferentOID/checkbox;blockOperationOID/id;"
data-vis-attrs1="group.blockOperation;blockOperationIfTrue/checkbox;blockOperationIfFalse/checkbox;blockOperationShowIcon/checkbox;blockOperationIcon/image;blockOperationIconNotInEditor/checkbox;blockOperationUseDifferentOID/checkbox;oidBlockOperation/id;"
>
<div class="homekitTiles settings value vis-widget <%== this.data.attr('class') %>" style="width:230px; height:17px;" id="<%= this.data.attr('wid') %>">

Expand Down Expand Up @@ -652,7 +551,7 @@
<% } %>
</div>

<div class="invisible-helper" data-oid="<%= this.data.attr('blockOperationOID') %>"></div>
<div class="invisible-helper" data-oid="<%= this.data.attr('oidBlockOperation') %>"></div>
<%
var blockOperationIfTrue = this.data.attr('blockOperationIfTrue');
var blockOperationIfFalse = this.data.attr('blockOperationIfFalse');
Expand All @@ -662,7 +561,7 @@

//get value for blocked
if (this.data.attr('blockOperationUseDifferentOID')) {
var currentState = vis.states.attr(this.data['blockOperationOID'] + '.val');
var currentState = vis.states.attr(this.data['oidBlockOperation'] + '.val');
} else {
var currentState = vis.states.attr(this.data['oid'] + '.val');
}
Expand Down
15 changes: 7 additions & 8 deletions widgets/vis-homekittiles/js/vis-homekittiles.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ $.extend(
"factor": { "en": "Multiplicator", "de": "Multiplikator" },
"comma": { "en": "Comma as separator", "de": "Komma als Trennzeichen" },
"tdp": { "en": "Thousends separator", "de": "Tausendertrennzeichen" },

"numberOfViews": { "en": "Number of views", "de": "Anzahl der Views" },
"numberOfButtons": { "en": "Number of buttons", "de": "Anzahl der Schaltflächen" },
"directionHorizontal": { "en": "Horizontal orientation", "de": "Horizontale Ausrichtung" },
Expand All @@ -32,7 +32,7 @@ $.extend(
"setValueOnClose": { "en": "Value on close", "de": "Wert bei Schließen" },
"arrowDirection": { "en": "Show arrow on dialog", "de": "Pfeil am Dialog anzeigen" },
"dialogWidgetId": { "en": "Dialog widget ID", "de": "Dialog-Widget-ID" },

"label": { "en": "Label", "de": "Beschriftung" },
"label_": { "en": "Label ", "de": "Beschriftung " },

Expand Down Expand Up @@ -76,7 +76,7 @@ $.extend(
"blockOperationIcon": { "en": "Icon if blocked", "de": "Icon wenn gesperrt" },
"blockOperationIconNotInEditor":{ "en": "Don't show icon in editor", "de": "Icon im Editor nicht anzeigen" },
"blockOperationUseDifferentOID":{ "en": "Use different OID", "de": "Verwende andere OID" },
"blockOperationOID": { "en": "OID for block operation", "de": "OID für Bedienung sperren" },
"oidBlockOperation": { "en": "OID for block operation", "de": "OID für Bedienung sperren" },

"group_acknowledge": { "en": "Acknowledged change", "de": "Bestätigte Änderung" },
"ackShowIcon": { "en": "Show icon for ack", "de": "Icon für Bestätigung anzeigen" },
Expand Down Expand Up @@ -759,7 +759,7 @@ vis.binds["vis-homekittiles"] = {
showHideIncrement(true);
});}
},
/* addBlockOperation: function (el, data) {
addBlockOperation: function (el, data) {
var $this = $(el);
var html = '';

Expand All @@ -783,7 +783,7 @@ vis.binds["vis-homekittiles"] = {
//get value for blocked on startup
var currentState = false;
if (data.blockOperationUseDifferentOID) {
currentState = vis.states.attr(data.blockOperationOID + '.val');
currentState = vis.states.attr(data.oidBlockOperation + '.val');
} else {
currentState = vis.states.attr(data.oid + '.val');
}
Expand All @@ -806,13 +806,12 @@ vis.binds["vis-homekittiles"] = {
}

if (data.blockOperationUseDifferentOID) {
vis.states.bind(data.blockOperationOID + '.val', function (e, newVal, oldVal){ updateBlocked(newVal); });
vis.states.bind(data.oidBlockOperation + '.val', function (e, newVal, oldVal){ updateBlocked(newVal); });
} else {
vis.states.bind(data.oid + '.val', function (e, newVal, oldVal){ updateBlocked(newVal); });
}
}
}, */

},
addAckIcon: function (el, data) {
var $this = $(el);
var html = '';
Expand Down

0 comments on commit bc0b43f

Please sign in to comment.