Commit 3f76ab12fb5dc32f61b2d7ada911dbed9fbe9924
1 parent
fc6e219b
Add further datakey settings: tooltip, text color, min-max range, margins, mandatory
Showing
3 changed files
with
53 additions
and
19 deletions
... | ... | @@ -56,6 +56,7 @@ function MultipleInputWidgetController($q, $scope, attributeService, toast, type |
56 | 56 | vm.datasources = null; |
57 | 57 | |
58 | 58 | vm.cellStyle = cellStyle; |
59 | + vm.textColor = textColor; | |
59 | 60 | vm.discardAll = discardAll; |
60 | 61 | vm.inputChanged = inputChanged; |
61 | 62 | vm.postData = postData; |
... | ... | @@ -82,7 +83,7 @@ function MultipleInputWidgetController($q, $scope, attributeService, toast, type |
82 | 83 | return {}; |
83 | 84 | } |
84 | 85 | |
85 | - function cellStyle(key) { | |
86 | + function cellStyle(key, rowIndex, firstKey, lastKey) { | |
86 | 87 | var style = {}; |
87 | 88 | if (key) { |
88 | 89 | var styleInfo = vm.stylesInfo[key.label]; |
... | ... | @@ -97,6 +98,33 @@ function MultipleInputWidgetController($q, $scope, attributeService, toast, type |
97 | 98 | style = defaultStyle(); |
98 | 99 | } |
99 | 100 | } |
101 | + if (vm.settings.rowMargin) { | |
102 | + if (angular.isUndefined(style.marginTop) && rowIndex != 0) { | |
103 | + style.marginTop = (vm.settings.rowMargin / 2) + 'px'; | |
104 | + } | |
105 | + if (angular.isUndefined(style.marginBottom)) { | |
106 | + style.marginBottom = (vm.settings.rowMargin / 2) + 'px'; | |
107 | + } | |
108 | + } | |
109 | + if (vm.settings.columnMargin) { | |
110 | + if (angular.isUndefined(style.marginLeft) && !firstKey) { | |
111 | + style.marginLeft = (vm.settings.columnMargin / 2) + 'px'; | |
112 | + } | |
113 | + if (angular.isUndefined(style.marginRight) && !lastKey) { | |
114 | + style.marginRight = (vm.settings.columnMargin / 2) + 'px'; | |
115 | + } | |
116 | + } | |
117 | + return style; | |
118 | + } | |
119 | + | |
120 | + function textColor(key) { | |
121 | + var style = {}; | |
122 | + if (key) { | |
123 | + var styleInfo = vm.stylesInfo[key.label]; | |
124 | + if (styleInfo.color) { | |
125 | + style = { color: styleInfo.color }; | |
126 | + } | |
127 | + } | |
100 | 128 | return style; |
101 | 129 | } |
102 | 130 | |
... | ... | @@ -232,7 +260,8 @@ function MultipleInputWidgetController($q, $scope, attributeService, toast, type |
232 | 260 | |
233 | 261 | vm.stylesInfo[dataKey.label] = { |
234 | 262 | useCellStyleFunction: useCellStyleFunction, |
235 | - cellStyleFunction: cellStyleFunction | |
263 | + cellStyleFunction: cellStyleFunction, | |
264 | + color: keySettings.color | |
236 | 265 | }; |
237 | 266 | |
238 | 267 | row.data.push(dataKey); | ... | ... |
... | ... | @@ -15,22 +15,34 @@ |
15 | 15 | limitations under the License. |
16 | 16 | |
17 | 17 | --> |
18 | -<form class="tb-multiple-input" name="multipleInputForm" ng-submit="vm.postData($event)"> | |
18 | +<form class="tb-multiple-input" name="multipleInputForm" ng-submit="vm.postData($event)" novalidate> | |
19 | 19 | <div style="padding: 0 8px; margin: auto 0;"> |
20 | - <div ng-show="vm.entityDetected" layout="row" flex ng-repeat="row in vm.rows track by $index"> | |
21 | - <div layout="column" flex ng-repeat="key in row.data track by $index"> | |
22 | - <md-input-container class="md-icon-float" ng-style="vm.cellStyle(key)"> | |
23 | - <label>{{key.label}}</label> | |
24 | - <md-icon class="material-icons" ng-if="key.settings.icon"> | |
20 | + <div ng-show="vm.entityDetected" layout="row" flex ng-repeat="row in vm.rows" ng-init="rowIndex=$index"> | |
21 | + <div layout="column" flex ng-repeat="key in row.data track by $index" ng-init="keyIndex=$index"> | |
22 | + <md-tooltip class="tb-tooltip-multiline" ng-if="key.settings.tooltipMessage && key.settings.tooltipMessage.length" md-direction="left"> | |
23 | + <span ng-bind-html="key.settings.tooltipMessage"></span> | |
24 | + </md-tooltip> | |
25 | + <md-input-container class="md-block" ng-style="vm.cellStyle(key, rowIndex, $first, $last)"> | |
26 | + <label ng-style="vm.textColor(key)">{{key.label}}</label> | |
27 | + <md-icon ng-style="vm.textColor(key)" class="material-icons" ng-if="key.settings.icon"> | |
25 | 28 | {{key.settings.icon}} |
26 | 29 | </md-icon> |
27 | - <input name="key.name" | |
30 | + <input name="value{{rowIndex}}{{keyIndex}}" | |
31 | + ng-style="vm.textColor(key)" | |
28 | 32 | ng-disabled="key.settings.readOnly" |
29 | 33 | ng-model="key.currentValue" |
34 | + min="{{key.settings.min}}" | |
35 | + max="{{key.settings.max}}" | |
36 | + ng-required="key.settings.required" | |
30 | 37 | type="{{key.settings.inputType}}" |
31 | 38 | step="{{key.settings.step}}" |
32 | 39 | md-select-on-focus |
33 | 40 | ng-change="vm.inputChanged()"> |
41 | + <div ng-messages="multipleInputForm['value' + rowIndex + keyIndex].$error"> | |
42 | + <div ng-message="min">Value must be greater than {{key.settings.min}}</div> | |
43 | + <div ng-message="max">Value must be lower than {{key.settings.max}}</div> | |
44 | + <div ng-message="required">This field is required</div> | |
45 | + </div> | |
34 | 46 | </md-input-container> |
35 | 47 | </div> |
36 | 48 | </div> |
... | ... | @@ -44,12 +56,12 @@ |
44 | 56 | Timeseries parameter cannot be used in this widget |
45 | 57 | </div> |
46 | 58 | </div> |
47 | - <div class="footer md-padding" layout="row" layout-align="end center" ng-show="vm.entityDetected && vm.dataKeyDetected"> | |
59 | + <div class="md-padding" layout="row" layout-align="end center" ng-show="vm.entityDetected && vm.dataKeyDetected"> | |
48 | 60 | <md-button class="md-primary" ng-click="vm.discardAll()" style="max-height: 50px;margin-right:20px;" ng-disabled="!vm.hasAnyChange"> |
49 | - {{ 'action.discard-changes' | translate }} | |
61 | + {{ 'action.undo' | translate }} | |
50 | 62 | </md-button> |
51 | 63 | <md-button class="md-raised md-primary" type="submit" value="Submit" style="max-height: 50px;margin-right:20px;" |
52 | - ng-disabled="!vm.hasAnyChange" ng-click="vm.isFocused = false"> | |
64 | + ng-disabled="!vm.hasAnyChange || multipleInputForm.$invalid" ng-click="vm.isFocused = false"> | |
53 | 65 | {{ 'action.save' | translate }} |
54 | 66 | </md-button> |
55 | 67 | </div> | ... | ... |