nice-elements 1.10.0 → 1.10.2

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nice-elements",
3
- "version": "1.10.0",
3
+ "version": "1.10.2",
4
4
  "description": "Nice elements used in olaii angular 1.x webapps.",
5
5
  "main": "dist/nice.js",
6
6
  "license": "MIT",
@@ -9,6 +9,8 @@
9
9
  "build": "./node_modules/.bin/grunt"
10
10
  },
11
11
  "dependencies": {
12
+ "@olaii/ng-infinite-scroll": "1.3.1",
13
+ "angular-infinite-scroll": "3.1.1",
12
14
  "@popperjs/core": "2.11.6",
13
15
  "angular": "1.5.8",
14
16
  "angular-animate": "1.5.8",
@@ -1,4 +1,4 @@
1
1
  <div class="nice-no-data" ng-class="{ 'nice-no-data-fulldiv': fulldiv }">
2
- <nice-icon class="nice-no-data-icon" icon="{{ icon }}" ng-if="icon"></nice-icon>
3
- <div class="nice-no-data-message" ng-transclude>{{ message }}</div>
2
+ <nice-icon class="nice-no-data-icon" icon="{{ innerIcon }}" ng-if="innerIcon"></nice-icon>
3
+ <div class="nice-no-data-message" ng-transclude>{{ innerMessage }}</div>
4
4
  </div>
@@ -15,12 +15,14 @@ angular.module('niceElements')
15
15
  replace: true,
16
16
  scope: {
17
17
  icon: '@?',
18
- message: '@',
19
- fulldiv: '@'
18
+ message: '@?',
19
+ fulldiv: '@?'
20
20
  },
21
21
  controller: function ($scope, gettextCatalog) {
22
- // if (!$scope.icon) $scope.icon = "icon-square";
23
- if (!$scope.message) $scope.message = gettextCatalog.getString("No data");
22
+ if ($scope.icon == "" || !$scope.icon) $scope.innerIcon = "icon-alert-circle";
23
+ else $scope.innerIcon = $scope.icon;
24
+ if ($scope.message == "" || !$scope.message) $scope.innerMessage = gettextCatalog.getString("No data");
25
+ else $scope.innerMessage = $scope.message;
24
26
  }
25
27
  };
26
28
  });
@@ -3,10 +3,16 @@
3
3
  flex-direction: column;
4
4
  align-items: center;
5
5
  justify-content: center;
6
- padding: 1rem;
6
+ padding: 2rem 1rem;
7
+ font-size: 0.9em;
7
8
  gap: 0.3rem;
8
9
  color: var(--nice-font-color);
9
- opacity: 0.6;
10
+ opacity: 0.5;
11
+ transition: opacity 0.3s ease;
12
+
13
+ &:hover {
14
+ opacity: 0.7;
15
+ }
10
16
 
11
17
  &.nice-no-data-fulldiv {
12
18
  position: absolute;
@@ -21,7 +27,5 @@
21
27
  width: 24px;
22
28
  }
23
29
 
24
- .nice-no-data-message {
25
- font-style: italic;
26
- }
30
+ .nice-no-data-message {}
27
31
  }
@@ -1,8 +1,17 @@
1
1
  <div class="nice-table-wrapper">
2
- <table class="nice-table">
2
+ <table class="nice-table" infinite-scroll='loadMore()' infinite-scroll-distance='1' infinite-scroll-disabled="loading || !data || !data._resultmeta || !data._resultmeta.next">
3
3
  <thead>
4
4
  <tr>
