Skip to content

Commit

Permalink
Merge pull request #414 from Tangerine-Community/disable-specific-com…
Browse files Browse the repository at this point in the history
…ponents-when-form-unlocked

fix(tangy-gps): GPS should not update the values when in Edit modified
  • Loading branch information
esurface authored Jul 19, 2024
2 parents 0d19a6d + 454fc98 commit 2e7d9c9
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 32 deletions.
81 changes: 50 additions & 31 deletions input/tangy-gps.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,44 +88,60 @@ class TangyGps extends TangyInputBase {
}
</style>
<div class="flex-container m-y-25">
<div id="qnum-number"></div>
<div id="qnum-content">
<label id="label"></label>
<div class="coordinates">
<div id="lat-long">
<span class="label">[[t.latitude]]:</span> [[currentLatitude]] <br>
<span class="label">[[t.longitude]]:</span> [[currentLongitude]] <br>
<div id="qnum-number"></div>
<div id="qnum-content">
<label id="label"></label>
<label class="hint-text"></label>
<div class="coordinates">
<template is="dom-if" if="[[!disabled]]">
<div id="lat-long">
<span class="label">[[t.latitude]]:</span> [[currentLatitude]] <br>
<span class="label">[[t.longitude]]:</span> [[currentLongitude]] <br>
</div>
<template is="dom-if" if="[[currentLatitude]]">
<div id="accuracy-distance">
<span class="label">[[t.accuracy]]:</span> [[currentAccuracy]] meters<br>
</div>
<div id="accuracy-level">
<span class="label">[[t.accuracyLevel]]:</span> [[accuracyLevel]]
</div>
</template>
<template is="dom-if" if="[[currentLatitude]]">
<div id="accuracy-distance">
<span class="label">[[t.accuracy]]:</span> [[currentAccuracy]] meters<br>
</div>
<div id="accuracy-level">
<span class="label">[[t.accuracyLevel]]:</span> [[accuracyLevel]]
</div>
</template>
<template is="dom-if" if="{{hasDelta}}">
<br>
<span class="label">[[t.disanceFromReference]]:</span> [[currentDelta]] meters
</template>
</template>
</div>
<template is="dom-if" if="{{hasDelta}}">
<br>
<span class="label">[[t.disanceFromReference]]:</span> [[currentDelta]] meters
</template>
<div>
<template is="dom-if" if="[[!currentLatitude]]">
[[t.searching]]...
</template>
<div class="geofence-message-container">
<div class="geofence-message"> [[geofenceMessage]]</div>
</div>
</div>
<div id="error-text"></div>
<div id="warn-text"></div>
<div id="discrepancy-text"></div>
<div>
<template is="dom-if" if="{{isDisabledAndHAsValue(disabled, value.latitude)}}">
<div id="lat-long">
<span class="label">[[t.latitude]]:</span> [[value.latitude]] <br>
<span class="label">[[t.longitude]]:</span> [[value.longitude]] <br>
</div>
<div>
<template is="dom-if" if="[[!currentLatitude]]">
[[t.searching]]...
</template>
<div class="geofence-message-container">
<div class="geofence-message"> [[geofenceMessage]]</div>
<template is="dom-if" if="[[value.accuracy]]">
<div id="accuracy-distance">
<span class="label">[[t.accuracy]]:</span> [[value.accuracy]] meters<br>
</div>
</div>
<label class="hint-text"></label>
<div id="error-text"></div>
<div id="warn-text"></div>
<div id="discrepancy-text"></div>
</div>
</template>
</div>
</div>
</div>
</div>
`;
}

Expand Down Expand Up @@ -421,6 +437,9 @@ class TangyGps extends TangyInputBase {
_deg2rad(deg) {
return deg * (Math.PI/180)
}
isDisabledAndHAsValue(disabled, value){
return disabled && value
}
}

window.customElements.define(TangyGps.is, TangyGps);
2 changes: 1 addition & 1 deletion tangy-form-reducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ const tangyFormReducer = function (state = initialState, action) {
const inputMeta = itemMeta.inputs.find(inputMeta => inputMeta.name === input.name)
if(action.meta.disableComponents && action.meta.disableComponents.length > 0){
inputMeta.disabled = action.meta.disableComponents.find(e => e.toLowerCase() === input.tagName.toLowerCase())
inputMeta.readOnly = true
inputMeta.readOnly = inputMeta.disabled
}
return Object.assign({}, input, {disabled: inputMeta ? !!inputMeta.disabled : false, readOnly: inputMeta.readOnly})
})
Expand Down

0 comments on commit 2e7d9c9

Please sign in to comment.