myio-js-library 0.1.204 → 0.1.206

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/index.cjs CHANGED
@@ -25829,9 +25829,12 @@ var AnnotationsTab = class {
25829
25829
  attachEventListeners() {
25830
25830
  const openModalBtn = this.container.querySelector("#open-new-annotation-modal");
25831
25831
  if (openModalBtn) {
25832
- openModalBtn.onclick = () => {
25832
+ openModalBtn.addEventListener("click", (e) => {
25833
+ e.preventDefault();
25834
+ e.stopPropagation();
25835
+ console.log("[AnnotationsTab] Create button clicked");
25833
25836
  this.showNewAnnotationModal();
25834
- };
25837
+ });
25835
25838
  } else {
25836
25839
  console.warn("[AnnotationsTab] Create button not found");
25837
25840
  }
@@ -42313,24 +42316,25 @@ var ContractDevicesModalView = class {
42313
42316
  <h4>Energia</h4>
42314
42317
  </div>
42315
42318
  <div class="domain-fields">
42316
- <div class="field-group">
42319
+ <div class="field-group field-total">
42317
42320
  <label for="energy_total">Total Contratado</label>
42318
- <input type="number" id="energy_total" name="energy_total" min="0" step="1" placeholder="0">
42321
+ <input type="number" id="energy_total" name="energy_total" min="0" step="1" placeholder="0" readonly class="input-readonly">
42319
42322
  <small class="field-key">${DEVICE_COUNT_KEYS.energy.total}</small>
42323
+ <small class="field-hint">Soma automatica</small>
42320
42324
  </div>
42321
42325
  <div class="field-group">
42322
42326
  <label for="energy_entries">Entradas</label>
42323
- <input type="number" id="energy_entries" name="energy_entries" min="0" step="1" placeholder="0">
42327
+ <input type="number" id="energy_entries" name="energy_entries" min="0" step="1" placeholder="0" data-domain="energy">
42324
42328
  <small class="field-key">${DEVICE_COUNT_KEYS.energy.entries}</small>
42325
42329
  </div>
42326
42330
  <div class="field-group">
42327
42331
  <label for="energy_commonArea">Area Comum</label>
42328
- <input type="number" id="energy_commonArea" name="energy_commonArea" min="0" step="1" placeholder="0">
42332
+ <input type="number" id="energy_commonArea" name="energy_commonArea" min="0" step="1" placeholder="0" data-domain="energy">
42329
42333
  <small class="field-key">${DEVICE_COUNT_KEYS.energy.commonArea}</small>
42330
42334
  </div>
42331
42335
  <div class="field-group">
42332
42336
  <label for="energy_stores">Lojas</label>
42333
- <input type="number" id="energy_stores" name="energy_stores" min="0" step="1" placeholder="0">
42337
+ <input type="number" id="energy_stores" name="energy_stores" min="0" step="1" placeholder="0" data-domain="energy">
42334
42338
  <small class="field-key">${DEVICE_COUNT_KEYS.energy.stores}</small>
42335
42339
  </div>
42336
42340
  </div>
@@ -42343,24 +42347,25 @@ var ContractDevicesModalView = class {
42343
42347
  <h4>Agua</h4>
42344
42348
  </div>
42345
42349
  <div class="domain-fields">
42346
- <div class="field-group">
42350
+ <div class="field-group field-total">
42347
42351
  <label for="water_total">Total Contratado</label>
42348
- <input type="number" id="water_total" name="water_total" min="0" step="1" placeholder="0">
42352
+ <input type="number" id="water_total" name="water_total" min="0" step="1" placeholder="0" readonly class="input-readonly">
42349
42353
  <small class="field-key">${DEVICE_COUNT_KEYS.water.total}</small>
42354
+ <small class="field-hint">Soma automatica</small>
42350
42355
  </div>
42351
42356
  <div class="field-group">
42352
42357
  <label for="water_entries">Entradas</label>
42353
- <input type="number" id="water_entries" name="water_entries" min="0" step="1" placeholder="0">
42358
+ <input type="number" id="water_entries" name="water_entries" min="0" step="1" placeholder="0" data-domain="water">
42354
42359
  <small class="field-key">${DEVICE_COUNT_KEYS.water.entries}</small>
42355
42360
  </div>
42356
42361
  <div class="field-group">
42357
42362
  <label for="water_commonArea">Area Comum</label>
42358
- <input type="number" id="water_commonArea" name="water_commonArea" min="0" step="1" placeholder="0">
42363
+ <input type="number" id="water_commonArea" name="water_commonArea" min="0" step="1" placeholder="0" data-domain="water">
42359
42364
  <small class="field-key">${DEVICE_COUNT_KEYS.water.commonArea}</small>
42360
42365
  </div>
42361
42366
  <div class="field-group">
42362
42367
  <label for="water_stores">Lojas</label>
42363
- <input type="number" id="water_stores" name="water_stores" min="0" step="1" placeholder="0">
42368
+ <input type="number" id="water_stores" name="water_stores" min="0" step="1" placeholder="0" data-domain="water">
42364
42369
  <small class="field-key">${DEVICE_COUNT_KEYS.water.stores}</small>
42365
42370
  </div>
42366
42371
  </div>
@@ -42373,19 +42378,20 @@ var ContractDevicesModalView = class {
42373
42378
  <h4>Temperatura</h4>
42374
42379
  </div>
42375
42380
  <div class="domain-fields">
42376
- <div class="field-group">
42381
+ <div class="field-group field-total">
42377
42382
  <label for="temperature_total">Total Contratado</label>
42378
- <input type="number" id="temperature_total" name="temperature_total" min="0" step="1" placeholder="0">
42383
+ <input type="number" id="temperature_total" name="temperature_total" min="0" step="1" placeholder="0" readonly class="input-readonly">
42379
42384
  <small class="field-key">${DEVICE_COUNT_KEYS.temperature.total}</small>
42385
+ <small class="field-hint">Soma automatica</small>
42380
42386
  </div>
42381
42387
  <div class="field-group">
42382
42388
  <label for="temperature_internal">Sensores Internos</label>
42383
- <input type="number" id="temperature_internal" name="temperature_internal" min="0" step="1" placeholder="0">
42389
+ <input type="number" id="temperature_internal" name="temperature_internal" min="0" step="1" placeholder="0" data-domain="temperature">
42384
42390
  <small class="field-key">${DEVICE_COUNT_KEYS.temperature.internal}</small>
42385
42391
  </div>
42386
42392
  <div class="field-group">
42387
- <label for="temperature_stores">Lojas</label>
42388
- <input type="number" id="temperature_stores" name="temperature_stores" min="0" step="1" placeholder="0">
42393
+ <label for="temperature_stores">Sensores Externos</label>
42394
+ <input type="number" id="temperature_stores" name="temperature_stores" min="0" step="1" placeholder="0" data-domain="temperature">
42389
42395
  <small class="field-key">${DEVICE_COUNT_KEYS.temperature.stores}</small>
42390
42396
  </div>
42391
42397
  </div>
@@ -42584,6 +42590,26 @@ var ContractDevicesModalView = class {
42584
42590
  font-family: 'Courier New', monospace;
42585
42591
  }
42586
42592
 
42593
+ .myio-contract-devices-modal .field-hint {
42594
+ font-size: 10px;
42595
+ color: #6c757d;
42596
+ font-style: italic;
42597
+ }
42598
+
42599
+ .myio-contract-devices-modal .input-readonly {
42600
+ background: #f0f0f0;
42601
+ color: #555;
42602
+ cursor: not-allowed;
42603
+ font-weight: 600;
42604
+ }
42605
+
42606
+ .myio-contract-devices-modal .field-total {
42607
+ background: #f8f9fa;
42608
+ padding: 10px;
42609
+ border-radius: 6px;
42610
+ margin-bottom: 4px;
42611
+ }
42612
+
42587
42613
  .myio-contract-devices-modal .modal-footer {
42588
42614
  padding: 16px 24px;
42589
42615
  border-top: 1px solid #e0e0e0;
@@ -42662,22 +42688,22 @@ var ContractDevicesModalView = class {
42662
42688
  }
42663
42689
  };
42664
42690
  if (data.energy) {
42665
- setValue("energy_total", data.energy.total);
42666
42691
  setValue("energy_entries", data.energy.entries);
42667
42692
  setValue("energy_commonArea", data.energy.commonArea);
42668
42693
  setValue("energy_stores", data.energy.stores);
42669
42694
  }
42670
42695
  if (data.water) {
42671
- setValue("water_total", data.water.total);
42672
42696
  setValue("water_entries", data.water.entries);
42673
42697
  setValue("water_commonArea", data.water.commonArea);
42674
42698
  setValue("water_stores", data.water.stores);
42675
42699
  }
42676
42700
  if (data.temperature) {
42677
- setValue("temperature_total", data.temperature.total);
42678
42701
  setValue("temperature_internal", data.temperature.internal);
42679
42702
  setValue("temperature_stores", data.temperature.stores);
42680
42703
  }
42704
+ this.calculateDomainTotal("energy");
42705
+ this.calculateDomainTotal("water");
42706
+ this.calculateDomainTotal("temperature");
42681
42707
  }
42682
42708
  attachEventListeners() {
42683
42709
  const closeBtn = this.modal.querySelector(".close-btn");
@@ -42709,6 +42735,50 @@ var ContractDevicesModalView = class {
42709
42735
  this.config.onClose();
42710
42736
  }
42711
42737
  });
42738
+ this.setupAutoCalculation();
42739
+ }
42740
+ setupAutoCalculation() {
42741
+ const energyFields = ["energy_entries", "energy_commonArea", "energy_stores"];
42742
+ energyFields.forEach((fieldName) => {
42743
+ const input = this.form.querySelector(`[name="${fieldName}"]`);
42744
+ if (input) {
42745
+ input.addEventListener("input", () => this.calculateDomainTotal("energy"));
42746
+ }
42747
+ });
42748
+ const waterFields = ["water_entries", "water_commonArea", "water_stores"];
42749
+ waterFields.forEach((fieldName) => {
42750
+ const input = this.form.querySelector(`[name="${fieldName}"]`);
42751
+ if (input) {
42752
+ input.addEventListener("input", () => this.calculateDomainTotal("water"));
42753
+ }
42754
+ });
42755
+ const temperatureFields = ["temperature_internal", "temperature_stores"];
42756
+ temperatureFields.forEach((fieldName) => {
42757
+ const input = this.form.querySelector(`[name="${fieldName}"]`);
42758
+ if (input) {
42759
+ input.addEventListener("input", () => this.calculateDomainTotal("temperature"));
42760
+ }
42761
+ });
42762
+ }
42763
+ calculateDomainTotal(domain) {
42764
+ const getValue = (name) => {
42765
+ const input = this.form.querySelector(`[name="${name}"]`);
42766
+ if (!input || input.value === "") return 0;
42767
+ const num = parseInt(input.value, 10);
42768
+ return isNaN(num) ? 0 : num;
42769
+ };
42770
+ let total = 0;
42771
+ if (domain === "energy") {
42772
+ total = getValue("energy_entries") + getValue("energy_commonArea") + getValue("energy_stores");
42773
+ } else if (domain === "water") {
42774
+ total = getValue("water_entries") + getValue("water_commonArea") + getValue("water_stores");
42775
+ } else if (domain === "temperature") {
42776
+ total = getValue("temperature_internal") + getValue("temperature_stores");
42777
+ }
42778
+ const totalInput = this.form.querySelector(`[name="${domain}_total"]`);
42779
+ if (totalInput) {
42780
+ totalInput.value = String(total);
42781
+ }
42712
42782
  }
42713
42783
  setupAccessibility() {
42714
42784
  const firstInput = this.modal.querySelector("input");
package/dist/index.js CHANGED
@@ -25657,9 +25657,12 @@ var AnnotationsTab = class {
25657
25657
  attachEventListeners() {
25658
25658
  const openModalBtn = this.container.querySelector("#open-new-annotation-modal");
25659
25659
  if (openModalBtn) {
25660
- openModalBtn.onclick = () => {
25660
+ openModalBtn.addEventListener("click", (e) => {
25661
+ e.preventDefault();
25662
+ e.stopPropagation();
25663
+ console.log("[AnnotationsTab] Create button clicked");
25661
25664
  this.showNewAnnotationModal();
25662
- };
25665
+ });
25663
25666
  } else {
25664
25667
  console.warn("[AnnotationsTab] Create button not found");
25665
25668
  }
@@ -42141,24 +42144,25 @@ var ContractDevicesModalView = class {
42141
42144
  <h4>Energia</h4>
42142
42145
  </div>
42143
42146
  <div class="domain-fields">
42144
- <div class="field-group">
42147
+ <div class="field-group field-total">
42145
42148
  <label for="energy_total">Total Contratado</label>
42146
- <input type="number" id="energy_total" name="energy_total" min="0" step="1" placeholder="0">
42149
+ <input type="number" id="energy_total" name="energy_total" min="0" step="1" placeholder="0" readonly class="input-readonly">
42147
42150
  <small class="field-key">${DEVICE_COUNT_KEYS.energy.total}</small>
42151
+ <small class="field-hint">Soma automatica</small>
42148
42152
  </div>
42149
42153
  <div class="field-group">
42150
42154
  <label for="energy_entries">Entradas</label>
42151
- <input type="number" id="energy_entries" name="energy_entries" min="0" step="1" placeholder="0">
42155
+ <input type="number" id="energy_entries" name="energy_entries" min="0" step="1" placeholder="0" data-domain="energy">
42152
42156
  <small class="field-key">${DEVICE_COUNT_KEYS.energy.entries}</small>
42153
42157
  </div>
42154
42158
  <div class="field-group">
42155
42159
  <label for="energy_commonArea">Area Comum</label>
42156
- <input type="number" id="energy_commonArea" name="energy_commonArea" min="0" step="1" placeholder="0">
42160
+ <input type="number" id="energy_commonArea" name="energy_commonArea" min="0" step="1" placeholder="0" data-domain="energy">
42157
42161
  <small class="field-key">${DEVICE_COUNT_KEYS.energy.commonArea}</small>
42158
42162
  </div>
42159
42163
  <div class="field-group">
42160
42164
  <label for="energy_stores">Lojas</label>
42161
- <input type="number" id="energy_stores" name="energy_stores" min="0" step="1" placeholder="0">
42165
+ <input type="number" id="energy_stores" name="energy_stores" min="0" step="1" placeholder="0" data-domain="energy">
42162
42166
  <small class="field-key">${DEVICE_COUNT_KEYS.energy.stores}</small>
42163
42167
  </div>
42164
42168
  </div>
@@ -42171,24 +42175,25 @@ var ContractDevicesModalView = class {
42171
42175
  <h4>Agua</h4>
42172
42176
  </div>
42173
42177
  <div class="domain-fields">
42174
- <div class="field-group">
42178
+ <div class="field-group field-total">
42175
42179
  <label for="water_total">Total Contratado</label>
42176
- <input type="number" id="water_total" name="water_total" min="0" step="1" placeholder="0">
42180
+ <input type="number" id="water_total" name="water_total" min="0" step="1" placeholder="0" readonly class="input-readonly">
42177
42181
  <small class="field-key">${DEVICE_COUNT_KEYS.water.total}</small>
42182
+ <small class="field-hint">Soma automatica</small>
42178
42183
  </div>
42179
42184
  <div class="field-group">
42180
42185
  <label for="water_entries">Entradas</label>
42181
- <input type="number" id="water_entries" name="water_entries" min="0" step="1" placeholder="0">
42186
+ <input type="number" id="water_entries" name="water_entries" min="0" step="1" placeholder="0" data-domain="water">
42182
42187
  <small class="field-key">${DEVICE_COUNT_KEYS.water.entries}</small>
42183
42188
  </div>
42184
42189
  <div class="field-group">
42185
42190
  <label for="water_commonArea">Area Comum</label>
42186
- <input type="number" id="water_commonArea" name="water_commonArea" min="0" step="1" placeholder="0">
42191
+ <input type="number" id="water_commonArea" name="water_commonArea" min="0" step="1" placeholder="0" data-domain="water">
42187
42192
  <small class="field-key">${DEVICE_COUNT_KEYS.water.commonArea}</small>
42188
42193
  </div>
42189
42194
  <div class="field-group">
42190
42195
  <label for="water_stores">Lojas</label>
42191
- <input type="number" id="water_stores" name="water_stores" min="0" step="1" placeholder="0">
42196
+ <input type="number" id="water_stores" name="water_stores" min="0" step="1" placeholder="0" data-domain="water">
42192
42197
  <small class="field-key">${DEVICE_COUNT_KEYS.water.stores}</small>
42193
42198
  </div>
42194
42199
  </div>
@@ -42201,19 +42206,20 @@ var ContractDevicesModalView = class {
42201
42206
  <h4>Temperatura</h4>
42202
42207
  </div>
42203
42208
  <div class="domain-fields">
42204
- <div class="field-group">
42209
+ <div class="field-group field-total">
42205
42210
  <label for="temperature_total">Total Contratado</label>
42206
- <input type="number" id="temperature_total" name="temperature_total" min="0" step="1" placeholder="0">
42211
+ <input type="number" id="temperature_total" name="temperature_total" min="0" step="1" placeholder="0" readonly class="input-readonly">
42207
42212
  <small class="field-key">${DEVICE_COUNT_KEYS.temperature.total}</small>
42213
+ <small class="field-hint">Soma automatica</small>
42208
42214
  </div>
42209
42215
  <div class="field-group">
42210
42216
  <label for="temperature_internal">Sensores Internos</label>
42211
- <input type="number" id="temperature_internal" name="temperature_internal" min="0" step="1" placeholder="0">
42217
+ <input type="number" id="temperature_internal" name="temperature_internal" min="0" step="1" placeholder="0" data-domain="temperature">
42212
42218
  <small class="field-key">${DEVICE_COUNT_KEYS.temperature.internal}</small>
42213
42219
  </div>
42214
42220
  <div class="field-group">
42215
- <label for="temperature_stores">Lojas</label>
42216
- <input type="number" id="temperature_stores" name="temperature_stores" min="0" step="1" placeholder="0">
42221
+ <label for="temperature_stores">Sensores Externos</label>
42222
+ <input type="number" id="temperature_stores" name="temperature_stores" min="0" step="1" placeholder="0" data-domain="temperature">
42217
42223
  <small class="field-key">${DEVICE_COUNT_KEYS.temperature.stores}</small>
42218
42224
  </div>
42219
42225
  </div>
@@ -42412,6 +42418,26 @@ var ContractDevicesModalView = class {
42412
42418
  font-family: 'Courier New', monospace;
42413
42419
  }
42414
42420
 
42421
+ .myio-contract-devices-modal .field-hint {
42422
+ font-size: 10px;
42423
+ color: #6c757d;
42424
+ font-style: italic;
42425
+ }
42426
+
42427
+ .myio-contract-devices-modal .input-readonly {
42428
+ background: #f0f0f0;
42429
+ color: #555;
42430
+ cursor: not-allowed;
42431
+ font-weight: 600;
42432
+ }
42433
+
42434
+ .myio-contract-devices-modal .field-total {
42435
+ background: #f8f9fa;
42436
+ padding: 10px;
42437
+ border-radius: 6px;
42438
+ margin-bottom: 4px;
42439
+ }
42440
+
42415
42441
  .myio-contract-devices-modal .modal-footer {
42416
42442
  padding: 16px 24px;
42417
42443
  border-top: 1px solid #e0e0e0;
@@ -42490,22 +42516,22 @@ var ContractDevicesModalView = class {
42490
42516
  }
42491
42517
  };
42492
42518
  if (data.energy) {
42493
- setValue("energy_total", data.energy.total);
42494
42519
  setValue("energy_entries", data.energy.entries);
42495
42520
  setValue("energy_commonArea", data.energy.commonArea);
42496
42521
  setValue("energy_stores", data.energy.stores);
42497
42522
  }
42498
42523
  if (data.water) {
42499
- setValue("water_total", data.water.total);
42500
42524
  setValue("water_entries", data.water.entries);
42501
42525
  setValue("water_commonArea", data.water.commonArea);
42502
42526
  setValue("water_stores", data.water.stores);
42503
42527
  }
42504
42528
  if (data.temperature) {
42505
- setValue("temperature_total", data.temperature.total);
42506
42529
  setValue("temperature_internal", data.temperature.internal);
42507
42530
  setValue("temperature_stores", data.temperature.stores);
42508
42531
  }
42532
+ this.calculateDomainTotal("energy");
42533
+ this.calculateDomainTotal("water");
42534
+ this.calculateDomainTotal("temperature");
42509
42535
  }
42510
42536
  attachEventListeners() {
42511
42537
  const closeBtn = this.modal.querySelector(".close-btn");
@@ -42537,6 +42563,50 @@ var ContractDevicesModalView = class {
42537
42563
  this.config.onClose();
42538
42564
  }
42539
42565
  });
42566
+ this.setupAutoCalculation();
42567
+ }
42568
+ setupAutoCalculation() {
42569
+ const energyFields = ["energy_entries", "energy_commonArea", "energy_stores"];
42570
+ energyFields.forEach((fieldName) => {
42571
+ const input = this.form.querySelector(`[name="${fieldName}"]`);
42572
+ if (input) {
42573
+ input.addEventListener("input", () => this.calculateDomainTotal("energy"));
42574
+ }
42575
+ });
42576
+ const waterFields = ["water_entries", "water_commonArea", "water_stores"];
42577
+ waterFields.forEach((fieldName) => {
42578
+ const input = this.form.querySelector(`[name="${fieldName}"]`);
42579
+ if (input) {
42580
+ input.addEventListener("input", () => this.calculateDomainTotal("water"));
42581
+ }
42582
+ });
42583
+ const temperatureFields = ["temperature_internal", "temperature_stores"];
42584
+ temperatureFields.forEach((fieldName) => {
42585
+ const input = this.form.querySelector(`[name="${fieldName}"]`);
42586
+ if (input) {
42587
+ input.addEventListener("input", () => this.calculateDomainTotal("temperature"));
42588
+ }
42589
+ });
42590
+ }
42591
+ calculateDomainTotal(domain) {
42592
+ const getValue = (name) => {
42593
+ const input = this.form.querySelector(`[name="${name}"]`);
42594
+ if (!input || input.value === "") return 0;
42595
+ const num = parseInt(input.value, 10);
42596
+ return isNaN(num) ? 0 : num;
42597
+ };
42598
+ let total = 0;
42599
+ if (domain === "energy") {
42600
+ total = getValue("energy_entries") + getValue("energy_commonArea") + getValue("energy_stores");
42601
+ } else if (domain === "water") {
42602
+ total = getValue("water_entries") + getValue("water_commonArea") + getValue("water_stores");
42603
+ } else if (domain === "temperature") {
42604
+ total = getValue("temperature_internal") + getValue("temperature_stores");
42605
+ }
42606
+ const totalInput = this.form.querySelector(`[name="${domain}_total"]`);
42607
+ if (totalInput) {
42608
+ totalInput.value = String(total);
42609
+ }
42540
42610
  }
42541
42611
  setupAccessibility() {
42542
42612
  const firstInput = this.modal.querySelector("input");
@@ -25471,9 +25471,12 @@
25471
25471
  attachEventListeners() {
25472
25472
  const openModalBtn = this.container.querySelector("#open-new-annotation-modal");
25473
25473
  if (openModalBtn) {
25474
- openModalBtn.onclick = () => {
25474
+ openModalBtn.addEventListener("click", (e) => {
25475
+ e.preventDefault();
25476
+ e.stopPropagation();
25477
+ console.log("[AnnotationsTab] Create button clicked");
25475
25478
  this.showNewAnnotationModal();
25476
- };
25479
+ });
25477
25480
  } else {
25478
25481
  console.warn("[AnnotationsTab] Create button not found");
25479
25482
  }
@@ -41950,24 +41953,25 @@
41950
41953
  <h4>Energia</h4>
41951
41954
  </div>
41952
41955
  <div class="domain-fields">
41953
- <div class="field-group">
41956
+ <div class="field-group field-total">
41954
41957
  <label for="energy_total">Total Contratado</label>
41955
- <input type="number" id="energy_total" name="energy_total" min="0" step="1" placeholder="0">
41958
+ <input type="number" id="energy_total" name="energy_total" min="0" step="1" placeholder="0" readonly class="input-readonly">
41956
41959
  <small class="field-key">${DEVICE_COUNT_KEYS.energy.total}</small>
41960
+ <small class="field-hint">Soma automatica</small>
41957
41961
  </div>
41958
41962
  <div class="field-group">
41959
41963
  <label for="energy_entries">Entradas</label>
41960
- <input type="number" id="energy_entries" name="energy_entries" min="0" step="1" placeholder="0">
41964
+ <input type="number" id="energy_entries" name="energy_entries" min="0" step="1" placeholder="0" data-domain="energy">
41961
41965
  <small class="field-key">${DEVICE_COUNT_KEYS.energy.entries}</small>
41962
41966
  </div>
41963
41967
  <div class="field-group">
41964
41968
  <label for="energy_commonArea">Area Comum</label>
41965
- <input type="number" id="energy_commonArea" name="energy_commonArea" min="0" step="1" placeholder="0">
41969
+ <input type="number" id="energy_commonArea" name="energy_commonArea" min="0" step="1" placeholder="0" data-domain="energy">
41966
41970
  <small class="field-key">${DEVICE_COUNT_KEYS.energy.commonArea}</small>
41967
41971
  </div>
41968
41972
  <div class="field-group">
41969
41973
  <label for="energy_stores">Lojas</label>
41970
- <input type="number" id="energy_stores" name="energy_stores" min="0" step="1" placeholder="0">
41974
+ <input type="number" id="energy_stores" name="energy_stores" min="0" step="1" placeholder="0" data-domain="energy">
41971
41975
  <small class="field-key">${DEVICE_COUNT_KEYS.energy.stores}</small>
41972
41976
  </div>
41973
41977
  </div>
@@ -41980,24 +41984,25 @@
41980
41984
  <h4>Agua</h4>
41981
41985
  </div>
41982
41986
  <div class="domain-fields">
41983
- <div class="field-group">
41987
+ <div class="field-group field-total">
41984
41988
  <label for="water_total">Total Contratado</label>
41985
- <input type="number" id="water_total" name="water_total" min="0" step="1" placeholder="0">
41989
+ <input type="number" id="water_total" name="water_total" min="0" step="1" placeholder="0" readonly class="input-readonly">
41986
41990
  <small class="field-key">${DEVICE_COUNT_KEYS.water.total}</small>
41991
+ <small class="field-hint">Soma automatica</small>
41987
41992
  </div>
41988
41993
  <div class="field-group">
41989
41994
  <label for="water_entries">Entradas</label>
41990
- <input type="number" id="water_entries" name="water_entries" min="0" step="1" placeholder="0">
41995
+ <input type="number" id="water_entries" name="water_entries" min="0" step="1" placeholder="0" data-domain="water">
41991
41996
  <small class="field-key">${DEVICE_COUNT_KEYS.water.entries}</small>
41992
41997
  </div>
41993
41998
  <div class="field-group">
41994
41999
  <label for="water_commonArea">Area Comum</label>
41995
- <input type="number" id="water_commonArea" name="water_commonArea" min="0" step="1" placeholder="0">
42000
+ <input type="number" id="water_commonArea" name="water_commonArea" min="0" step="1" placeholder="0" data-domain="water">
41996
42001
  <small class="field-key">${DEVICE_COUNT_KEYS.water.commonArea}</small>
41997
42002
  </div>
41998
42003
  <div class="field-group">
41999
42004
  <label for="water_stores">Lojas</label>
42000
- <input type="number" id="water_stores" name="water_stores" min="0" step="1" placeholder="0">
42005
+ <input type="number" id="water_stores" name="water_stores" min="0" step="1" placeholder="0" data-domain="water">
42001
42006
  <small class="field-key">${DEVICE_COUNT_KEYS.water.stores}</small>
42002
42007
  </div>
42003
42008
  </div>
@@ -42010,19 +42015,20 @@
42010
42015
  <h4>Temperatura</h4>
42011
42016
  </div>
42012
42017
  <div class="domain-fields">
42013
- <div class="field-group">
42018
+ <div class="field-group field-total">
42014
42019
  <label for="temperature_total">Total Contratado</label>
42015
- <input type="number" id="temperature_total" name="temperature_total" min="0" step="1" placeholder="0">
42020
+ <input type="number" id="temperature_total" name="temperature_total" min="0" step="1" placeholder="0" readonly class="input-readonly">
42016
42021
  <small class="field-key">${DEVICE_COUNT_KEYS.temperature.total}</small>
42022
+ <small class="field-hint">Soma automatica</small>
42017
42023
  </div>
42018
42024
  <div class="field-group">
42019
42025
  <label for="temperature_internal">Sensores Internos</label>
42020
- <input type="number" id="temperature_internal" name="temperature_internal" min="0" step="1" placeholder="0">
42026
+ <input type="number" id="temperature_internal" name="temperature_internal" min="0" step="1" placeholder="0" data-domain="temperature">
42021
42027
  <small class="field-key">${DEVICE_COUNT_KEYS.temperature.internal}</small>
42022
42028
  </div>
42023
42029
  <div class="field-group">
42024
- <label for="temperature_stores">Lojas</label>
42025
- <input type="number" id="temperature_stores" name="temperature_stores" min="0" step="1" placeholder="0">
42030
+ <label for="temperature_stores">Sensores Externos</label>
42031
+ <input type="number" id="temperature_stores" name="temperature_stores" min="0" step="1" placeholder="0" data-domain="temperature">
42026
42032
  <small class="field-key">${DEVICE_COUNT_KEYS.temperature.stores}</small>
42027
42033
  </div>
42028
42034
  </div>
@@ -42221,6 +42227,26 @@
42221
42227
  font-family: 'Courier New', monospace;
42222
42228
  }
42223
42229
 
42230
+ .myio-contract-devices-modal .field-hint {
42231
+ font-size: 10px;
42232
+ color: #6c757d;
42233
+ font-style: italic;
42234
+ }
42235
+
42236
+ .myio-contract-devices-modal .input-readonly {
42237
+ background: #f0f0f0;
42238
+ color: #555;
42239
+ cursor: not-allowed;
42240
+ font-weight: 600;
42241
+ }
42242
+
42243
+ .myio-contract-devices-modal .field-total {
42244
+ background: #f8f9fa;
42245
+ padding: 10px;
42246
+ border-radius: 6px;
42247
+ margin-bottom: 4px;
42248
+ }
42249
+
42224
42250
  .myio-contract-devices-modal .modal-footer {
42225
42251
  padding: 16px 24px;
42226
42252
  border-top: 1px solid #e0e0e0;
@@ -42299,22 +42325,22 @@
42299
42325
  }
42300
42326
  };
42301
42327
  if (data.energy) {
42302
- setValue("energy_total", data.energy.total);
42303
42328
  setValue("energy_entries", data.energy.entries);
42304
42329
  setValue("energy_commonArea", data.energy.commonArea);
42305
42330
  setValue("energy_stores", data.energy.stores);
42306
42331
  }
42307
42332
  if (data.water) {
42308
- setValue("water_total", data.water.total);
42309
42333
  setValue("water_entries", data.water.entries);
42310
42334
  setValue("water_commonArea", data.water.commonArea);
42311
42335
  setValue("water_stores", data.water.stores);
42312
42336
  }
42313
42337
  if (data.temperature) {
42314
- setValue("temperature_total", data.temperature.total);
42315
42338
  setValue("temperature_internal", data.temperature.internal);
42316
42339
  setValue("temperature_stores", data.temperature.stores);
42317
42340
  }
42341
+ this.calculateDomainTotal("energy");
42342
+ this.calculateDomainTotal("water");
42343
+ this.calculateDomainTotal("temperature");
42318
42344
  }
42319
42345
  attachEventListeners() {
42320
42346
  const closeBtn = this.modal.querySelector(".close-btn");
@@ -42346,6 +42372,50 @@
42346
42372
  this.config.onClose();
42347
42373
  }
42348
42374
  });
42375
+ this.setupAutoCalculation();
42376
+ }
42377
+ setupAutoCalculation() {
42378
+ const energyFields = ["energy_entries", "energy_commonArea", "energy_stores"];
42379
+ energyFields.forEach((fieldName) => {
42380
+ const input = this.form.querySelector(`[name="${fieldName}"]`);
42381
+ if (input) {
42382
+ input.addEventListener("input", () => this.calculateDomainTotal("energy"));
42383
+ }
42384
+ });
42385
+ const waterFields = ["water_entries", "water_commonArea", "water_stores"];
42386
+ waterFields.forEach((fieldName) => {
42387
+ const input = this.form.querySelector(`[name="${fieldName}"]`);
42388
+ if (input) {
42389
+ input.addEventListener("input", () => this.calculateDomainTotal("water"));
42390
+ }
42391
+ });
42392
+ const temperatureFields = ["temperature_internal", "temperature_stores"];
42393
+ temperatureFields.forEach((fieldName) => {
42394
+ const input = this.form.querySelector(`[name="${fieldName}"]`);
42395
+ if (input) {
42396
+ input.addEventListener("input", () => this.calculateDomainTotal("temperature"));
42397
+ }
42398
+ });
42399
+ }
42400
+ calculateDomainTotal(domain) {
42401
+ const getValue = (name) => {
42402
+ const input = this.form.querySelector(`[name="${name}"]`);
42403
+ if (!input || input.value === "") return 0;
42404
+ const num = parseInt(input.value, 10);
42405
+ return isNaN(num) ? 0 : num;
42406
+ };
42407
+ let total = 0;
42408
+ if (domain === "energy") {
42409
+ total = getValue("energy_entries") + getValue("energy_commonArea") + getValue("energy_stores");
42410
+ } else if (domain === "water") {
42411
+ total = getValue("water_entries") + getValue("water_commonArea") + getValue("water_stores");
42412
+ } else if (domain === "temperature") {
42413
+ total = getValue("temperature_internal") + getValue("temperature_stores");
42414
+ }
42415
+ const totalInput = this.form.querySelector(`[name="${domain}_total"]`);
42416
+ if (totalInput) {
42417
+ totalInput.value = String(total);
42418
+ }
42349
42419
  }
42350
42420
  setupAccessibility() {
42351
42421
  const firstInput = this.modal.querySelector("input");