5
- <th ng-repeat="column in columns" ng-class="[column.class, handleFreeze($first, $last)]">{{ column.title }}</th>
5
+ <th
6
+ ng-repeat="column in columns"
7
+ ng-class="[column.class, handleFreeze(column, $first, $last, $index)]"
8
+ ng-click="setOrder(column.key)"
9
+ >
10
+ <div ng-class="{ 'nice-table-order': canOrder, 'nice-table-order-asc': order == column.key, 'nice-table-order-desc': order == '!' + column.key }">
11
+ <span>{{ column.title }}</span>
12
+ <nice-icon ng-if="order == column.key || order == '!' + column.key" icon="icon-bar-chart"></nice-icon>
13
+ </div>
14
+ </th>
6
15
  <th class="w-0 text-right" ng-if="hasActions">
7
16
  <span>{{ data.length }}</span>
8
17
  <span ng-if="data._resultmeta"> / {{ data._resultmeta.count }}</span>
@@ -11,18 +20,19 @@
11
20
  </thead>
12
21
 
13
22
  <tbody>
14
- <tr ng-repeat="row in data">
15
- <td ng-repeat="column in columns" ng-class="[column.class, handleFreeze($first, $last)]">
16
- <span ng-style="rowStyle(column, row)" ng-class="rowClass(column, row)" ng-if="column.formatter">{{ column.formatter(row[column.key], row) }}</span>
23
+ <tr ng-repeat="row in data | orderBy:order">
24
+ <td ng-repeat="column in columns" ng-class="[column.class, handleFreeze(column, $first, $last, $index)]">
25
+ <span ng-style="rowStyle(column, row)" ng-class="rowClass(column, row)" ng-if="column.formatter" ng-bind-html="column.formatter(row[column.key], row)"></span>
17
26
  <span ng-style="rowStyle(column, row)" ng-class="rowClass(column, row)" ng-if="!column.formatter">{{ row[column.key] }}</span>
18
27
  </td>
19
28
 
20
- <td class="w-0" ng-if="hasActions">
29
+ <td class="w-0" ng-if="hasActions" ng-class="{ 'nice-table-freeze-right': freezeLast }">
21
30
  <div class="nice-table-actions" ng-transclude></div>
22
31
  </td>
23
32
  </tr>
24
33
  </tbody>
25
34
  </table>
26
35
 
27
- <nice-no-data ng-if="!data || data.length == 0"></nice-no-data>
36
+ <nice-loader class="nice-table-loader" ng-if="loading"></nice-loader>
37
+ <nice-no-data ng-if="!loading && (!data || data.length == 0)" message="{{ noData }}" icon="{{ noDataIcon }}"></nice-no-data>
28
38
  </div>
@@ -12,16 +12,34 @@ angular.module('niceElements')
12
12
  templateUrl: 'src/components/nice-table/nice-table.html',
13
13
  restrict: 'E',
14
14
  transclude: true,
15
- replace: true,
16
15
  scope: {
17
16
  data: '=',
18
17
  columns: '=',
19
- freezeFirst: '@',
20
- freezeLast: '@',
18
+ loading: '=',
19
+ canOrder: '=?',
20
+ orderChanged: '&?',
21
+ order: '=?',
22
+ noData: '@?',
23
+ noDataIcon: '@?',
24
+ freezeFirst: '@?',
25
+ freezeLast: '@?',
26
+ loadMore: '&?'
21
27
  },
22
28
  controller: function ($scope, $transclude) {
23
29
  $scope.hasActions = $transclude().length > 0;
24
30
 
31
+ $scope.setOrder = function(key) {
32
+ if (!$scope.canOrder) return;
33
+ if ($scope.order == "!" + key) {
34
+ $scope.order = null;
35
+ } else if ($scope.order == key) {
36
+ $scope.order = "!" + key;
37
+ } else {
38
+ $scope.order = key;
39
+ }
40
+ if ($scope.orderChanged) $scope.orderChanged($scope.order);
41
+ }
42
+
25
43
  $scope.rowStyle = function(column, row) {
26
44
  if (!column.valueStyle) return;
27
45
  return column.valueStyle(row[column.key], row);
@@ -32,8 +50,11 @@ angular.module('niceElements')
32
50
  return column.valueClass(row[column.key], row);
33
51
  }
34
52
 
35
- $scope.handleFreeze = function(isFirst, isLast) {
36
- return { 'nice-table-freeze-first': $scope.freezeFirst && isFirst, 'nice-table-freeze-last': $scope.freezeLast && isLast }
53
+ $scope.handleFreeze = function(column, isFirst, isLast, index) {
54
+ return {
55
+ 'nice-table-freeze-left': ($scope.freezeFirst && isFirst) || column.freeze,
56
+ 'nice-table-freeze-right': $scope.freezeLast && isLast && !$scope.hasActions
57
+ }
37
58
  }
38
59
  }
39
60
  };
