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/CHANGELOG.md CHANGED
@@ -1,5 +1,20 @@
1
1
  # Changelog
2
2
 
3
+ ## v1.10.2 (3.4.2024)
4
+
5
+ - worked on nice-toggle component style,
6
+ - added isBlock and titleRight props to nice-toggle component
7
+
8
+ ## v1.10.1 (22.3.2024)
9
+
10
+ - added html bind to nice table column,
11
+ - added infinite load to nice table,
12
+ - added order columns to nice table,
13
+ - added loading, noData, noDataIcon and canOrder to nice table,
14
+ - added loadMore and orderChanged function to nice table,
15
+ - added @olaii/ng-infinite-scroll and angular-infinite-scroll deps,
16
+ - worked on nice no data
17
+
3
18
  ## v1.10.0 (22.3.2024)
4
19
 
5
20
  - created nice-table component,
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  ![Nice elements](https://github.com/Klemen1337/angularjs-nice-elements/raw/master/demo/assets/logo.png)
2
2
 
3
- # Nice elements v1.10.0
3
+ # Nice elements v1.10.2
4
4
 
5
5
  Nice elements is an AngularJS v1.5.8 module that contains nice form elements like inputs, choice fields, search, toggle, dropdown, etc.
6
6
 
package/bower.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
  "authors": ["Klemen Kastelic <klemen@olaii.com>"],
5
5
  "description": "Nice elements",
6
6
  "keywords": [],
package/dist/nice.js CHANGED
@@ -4026,12 +4026,14 @@ angular.module('niceElements')
4026
4026
  replace: true,
4027
4027
  scope: {
4028
4028
  icon: '@?',
4029
- message: '@',
4030
- fulldiv: '@'
4029
+ message: '@?',
4030
+ fulldiv: '@?'
4031
4031
  },
4032
4032
  controller: function ($scope, gettextCatalog) {
4033
- // if (!$scope.icon) $scope.icon = "icon-square";
4034
- if (!$scope.message) $scope.message = gettextCatalog.getString("No data");
4033
+ if ($scope.icon == "" || !$scope.icon) $scope.innerIcon = "icon-alert-circle";
4034
+ else $scope.innerIcon = $scope.icon;
4035
+ if ($scope.message == "" || !$scope.message) $scope.innerMessage = gettextCatalog.getString("No data");
4036
+ else $scope.innerMessage = $scope.message;
4035
4037
  }
4036
4038
  };
4037
4039
  });
@@ -5255,16 +5257,34 @@ angular.module('niceElements')
5255
5257
  templateUrl: 'src/components/nice-table/nice-table.html',
5256
5258
  restrict: 'E',
5257
5259
  transclude: true,
5258
- replace: true,
5259
5260
  scope: {
5260
5261
  data: '=',
5261
5262
  columns: '=',
5262
- freezeFirst: '@',
5263
- freezeLast: '@',
5263
+ loading: '=',
5264
+ canOrder: '=?',
5265
+ orderChanged: '&?',
5266
+ order: '=?',
5267
+ noData: '@?',
5268
+ noDataIcon: '@?',
5269
+ freezeFirst: '@?',
5270
+ freezeLast: '@?',
5271
+ loadMore: '&?'
5264
5272
  },
