1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586 |
- /**
- * Created by robin on 12/15/16.
- */
-
- (function () {
- 'use strict';
-
- angular.module('appSdk')
- .factory('AppUtilsBusiness', ['$rootScope', '$translate', 'luBusyBusiness', 'luRequest',
- function($rootScope, $translate, luBusyBusiness, luRequest) {
-
- var AppUtilsBusiness = {};
-
- AppUtilsBusiness.convertOrderBy = function(orderBy)
- {
- if (orderBy[0] == '-') {
- orderBy = orderBy.substr(1) + ":DESC";
- }
- else {
- orderBy = orderBy + ":ASC";
- }
- return orderBy;
- };
-
- AppUtilsBusiness.setTitle = function(title)
- {
- $rootScope.title = title + ' - ' + AppUtilsBusiness.tr('common.appName');
- };
-
- AppUtilsBusiness.setToolbarTitle = function(title)
- {
- $rootScope.$emit('toolbar.title', {title: title});
- };
-
- AppUtilsBusiness.mdTableLabels = function()
- {
- return {
- of: AppUtilsBusiness.tr('common.pagination.of'),
- page: AppUtilsBusiness.tr('common.pagination.page'),
- rowsPerPage: AppUtilsBusiness.tr('common.pagination.rowsPerPage')
- };
- };
-
- AppUtilsBusiness.cgBusy = function(luBusyGroup)
- {
- return {
- promise: luBusyBusiness.promise(luBusyGroup),
- message: AppUtilsBusiness.tr('common.busyLoading'),
- templateUrl:'views/busy-template.html'
- };
- };
-
- AppUtilsBusiness.tr = function(id, data)
- {
- return $translate.instant(id, data);
- };
-
- AppUtilsBusiness.addApiVersionChangedCallback = function(callback)
- {
- var apiVersion = null;
- luRequest.addHook('resolve', function(url, method, dataGet, dataPost, luBusyGroups, data)
- {
- if (apiVersion == null) {
- apiVersion = data.version;
- }
- else if (data.version != null && data.version != apiVersion) {
- callback(apiVersion, data.version);
- apiVersion = data.version;
- }
- });
-
- luRequest.addHook('reject', function(url, method, dataGet, dataPost, luBusyGroups, error)
- {
- if (apiVersion == null) {
- apiVersion = error.data.version;
- }
- else if (error.data.version != null && error.data.version != apiVersion) {
- callback(apiVersion, error.data.version);
- apiVersion = error.data.version;
- }
- });
- };
-
- return AppUtilsBusiness;
- }]);
- })();
|