@@ -8,17 +8,21 @@
8
8
  border-collapse: collapse;
9
9
  border-spacing: 0;
10
10
  background: var(--nice-card-bg);
11
+ color: var(--nice-font-color);
11
12
 
12
- .nice-table-freeze-first {
13
+ .nice-table-freeze-left,
14
+ .nice-table-freeze-right {
13
15
  position: sticky;
16
+ background: var(--nice-card-bg-opacity);
17
+ backdrop-filter: blur(3px);
18
+ }
19
+
20
+ .nice-table-freeze-left {
14
21
  left: 0;
15
- background: var(--nice-card-bg);
16
22
  }
17
23
 
18
- .nice-table-freeze-last {
19
- position: sticky;
24
+ .nice-table-freeze-right {
20
25
  right: 0;
21
- background: var(--nice-card-bg);
22
26
  }
23
27
 
24
28
  .nice-table-actions {
@@ -34,8 +38,48 @@
34
38
  padding: 8px;
35
39
  vertical-align: bottom;
36
40
  text-transform: uppercase;
41
+ font-weight: normal;
37
42
  font-size: 12px;
38
43
  color: var(--nice-primary-color);
44
+
45
+ &.text-right {
46
+ .nice-table-order {
47
+ justify-content: flex-end;
48
+ }
49
+ }
50
+
51
+ &.text-center {
52
+ .nice-table-order {
53
+ justify-content: center;
54
+ }
55
+ }
56
+ }
57
+ }
58
+
59
+ .nice-table-order {
60
+ cursor: pointer;
61
+ display: flex;
62
+ align-items: center;
63
+ gap: 3px;
64
+
65
+ .nice-icon {
66
+ width: 14px;
67
+ height: 14px;
68
+ // transition: transform 0.3s ease;
69
+ transform: rotate(90deg);
70
+ }
71
+
72
+ &.nice-table-order-asc {
73
+ color: var(--nice-danger-color);
74
+ transition: transform 0.3s ease;
75
+ }
76
+
77
+ &.nice-table-order-desc {
78
+ color: var(--nice-danger-color);
79
+
80
+ .nice-icon {
81
+ transform: rotate(-90deg);
82
+ }
39
83
  }
40
84
  }
41
85
  }
@@ -45,8 +89,8 @@
45
89
  &:hover {
46
90
  background-color: var(--nice-hover-color);
47
91
 
48
- .nice-table-freeze-first,
49
- .nice-table-freeze-last {
92
+ .nice-table-freeze-left,
93
+ .nice-table-freeze-right {
50
94
  background-color: var(--nice-hover-color);
51
95
  }
52
96
  }
@@ -59,4 +103,10 @@
59
103
  }
60
104
  }
61
105
  }
106
+
107
+ .nice-table-loader {
108
+ padding: 2rem 1rem;
109
+ margin-top: -1px;
110
+ border-top: 1px solid var(--nice-border-color);
111
+ }
62
112
  }
@@ -1,11 +1,11 @@
1
- <div class="nice-component nice-toggle" ng-class="{ 'margin-bottom-0' : noMargin, 'nice-component-inline': isInline, 'active': model }" ng-form="formToggle">
1
+ <div class="nice-component nice-toggle" ng-class="{ 'margin-bottom-0' : noMargin, 'title-right': titleRight, 'nice-component-inline': isInline, 'nice-component-block': isBlock, 'active': model }" ng-form="formToggle">
2
2
  <div class="row">