5265
5273
  controller: function ($scope, $transclude) {
5266
5274
  $scope.hasActions = $transclude().length > 0;
5267
5275
 
5276
+ $scope.setOrder = function(key) {
5277
+ if (!$scope.canOrder) return;
5278
+ if ($scope.order == "!" + key) {
5279
+ $scope.order = null;
5280
+ } else if ($scope.order == key) {
5281
+ $scope.order = "!" + key;
5282
+ } else {
5283
+ $scope.order = key;
5284
+ }
5285
+ if ($scope.orderChanged) $scope.orderChanged($scope.order);
5286
+ }
5287
+
5268
5288
  $scope.rowStyle = function(column, row) {
5269
5289
  if (!column.valueStyle) return;
5270
5290
  return column.valueStyle(row[column.key], row);
@@ -5275,8 +5295,11 @@ angular.module('niceElements')
5275
5295
  return column.valueClass(row[column.key], row);
5276
5296
  }
5277
5297
 
5278
- $scope.handleFreeze = function(isFirst, isLast) {
5279
- return { 'nice-table-freeze-first': $scope.freezeFirst && isFirst, 'nice-table-freeze-last': $scope.freezeLast && isLast }
5298
+ $scope.handleFreeze = function(column, isFirst, isLast, index) {
5299
+ return {
5300
+ 'nice-table-freeze-left': ($scope.freezeFirst && isFirst) || column.freeze,
5301
+ 'nice-table-freeze-right': $scope.freezeLast && isLast && !$scope.hasActions
5302
+ }
5280
5303
  }
5281
5304
  }
5282
5305
  };
@@ -5463,79 +5486,36 @@ angular.module('niceElements')
5463
5486
  isDisabled: '=',
5464
5487
  fieldWidth: '@',
5465
5488
  labelWidth: '@',
5466
- defaultFalse: '@',
5467
5489
  noMargin: '@',
5468
5490
  onChange: '&?',
5469
5491
  isInline: '=',
5492
+ isBlock: '=',
5493
+ titleRight: '=',
5470
5494
  help: '@'
5471
5495
  },
5472
- controller: function ($scope) {
5496
+ controller: function ($scope, $timeout) {
5473
5497
  if (!$scope.title) { $scope.title = ''; }
5474
5498
  if (!$scope.fieldWidth) { $scope.fieldWidth = 'col-sm-8'; }
5475
5499
  if (!$scope.labelWidth) { $scope.labelWidth = 'col-sm-4'; }
5476
5500
 
5477
- // ------------------------- Set overlay button position based on passed state in $scope.model -------------------------
5478
- $scope.setButtonPosition = function (state) {
5479
- if (state) {
5480
- $scope.buttonClass = "yesno-button-yes";
5481
- } else {
5482
- $scope.buttonClass = "yesno-button-no";
5483
- }
5484
- };
5485
-
5486
- // ------------------------- Watch for changes from outside -------------------------
5487
- $scope.$watch('model', function (value_new, value_old) {
5488
- if (angular.isDefined($scope.model)) {
5489
- $scope.setButtonLabel($scope.model);
5490
- $scope.setButtonPosition($scope.model);
5491
- }
5492
- });
5493
-
5494
- // ------------------------- Watch for model value -------------------------
5495
- $scope.$watch('modelValue', function (value_new, value_old) {
5496
- if ($scope.options) {
5497
- $scope.model = $scope.modelValue == $scope.options[0];
5498
- }
5499
- });
5500
-
5501
- // ------------------------- Set button label -------------------------
5502
- $scope.setButtonLabel = function (state) {
5503
- if (state) {
5504
- $scope.state = $scope.yes;
5505
- } else {
5506
- $scope.state = $scope.no;
5507
- }
5508
- };
5509
-
5510
- // ------------------------- Set width -------------------------
5511
- $scope.setWidth = function (width, el) {
5512
- el.style.width = width;
5513
- };
5514
-
5515
-
5516
5501
  // ------------------------- Switch -------------------------
5517
- $scope.switch = function () {
5518
- if (!$scope.isDisabled) {
5519
- $scope.model = !$scope.model;
5502
+ $scope.toggle = function () {
5503
+ if ($scope.isDisabled) return;
5504
+ $scope.model = !$scope.model;
5520
5505
 
5521
- if ($scope.options) {
5522
- if ($scope.model) {
5523
- $scope.modelValue = $scope.options[0];
5524
- } else {
5525
- $scope.modelValue = $scope.options[1];
5526
- }
5506
+ if ($scope.options) {
5507
+ if ($scope.model) {
5508
+ $scope.modelValue = $scope.options[0];
5509
+ } else {
5510
+ $scope.modelValue = $scope.options[1];
5527
5511
  }
5512
+ }
5528
5513
 
5514
+ $timeout(function() {
5529
5515
  if ($scope.onChange) $scope.onChange({ model: $scope.model });
5530
5516
  $scope.formToggle.$setDirty();
5531
- }
5517
+ });
5532
5518
  };
5533
-
5534
- // Call it first time
5535
- $scope.setButtonPosition($scope.model);
5536
-
5537
- // Set label based on state passed in $scope.model
5538
- $scope.setButtonLabel($scope.model);
5539
5519
  }
5540
5520
  };
5541
5521
  });
