nice-elements 1.12.10 → 1.12.11
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/.vscode/settings.json +18 -18
- package/CHANGELOG.md +585 -580
- package/LICENSE.md +21 -21
- package/README.md +102 -102
- package/bower.json +17 -17
- package/dist/nice.js +9187 -11627
- package/dist/nice.min.js +1 -1
- package/dist/style.css +12 -12
- package/dist/style.css.map +1 -1
- package/dist/style.min.css +8 -8
- package/eslint.config.mjs +32 -32
- package/package.json +44 -44
- package/src/components/nice-alert/nice-alert.html +6 -6
- package/src/components/nice-alert/nice-alert.js +29 -29
- package/src/components/nice-alert/nice-alert.scss +59 -59
- package/src/components/nice-avatar/nice-avatar.js +122 -122
- package/src/components/nice-avatar/nice-avatar.scss +4 -4
- package/src/components/nice-button/nice-button.html +4 -4
- package/src/components/nice-button/nice-button.js +41 -41
- package/src/components/nice-button/nice-button.scss +16 -16
- package/src/components/nice-button-toggle/nice-button-toggle.html +9 -9
- package/src/components/nice-button-toggle/nice-button-toggle.js +23 -23
- package/src/components/nice-button-toggle/nice-button-toggle.scss +2 -2
- package/src/components/nice-calendar/nice-calendar.html +91 -91
- package/src/components/nice-calendar/nice-calendar.js +346 -346
- package/src/components/nice-calendar/nice-calendar.scss +288 -288
- package/src/components/nice-checkbox/nice-checkbox.html +20 -9
- package/src/components/nice-checkbox/nice-checkbox.js +38 -37
- package/src/components/nice-checkbox/nice-checkbox.scss +120 -120
- package/src/components/nice-choice/nice-choice.html +18 -18
- package/src/components/nice-choice/nice-choice.js +211 -211
- package/src/components/nice-choice/nice-choice.scss +110 -110
- package/src/components/nice-comment/nice-comment.html +10 -10
- package/src/components/nice-comment/nice-comment.js +71 -71
- package/src/components/nice-comment/nice-comment.scss +39 -39
- package/src/components/nice-date/nice-date.html +82 -82
- package/src/components/nice-date/nice-date.js +350 -350
- package/src/components/nice-date/nice-date.scss +305 -305
- package/src/components/nice-date-input/nice-date-input.html +56 -56
- package/src/components/nice-date-input/nice-date-input.js +143 -143
- package/src/components/nice-date-input/nice-date-input.scss +55 -55
- package/src/components/nice-date-range/nice-date-range.html +15 -15
- package/src/components/nice-date-range/nice-date-range.js +78 -78
- package/src/components/nice-date-range/nice-date-range.scss +390 -390
- package/src/components/nice-datetime-picker/nice-datetime-picker.html +29 -29
- package/src/components/nice-datetime-picker/nice-datetime-picker.js +89 -89
- package/src/components/nice-datetime-picker/nice-datetime-picker.scss +428 -428
- package/src/components/nice-datetimerange-picker/nice-datetimerange-picker.html +55 -55
- package/src/components/nice-datetimerange-picker/nice-datetimerange-picker.js +248 -248
- package/src/components/nice-datetimerange-picker/nice-datetimerange-picker.scss +73 -73
- package/src/components/nice-datetimerange-picker-2/nice-datetimerange-picker-2.html +44 -44
- package/src/components/nice-datetimerange-picker-2/nice-datetimerange-picker-2.js +175 -175
- package/src/components/nice-datetimerange-picker-2/nice-datetimerange-picker-2.scss +127 -127
- package/src/components/nice-dropdown/nice-dropdown.html +61 -61
- package/src/components/nice-dropdown/nice-dropdown.js +517 -517
- package/src/components/nice-dropdown/nice-dropdown.scss +262 -262
- package/src/components/nice-dropdown-date/nice-dropdown-date.html +28 -28
- package/src/components/nice-dropdown-date/nice-dropdown-date.js +132 -132
- package/src/components/nice-dropdown-date/nice-dropdown-date.scss +87 -87
- package/src/components/nice-dropdown-old/nice-dropdown-old.html +44 -44
- package/src/components/nice-dropdown-old/nice-dropdown-old.js +330 -330
- package/src/components/nice-dropdown-old/nice-dropdown-old.scss +129 -129
- package/src/components/nice-dtp/nice-dtp.html +91 -91
- package/src/components/nice-dtp/nice-dtp.js +835 -835
- package/src/components/nice-help/nice-help.html +6 -6
- package/src/components/nice-help/nice-help.js +58 -58
- package/src/components/nice-help/nice-help.scss +78 -78
- package/src/components/nice-input/nice-input.html +47 -47
- package/src/components/nice-input/nice-input.js +251 -251
- package/src/components/nice-input/nice-input.scss +130 -130
- package/src/components/nice-label/nice-label.html +10 -10
- package/src/components/nice-label/nice-label.js +32 -32
- package/src/components/nice-loader/nice-loader.html +6 -6
- package/src/components/nice-loader/nice-loader.js +28 -28
- package/src/components/nice-loader/nice-loader.scss +47 -47
- package/src/components/nice-no-data/nice-no-data.html +3 -3
- package/src/components/nice-no-data/nice-no-data.js +27 -27
- package/src/components/nice-no-data/nice-no-data.scss +26 -26
- package/src/components/nice-notification/nice-notification.html +3 -3
- package/src/components/nice-notification/nice-notification.js +124 -124
- package/src/components/nice-notification/nice-notification.scss +66 -66
- package/src/components/nice-number/nice-number.html +40 -40
- package/src/components/nice-number/nice-number.js +172 -172
- package/src/components/nice-number/nice-number.scss +18 -18
- package/src/components/nice-on-scroll/nice-on-scroll.js +17 -17
- package/src/components/nice-percent/nice-percent.html +24 -24
- package/src/components/nice-percent/nice-percent.js +95 -95
- package/src/components/nice-pill/nice-pill.html +3 -3
- package/src/components/nice-pill/nice-pill.js +29 -29
- package/src/components/nice-pill/nice-pill.scss +25 -25
- package/src/components/nice-popup/nice-popup.html +6 -6
- package/src/components/nice-popup/nice-popup.js +122 -122
- package/src/components/nice-popup/nice-popup.scss +43 -43
- package/src/components/nice-progress-bar/nice-progress-bar.html +15 -15
- package/src/components/nice-progress-bar/nice-progress-bar.js +55 -55
- package/src/components/nice-progress-bar/nice-progress-bar.scss +47 -47
- package/src/components/nice-quantity/nice-quantity.html +22 -22
- package/src/components/nice-quantity/nice-quantity.js +57 -57
- package/src/components/nice-quantity/nice-quantity.scss +51 -51
- package/src/components/nice-search/nice-search.html +44 -44
- package/src/components/nice-search/nice-search.js +243 -243
- package/src/components/nice-search/nice-search.scss +90 -90
- package/src/components/nice-search2/nice-search2.html +32 -32
- package/src/components/nice-search2/nice-search2.js +267 -267
- package/src/components/nice-search2/nice-search2.scss +80 -80
- package/src/components/nice-slot/nice-slot.html +10 -10
- package/src/components/nice-slot/nice-slot.js +31 -31
- package/src/components/nice-steps/nice-steps.scss +81 -81
- package/src/components/nice-svgs/nice-svgs.html +1332 -1332
- package/src/components/nice-svgs/nice-svgs.js +19 -19
- package/src/components/nice-table/nice-table.html +38 -38
- package/src/components/nice-table/nice-table.js +60 -60
- package/src/components/nice-table/nice-table.scss +112 -112
- package/src/components/nice-time-picker/nice-time-picker.html +43 -43
- package/src/components/nice-time-picker/nice-time-picker.js +85 -85
- package/src/components/nice-time-picker/nice-time-picker.scss +37 -37
- package/src/components/nice-title/nice-title.html +6 -6
- package/src/components/nice-title/nice-title.js +22 -22
- package/src/components/nice-toast/nice-toast.html +2 -2
- package/src/components/nice-toast/nice-toast.js +56 -56
- package/src/components/nice-toast/nice-toast.scss +74 -74
- package/src/components/nice-toggle/nice-toggle.html +12 -12
- package/src/components/nice-toggle/nice-toggle.js +57 -57
- package/src/components/nice-toggle/nice-toggle.scss +131 -131
- package/src/components/nice-upload/nice-upload.html +22 -22
- package/src/components/nice-upload/nice-upload.js +160 -160
- package/src/components/nice-upload/nice-upload.scss +85 -85
- package/src/components/nice-view/_nice-view.scss +63 -63
- package/src/components/nice-view/nice-view.html +12 -12
- package/src/components/nice-view/nice-view.js +29 -30
- package/src/components/nice-virtual-scroll/_nice-virtual-scroll.scss +17 -17
- package/src/components/nice-virtual-scroll/nice-virtual-scroll.html +12 -12
- package/src/components/nice-virtual-scroll/nice-virtual-scroll.js +70 -70
- package/src/components/nice-wrapper/_nice-wrapper.scss +87 -87
- package/src/components/nice-wrapper/nice-wrapper.html +12 -12
- package/src/components/nice-wrapper/nice-wrapper.js +44 -44
- package/src/components/nice-yesno/nice-yesno.html +14 -14
- package/src/components/nice-yesno/nice-yesno.js +111 -111
- package/src/components/nice-yesno/nice-yesno.scss +95 -95
- package/src/directives/nice-click-outside.js +105 -105
- package/src/directives/nice-infinite-loader.js +27 -27
- package/src/directives/nice-tooltip/_nice-tooltip.scss +55 -55
- package/src/directives/nice-tooltip/nice-tooltip.js +84 -84
- package/src/filters/nice-date.js +17 -17
- package/src/filters/nice-highlight.js +16 -16
- package/src/modals/nice-multilangual-modal/nice-multilangual-modal.html +30 -30
- package/src/modals/nice-multilangual-modal/nice-multilangual-modal.js +67 -67
- package/src/modals/nice-multilangual-modal/nice-multilangual-modal.scss +19 -19
- package/src/nice.js +2 -2
- package/src/services/nice-service.js +22 -22
- package/src/styles/_bootstrap-variables.scss +178 -178
- package/src/styles/_nice-buttons.scss +612 -612
- package/src/styles/_nice-common.scss +479 -479
- package/src/styles/_nice-ngdialog.scss +85 -85
- package/src/styles/_nice-spacing.scss +283 -283
- package/src/styles/_nice.scss +75 -75
- package/src/styles/_variables.scss +194 -194
|
@@ -1,243 +1,243 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* @ngdoc directive
|
|
5
|
-
* @name niceElements.directive:niceSearch
|
|
6
|
-
* @description
|
|
7
|
-
* # niceSearch
|
|
8
|
-
*/
|
|
9
|
-
angular.module('niceElements')
|
|
10
|
-
.directive('niceSearch', function () {
|
|
11
|
-
return {
|
|
12
|
-
transclude: true,
|
|
13
|
-
templateUrl: 'src/components/nice-search/nice-search.html',
|
|
14
|
-
restrict: 'E',
|
|
15
|
-
scope: {
|
|
16
|
-
model: '=',
|
|
17
|
-
isDisabled: '=',
|
|
18
|
-
title: '@?',
|
|
19
|
-
niceTitle: '@?',
|
|
20
|
-
placeholder: '@',
|
|
21
|
-
required: '=',
|
|
22
|
-
fieldWidth: '@',
|
|
23
|
-
labelWidth: '@',
|
|
24
|
-
hideValid: '@',
|
|
25
|
-
refreshFunction: '=',
|
|
26
|
-
refreshSelectedCallback: '=',
|
|
27
|
-
showDropdown: '@?',
|
|
28
|
-
clearInput: '@',
|
|
29
|
-
resetSearchInput: '@?',
|
|
30
|
-
keyForInputLabel: '@?',
|
|
31
|
-
disableRow: '@?',
|
|
32
|
-
noMargin: '@',
|
|
33
|
-
setText: '@',
|
|
34
|
-
tabIndex: '@',
|
|
35
|
-
isFocused: '@',
|
|
36
|
-
help: '@',
|
|
37
|
-
isInline: '=',
|
|
38
|
-
onChange: '&?'
|
|
39
|
-
},
|
|
40
|
-
link: function (scope, element, attrs) {
|
|
41
|
-
if (!attrs.title) { attrs.title = ''; }
|
|
42
|
-
if (!attrs.placeholder) { attrs.placeholder = ''; }
|
|
43
|
-
if (!attrs.fieldWidth) { attrs.fieldWidth = 'col-sm-8'; }
|
|
44
|
-
if (!attrs.labelWidth) { attrs.labelWidth = 'col-sm-4'; }
|
|
45
|
-
if (!attrs.setText) { attrs.setText = ''; }
|
|
46
|
-
|
|
47
|
-
attrs.required = attrs.required === 'true' || attrs.required === true;
|
|
48
|
-
attrs.hideValid = attrs.hideValid === 'true' || attrs.hideValid === true;
|
|
49
|
-
attrs.showDropdown = attrs.showDropdown === 'true' || attrs.showDropdown === true;
|
|
50
|
-
attrs.clearInput = attrs.clearInput === 'true' || attrs.clearInput === true;
|
|
51
|
-
attrs.resetSearchInput = attrs.resetSearchInput === 'true' || attrs.resetSearchInput === true;
|
|
52
|
-
attrs.disableRow = attrs.disableRow === 'true' || attrs.disableRow === true;
|
|
53
|
-
attrs.noMargin = attrs.noMargin === 'true' || attrs.noMargin === true;
|
|
54
|
-
|
|
55
|
-
// This is used for connecting directive's scope to transcluded html.
|
|
56
|
-
// transcludeFn(scope, function(clone, scope) {
|
|
57
|
-
// var el = element.find('.nice-search');
|
|
58
|
-
// el.append(clone);
|
|
59
|
-
// });
|
|
60
|
-
|
|
61
|
-
// Set default text
|
|
62
|
-
scope.$watch("setText", function () {
|
|
63
|
-
scope.modelString = scope.setText;
|
|
64
|
-
});
|
|
65
|
-
|
|
66
|
-
// Check if object is defined
|
|
67
|
-
if (angular.isDefined(scope.model)) {
|
|
68
|
-
if (angular.isDefined(scope.keyForInputLabel))
|
|
69
|
-
scope.modelString = scope.model[scope.keyForInputLabel];
|
|
70
|
-
else
|
|
71
|
-
scope.modelString = scope.model;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
const setValid = function (isValid) {
|
|
75
|
-
if (scope.required && scope.form) {
|
|
76
|
-
scope.form.$setValidity('objectSelected', isValid);
|
|
77
|
-
}
|
|
78
|
-
};
|
|
79
|
-
|
|
80
|
-
scope.$watch('model', function (newValue) {
|
|
81
|
-
if (scope.model && scope.model.id) {
|
|
82
|
-
setValid(true);
|
|
83
|
-
} else {
|
|
84
|
-
setValid(false);
|
|
85
|
-
}
|
|
86
|
-
});
|
|
87
|
-
|
|
88
|
-
scope.selectRow = function (obj) {
|
|
89
|
-
if (angular.isDefined(scope.refreshSelectedCallback)) {
|
|
90
|
-
scope.refreshSelectedCallback(obj);
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
if (scope.resetSearchInput) {
|
|
94
|
-
scope.model = null;
|
|
95
|
-
} else {
|
|
96
|
-
scope.model = obj;
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
if (angular.isDefined(scope.keyForInputLabel))
|
|
100
|
-
scope.modelString = obj[scope.keyForInputLabel];
|
|
101
|
-
else
|
|
102
|
-
scope.modelString = obj;
|
|
103
|
-
|
|
104
|
-
scope.clear();
|
|
105
|
-
|
|
106
|
-
};
|
|
107
|
-
|
|
108
|
-
scope.clear = function () {
|
|
109
|
-
scope.results = [];
|
|
110
|
-
|
|
111
|
-
if (scope.clearInput) {
|
|
112
|
-
scope.modelString = "";
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
//scope.$apply();
|
|
116
|
-
};
|
|
117
|
-
|
|
118
|
-
// Close the dropdown if clicked outside
|
|
119
|
-
const onClick = function (event) {
|
|
120
|
-
const isClickedElementChildOfPopup = element.find(event.target).length > 0;
|
|
121
|
-
|
|
122
|
-
if (isClickedElementChildOfPopup) return;
|
|
123
|
-
|
|
124
|
-
scope.results = [];
|
|
125
|
-
scope.noResults = false;
|
|
126
|
-
scope.$apply();
|
|
127
|
-
};
|
|
128
|
-
|
|
129
|
-
angular.element(element).on('click', onClick);
|
|
130
|
-
|
|
131
|
-
// Keyboard up/down on search results
|
|
132
|
-
const onKeyDown = function (event) {
|
|
133
|
-
if ((event.keyCode == 38 || event.keyCode == 40 || event.keyCode == 13 || event.keyCode == 27) && scope.results && scope.results.length > 0) {
|
|
134
|
-
event.preventDefault();
|
|
135
|
-
|
|
136
|
-
if (event.keyCode == 27) { // Escape
|
|
137
|
-
scope.modelString = "";
|
|
138
|
-
scope.clear();
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
if (event.keyCode == 13) { // Enter
|
|
142
|
-
scope.selectRow(scope.results[scope.selectedIndex]);
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
if (event.keyCode == 40 && scope.results && scope.selectedIndex + 1 < scope.results.length) { // Down
|
|
146
|
-
scope.selectedIndex += 1;
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
if (event.keyCode == 38 && scope.results && scope.selectedIndex - 1 >= 0) { // Up
|
|
150
|
-
scope.selectedIndex -= 1;
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
// TODO: What to do when hover?
|
|
154
|
-
|
|
155
|
-
scope.$apply();
|
|
156
|
-
}
|
|
157
|
-
};
|
|
158
|
-
|
|
159
|
-
angular.element(element).on('keydown', onKeyDown);
|
|
160
|
-
|
|
161
|
-
scope.$on('$destroy', function () {
|
|
162
|
-
angular.element(element).off('click', onClick);
|
|
163
|
-
angular.element(element).off('keydown', onKeyDown);
|
|
164
|
-
});
|
|
165
|
-
|
|
166
|
-
},
|
|
167
|
-
controller: function ($scope, $timeout, $element) {
|
|
168
|
-
$scope.id = Math.random().toString(36).substring(7);
|
|
169
|
-
$scope.loading = false;
|
|
170
|
-
$scope.noResults = false;
|
|
171
|
-
$scope.requests = 0;
|
|
172
|
-
|
|
173
|
-
$scope.focus = function () {
|
|
174
|
-
const input = $element[0].getElementsByTagName('input')[0];
|
|
175
|
-
if (input) {
|
|
176
|
-
input.focus();
|
|
177
|
-
}
|
|
178
|
-
};
|
|
179
|
-
|
|
180
|
-
// Is focused
|
|
181
|
-
if ($scope.isFocused) {
|
|
182
|
-
$scope.focus();
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
$scope.results = [];
|
|
186
|
-
const updateList = function (results, requestNumber) {
|
|
187
|
-
|
|
188
|
-
if (results) {
|
|
189
|
-
if ($scope.requests == requestNumber) {
|
|
190
|
-
$scope.noResults = results.length == 0;
|
|
191
|
-
$scope.results = results;
|
|
192
|
-
|
|
193
|
-
if (!$scope.noResults) {
|
|
194
|
-
$scope.selectedIndex = 0;
|
|
195
|
-
}
|
|
196
|
-
}
|
|
197
|
-
}
|
|
198
|
-
$scope.loading = false;
|
|
199
|
-
};
|
|
200
|
-
|
|
201
|
-
// ng-change function
|
|
202
|
-
$scope.updateSearch = function () {
|
|
203
|
-
$scope.loading = true;
|
|
204
|
-
|
|
205
|
-
if ($scope.timer_promise) $timeout.cancel($scope.timer_promise);
|
|
206
|
-
|
|
207
|
-
$scope.timer_promise = $timeout(function () {
|
|
208
|
-
if ($scope.onChange) $scope.onChange({ model: $scope.model, modelString: $scope.modelString });
|
|
209
|
-
if (!$scope.refreshFunction) {
|
|
210
|
-
$scope.loading = false;
|
|
211
|
-
return console.warn("[NICE ELEMENTS] No refresh function set to the nice-search component!");
|
|
212
|
-
}
|
|
213
|
-
$scope.requests = $scope.requests + 1;
|
|
214
|
-
const requestNumber = angular.copy($scope.requests);
|
|
215
|
-
$scope.refreshFunction($scope.modelString).then(function (response) {
|
|
216
|
-
updateList(response, requestNumber);
|
|
217
|
-
}, function (error) {
|
|
218
|
-
$scope.loading = false;
|
|
219
|
-
});
|
|
220
|
-
// Why was this here?
|
|
221
|
-
// $scope.model = $scope.modelString;
|
|
222
|
-
}, 200);
|
|
223
|
-
|
|
224
|
-
};
|
|
225
|
-
|
|
226
|
-
// If search button is clicked set focus or make request
|
|
227
|
-
$scope.search = function () {
|
|
228
|
-
if (!$scope.isDisabled) {
|
|
229
|
-
if ($scope.showDropdown) {
|
|
230
|
-
$scope.updateSearch();
|
|
231
|
-
}
|
|
232
|
-
$scope.focus();
|
|
233
|
-
}
|
|
234
|
-
};
|
|
235
|
-
|
|
236
|
-
// Clear model
|
|
237
|
-
$scope.remove = function () {
|
|
238
|
-
$scope.model = null;
|
|
239
|
-
$scope.modelString = null;
|
|
240
|
-
};
|
|
241
|
-
}
|
|
242
|
-
};
|
|
243
|
-
});
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @ngdoc directive
|
|
5
|
+
* @name niceElements.directive:niceSearch
|
|
6
|
+
* @description
|
|
7
|
+
* # niceSearch
|
|
8
|
+
*/
|
|
9
|
+
angular.module('niceElements')
|
|
10
|
+
.directive('niceSearch', function () {
|
|
11
|
+
return {
|
|
12
|
+
transclude: true,
|
|
13
|
+
templateUrl: 'src/components/nice-search/nice-search.html',
|
|
14
|
+
restrict: 'E',
|
|
15
|
+
scope: {
|
|
16
|
+
model: '=',
|
|
17
|
+
isDisabled: '=',
|
|
18
|
+
title: '@?',
|
|
19
|
+
niceTitle: '@?',
|
|
20
|
+
placeholder: '@',
|
|
21
|
+
required: '=',
|
|
22
|
+
fieldWidth: '@',
|
|
23
|
+
labelWidth: '@',
|
|
24
|
+
hideValid: '@',
|
|
25
|
+
refreshFunction: '=',
|
|
26
|
+
refreshSelectedCallback: '=',
|
|
27
|
+
showDropdown: '@?',
|
|
28
|
+
clearInput: '@',
|
|
29
|
+
resetSearchInput: '@?',
|
|
30
|
+
keyForInputLabel: '@?',
|
|
31
|
+
disableRow: '@?',
|
|
32
|
+
noMargin: '@',
|
|
33
|
+
setText: '@',
|
|
34
|
+
tabIndex: '@',
|
|
35
|
+
isFocused: '@',
|
|
36
|
+
help: '@',
|
|
37
|
+
isInline: '=',
|
|
38
|
+
onChange: '&?'
|
|
39
|
+
},
|
|
40
|
+
link: function (scope, element, attrs) {
|
|
41
|
+
if (!attrs.title) { attrs.title = ''; }
|
|
42
|
+
if (!attrs.placeholder) { attrs.placeholder = ''; }
|
|
43
|
+
if (!attrs.fieldWidth) { attrs.fieldWidth = 'col-sm-8'; }
|
|
44
|
+
if (!attrs.labelWidth) { attrs.labelWidth = 'col-sm-4'; }
|
|
45
|
+
if (!attrs.setText) { attrs.setText = ''; }
|
|
46
|
+
|
|
47
|
+
attrs.required = attrs.required === 'true' || attrs.required === true;
|
|
48
|
+
attrs.hideValid = attrs.hideValid === 'true' || attrs.hideValid === true;
|
|
49
|
+
attrs.showDropdown = attrs.showDropdown === 'true' || attrs.showDropdown === true;
|
|
50
|
+
attrs.clearInput = attrs.clearInput === 'true' || attrs.clearInput === true;
|
|
51
|
+
attrs.resetSearchInput = attrs.resetSearchInput === 'true' || attrs.resetSearchInput === true;
|
|
52
|
+
attrs.disableRow = attrs.disableRow === 'true' || attrs.disableRow === true;
|
|
53
|
+
attrs.noMargin = attrs.noMargin === 'true' || attrs.noMargin === true;
|
|
54
|
+
|
|
55
|
+
// This is used for connecting directive's scope to transcluded html.
|
|
56
|
+
// transcludeFn(scope, function(clone, scope) {
|
|
57
|
+
// var el = element.find('.nice-search');
|
|
58
|
+
// el.append(clone);
|
|
59
|
+
// });
|
|
60
|
+
|
|
61
|
+
// Set default text
|
|
62
|
+
scope.$watch("setText", function () {
|
|
63
|
+
scope.modelString = scope.setText;
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
// Check if object is defined
|
|
67
|
+
if (angular.isDefined(scope.model)) {
|
|
68
|
+
if (angular.isDefined(scope.keyForInputLabel))
|
|
69
|
+
scope.modelString = scope.model[scope.keyForInputLabel];
|
|
70
|
+
else
|
|
71
|
+
scope.modelString = scope.model;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
const setValid = function (isValid) {
|
|
75
|
+
if (scope.required && scope.form) {
|
|
76
|
+
scope.form.$setValidity('objectSelected', isValid);
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
scope.$watch('model', function (newValue) {
|
|
81
|
+
if (scope.model && scope.model.id) {
|
|
82
|
+
setValid(true);
|
|
83
|
+
} else {
|
|
84
|
+
setValid(false);
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
scope.selectRow = function (obj) {
|
|
89
|
+
if (angular.isDefined(scope.refreshSelectedCallback)) {
|
|
90
|
+
scope.refreshSelectedCallback(obj);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
if (scope.resetSearchInput) {
|
|
94
|
+
scope.model = null;
|
|
95
|
+
} else {
|
|
96
|
+
scope.model = obj;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
if (angular.isDefined(scope.keyForInputLabel))
|
|
100
|
+
scope.modelString = obj[scope.keyForInputLabel];
|
|
101
|
+
else
|
|
102
|
+
scope.modelString = obj;
|
|
103
|
+
|
|
104
|
+
scope.clear();
|
|
105
|
+
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
scope.clear = function () {
|
|
109
|
+
scope.results = [];
|
|
110
|
+
|
|
111
|
+
if (scope.clearInput) {
|
|
112
|
+
scope.modelString = "";
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
//scope.$apply();
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
// Close the dropdown if clicked outside
|
|
119
|
+
const onClick = function (event) {
|
|
120
|
+
const isClickedElementChildOfPopup = element.find(event.target).length > 0;
|
|
121
|
+
|
|
122
|
+
if (isClickedElementChildOfPopup) return;
|
|
123
|
+
|
|
124
|
+
scope.results = [];
|
|
125
|
+
scope.noResults = false;
|
|
126
|
+
scope.$apply();
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
angular.element(element).on('click', onClick);
|
|
130
|
+
|
|
131
|
+
// Keyboard up/down on search results
|
|
132
|
+
const onKeyDown = function (event) {
|
|
133
|
+
if ((event.keyCode == 38 || event.keyCode == 40 || event.keyCode == 13 || event.keyCode == 27) && scope.results && scope.results.length > 0) {
|
|
134
|
+
event.preventDefault();
|
|
135
|
+
|
|
136
|
+
if (event.keyCode == 27) { // Escape
|
|
137
|
+
scope.modelString = "";
|
|
138
|
+
scope.clear();
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
if (event.keyCode == 13) { // Enter
|
|
142
|
+
scope.selectRow(scope.results[scope.selectedIndex]);
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
if (event.keyCode == 40 && scope.results && scope.selectedIndex + 1 < scope.results.length) { // Down
|
|
146
|
+
scope.selectedIndex += 1;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
if (event.keyCode == 38 && scope.results && scope.selectedIndex - 1 >= 0) { // Up
|
|
150
|
+
scope.selectedIndex -= 1;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
// TODO: What to do when hover?
|
|
154
|
+
|
|
155
|
+
scope.$apply();
|
|
156
|
+
}
|
|
157
|
+
};
|
|
158
|
+
|
|
159
|
+
angular.element(element).on('keydown', onKeyDown);
|
|
160
|
+
|
|
161
|
+
scope.$on('$destroy', function () {
|
|
162
|
+
angular.element(element).off('click', onClick);
|
|
163
|
+
angular.element(element).off('keydown', onKeyDown);
|
|
164
|
+
});
|
|
165
|
+
|
|
166
|
+
},
|
|
167
|
+
controller: function ($scope, $timeout, $element) {
|
|
168
|
+
$scope.id = Math.random().toString(36).substring(7);
|
|
169
|
+
$scope.loading = false;
|
|
170
|
+
$scope.noResults = false;
|
|
171
|
+
$scope.requests = 0;
|
|
172
|
+
|
|
173
|
+
$scope.focus = function () {
|
|
174
|
+
const input = $element[0].getElementsByTagName('input')[0];
|
|
175
|
+
if (input) {
|
|
176
|
+
input.focus();
|
|
177
|
+
}
|
|
178
|
+
};
|
|
179
|
+
|
|
180
|
+
// Is focused
|
|
181
|
+
if ($scope.isFocused) {
|
|
182
|
+
$scope.focus();
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
$scope.results = [];
|
|
186
|
+
const updateList = function (results, requestNumber) {
|
|
187
|
+
|
|
188
|
+
if (results) {
|
|
189
|
+
if ($scope.requests == requestNumber) {
|
|
190
|
+
$scope.noResults = results.length == 0;
|
|
191
|
+
$scope.results = results;
|
|
192
|
+
|
|
193
|
+
if (!$scope.noResults) {
|
|
194
|
+
$scope.selectedIndex = 0;
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
$scope.loading = false;
|
|
199
|
+
};
|
|
200
|
+
|
|
201
|
+
// ng-change function
|
|
202
|
+
$scope.updateSearch = function () {
|
|
203
|
+
$scope.loading = true;
|
|
204
|
+
|
|
205
|
+
if ($scope.timer_promise) $timeout.cancel($scope.timer_promise);
|
|
206
|
+
|
|
207
|
+
$scope.timer_promise = $timeout(function () {
|
|
208
|
+
if ($scope.onChange) $scope.onChange({ model: $scope.model, modelString: $scope.modelString });
|
|
209
|
+
if (!$scope.refreshFunction) {
|
|
210
|
+
$scope.loading = false;
|
|
211
|
+
return console.warn("[NICE ELEMENTS] No refresh function set to the nice-search component!");
|
|
212
|
+
}
|
|
213
|
+
$scope.requests = $scope.requests + 1;
|
|
214
|
+
const requestNumber = angular.copy($scope.requests);
|
|
215
|
+
$scope.refreshFunction($scope.modelString).then(function (response) {
|
|
216
|
+
updateList(response, requestNumber);
|
|
217
|
+
}, function (error) {
|
|
218
|
+
$scope.loading = false;
|
|
219
|
+
});
|
|
220
|
+
// Why was this here?
|
|
221
|
+
// $scope.model = $scope.modelString;
|
|
222
|
+
}, 200);
|
|
223
|
+
|
|
224
|
+
};
|
|
225
|
+
|
|
226
|
+
// If search button is clicked set focus or make request
|
|
227
|
+
$scope.search = function () {
|
|
228
|
+
if (!$scope.isDisabled) {
|
|
229
|
+
if ($scope.showDropdown) {
|
|
230
|
+
$scope.updateSearch();
|
|
231
|
+
}
|
|
232
|
+
$scope.focus();
|
|
233
|
+
}
|
|
234
|
+
};
|
|
235
|
+
|
|
236
|
+
// Clear model
|
|
237
|
+
$scope.remove = function () {
|
|
238
|
+
$scope.model = null;
|
|
239
|
+
$scope.modelString = null;
|
|
240
|
+
};
|
|
241
|
+
}
|
|
242
|
+
};
|
|
243
|
+
});
|
|
@@ -1,91 +1,91 @@
|
|
|
1
|
-
.nice-search {
|
|
2
|
-
position: relative;
|
|
3
|
-
|
|
4
|
-
i.ng-hide {
|
|
5
|
-
-webkit-animation: 0;
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
.symbol {
|
|
9
|
-
input {
|
|
10
|
-
text-align: left;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
.form-control {
|
|
14
|
-
padding-left: 12px;
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
.input-group-addon {
|
|
19
|
-
.nice-loader {
|
|
20
|
-
svg {
|
|
21
|
-
height: 18px;
|
|
22
|
-
width: 18px;
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
.nice-dropdown {
|
|
28
|
-
position: absolute;
|
|
29
|
-
z-index: 999;
|
|
30
|
-
//top: 35px;
|
|
31
|
-
left: 0;
|
|
32
|
-
// right: 0;
|
|
33
|
-
//min-width: 340px;
|
|
34
|
-
max-height: 300px;
|
|
35
|
-
background-color: white;
|
|
36
|
-
border-radius: $nice-border-radius;
|
|
37
|
-
border: 1px solid $nice-border-color;
|
|
38
|
-
overflow-x: auto;
|
|
39
|
-
|
|
40
|
-
-webkit-box-shadow: 0 0 1px rgba(0, 0, 0, 0.175);
|
|
41
|
-
box-shadow: 0 0 1px rgba(0, 0, 0, 0.175);
|
|
42
|
-
|
|
43
|
-
top: -13px;
|
|
44
|
-
margin: 15px;
|
|
45
|
-
right: 0;
|
|
46
|
-
|
|
47
|
-
.nice-search-row {
|
|
48
|
-
padding: 10px 15px;
|
|
49
|
-
z-index: 1000;
|
|
50
|
-
width: 100%;
|
|
51
|
-
|
|
52
|
-
&:hover {
|
|
53
|
-
//color: white !important;
|
|
54
|
-
//background-color: $nice-base-color !important;
|
|
55
|
-
background-color: $nice-hover-color;
|
|
56
|
-
cursor: pointer;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
&.active {
|
|
60
|
-
// color: white;
|
|
61
|
-
background-color: $nice-hover-color;
|
|
62
|
-
cursor: pointer;
|
|
63
|
-
|
|
64
|
-
// p{color:white;}
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
&:hover {
|
|
69
|
-
.active {
|
|
70
|
-
color: $text-color;
|
|
71
|
-
background-color: white;
|
|
72
|
-
|
|
73
|
-
p {
|
|
74
|
-
color: $text-color;
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
.nice-dropdown-empty {
|
|
81
|
-
@extend .nice-dropdown;
|
|
82
|
-
top: -13px;
|
|
83
|
-
margin: 15px;
|
|
84
|
-
right: 0;
|
|
85
|
-
box-shadow: 0 6px 12px rgba(0, 0, 0, 0.175);
|
|
86
|
-
|
|
87
|
-
.nice-search-row {
|
|
88
|
-
opacity: 0.4;
|
|
89
|
-
}
|
|
90
|
-
}
|
|
1
|
+
.nice-search {
|
|
2
|
+
position: relative;
|
|
3
|
+
|
|
4
|
+
i.ng-hide {
|
|
5
|
+
-webkit-animation: 0;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
.symbol {
|
|
9
|
+
input {
|
|
10
|
+
text-align: left;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
.form-control {
|
|
14
|
+
padding-left: 12px;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
.input-group-addon {
|
|
19
|
+
.nice-loader {
|
|
20
|
+
svg {
|
|
21
|
+
height: 18px;
|
|
22
|
+
width: 18px;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
.nice-dropdown {
|
|
28
|
+
position: absolute;
|
|
29
|
+
z-index: 999;
|
|
30
|
+
//top: 35px;
|
|
31
|
+
left: 0;
|
|
32
|
+
// right: 0;
|
|
33
|
+
//min-width: 340px;
|
|
34
|
+
max-height: 300px;
|
|
35
|
+
background-color: white;
|
|
36
|
+
border-radius: $nice-border-radius;
|
|
37
|
+
border: 1px solid $nice-border-color;
|
|
38
|
+
overflow-x: auto;
|
|
39
|
+
|
|
40
|
+
-webkit-box-shadow: 0 0 1px rgba(0, 0, 0, 0.175);
|
|
41
|
+
box-shadow: 0 0 1px rgba(0, 0, 0, 0.175);
|
|
42
|
+
|
|
43
|
+
top: -13px;
|
|
44
|
+
margin: 15px;
|
|
45
|
+
right: 0;
|
|
46
|
+
|
|
47
|
+
.nice-search-row {
|
|
48
|
+
padding: 10px 15px;
|
|
49
|
+
z-index: 1000;
|
|
50
|
+
width: 100%;
|
|
51
|
+
|
|
52
|
+
&:hover {
|
|
53
|
+
//color: white !important;
|
|
54
|
+
//background-color: $nice-base-color !important;
|
|
55
|
+
background-color: $nice-hover-color;
|
|
56
|
+
cursor: pointer;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
&.active {
|
|
60
|
+
// color: white;
|
|
61
|
+
background-color: $nice-hover-color;
|
|
62
|
+
cursor: pointer;
|
|
63
|
+
|
|
64
|
+
// p{color:white;}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
&:hover {
|
|
69
|
+
.active {
|
|
70
|
+
color: $text-color;
|
|
71
|
+
background-color: white;
|
|
72
|
+
|
|
73
|
+
p {
|
|
74
|
+
color: $text-color;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
.nice-dropdown-empty {
|
|
81
|
+
@extend .nice-dropdown;
|
|
82
|
+
top: -13px;
|
|
83
|
+
margin: 15px;
|
|
84
|
+
right: 0;
|
|
85
|
+
box-shadow: 0 6px 12px rgba(0, 0, 0, 0.175);
|
|
86
|
+
|
|
87
|
+
.nice-search-row {
|
|
88
|
+
opacity: 0.4;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
91
|
}
|