You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

apputils.business.js 2.9KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. /**
  2. * Created by robin on 12/15/16.
  3. */
  4. (function () {
  5. 'use strict';
  6. angular.module('appSdk')
  7. .factory('AppUtilsBusiness', ['$rootScope', '$translate', 'luBusyBusiness', 'luRequest',
  8. function($rootScope, $translate, luBusyBusiness, luRequest) {
  9. var AppUtilsBusiness = {};
  10. AppUtilsBusiness.convertOrderBy = function(orderBy)
  11. {
  12. if (orderBy[0] == '-') {
  13. orderBy = orderBy.substr(1) + ":DESC";
  14. }
  15. else {
  16. orderBy = orderBy + ":ASC";
  17. }
  18. return orderBy;
  19. };
  20. AppUtilsBusiness.setTitle = function(title)
  21. {
  22. $rootScope.title = title + ' - ' + AppUtilsBusiness.tr('common.appName');
  23. };
  24. AppUtilsBusiness.setToolbarTitle = function(title)
  25. {
  26. $rootScope.$emit('toolbar.title', {title: title});
  27. };
  28. AppUtilsBusiness.mdTableLabels = function()
  29. {
  30. return {
  31. of: AppUtilsBusiness.tr('common.pagination.of'),
  32. page: AppUtilsBusiness.tr('common.pagination.page'),
  33. rowsPerPage: AppUtilsBusiness.tr('common.pagination.rowsPerPage')
  34. };
  35. };
  36. AppUtilsBusiness.cgBusy = function(luBusyGroup)
  37. {
  38. return {
  39. promise: luBusyBusiness.promise(luBusyGroup),
  40. message: AppUtilsBusiness.tr('common.busyLoading'),
  41. templateUrl:'views/busy-template.html'
  42. };
  43. };
  44. AppUtilsBusiness.tr = function(id, data)
  45. {
  46. return $translate.instant(id, data);
  47. };
  48. AppUtilsBusiness.addApiVersionChangedCallback = function(callback)
  49. {
  50. var apiVersion = null;
  51. luRequest.addHook('resolve', function(url, method, dataGet, dataPost, luBusyGroups, data)
  52. {
  53. if (apiVersion == null) {
  54. apiVersion = data.version;
  55. }
  56. else if (data.version != null && data.version != apiVersion) {
  57. callback(apiVersion, data.version);
  58. apiVersion = data.version;
  59. }
  60. });
  61. luRequest.addHook('reject', function(url, method, dataGet, dataPost, luBusyGroups, error)
  62. {
  63. if (apiVersion == null) {
  64. apiVersion = error.data.version;
  65. }
  66. else if (error.data.version != null && error.data.version != apiVersion) {
  67. callback(apiVersion, error.data.version);
  68. apiVersion = error.data.version;
  69. }
  70. });
  71. };
  72. return AppUtilsBusiness;
  73. }]);
  74. })();