3
3
  <!------------------------- Title ------------------------->
4
4
  <nice-title text="title" help="help" required="required" label-width="labelWidth"></nice-title>
5
5
 
6
6
  <!------------------------- Field ------------------------->
7
7
  <div class="nice-field col-xs-12" ng-class="[fieldWidth ? fieldWidth : 'col-sm-8', { 'nice-disabled': isDisabled }]">
8
- <button type="button" class="nice-toggle-field" ng-click="switch()" ng-disabled="isDisabled">
8
+ <button type="button" class="nice-toggle-field" ng-click="toggle()" ng-disabled="isDisabled">
9
9
  <div class="nice-toggle-field-handle">{{ state }}</div>
10
10
  </button>
11
11
  </div>
@@ -17,79 +17,36 @@ angular.module('niceElements')
17
17
  isDisabled: '=',
18
18
  fieldWidth: '@',
19
19
  labelWidth: '@',
20
- defaultFalse: '@',
21
20
  noMargin: '@',
22
21
  onChange: '&?',
23
22
  isInline: '=',
23
+ isBlock: '=',
24
+ titleRight: '=',
24
25
  help: '@'
25
26
  },
26
- controller: function ($scope) {
27
+ controller: function ($scope, $timeout) {
27
28
  if (!$scope.title) { $scope.title = ''; }
28
29
  if (!$scope.fieldWidth) { $scope.fieldWidth = 'col-sm-8'; }
29
30
  if (!$scope.labelWidth) { $scope.labelWidth = 'col-sm-4'; }
30
31
 
31
- // ------------------------- Set overlay button position based on passed state in $scope.model -------------------------
32
- $scope.setButtonPosition = function (state) {
33
- if (state) {
34
- $scope.buttonClass = "yesno-button-yes";
35
- } else {
36
- $scope.buttonClass = "yesno-button-no";
37
- }
38
- };
39
-
40
- // ------------------------- Watch for changes from outside -------------------------
41
- $scope.$watch('model', function (value_new, value_old) {
42
- if (angular.isDefined($scope.model)) {
43
- $scope.setButtonLabel($scope.model);
44
- $scope.setButtonPosition($scope.model);
45
- }
46
- });
47
-
48
- // ------------------------- Watch for model value -------------------------
49
- $scope.$watch('modelValue', function (value_new, value_old) {
50
- if ($scope.options) {
51
- $scope.model = $scope.modelValue == $scope.options[0];
52
- }
53
- });
54
-
55
- // ------------------------- Set button label -------------------------
56
- $scope.setButtonLabel = function (state) {
57
- if (state) {
58
- $scope.state = $scope.yes;
59
- } else {
60
- $scope.state = $scope.no;
61
- }
62
- };
63
-
64
- // ------------------------- Set width -------------------------
65
- $scope.setWidth = function (width, el) {
66
- el.style.width = width;
67
- };
68
-
69
-
70
32
  // ------------------------- Switch -------------------------
71
- $scope.switch = function () {
72
- if (!$scope.isDisabled) {
73
- $scope.model = !$scope.model;
33
+ $scope.toggle = function () {
34
+ if ($scope.isDisabled) return;
35
+ $scope.model = !$scope.model;
74
36
 
75
- if ($scope.options) {
76
- if ($scope.model) {
77
- $scope.modelValue = $scope.options[0];
78
- } else {
79
- $scope.modelValue = $scope.options[1];
80
- }
37
+ if ($scope.options) {
38
+ if ($scope.model) {
39
+ $scope.modelValue = $scope.options[0];
40
+ } else {
41
+ $scope.modelValue = $scope.options[1];
81
42
  }
43
+ }
82
44
 
45
+ $timeout(function() {
83
46
  if ($scope.onChange) $scope.onChange({ model: $scope.model });
84
47
  $scope.formToggle.$setDirty();
85
- }
48
+ });
86
49
  };
87
-
88
- // Call it first time
89
- $scope.setButtonPosition($scope.model);
90
-
91
- // Set label based on state passed in $scope.model
92
- $scope.setButtonLabel($scope.model);
93
50
  }
94
51
  };
95
52
  });
