123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100 |
- /**
- * 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.toolbarTitle = null;
-
- 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)
- {
- AppUtilsBusiness.toolbarTitle = title;
- $rootScope.$emit('toolbar.title', {title: title});
- };
-
- AppUtilsBusiness.getToolbarTitle = function()
- {
- return AppUtilsBusiness.toolbarTitle;
- };
-
- 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;
- }
- });
- };
-
- AppUtilsBusiness.articleTypes = ['persons', 'locations', 'countries'];
-
- AppUtilsBusiness.articleFieldTypes = ['date/date', 'text/plain', 'number/number'];
-
- AppUtilsBusiness.articleFieldProperties = ['birthDate', 'deathDate', 'capital', 'language', 'area', 'population'];
-
- return AppUtilsBusiness;
- }]);
- })();
|