nice-elements 1.14.0 → 1.15.0
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/CHANGELOG.md +28 -0
- package/CLAUDE.md +89 -0
- package/README.md +3 -1
- package/bower.json +1 -1
- package/dist/nice.js +605 -93
- package/dist/nice.min.js +1 -1
- package/dist/style.css +216 -3
- package/dist/style.css.map +1 -1
- package/dist/style.min.css +2 -2
- package/package.json +2 -2
- package/src/components/nice-alert/nice-alert.scss +5 -0
- package/src/components/nice-badges-list/nice-badges-list.html +13 -0
- package/src/components/nice-badges-list/nice-badges-list.js +135 -0
- package/src/components/nice-badges-list/nice-badges-list.scss +75 -0
- package/src/components/nice-checkbox/nice-checkbox.html +1 -1
- package/src/components/nice-date/nice-date.js +3 -1
- package/src/components/nice-date/nice-date.scss +1 -0
- package/src/components/nice-date-range/nice-date-range.js +7 -7
- package/src/components/nice-datetime-picker/nice-datetime-picker.html +3 -3
- package/src/components/nice-datetime-picker/nice-datetime-picker.js +7 -2
- package/src/components/nice-datetimerange-picker-2/nice-datetimerange-picker-2.html +2 -2
- package/src/components/nice-datetimerange-picker-2/nice-datetimerange-picker-2.scss +1 -0
- package/src/components/nice-dialog/nice-dialog.html +16 -0
- package/src/components/nice-dialog/nice-dialog.js +47 -0
- package/src/components/nice-dialog/nice-dialog.scss +126 -0
- package/src/components/nice-dropdown/nice-dropdown.html +3 -3
- package/src/components/nice-dropdown/nice-dropdown.js +9 -1
- package/src/components/nice-dropdown/nice-dropdown.scss +20 -0
- package/src/components/nice-dropdown-date/nice-dropdown-date.js +3 -1
- package/src/components/nice-input/nice-input.js +12 -8
- package/src/components/nice-input/nice-input.scss +1 -1
- package/src/components/nice-no-data/nice-no-data.js +3 -1
- package/src/components/nice-notification/nice-notification.scss +3 -1
- package/src/components/nice-number/nice-number.html +23 -9
- package/src/components/nice-number/nice-number.js +81 -12
- package/src/components/nice-percent/nice-percent.html +5 -5
- package/src/components/nice-percent/nice-percent.js +5 -3
- package/src/components/nice-popup/nice-popup.js +2 -2
- package/src/components/nice-search/nice-search.html +2 -4
- package/src/components/nice-search/nice-search.js +32 -6
- package/src/components/nice-svgs/nice-svgs.html +165 -20
- package/src/components/nice-table/nice-table.js +9 -4
- package/src/components/nice-toggle/nice-toggle.html +1 -1
- package/src/components/nice-toggle/nice-toggle.scss +15 -1
- package/src/components/nice-upload/nice-upload.html +1 -1
- package/src/components/nice-upload/nice-upload.scss +3 -0
- package/src/components/nice-view/_nice-view.scss +10 -1
- package/src/components/nice-view/nice-view.html +1 -0
- package/src/components/nice-wrapper/nice-wrapper.js +3 -1
- package/src/components/nice-yesno/nice-yesno.js +4 -2
- package/src/services/nice-service.js +16 -1
- package/src/styles/_nice.scss +2 -0
|
@@ -45,16 +45,14 @@ angular.module('niceElements')
|
|
|
45
45
|
autocomplete: "@?",
|
|
46
46
|
disableTrim: "@?"
|
|
47
47
|
},
|
|
48
|
-
controller: function ($scope, $attrs, $rootScope, $element, ngDialog, NiceService) {
|
|
48
|
+
controller: function ($scope, $attrs, $rootScope, $element, $timeout, ngDialog, NiceService) {
|
|
49
49
|
if (!$attrs.type) { $attrs.type = 'text'; }
|
|
50
50
|
if (!$attrs.title) { $attrs.title = ''; }
|
|
51
51
|
if (!$attrs.regex) { $attrs.regex = null; }
|
|
52
52
|
if (!$attrs.placeholder) { $attrs.placeholder = ''; }
|
|
53
|
-
if (!$attrs.minlength) { $attrs.minlength = 1; }
|
|
54
|
-
if (!$attrs.maxlength) { $attrs.maxlength = 100; }
|
|
55
53
|
if (!$attrs.fieldWidth) { $attrs.fieldWidth = 'col-sm-8'; }
|
|
56
54
|
if (!$attrs.labelWidth) { $attrs.labelWidth = 'col-sm-4'; }
|
|
57
|
-
if (!$
|
|
55
|
+
if (!$scope.textAreaLines) { $scope.textAreaLines = 3; }
|
|
58
56
|
if (!$attrs.symbol) { $attrs.symbol = ''; }
|
|
59
57
|
if (!$attrs.help) { $attrs.help = ''; }
|
|
60
58
|
if (!$attrs.name) { $attrs.name = ''; }
|
|
@@ -74,9 +72,12 @@ angular.module('niceElements')
|
|
|
74
72
|
$scope.elementType = "textarea";
|
|
75
73
|
}
|
|
76
74
|
|
|
75
|
+
// Focus after the input (rendered inside ng-if) is in the DOM
|
|
77
76
|
if ($scope.isFocused) {
|
|
78
|
-
|
|
79
|
-
|
|
77
|
+
$timeout(function () {
|
|
78
|
+
const input = $element[0].getElementsByTagName($scope.elementType)[0];
|
|
79
|
+
if (input) input.focus();
|
|
80
|
+
});
|
|
80
81
|
}
|
|
81
82
|
|
|
82
83
|
if ($scope.numbersOnly) {
|
|
@@ -111,8 +112,11 @@ angular.module('niceElements')
|
|
|
111
112
|
$scope.regexexp = new RegExp("^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}$");
|
|
112
113
|
}
|
|
113
114
|
|
|
114
|
-
|
|
115
|
-
|
|
115
|
+
// Link form object with valid object (the form only exists after the template is linked)
|
|
116
|
+
if ($attrs.valid) {
|
|
117
|
+
$scope.$watch('forma', function (form) {
|
|
118
|
+
if (form) $scope.valid = form;
|
|
119
|
+
});
|
|
116
120
|
}
|
|
117
121
|
|
|
118
122
|
if ($scope.model && !$scope.decimalConstructor && angular.isDefined($scope.minDecimalsCutZeros) && $scope.type == 'number') {
|
|
@@ -18,7 +18,9 @@ angular.module('niceElements')
|
|
|
18
18
|
message: '@?',
|
|
19
19
|
fulldiv: '@?'
|
|
20
20
|
},
|
|
21
|
-
controller: function ($scope, gettextCatalog) {
|
|
21
|
+
controller: function ($scope, $attrs, gettextCatalog, NiceService) {
|
|
22
|
+
NiceService.bindFlag($scope, $attrs, 'fulldiv');
|
|
23
|
+
|
|
22
24
|
if ($scope.icon == "" || !$scope.icon) $scope.innerIcon = "icon-alert-circle";
|
|
23
25
|
else $scope.innerIcon = $scope.icon;
|
|
24
26
|
if ($scope.message == "" || !$scope.message) $scope.innerMessage = gettextCatalog.getString("No data");
|
|
@@ -96,7 +96,8 @@
|
|
|
96
96
|
flex: 0 0 auto;
|
|
97
97
|
width: 20px;
|
|
98
98
|
height: 20px;
|
|
99
|
-
margin-right:
|
|
99
|
+
margin-right: 1rem;
|
|
100
|
+
flex-shrink: 0;
|
|
100
101
|
}
|
|
101
102
|
|
|
102
103
|
.notification-content {
|
|
@@ -109,6 +110,7 @@
|
|
|
109
110
|
text-align: left;
|
|
110
111
|
font-size: 1em;
|
|
111
112
|
font-weight: bold;
|
|
113
|
+
margin-bottom: 3px;
|
|
112
114
|
}
|
|
113
115
|
|
|
114
116
|
& a {
|
|
@@ -26,15 +26,29 @@
|
|
|
26
26
|
</button>
|
|
27
27
|
</span>
|
|
28
28
|
|
|
29
|
-
<!-- Value -->
|
|
30
|
-
<input
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
29
|
+
<!-- Value. Two inputs, because Angular picks the input type before {{ }} is evaluated -->
|
|
30
|
+
<input
|
|
31
|
+
ng-if="!decimalMode"
|
|
32
|
+
type="number"
|
|
33
|
+
inputmode="numeric"
|
|
34
|
+
step="{{ step }}"
|
|
35
|
+
ng-change="inputChanged()"
|
|
36
|
+
class="form-control"
|
|
37
|
+
max="{{ max }}"
|
|
38
|
+
min="{{ min }}"
|
|
39
|
+
ng-disabled="isDisabled"
|
|
40
|
+
ng-model="internal.value"
|
|
41
|
+
/>
|
|
42
|
+
|
|
43
|
+
<!-- Value in decimal mode: text input, so "1,5" can be typed -->
|
|
44
|
+
<input
|
|
45
|
+
ng-if="decimalMode"
|
|
46
|
+
type="text"
|
|
47
|
+
inputmode="decimal"
|
|
48
|
+
ng-change="inputChanged()"
|
|
49
|
+
ng-blur="inputBlurred()"
|
|
50
|
+
class="form-control"
|
|
51
|
+
ng-disabled="isDisabled"
|
|
38
52
|
ng-model="internal.value"
|
|
39
53
|
/>
|
|
40
54
|
|
|
@@ -29,6 +29,7 @@ angular.module('niceElements')
|
|
|
29
29
|
noMargin: '@',
|
|
30
30
|
step: '@',
|
|
31
31
|
decimals: '@',
|
|
32
|
+
lang: '@',
|
|
32
33
|
allowNegative: '@',
|
|
33
34
|
floatingError: '@',
|
|
34
35
|
help: '@',
|
|
@@ -36,14 +37,20 @@ angular.module('niceElements')
|
|
|
36
37
|
onChange: '&?'
|
|
37
38
|
},
|
|
38
39
|
|
|
39
|
-
controller: function ($scope, $timeout, NiceService) {
|
|
40
|
+
controller: function ($scope, $attrs, $timeout, NiceService, gettextCatalog) {
|
|
41
|
+
NiceService.bindFlag($scope, $attrs, 'allowNegative');
|
|
42
|
+
NiceService.bindFlag($scope, $attrs, 'hideError');
|
|
43
|
+
NiceService.bindFlag($scope, $attrs, 'floatingError');
|
|
44
|
+
|
|
40
45
|
$scope.canAdd = true;
|
|
41
46
|
$scope.canSubtract = true;
|
|
42
47
|
$scope.preventZero = $scope.preventZero == "true";
|
|
43
48
|
|
|
44
49
|
// Link form object with valid object
|
|
45
|
-
if ($
|
|
46
|
-
$scope
|
|
50
|
+
if ($attrs.valid) {
|
|
51
|
+
$scope.$watch('niceNumberForm', function (form) {
|
|
52
|
+
if (form) $scope.valid = form;
|
|
53
|
+
});
|
|
47
54
|
}
|
|
48
55
|
|
|
49
56
|
// Fix min
|
|
@@ -61,12 +68,22 @@ angular.module('niceElements')
|
|
|
61
68
|
if ($scope.min != 0 && $scope.min != -Infinity) $scope.defaultValue = $scope.min;
|
|
62
69
|
else $scope.defaultValue = 0;
|
|
63
70
|
} else {
|
|
64
|
-
$scope.defaultValue =
|
|
71
|
+
$scope.defaultValue = parseFloat($scope.defaultValue);
|
|
65
72
|
}
|
|
66
73
|
|
|
67
|
-
//
|
|
68
|
-
|
|
69
|
-
|
|
74
|
+
// Decimal mode: when `decimals` is set, the input is a text field so "1.5" and "1,5" can be typed,
|
|
75
|
+
// and values are rounded to `decimals` places. Kept in a local variable, because Angular
|
|
76
|
+
// writes the "@" attribute back to $scope.decimals as a string.
|
|
77
|
+
const decimalPlaces = parseInt($attrs.decimals);
|
|
78
|
+
$scope.decimalMode = !Number.isNaN(decimalPlaces);
|
|
79
|
+
|
|
80
|
+
// Decimal separator of the locale, e.g. "." for "en" and "," for "sl".
|
|
81
|
+
// Uses the `lang` attribute, or the app language from angular-gettext ("sl_SI" -> "sl-SI").
|
|
82
|
+
const lang = ($attrs.lang || gettextCatalog.getCurrentLanguage()).replace("_", "-");
|
|
83
|
+
const decimalSeparator = new Intl.NumberFormat(lang)
|
|
84
|
+
.formatToParts(1.5)
|
|
85
|
+
.find(function (part) { return part.type === "decimal"; })
|
|
86
|
+
.value;
|
|
70
87
|
|
|
71
88
|
// Fix step
|
|
72
89
|
if (!$scope.step) $scope.step = 1;
|
|
@@ -122,6 +139,15 @@ angular.module('niceElements')
|
|
|
122
139
|
$scope.niceNumberForm.$setValidity("zero", null);
|
|
123
140
|
}
|
|
124
141
|
}
|
|
142
|
+
|
|
143
|
+
// Text input has no built-in min/max validation, so decimal mode checks it here
|
|
144
|
+
if ($scope.decimalMode && $scope.niceNumberForm) {
|
|
145
|
+
const value = parseFloat($scope.model);
|
|
146
|
+
const tooSmall = !Number.isNaN(value) && value < $scope.min;
|
|
147
|
+
const tooBig = !Number.isNaN(value) && $scope.max && value > $scope.max;
|
|
148
|
+
$scope.niceNumberForm.$setValidity("min", tooSmall ? false : null);
|
|
149
|
+
$scope.niceNumberForm.$setValidity("max", tooBig ? false : null);
|
|
150
|
+
}
|
|
125
151
|
};
|
|
126
152
|
|
|
127
153
|
|
|
@@ -131,11 +157,35 @@ angular.module('niceElements')
|
|
|
131
157
|
});
|
|
132
158
|
|
|
133
159
|
|
|
134
|
-
//
|
|
160
|
+
// Returns a plain number, rounded to `decimals` places in decimal mode
|
|
161
|
+
const round = function (value) {
|
|
162
|
+
if (value == null) return null;
|
|
163
|
+
if (!$scope.decimalMode) return Number(value);
|
|
164
|
+
return new Decimal(value).toDecimalPlaces(decimalPlaces).toNumber();
|
|
165
|
+
};
|
|
166
|
+
|
|
167
|
+
// Decimal mode: typed text -> number ("1,5" -> 1.5).
|
|
168
|
+
// Returns null for empty text and NaN for text that is not a number.
|
|
169
|
+
const parseText = function (text) {
|
|
170
|
+
const cleaned = (text || "").trim().replace(",", ".");
|
|
171
|
+
if (cleaned === "") return null;
|
|
172
|
+
if (!/^-?(\d+\.?\d*|\.\d+)$/.test(cleaned)) return NaN;
|
|
173
|
+
return parseFloat(cleaned);
|
|
174
|
+
};
|
|
175
|
+
|
|
176
|
+
// Model -> input value. Number input needs a number, decimal mode needs text
|
|
177
|
+
// with the locale separator. Decimal.toFixed() avoids exponent notation (1e-7).
|
|
135
178
|
const toInternal = function (value) {
|
|
179
|
+
if ($scope.decimalMode) return value == null ? "" : new Decimal(value).toFixed().replace(".", decimalSeparator);
|
|
136
180
|
return NiceService.isDecimal(value) ? value.toNumber() : value;
|
|
137
181
|
};
|
|
138
182
|
|
|
183
|
+
// Does the input already show the model value? (In decimal mode "1,50" shows 1.5)
|
|
184
|
+
const isInputInSync = function () {
|
|
185
|
+
if (!$scope.decimalMode) return toInternal($scope.model) === $scope.internal.value;
|
|
186
|
+
return round($scope.model) === round(parseText($scope.internal.value));
|
|
187
|
+
};
|
|
188
|
+
|
|
139
189
|
const setModel = function (value) {
|
|
140
190
|
if ($scope.decimalConstructor && value != null && !NiceService.isDecimal(value)) {
|
|
141
191
|
value = new $scope.decimalConstructor(value);
|
|
@@ -150,11 +200,28 @@ angular.module('niceElements')
|
|
|
150
200
|
|
|
151
201
|
// On input change
|
|
152
202
|
$scope.inputChanged = function () {
|
|
153
|
-
|
|
203
|
+
if ($scope.decimalMode) {
|
|
204
|
+
// Invalid text keeps the last valid model and marks the field invalid
|
|
205
|
+
const value = parseText($scope.internal.value);
|
|
206
|
+
const isNumber = !Number.isNaN(value);
|
|
207
|
+
$scope.niceNumberForm.$setValidity("number", isNumber ? null : false);
|
|
208
|
+
if (isNumber) setModel(round(value));
|
|
209
|
+
} else {
|
|
210
|
+
setModel($scope.internal.value);
|
|
211
|
+
}
|
|
154
212
|
$scope.check();
|
|
155
213
|
};
|
|
156
214
|
|
|
157
215
|
|
|
216
|
+
// Decimal mode: on blur show the cleaned up value ("1,239" -> "1.24" with decimals="2")
|
|
217
|
+
$scope.inputBlurred = function () {
|
|
218
|
+
if (!$scope.decimalMode) return;
|
|
219
|
+
if (!Number.isNaN(parseText($scope.internal.value))) {
|
|
220
|
+
$scope.internal.value = toInternal($scope.model);
|
|
221
|
+
}
|
|
222
|
+
};
|
|
223
|
+
|
|
224
|
+
|
|
158
225
|
// Watch for model change. Decimal is watched by value, because parent can replace it with new equal object.
|
|
159
226
|
$scope.$watch(function () {
|
|
160
227
|
return NiceService.isDecimal($scope.model) ? $scope.model.toString() : $scope.model;
|
|
@@ -164,8 +231,10 @@ angular.module('niceElements')
|
|
|
164
231
|
} else if ($scope.model != null) {
|
|
165
232
|
$scope.decimalConstructor = null; // Parent switched to plain value
|
|
166
233
|
}
|
|
167
|
-
if (
|
|
234
|
+
if (!isInputInSync()) {
|
|
168
235
|
$scope.internal.value = toInternal($scope.model);
|
|
236
|
+
// Input shows a valid value again (e.g. after plus/minus)
|
|
237
|
+
if ($scope.decimalMode && $scope.niceNumberForm) $scope.niceNumberForm.$setValidity("number", null);
|
|
169
238
|
}
|
|
170
239
|
$scope.check();
|
|
171
240
|
if ($scope.onChange && oldModel != newModel) {
|
|
@@ -178,7 +247,7 @@ angular.module('niceElements')
|
|
|
178
247
|
|
|
179
248
|
// Add to the value
|
|
180
249
|
$scope.add = function () {
|
|
181
|
-
const result = new Decimal($scope.model != undefined ? $scope.model : $scope.defaultValue).plus($scope.innerStep)
|
|
250
|
+
const result = round(new Decimal($scope.model != undefined ? $scope.model : $scope.defaultValue).plus($scope.innerStep));
|
|
182
251
|
if ($scope.max) {
|
|
183
252
|
if (result <= parseFloat($scope.max)) {
|
|
184
253
|
setModel(result);
|
|
@@ -194,7 +263,7 @@ angular.module('niceElements')
|
|
|
194
263
|
|
|
195
264
|
// Subtract to the value
|
|
196
265
|
$scope.subtract = function () {
|
|
197
|
-
const result = new Decimal($scope.model != undefined ? $scope.model : $scope.defaultValue).minus($scope.innerStep)
|
|
266
|
+
const result = round(new Decimal($scope.model != undefined ? $scope.model : $scope.defaultValue).minus($scope.innerStep));
|
|
198
267
|
if (result >= Number($scope.min)) {
|
|
199
268
|
setModel(result);
|
|
200
269
|
$scope.niceNumberForm.$setDirty();
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
<ng-form class="nice-component nice-input" ng-class="{ 'margin-bottom-0' : noMargin, 'nice-component-inline': isInline }" name="form">
|
|
1
|
+
<ng-form class="nice-component nice-percent nice-input nice-input-type-number" ng-class="{ 'margin-bottom-0' : noMargin, 'nice-component-inline': isInline }" name="form">
|
|
2
2
|
<div class="row">
|
|
3
3
|
<!------------------------- Title ------------------------->
|
|
4
4
|
<nice-title text="title || niceTitle" help="help" required="required" description="description" label-width="labelWidth"></nice-title>
|
|
@@ -6,10 +6,10 @@
|
|
|
6
6
|
<!------------------------- Field ------------------------->
|
|
7
7
|
<div class="nice-field col-xs-12" ng-class="fieldWidth ? fieldWidth : 'col-sm-8'">
|
|
8
8
|
<div class="input-group has-feedback symbol" ng-class="{
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
9
|
+
'has-warning': !isDisabled && form.$invalid && form.$dirty && !hideValid,
|
|
10
|
+
'has-success': !isDisabled && form.$valid && form.$dirty && showValid,
|
|
11
|
+
'disabled': isDisabled
|
|
12
|
+
}">
|
|
13
13
|
<input class="form-control" type="text" max="100" min="0" ng-model="internalModel" placeholder="{{ placeholder }}" ng-required="required" ng-keypress="keypress($event)" ng-change="change()" ng-disabled="isDisabled">
|
|
14
14
|
<span class="input-group-addon">%</span>
|
|
15
15
|
<!--<span ng-if="!disabled && showValid && form.$valid && form.$dirty" class="glyphicon glyphicon-ok form-control-feedback feedback-valid" aria-hidden="true"></span>-->
|
|
@@ -38,10 +38,12 @@ angular.module('niceElements')
|
|
|
38
38
|
attrs.noMargin = attrs.noMargin === 'true' || attrs.noMargin === true;
|
|
39
39
|
},
|
|
40
40
|
|
|
41
|
-
controller: function ($rootScope, $scope) {
|
|
41
|
+
controller: function ($rootScope, $scope, $attrs) {
|
|
42
42
|
// Link form object with valid object
|
|
43
|
-
if (
|
|
44
|
-
$scope
|
|
43
|
+
if ($attrs.valid) {
|
|
44
|
+
$scope.$watch('form', function (form) {
|
|
45
|
+
if (form) $scope.valid = form;
|
|
46
|
+
});
|
|
45
47
|
}
|
|
46
48
|
|
|
47
49
|
const roundN = function (number, decimals) {
|
|
@@ -112,13 +112,13 @@ angular.module('niceElements')
|
|
|
112
112
|
|
|
113
113
|
$scope.close = function () {
|
|
114
114
|
$scope.isOpen = false;
|
|
115
|
-
if ($scope.onChange) $scope.onChange($scope.isOpen);
|
|
115
|
+
if ($scope.onChange) $scope.onChange({ isOpen: $scope.isOpen });
|
|
116
116
|
};
|
|
117
117
|
|
|
118
118
|
$scope.open = function () {
|
|
119
119
|
if ($scope.popper) $scope.popper.update();
|
|
120
120
|
$scope.isOpen = true;
|
|
121
|
-
if ($scope.onChange) $scope.onChange($scope.isOpen);
|
|
121
|
+
if ($scope.onChange) $scope.onChange({ isOpen: $scope.isOpen });
|
|
122
122
|
$timeout(function () {
|
|
123
123
|
if ($scope.popper) $scope.popper.update();
|
|
124
124
|
});
|
|
@@ -33,13 +33,11 @@
|
|
|
33
33
|
|
|
34
34
|
<div class="nice-dropdown" ng-if="results.length">
|
|
35
35
|
<div ng-repeat="result in results" class="nice-search-row" ng-class="{'active': selectedIndex == $index}" ng-click="selectRow(result)">
|
|
36
|
-
<span class="text-bold">{{ result[keyForInputLabel] }}</span>
|
|
37
|
-
|
|
36
|
+
<span class="text-bold" ng-if="!hasRowTemplate">{{ result[keyForInputLabel] }}</span>
|
|
37
|
+
<div ng-if="hasRowTemplate" nice-search-row-transclude></div>
|
|
38
38
|
</div>
|
|
39
39
|
</div>
|
|
40
40
|
</div>
|
|
41
41
|
</div>
|
|
42
42
|
|
|
43
|
-
<!--Here is injected dropdown html if passed and results present and open.-->
|
|
44
|
-
<!--<div ng-transclude></div>-->
|
|
45
43
|
</ng-form>
|
|
@@ -38,7 +38,7 @@ angular.module('niceElements')
|
|
|
38
38
|
isInline: '=',
|
|
39
39
|
onChange: '&?'
|
|
40
40
|
},
|
|
41
|
-
link: function (scope, element, attrs) {
|
|
41
|
+
link: function (scope, element, attrs, ctrl, transcludeFn) {
|
|
42
42
|
if (!attrs.title) { attrs.title = ''; }
|
|
43
43
|
if (!attrs.placeholder) { attrs.placeholder = ''; }
|
|
44
44
|
if (!attrs.fieldWidth) { attrs.fieldWidth = 'col-sm-8'; }
|
|
@@ -53,11 +53,20 @@ angular.module('niceElements')
|
|
|
53
53
|
attrs.disableRow = attrs.disableRow === 'true' || attrs.disableRow === true;
|
|
54
54
|
attrs.noMargin = attrs.noMargin === 'true' || attrs.noMargin === true;
|
|
55
55
|
|
|
56
|
-
//
|
|
57
|
-
//
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
56
|
+
// Custom row content: markup placed inside <nice-search> is rendered for every
|
|
57
|
+
// result row (with `result` in scope) instead of the default label.
|
|
58
|
+
scope.rowTransclude = transcludeFn;
|
|
59
|
+
scope.hasRowTemplate = false;
|
|
60
|
+
|
|
61
|
+
// Make one throwaway copy of the content just to check if there is any
|
|
62
|
+
transcludeFn(function (clone, cloneScope) {
|
|
63
|
+
for (let i = 0; i < clone.length; i++) {
|
|
64
|
+
const isElement = clone[i].nodeType === 1;
|
|
65
|
+
const isText = clone[i].nodeType === 3 && clone[i].textContent.trim() !== '';
|
|
66
|
+
if (isElement || isText) scope.hasRowTemplate = true;
|
|
67
|
+
}
|
|
68
|
+
cloneScope.$destroy();
|
|
69
|
+
});
|
|
61
70
|
|
|
62
71
|
// Set default text
|
|
63
72
|
scope.$watch("setText", function () {
|
|
@@ -241,4 +250,21 @@ angular.module('niceElements')
|
|
|
241
250
|
};
|
|
242
251
|
}
|
|
243
252
|
};
|
|
253
|
+
})
|
|
254
|
+
|
|
255
|
+
// Renders nice-search's transcluded content for one result row, with `result` in scope
|
|
256
|
+
.directive('niceSearchRowTransclude', function () {
|
|
257
|
+
return {
|
|
258
|
+
restrict: 'A',
|
|
259
|
+
link: function (scope, element) {
|
|
260
|
+
// Copy the content into this row; the copy gets its own scope (rowScope)
|
|
261
|
+
scope.rowTransclude(function (clone, rowScope) {
|
|
262
|
+
// Give the copy access to this row's result, and keep it up to date
|
|
263
|
+
scope.$watch('result', function (result) {
|
|
264
|
+
rowScope.result = result;
|
|
265
|
+
});
|
|
266
|
+
element.append(clone);
|
|
267
|
+
});
|
|
268
|
+
}
|
|
269
|
+
};
|
|
244
270
|
});
|