@@ -5923,7 +5903,7 @@ angular.module('niceElements')
5923
5903
  .service('NiceService', function () {
5924
5904
  var service = {
5925
5905
  name: "Nice elements",
5926
- version: "1.10.0",
5906
+ version: "1.10.2",
5927
5907
  getHeader: function () {
5928
5908
  return {};
5929
5909
  }
@@ -5999,7 +5979,7 @@ angular.module('niceElements')
5999
5979
  };
6000
5980
  });
6001
5981
 
6002
- angular.module('niceElements').run(['$templateCache', function($templateCache) {
5982
+ angular.module('niceElements').run(['$templateCache', function($templateCache) {
6003
5983
  'use strict';
6004
5984
 
6005
5985
  $templateCache.put('src/components/nice-button-toggle/nice-button-toggle.html',
@@ -6706,8 +6686,8 @@ angular.module('niceElements').run(['$templateCache', function($templateCache) {
6706
6686
 
6707
6687
  $templateCache.put('src/components/nice-no-data/nice-no-data.html',
6708
6688
  "<div class=\"nice-no-data\" ng-class=\"{ 'nice-no-data-fulldiv': fulldiv }\">\n" +
6709
- "<nice-icon class=\"nice-no-data-icon\" icon=\"{{ icon }}\" ng-if=\"icon\"></nice-icon>\n" +
6710
- "<div class=\"nice-no-data-message\" ng-transclude>{{ message }}</div>\n" +
6689
+ "<nice-icon class=\"nice-no-data-icon\" icon=\"{{ innerIcon }}\" ng-if=\"innerIcon\"></nice-icon>\n" +
6690
+ "<div class=\"nice-no-data-message\" ng-transclude>{{ innerMessage }}</div>\n" +
6711
6691
  "</div>"
6712
6692
  );
6713
6693
 
@@ -7898,10 +7878,15 @@ angular.module('niceElements').run(['$templateCache', function($templateCache) {
7898
7878
 
7899
7879
  $templateCache.put('src/components/nice-table/nice-table.html',
7900
7880
  "<div class=\"nice-table-wrapper\">\n" +
7901
- "<table class=\"nice-table\">\n" +
7881
+ "<table class=\"nice-table\" infinite-scroll=\"loadMore()\" infinite-scroll-distance=\"1\" infinite-scroll-disabled=\"loading || !data || !data._resultmeta || !data._resultmeta.next\">\n" +
7902
7882
  "<thead>\n" +
7903
7883
  "<tr>\n" +
7904
- "<th ng-repeat=\"column in columns\" ng-class=\"[column.class, handleFreeze($first, $last)]\">{{ column.title }}</th>\n" +
7884
+ "<th ng-repeat=\"column in columns\" ng-class=\"[column.class, handleFreeze(column, $first, $last, $index)]\" ng-click=\"setOrder(column.key)\">\n" +
7885
+ "<div ng-class=\"{ 'nice-table-order': canOrder, 'nice-table-order-asc': order == column.key, 'nice-table-order-desc': order == '!' + column.key }\">\n" +
7886
+ "<span>{{ column.title }}</span>\n" +
7887
+ "<nice-icon ng-if=\"order == column.key || order == '!' + column.key\" icon=\"icon-bar-chart\"></nice-icon>\n" +
7888
+ "</div>\n" +
7889
+ "</th>\n" +
7905
7890
  "<th class=\"w-0 text-right\" ng-if=\"hasActions\">\n" +
7906
7891
  "<span>{{ data.length }}</span>\n" +
7907
7892
  "<span ng-if=\"data._resultmeta\">/ {{ data._resultmeta.count }}</span>\n" +
@@ -7909,18 +7894,19 @@ angular.module('niceElements').run(['$templateCache', function($templateCache) {
7909
7894
  "</tr>\n" +
7910
7895
  "</thead>\n" +
7911
7896
  "<tbody>\n" +
7912
- "<tr ng-repeat=\"row in data\">\n" +
7913
- "<td ng-repeat=\"column in columns\" ng-class=\"[column.class, handleFreeze($first, $last)]\">\n" +
7914
- "<span ng-style=\"rowStyle(column, row)\" ng-class=\"rowClass(column, row)\" ng-if=\"column.formatter\">{{ column.formatter(row[column.key], row) }}</span>\n" +
7897
+ "<tr ng-repeat=\"row in data | orderBy:order\">\n" +
7898
+ "<td ng-repeat=\"column in columns\" ng-class=\"[column.class, handleFreeze(column, $first, $last, $index)]\">\n" +
7899
+ "<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>\n" +
7915
7900
  "<span ng-style=\"rowStyle(column, row)\" ng-class=\"rowClass(column, row)\" ng-if=\"!column.formatter\">{{ row[column.key] }}</span>\n" +
7916
7901
  "</td>\n" +
7917
- "<td class=\"w-0\" ng-if=\"hasActions\">\n" +
7902
+ "<td class=\"w-0\" ng-if=\"hasActions\" ng-class=\"{ 'nice-table-freeze-right': freezeLast }\">\n" +
7918
7903
  "<div class=\"nice-table-actions\" ng-transclude></div>\n" +
7919
7904
  "</td>\n" +
7920
7905
  "</tr>\n" +
7921
7906
  "</tbody>\n" +
7922
7907
  "</table>\n" +
7923
- "<nice-no-data ng-if=\"!data || data.length == 0\"></nice-no-data>\n" +
7908
+ "<nice-loader class=\"nice-table-loader\" ng-if=\"loading\"></nice-loader>\n" +
7909
+ "<nice-no-data ng-if=\"!loading && (!data || data.length == 0)\" message=\"{{ noData }}\" icon=\"{{ noDataIcon }}\"></nice-no-data>\n" +
7924
7910
  "</div>\n"
7925
7911
  );
7926
7912
 
@@ -7987,11 +7973,11 @@ angular.module('niceElements').run(['$templateCache', function($templateCache) {
7987
7973
 
7988
7974
 
7989
7975
  $templateCache.put('src/components/nice-toggle/nice-toggle.html',
7990
- "<div class=\"nice-component nice-toggle\" ng-class=\"{ 'margin-bottom-0' : noMargin, 'nice-component-inline': isInline, 'active': model }\" ng-form=\"formToggle\">\n" +
7976
+ "<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\">\n" +
7991
7977
  "<div class=\"row\">\n" +
7992
7978
  "<nice-title text=\"title\" help=\"help\" required=\"required\" label-width=\"labelWidth\"></nice-title>\n" +
7993
7979
  "<div class=\"nice-field col-xs-12\" ng-class=\"[fieldWidth ? fieldWidth : 'col-sm-8', { 'nice-disabled': isDisabled }]\">\n" +
7994
- "<button type=\"button\" class=\"nice-toggle-field\" ng-click=\"switch()\" ng-disabled=\"isDisabled\">\n" +
7980
+ "<button type=\"button\" class=\"nice-toggle-field\" ng-click=\"toggle()\" ng-disabled=\"isDisabled\">\n" +
7995
7981
  "<div class=\"nice-toggle-field-handle\">{{ state }}</div>\n" +
7996
7982
  "</button>\n" +
7997
7983
  "</div>\n" +
@@ -8082,5 +8068,5 @@ angular.module('niceElements').run(['$templateCache', function($templateCache) {
8082
8068
  "</div>\n" +
8083
8069
  "</div>"
8084
8070
  );
8085
-
8086
- }]);
8071
+
8072
+ }]);