Skip to content

Commit

Permalink
Merge pull request #9 from Sanji-IO/hotfix/tag-selector
Browse files Browse the repository at this point in the history
fix(tag-selector): display error as users change devices
  • Loading branch information
zack9433 authored Jul 2, 2018
2 parents 98940bb + d040970 commit 8ec369a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 2 additions & 0 deletions src/component/tag-selector/tag-list.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export default class TagListController {
}

$onInit() {
this.tagId = 0; // To prevent display error as users change devices, each tag need a unique id.
this.types = this.devices
.map(device => device.equipmentType)
.filter((type, idx, self) => self.indexOf(type) === idx);
Expand All @@ -27,6 +28,7 @@ export default class TagListController {
equipments.forEach(equip => {
// reset status
equip.equipmentTags.forEach(tag => {
tag.Id = this.tagId = this.tagId + 1;
tag.logOnChange = false;
tag.isSelected = false;
tag.logDescription = false;
Expand Down
6 changes: 3 additions & 3 deletions src/component/tag-selector/tag-list.tpl.html
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ <h2 translate="TAG_SELECTOR_DIALOG_UPLOAD_EDIT_DIALOG_TITLE"></h2>
<th md-column>
<span translate="TAG_SELECTOR_DIALOG_TABLE_DESCRIPTION"></span>
<md-switch class="md-primary" ng-model="$ctrl.table[$ctrl.selectedDevice.equipmentName].selectedAllLogDescription" ng-change="$ctrl.toggleAllLogDescription($ctrl.selectedDevice, $ctrl.table[$ctrl.selectedDevice.equipmentName].selectedAllLogDescription)"
aria-label="toggle all log description"></md-switch>
aria-label="toggle all log description"></md-switch>
</th>
<th md-column>
<span translate="TAG_SELECTOR_DIALOG_TABLE_LOG_UNIT"></span>
Expand All @@ -63,7 +63,7 @@ <h2 translate="TAG_SELECTOR_DIALOG_UPLOAD_EDIT_DIALOG_TITLE"></h2>
</tr>
</thead>
<tbody md-body>
<tr md-row md-auto-select md-on-select="$ctrl.changeSelectedItem()" md-on-deselect="$ctrl.changeSelectedItem()" md-select="tag" md-select-id="name" ng-repeat="tag in $ctrl.tags | orderBy: $ctrl.table[$ctrl.selectedDevice.equipmentName].query.order | limitTo: $ctrl.table[$ctrl.selectedDevice.equipmentName].query.limit : ($ctrl.table[$ctrl.selectedDevice.equipmentName].query.page - 1) * $ctrl.table[$ctrl.selectedDevice.equipmentName].query.limit track by tag.name">
<tr md-row md-auto-select md-on-select="$ctrl.changeSelectedItem()" md-on-deselect="$ctrl.changeSelectedItem()" md-select="tag" md-select-id="tagId" ng-repeat="tag in $ctrl.tags | orderBy: $ctrl.table[$ctrl.selectedDevice.equipmentName].query.order | limitTo: $ctrl.table[$ctrl.selectedDevice.equipmentName].query.limit : ($ctrl.table[$ctrl.selectedDevice.equipmentName].query.page - 1) * $ctrl.table[$ctrl.selectedDevice.equipmentName].query.limit track by tag.name">
<td md-cell>{{tag.name}}</td>
<td md-cell>
<md-switch class="md-primary" ng-model="tag.logOnChange" ng-click="$ctrl.stopPropagation($event)" aria-label="log on change switcher"></md-switch>
Expand All @@ -84,7 +84,7 @@ <h2 translate="TAG_SELECTOR_DIALOG_UPLOAD_EDIT_DIALOG_TITLE"></h2>
md-total="{{$ctrl.tags.length}}" md-boundary-links md-page-select></md-table-pagination>
</div>

<div layout layout-align="space-between center">
<div layout layout-align="space-between center">
<span layout layout-align="start center" style="font-size: 16px;">
{{'TAG_SELECTOR_DIALOG_ITEM_SELECTED_TOTAL' | translate}}: {{$ctrl.selectedTags.length}}
</span>
Expand Down

0 comments on commit 8ec369a

Please sign in to comment.