@@ -6,10 +6,38 @@
6
6
  }
7
7
 
8
8
  .nice-title {
9
- min-height: 27px;
9
+ min-height: 25px;
10
+ }
11
+
12
+ @media (max-width: 767px) {
13
+ .nice-field {
14
+ min-height: unset;
15
+ }
16
+ }
17
+
18
+ &.nice-component-block {
19
+ .nice-title {
20
+ min-height: unset;
21
+ }
22
+
23
+ .nice-field {
24
+ min-height: 34px;
25
+ display: flex;
26
+ align-items: center;
27
+ }
10
28
  }
11
29
 
12
30
  &.nice-component-inline {
31
+ nice-title {
32
+ display: block;
33
+
34
+ .nice-title {
35
+ min-height: unset;
36
+ }
37
+ }
38
+ }
39
+
40
+ &.title-right {
13
41
  .row {
14
42
  display: flex;
15
43
  align-items: center;
@@ -17,28 +45,33 @@
17
45
 
18
46
  nice-title {
19
47
  order: 2;
20
- }
48
+ flex-grow: 1;
21
49
 
22
- .nice-title {
23
- margin: 0;
24
- padding: 0;
25
- margin-left: 1rem;
26
- line-height: 25px;
50
+ .nice-title {
51
+ margin: 0;
52
+ padding: 0;
53
+ margin-left: 1rem;
54
+ text-align: left;
55
+ width: auto;
56
+ }
27
57
  }
28
58
 
29
59
  .nice-field {
30
60
  margin: 0;
31
61
  padding: 0;
62
+ flex-shrink: 0;
32
63
  width: auto;
33
64
  order: 1;
34
65
  }
35
66
  }
36
67
  }
37
68
 
69
+
38
70
  .nice-toggle-field {
71
+ display: block;
39
72
  border: 1px solid var(--nice-border-color);
40
73
  background: var(--nice-input-bg);
41
- border-radius: 1rem;
74
+ border-radius: 2rem;
42
75
  position: relative;
43
76
  width: 50px;
44
77
  height: 25px;
@@ -72,4 +105,24 @@
72
105
  }
73
106
  }
74
107
  }
108
+
109
+ &.nice-toggle-lg {
110
+ .nice-toggle-field {
111
+ width: 60px;
112
+ height: 30px;
113
+
114
+ .nice-toggle-field-handle {
115
+ top: 4px;
116
+ left: 4px;
117
+ width: 20px;
118
+ height: 20px;
119
+ }
120
+ }
121
+
122
+ &.active {
123
+ .nice-toggle-field-handle {
124
+ left: calc(100% - 24px);
125
+ }
126
+ }
127
+ }
75
128
  }
@@ -10,7 +10,7 @@ angular.module('niceElements')
10
10
  .service('NiceService', function () {
11
11
  var service = {
12
12
  name: "Nice elements",
13
- version: "1.10.0",
13
+ version: "1.10.2",
14
14
  getHeader: function () {
15
15
  return {};
16
16
  }
@@ -190,6 +190,7 @@ $nice-table-bg-active: #f5f5f5 !default;
190
190
  // ---------- Card ----------
191
191
  --nice-card-border: #{$nice-border-color};
192
192
  --nice-card-bg: white;
193
+ --nice-card-bg-opacity: rgba(255, 255, 255, 0.8);
193
194
  --nice-card-padding: 2rem;
194
195
 
195
196
  // ---------- Input ----------