;\r\n\r\n constructor() {\r\n this.controller = InformationController;\r\n this.templateUrl = './dist/app/information/information.template.html';\r\n this.bindings = {\r\n trans: '<'\r\n }\r\n }\r\n}","\r\n/* section: Language\r\n class Template\r\n\r\n A class for sophisticated string interpolation.\r\n\r\n Any time you have a group of similar objects and you need to produce\r\n formatted output for these objects, maybe inside a loop, you typically\r\n resort to concatenating string literals with the object's fields:\r\n\r\n \"The TV show \" + title + \" was created by \" + author + \".\";\r\n\r\n There's nothing wrong with this approach, except that it is hard to\r\n visualize the output immediately just by glancing at the concatenation\r\n expression. The [[Template]] class provides a much nicer and clearer way of\r\n achieving this formatting.\r\n\r\n ##### Straightforward templates\r\n\r\n The [[Template]] class uses a basic formatting syntax, similar to what is\r\n used in Ruby. The templates are created from strings that have embedded\r\n symbols in the form (e.g., `#{fieldName}`) that will be replaced by\r\n actual values when the template is applied (evaluated) to an object.\r\n\r\n // the template (our formatting expression)\r\n var myTemplate = new Template(\r\n \"The TV show #{title} was created by #{author}.\");\r\n\r\n // our data to be formatted by the template\r\n var show = {\r\n title: \"The Simpsons\",\r\n author: \"Matt Groening\",\r\n network: \"FOX\"\r\n };\r\n\r\n // let\"s format our data\r\n myTemplate.evaluate(show);\r\n // -> \"The TV show The Simpsons was created by Matt Groening.\"\r\n\r\n ##### Templates are meant to be reused\r\n\r\n As the example illustrates, [[Template]] objects are not tied to specific\r\n data. The data is bound to the template only during the evaluation of the\r\n template, without affecting the template itself. The next example shows the\r\n same template being used with a handful of distinct objects.\r\n\r\n // creating a few similar objects\r\n var conversion1 = { from: \"meters\", to: \"feet\", factor: 3.28 };\r\n var conversion2 = { from: \"kilojoules\", to: \"BTUs\", factor: 0.9478 };\r\n var conversion3 = { from: \"megabytes\", to: \"gigabytes\", factor: 1024 };\r\n\r\n // the template\r\n var templ = new Template(\r\n \"Multiply by #{factor} to convert from #{from} to #{to}.\");\r\n\r\n // let's format each object\r\n [conversion1, conversion2, conversion3].each( function(conv){\r\n templ.evaluate(conv);\r\n });\r\n // -> Multiply by 3.28 to convert from meters to feet.\r\n // -> Multiply by 0.9478 to convert from kilojoules to BTUs.\r\n // -> Multiply by 1024 to convert from megabytes to gigabytes.\r\n\r\n ##### Escape sequence\r\n\r\n There's always the chance that one day you'll need to have a literal in your\r\n template that looks like a symbol, but is not supposed to be replaced. For\r\n these situations there's an escape character: the backslash (`\\\\`).\r\n\r\n // NOTE: you're seeing two backslashes here because the backslash\r\n // is also an escape character in JavaScript strings, so a literal\r\n // backslash is represented by two backslashes.\r\n var t = new Template(\r\n \"in #{lang} we also use the \\\\#{variable} syntax for templates.\");\r\n var data = { lang:\"Ruby\", variable: \"(not used)\" };\r\n t.evaluate(data);\r\n // -> in Ruby we also use the #{variable} syntax for templates.\r\n\r\n ##### Custom syntaxes\r\n\r\n The default syntax of the template strings will probably be enough for most\r\n scenarios. In the rare occasion where the default Ruby-like syntax is\r\n inadequate, there's a provision for customization. [[Template]]'s\r\n constructor accepts an optional second argument that is a regular expression\r\n object to match the replaceable symbols in the template string. Let's put\r\n together a template that uses a syntax similar to the now ubiquitous `{{ }}`\r\n constructs:\r\n\r\n // matches symbols like \"{{ field }}\"\r\n var syntax = /(^|.|\\r|\\n)(\\{{\\s*(\\w+)\\s*}})/;\r\n\r\n var t = new Template(\r\n \"Name: {{ name }}, Age: {{ age }}
\",\r\n syntax);\r\n t.evaluate( {name: \"John Smith\", age: 26} );\r\n // -> Name: John Smith, Age: 26
\r\n\r\n There are important constraints to any custom syntax. Any syntax must\r\n provide at least three groupings in the regular expression. The first\r\n grouping is to capture what comes before the symbol, to detect the backslash\r\n escape character (no, you cannot use a different character). The second\r\n grouping captures the entire symbol and will be completely replaced upon\r\n evaluation. Lastly, the third required grouping captures the name of the\r\n field inside the symbol.\r\n\r\n*/\r\nexport default class Template {\r\n private template: string;\r\n\r\n /* new Template(template[, pattern = Template.Pattern])\r\n\r\n Creates a Template object.\r\n\r\n The optional `pattern` argument expects a `RegExp` that defines a custom\r\n syntax for the replaceable symbols in `template`.\r\n */\r\n constructor(template: string, private pattern: RegExp = /(^|.|\\r|\\n)(#\\{(.*?)\\})/) {\r\n this.template = template.toString();\r\n }\r\n\r\n /* Template#evaluate(object) -> String\r\n\r\n Applies the template to `object`'s data, producing a formatted string\r\n with symbols replaced by `object`'s corresponding properties.\r\n\r\n ##### Examples\r\n\r\n var hrefTemplate = new Template(\"/dir/showAll?lang=#{language}&categ=#{category}&lv=#{levels}\");\r\n var selection = {category: \"books\" , language: \"en-US\"};\r\n\r\n hrefTemplate.evaluate(selection);\r\n // -> \"/dir/showAll?lang=en-US&categ=books&lv=\"\r\n\r\n hrefTemplate.evaluate({language: \"jp\", levels: 3, created: \"10/12/2005\"});\r\n // -> \"/dir/showAll?lang=jp&categ=&lv=3\"\r\n\r\n hrefTemplate.evaluate({});\r\n // -> \"/dir/showAll?lang=&categ=&lv=\"\r\n\r\n hrefTemplate.evaluate(null);\r\n // -> error !\r\n */\r\n public evaluate(object: any): RegExpExecArray {\r\n if (object && Template.isFunction(object.toTemplateReplacements)) {\r\n object = object.toObject();\r\n }\r\n\r\n return Template.gsub(object, this.pattern, function (match: any): any {\r\n if (object == null) {\r\n return (match[1] + \"\");\r\n }\r\n\r\n var before: string = match[1] || \"\";\r\n if (before === \"\\\\\") {\r\n return match[2];\r\n }\r\n\r\n var ctx: any = object, expr: any = match[3],\r\n pattern: RegExp = /^([^.[]+|\\[((?:.*?[^\\\\])?)\\])(\\.|\\[|$)/;\r\n\r\n match = pattern.exec(expr);\r\n if (match == null) {\r\n return before;\r\n }\r\n\r\n while (match != null) {\r\n var comp: string = (match[1]).startsWith(\"[\") ? match[2].replace(/\\\\\\\\]/g, \"]\") : match[1];\r\n ctx = ctx[comp];\r\n\r\n if (null == ctx || \"\" === match[3]) {\r\n break;\r\n }\r\n\r\n expr = expr.substring(\"[\" === match[3] ? match[1].length : match[0].length);\r\n match = pattern.exec(expr);\r\n }\r\n\r\n\r\n return before + this.interpret(ctx);\r\n });\r\n }\r\n\r\n public static interpret(value: string): string {\r\n return value == null ? \"\" : String(value);\r\n }\r\n\r\n public static prepareReplacement(replacement: any): any {\r\n if (typeof replacement === \"function\") {\r\n return replacement;\r\n }\r\n\r\n var template: Template = new Template(replacement);\r\n\r\n return (match: RegExpExecArray): RegExpExecArray => template.evaluate(match);\r\n }\r\n\r\n public static isString(obj: any): boolean {\r\n var getType: any = {};\r\n return obj && getType.toString.call(obj) === \"[object String]\";\r\n }\r\n\r\n public static isFunction(obj: any): boolean {\r\n var getType: any = {};\r\n return obj && getType.toString.call(obj) === \"[object Function]\";\r\n }\r\n\r\n public static isNonEmptyRegExp(regexp: RegExp): boolean {\r\n return regexp.source && regexp.source !== \"(?:)\";\r\n }\r\n\r\n public static escape(str: string): string {\r\n return String(str).replace(/([.*+?^=!:${}()|[\\]\\/\\\\])/g, \"\\\\$1\");\r\n }\r\n\r\n public static gsub(text: any, pattern: any, replacement: any): any {\r\n var result: string = \"\", source: any = text, match: any;\r\n replacement = this.prepareReplacement(replacement);\r\n\r\n\r\n if (this.isString(pattern)) {\r\n pattern = this.escape(pattern);\r\n }\r\n\r\n if (!(pattern.length || this.isNonEmptyRegExp(pattern))) {\r\n replacement = replacement(\"\");\r\n return replacement + source.split(\"\").join(replacement) + replacement;\r\n }\r\n\r\n\r\n while (source.length > 0) {\r\n match = source.match(pattern);\r\n\r\n if (match && match[0].length > 0) {\r\n result += source.slice(0, match.index);\r\n result += this.interpret(replacement(match));\r\n source = source.slice(match.index + match[0].length);\r\n } else {\r\n result += source || \"\";\r\n }\r\n }\r\n return result;\r\n }\r\n}","/// \r\n/// \r\n/// \r\n\r\nimport { module } from \"angular\";\r\nimport IBDate, { DateCompareGranularities } from \"../core/IBDate\";\r\nimport BaseService from \"../services/base/BaseService\";\r\nimport { ArticleInformation } from \"./model/ArticleInformation\";\r\n\r\nexport default class OrderingArticleInformationService extends BaseService {\r\n\r\n static $inject = [\"$http\", \"$cacheFactory\", \"$q\", \"$rootScope\", \"$log\", \"appSettings\"];\r\n\r\n constructor($http: ng.IHttpService,\r\n $cacheFactory: ng.ICacheFactoryService,\r\n $q: ng.IQService,\r\n $rootScope: ng.IRootScopeService,\r\n $log: ng.ILogService,\r\n appSettings: any,\r\n apiUrlFragment: string) {\r\n super($http, $cacheFactory, $q, $rootScope, $log, appSettings, apiUrlFragment);\r\n this.baseUrl = `${appSettings.SERVICE_URL}/api/v1.0`;\r\n }\r\n\r\n getSingleByCustomerAndArticleAndDeliveryDate(customerId: number, articleId: number, deliveryDate: IBDate, languageId: number = 1): ng.IPromise {\r\n return this.getOneByUrlPart(`${this.apiUrlFragment}/customer/${customerId}/article/${articleId}/deliverydate/${deliveryDate.toJSONDate()}`);\r\n }\r\n\r\n public static Factory($http: ng.IHttpService,\r\n $cacheFactory: ng.ICacheFactoryService,\r\n $q: ng.IQService,\r\n $rootScope: ng.IRootScopeService,\r\n $log: ng.ILogService,\r\n appSettings: any): OrderingArticleInformationService {\r\n return new OrderingArticleInformationService($http, $cacheFactory, $q, $rootScope, $log, appSettings, \"orderingArticleInformations\");\r\n }\r\n}","/// \r\n/// \r\n\r\nimport { module, element } from \"angular\";\r\nimport SpinnerService from \"../services/SpinnerService\";\r\n\r\nexport default class SmartTableResetSearchOnDirective implements ng.IDirective {\r\n public restrict: string = \"A\";\r\n public scope: boolean = true;\r\n public replace: boolean = false;\r\n //public require: string[] = [\"^stTable\", \"ngModel\"];\r\n public require: string = \"^stTable\";\r\n\r\n constructor(private $timeout: ng.ITimeoutService, private stConfig: any) { }\r\n\r\n public link: ng.IDirectiveLinkFn = (scope: ng.IScope, elem: JQLite, attributes: ng.IAttributes, ctrl: any) => {\r\n let self = this;\r\n let stTableCtrl = ctrl;\r\n let event = attributes['stResetSearchOn'];\r\n scope.$on(event, (event: ng.IAngularEvent, args: any[]) => {\r\n let e = elem;\r\n let e1 = elem[0] as HTMLInputElement;\r\n\r\n if (e1 != undefined) {\r\n e1.value = \"\";\r\n }\r\n\r\n let tableState = stTableCtrl.tableState();\r\n tableState.search.predicateObject = {};\r\n tableState.pagination.start = 0;\r\n ctrl.pipe();\r\n });\r\n };\r\n\r\n public static Factory(): ng.IDirectiveFactory {\r\n let d = ($timeout: ng.ITimeoutService, stConfig: any) => new SmartTableResetSearchOnDirective($timeout, stConfig);\r\n d.$inject = ['$timeout', 'stConfig'];\r\n return d;\r\n }\r\n}","/// \r\n/// \r\n/// \r\n\r\nimport { module } from \"angular\";\r\nimport IBDate from \"../core/IBDate\";\r\nimport BaseService from \"../services/base/BaseService\";\r\nimport HtmlStorageService from \"../services/HtmlStorageService\";\r\nimport UserService from \"../services/UserService\";\r\nimport SpinnerService from \"../services/SpinnerService\";\r\nimport IHttpPromiseError from \"../core/IHttpPromiseError\";\r\nimport { IStateOptions } from \"angular-ui-router\";\r\nimport { toJson } from \"@uirouter/core\";\r\n\r\nexport default class AuthenticationService {\r\n\r\n static $inject = [\"$http\", \"$rootScope\", \"$state\", \"$timeout\", \"$q\", \"$log\", \"htmlStorageService\", \"userService\", \"spinnerService\", \"appSettings\"];\r\n\r\n protected baseUrl: string;\r\n\r\n constructor(private $http: ng.IHttpService,\r\n private $rootScope: ng.IRootScopeService,\r\n private $state: angular.ui.IStateService,\r\n private $timeout: ng.ITimeoutService,\r\n private $q: ng.IQService,\r\n private $log: ng.ILogService,\r\n private htmlStorageService: HtmlStorageService,\r\n private userService: UserService,\r\n private spinnerService: SpinnerService,\r\n private appSettings: any) {\r\n\r\n this.baseUrl = `${appSettings.SERVICE_URL}/api/v1.0/`;\r\n }\r\n\r\n isAuthenticated(): boolean {\r\n let token: string = this.htmlStorageService.getSessionStorageItem(\"token\") as string;\r\n return (token) ? true : false;\r\n }\r\n\r\n //signinUser(username: string, password: string, rememberMe: boolean): ng.IPromise {\r\n // let defer = this.$q.defer();\r\n\r\n // this.signoutUser(false, true).finally(() => {\r\n // var authInfo = btoa(encodeURI(`${username}:${password}`));\r\n\r\n // console.debug(`Logging in user ${username}`);\r\n\r\n // this.$http.get(`${this.baseUrl}Authentication/SignIn/${username}/${password}`).then(response => {\r\n // var data = <{ token: string }>response.data;\r\n // var token = data.token;\r\n\r\n // this.setToken(token);\r\n // this.setUername(username);\r\n // this.setHasAuthenticationError(false);\r\n // this.setAuthenticated(true);\r\n\r\n // defer.resolve(token);\r\n // }).catch(exception => {\r\n // console.debug(`Failed to login user ${username}`);\r\n // let e: IHttpPromiseError = exception as IHttpPromiseError;\r\n // if (e != null && e.status === 401) {\r\n // // TODO set unauthorized\r\n // } else {\r\n // // TODO set unknown error\r\n // }\r\n // this.setHasAuthenticationError(true);\r\n // this.$http.defaults.headers.common['Authorization'] = null;\r\n // defer.reject();\r\n // });\r\n // });\r\n\r\n // return defer.promise;\r\n //}\r\n\r\n signinUser(username: string, password: string, rememberMe: boolean): ng.IPromise {\r\n let defer = this.$q.defer();\r\n\r\n this.signoutUser(false, true).finally(() => {\r\n var authInfo = btoa(encodeURI(`${username}:${password}`));\r\n\r\n console.debug(`Logging in user ${username}`);\r\n\r\n this.$http.put(`${this.baseUrl}Authentication/SignIn`, JSON.stringify(authInfo)).then(response => {\r\n var data = <{ token: string }>response.data;\r\n var token = data.token;\r\n\r\n this.setToken(token);\r\n this.setUername(username);\r\n this.setHasAuthenticationError(false);\r\n this.setAuthenticated(true);\r\n\r\n defer.resolve(token);\r\n }).catch(exception => {\r\n console.debug(`Failed to login user ${username}`);\r\n let e: IHttpPromiseError = exception as IHttpPromiseError;\r\n if (e != null && e.status === 401) {\r\n // TODO set unauthorized\r\n } else {\r\n // TODO set unknown error\r\n }\r\n this.setHasAuthenticationError(true);\r\n this.$http.defaults.headers.common['Authorization'] = null;\r\n defer.reject();\r\n });\r\n });\r\n\r\n return defer.promise;\r\n }\r\n\r\n signoutUser(redirectToStart: boolean = true, suppressException: boolean = false): ng.IPromise {\r\n let defer = this.$q.defer();\r\n let self = this;\r\n\r\n let token = this.getToken();\r\n if (token == undefined) {\r\n this.setAuthenticated(false);\r\n this.clearToken();\r\n this.clearUsername();\r\n this.htmlStorageService.clearSessionStorage();\r\n\r\n if (redirectToStart) {\r\n console.debug(\"redirecting to login site\");\r\n let options: IStateOptions = {\r\n inherit: false,\r\n location: \"replace\"\r\n };\r\n this.$state.go(\"root.authenticate\", options).finally(() => {\r\n });\r\n }\r\n\r\n defer.resolve();\r\n } else {\r\n this.spinnerService.showBusy();\r\n this.$http.get(`${this.baseUrl}Authentication/SignOut/${token}`).then(response => {\r\n // TODO: What shall we do here?\r\n var code = response.statusText;\r\n this.setHasAuthenticationError(false);\r\n defer.resolve();\r\n }).catch(exception => {\r\n this.setHasAuthenticationError(!suppressException);\r\n defer.reject();\r\n }).finally(() => {\r\n this.setAuthenticated(false);\r\n this.clearToken();\r\n this.clearUsername();\r\n this.htmlStorageService.clearSessionStorage();\r\n\r\n if (redirectToStart) {\r\n console.debug(\"redirecting to login site\");\r\n let options: IStateOptions = {\r\n inherit: false,\r\n location: \"replace\"\r\n };\r\n this.$state.go(\"root.authenticate\", options).finally(() => {\r\n });\r\n }\r\n this.spinnerService.hideBusy();\r\n defer.resolve();\r\n });\r\n }\r\n\r\n return defer.promise;\r\n }\r\n\r\n //signinUser(username: string, password: string, rememberMe: boolean): ng.IPromise {\r\n // let defer = this.$q.defer();\r\n\r\n // this.signoutUser(false, true).finally(() => {\r\n // var authInfo = btoa(encodeURI(`${username}:${password}`));\r\n\r\n // this.$http.defaults.headers.common['Authorization'] = 'Basic ' + authInfo;\r\n // this.setXRequestedWithHeader();\r\n\r\n // console.debug(`Logging in user ${username}`);\r\n\r\n // this.$http.post(`${this.baseUrl}Authentication/SignIn`, null).then(response => {\r\n // var data = <{ token: string }>response.data;\r\n // //var token = btoa(String(data));\r\n // var token = data.token;\r\n\r\n // this.setToken(token);\r\n // this.setUername(username);\r\n // this.setHasAuthenticationError(false);\r\n // this.setAuthenticated(true);\r\n\r\n // defer.resolve(token);\r\n // }).catch(exception => {\r\n // console.debug(`Failed to login user ${username}`);\r\n // let e: IHttpPromiseError = exception as IHttpPromiseError;\r\n // if (e != null && e.status === 401) {\r\n // // TODO set unauthorized\r\n // } else {\r\n // // TODO set unknown error\r\n // }\r\n // this.setHasAuthenticationError(true);\r\n // this.$http.defaults.headers.common['Authorization'] = null;\r\n // defer.reject();\r\n // });\r\n // });\r\n\r\n // return defer.promise;\r\n //}\r\n\r\n //signoutUser(redirectToStart: boolean = true, suppressException: boolean = false): ng.IPromise {\r\n // let defer = this.$q.defer();\r\n // let self = this;\r\n // this.spinnerService.showBusy();\r\n\r\n // this.$http.post(`${this.baseUrl}Authentication/SignOut`, null).then(response => {\r\n // // TODO: What shall we do here?\r\n // var code = response.statusText;\r\n // this.setHasAuthenticationError(false);\r\n // defer.resolve();\r\n // }).catch(exception => {\r\n // this.setHasAuthenticationError(!suppressException);\r\n // defer.reject();\r\n // }).finally(() => {\r\n // this.setAuthenticated(false);\r\n // this.clearToken();\r\n // this.clearUsername();\r\n // this.htmlStorageService.clearSessionStorage();\r\n\r\n // if (redirectToStart) {\r\n // console.debug(\"redirecting to login site\");\r\n // let options: IStateOptions = {\r\n // inherit: false,\r\n // location: \"replace\"\r\n // };\r\n // this.$state.go(\"root.authenticate\", options).finally(() => {\r\n // });\r\n // }\r\n // this.spinnerService.hideBusy();\r\n // defer.resolve();\r\n // });\r\n\r\n // return defer.promise;\r\n //}\r\n\r\n setAuthenticatedAfterReload(): void {\r\n this.setXRequestedWithHeader();\r\n\r\n let token = this.htmlStorageService.getSessionStorageItem(\"token\");\r\n this.$http.defaults.headers.common['Authorization'] = `Bearer ${token}`;\r\n }\r\n\r\n private setXRequestedWithHeader(): void {\r\n this.$http.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest';\r\n }\r\n\r\n private setAuthenticated(authenticated: boolean): void {\r\n this.raiseEvent(\"authenticationChanged\", authenticated);\r\n }\r\n\r\n private setHasAuthenticationError(hasError: boolean): void {\r\n this.raiseEvent(\"hasAuthenticationErrorChanged\", hasError);\r\n }\r\n\r\n private setUername(username: string): void {\r\n this.htmlStorageService.setSessionStorageItem(\"username\", username);\r\n }\r\n\r\n private clearUsername(): void {\r\n this.htmlStorageService.removeSessionStorageItem(\"username\");\r\n }\r\n\r\n private clearToken(): void {\r\n this.htmlStorageService.removeSessionStorageItem(\"token\");\r\n this.$http.defaults.headers.common['Authorization'] = null;\r\n }\r\n\r\n private getToken(): string {\r\n return this.htmlStorageService.getSessionStorageItem(\"token\");\r\n }\r\n\r\n private setToken(token: string): void {\r\n this.htmlStorageService.setSessionStorageItem(\"token\", token);\r\n this.$http.defaults.headers.common['Authorization'] = `Bearer ${token}`;\r\n }\r\n\r\n private raiseEvent(eventName: string, ...args: any[]): void {\r\n this.$rootScope.$broadcast(eventName, args);\r\n }\r\n\r\n public static Factory($http: ng.IHttpService,\r\n $rootScope: ng.IRootScopeService,\r\n $state: angular.ui.IStateService,\r\n $timeout: ng.ITimeoutService,\r\n $q: ng.IQService,\r\n $log: ng.ILogService,\r\n htmlStorageService: HtmlStorageService,\r\n userService: UserService,\r\n spinnerService: SpinnerService,\r\n appSettings: any): AuthenticationService {\r\n return new AuthenticationService($http, $rootScope, $state, $timeout, $q, $log, htmlStorageService, userService, spinnerService, appSettings);\r\n }\r\n}","import { module, IOnChangesObject, IChangesObject } from \"angular\";\r\nimport HtmlStorageService from \"../services/HtmlStorageService\";\r\nimport SpinnerService from \"../services/SpinnerService\";\r\nimport IBDate from \"../core/IBDate\";\r\nimport { Transition, TransitionService } from \"@uirouter/angularjs\";\r\nimport IHttpPromiseError from \"../core/IHttpPromiseError\";\r\nimport * as angular from \"angular\";\r\nimport { IModalScope } from \"angular-ui-bootstrap\";\r\nimport OrderingArticleInformationService from \"../services/OrderingArticleInformationService\";\r\nimport { ArticleInformation } from \"../services/model/ArticleInformation\";\r\n\r\nexport class OrderingOrderOrderingArticleInformationController implements ng.IController { // ng.IDoCheck IModalScope\r\n static $inject = [\"$http\", \"$rootScope\", \"$scope\", \"$state\", \"$timeout\", \"$q\", \"$transitions\", \"$interval\", \"$window\", \"$log\", \"$locale\", \"spinnerService\", \"htmlStorageService\", \"orderingArticleInformationService\"];\r\n\r\n constructor(private $http: ng.IHttpService,\r\n private $rootScope: ng.IRootScopeService,\r\n private $scope: ng.IScope,\r\n private $state: angular.ui.IStateService,\r\n private $timeout: ng.ITimeoutService,\r\n private $q: ng.IQService,\r\n private $transitions: TransitionService,\r\n private $interval: ng.IIntervalService,\r\n private $window: ng.IWindowService,\r\n private $log: ng.ILogService,\r\n private $locale: ng.ILocaleService,\r\n private spinnerService: SpinnerService,\r\n private htmlStorageService: HtmlStorageService,\r\n private orderingArticleInformationService: OrderingArticleInformationService) {\r\n }\r\n\r\n articleId: number;\r\n customerId: number;\r\n deliveryDate: IBDate;\r\n articleInformation: ArticleInformation;\r\n\r\n ok(): void {\r\n this.close({ $value: true });\r\n }\r\n\r\n cancel(): void {\r\n this.dismiss({ $value: false });\r\n }\r\n\r\n private LoadArticleInformation(): void {\r\n this.spinnerService.showBusy();\r\n let self = this;\r\n this.orderingArticleInformationService.getSingleByCustomerAndArticleAndDeliveryDate(this.customerId, this.articleId, this.deliveryDate).then((articleInformation: ArticleInformation) => {\r\n self.articleInformation = articleInformation;\r\n }).catch((error: IHttpPromiseError) => {\r\n self.$log.error(`Could not load article information. (${error.status}:${error.statusText})`);\r\n }).finally(() => {\r\n this.spinnerService.hideBusy();\r\n });\r\n }\r\n\r\n /*** ng.IController and ng.IDoCheck methods ***/\r\n $onChanges?(onChangesObj: IOnChangesObject): void {\r\n let c = onChangesObj[\"resolve\"] as IChangesObject<{\r\n customerId: number,\r\n articleId: number,\r\n deliveryDate: Date,\r\n languageId: number\r\n }>;\r\n if (c != undefined) {\r\n this.articleId = c.currentValue.articleId;\r\n this.customerId = c.currentValue.customerId;\r\n this.deliveryDate = new IBDate(c.currentValue.deliveryDate);\r\n\r\n this.LoadArticleInformation();\r\n }\r\n }\r\n\r\n $onInit(): void {\r\n }\r\n\r\n $onDestroy(): void {\r\n }\r\n\r\n $doCheck(): void {\r\n //if (this.oldOrdering != this.ordering) {\r\n // this.oldOrdering = this.ordering;\r\n\r\n // this.clearLocalParameters();\r\n\r\n // if (this.ordering != undefined) {\r\n // this.loadOrderingRows();\r\n // if (!this.isReadOnly()) {\r\n // this.loadArticleGroups();\r\n // this.loadArticles();\r\n // }\r\n // } else {\r\n // this.orderingRows = undefined;\r\n // }\r\n //}\r\n }\r\n\r\n /*** Bindings properties ***/\r\n trans: Transition;\r\n resolve: any;\r\n\r\n /*** Bindings callbacks ***/\r\n close: (param: { $value: any }) => void;\r\n dismiss: (param: { $value: any }) => void;\r\n}\r\n\r\nexport default class OrderingOrderOrderingArticleInformationComponent implements ng.IComponentOptions {\r\n bindings?: { [boundProperty: string]: string };\r\n templateUrl: string;\r\n controller: ng.Injectable;\r\n\r\n constructor() {\r\n this.controller = OrderingOrderOrderingArticleInformationController;\r\n this.templateUrl = './dist/app/ordering/ordering-order-ordering-article-information.template.html';\r\n this.bindings = {\r\n trans: '<',\r\n resolve: '<',\r\n close: '&',\r\n dismiss: '&'\r\n }\r\n }\r\n}","export default class ImageHelper {\r\n constructor() {\r\n console.log(\"An instance of the ImageHelper class is unexpected\");\r\n }\r\n\r\n public static createBase64ImageSrcString(base64EncodedImage: string): string {\r\n if (base64EncodedImage.length < 4) {\r\n return null;\r\n }\r\n\r\n var mime;\r\n var binaryString = atob(base64EncodedImage.substr(0, 8));\r\n var a = new Uint8Array(4);\r\n\r\n for (var i = 0; i < binaryString.length; i++) {\r\n a[i] = binaryString.charCodeAt(i);\r\n }\r\n\r\n var b0 = a[0];\r\n var b1 = a[1];\r\n var b2 = a[2];\r\n var b3 = a[3];\r\n\r\n if (b0 == 0x89 && b1 == 0x50 && b2 == 0x4E && b3 == 0x47) {\r\n mime = 'image/png';\r\n } else if (b0 == 0xff && b1 == 0xd8) {\r\n mime = 'image/jpeg';\r\n } else if (b0 == 0x47 && b1 == 0x49 && b2 == 0x46) {\r\n mime = 'image/gif';\r\n } else {\r\n return null;\r\n }\r\n\r\n return 'data:' + mime + ';base64,' + base64EncodedImage;\r\n }\r\n}","import { module, IOnChangesObject, IChangesObject } from \"angular\";\r\nimport HtmlStorageService from \"../services/HtmlStorageService\";\r\nimport SpinnerService from \"../services/SpinnerService\";\r\nimport IBDate from \"../core/IBDate\";\r\nimport { Transition, TransitionService } from \"@uirouter/angularjs\";\r\nimport { TemplateInfo } from \"../services/model/TemplateInfo\";\r\nimport IHttpPromiseError from \"../core/IHttpPromiseError\";\r\nimport TemplateInfoService from \"../services/TemplateInfoService\";\r\nimport { Template } from \"../services/model/Template\";\r\n\r\nexport class OrderingTemplateTemplateSelectController implements ng.IController { // ng.IDoCheck\r\n static $inject = [\"$http\", \"$rootScope\", \"$scope\", \"$state\", \"$timeout\", \"$q\", \"$transitions\", \"$interval\", \"$window\", \"$log\", \"spinnerService\", \"htmlStorageService\", \"templateInfoService\"];\r\n\r\n constructor(private $http: ng.IHttpService,\r\n private $rootScope: ng.IRootScopeService,\r\n private $scope: ng.IScope,\r\n private $state: angular.ui.IStateService,\r\n private $timeout: ng.ITimeoutService,\r\n private $q: ng.IQService,\r\n private $transitions: TransitionService,\r\n private $interval: ng.IIntervalService,\r\n private $window: ng.IWindowService,\r\n private $log: ng.ILogService,\r\n private spinnerService: SpinnerService,\r\n private htmlStorageService: HtmlStorageService,\r\n private templateInfoService: TemplateInfoService) {\r\n }\r\n\r\n private reloadInternal: boolean;\r\n private templates: TemplateInfo[];\r\n selectedTemplate: TemplateInfo;\r\n\r\n textHeading: string = `Välj beställningsmall`;\r\n\r\n fixedTemplates: TemplateInfo[];\r\n weekdayTemplates: TemplateInfo[];\r\n userTemplates: TemplateInfo[];\r\n\r\n isSelected(template: TemplateInfo): boolean {\r\n return this.selectedTemplate != undefined && this.selectedTemplate.id == template.id;\r\n }\r\n\r\n textColor(templateId: number): string {\r\n switch (templateId) {\r\n case -2: return \"#dadada\";\r\n case -1: return \"#dadada\";\r\n case 0: return \"#626262\";\r\n default: return \"#dadada\";\r\n }\r\n }\r\n\r\n select(templateId: number): void {\r\n let template: TemplateInfo = this.templates.find((templateInfo, index, templates) => {\r\n return templateInfo.id == templateId;\r\n }, this);\r\n this.selectedTemplate = template;\r\n this.onTemplateSelected({ templateId: templateId, readonly: template.fromOrderSystem });\r\n }\r\n\r\n private loadTemplates = () => {\r\n this.spinnerService.showBusy();\r\n let self = this;\r\n this.templateInfoService.getAllByCustomer(this.customerId)\r\n .then((p: TemplateInfo[]) => {\r\n self.templates = p;\r\n\r\n self.fixedTemplates = p.filter((template: TemplateInfo, index: number, items: TemplateInfo[]): boolean => {\r\n return template.id <= 0;\r\n });\r\n\r\n self.weekdayTemplates = p.filter((template: TemplateInfo, index: number, items: TemplateInfo[]): boolean => {\r\n return template.id > 0 && template.templateTypeId <= 7;\r\n });\r\n\r\n self.userTemplates = p.filter((template: TemplateInfo, index: number, items: TemplateInfo[]): boolean => {\r\n return template.id > 0 && template.templateTypeId > 7;\r\n });\r\n\r\n if (self.reloadInternal != undefined && self.reloadInternal == true) {\r\n if (self.selectedTemplateId != undefined) {\r\n self.select(this.selectedTemplateId);\r\n }\r\n\r\n self.reloadInternal = undefined;\r\n }\r\n }).catch(((error: IHttpPromiseError) => {\r\n self.$log.error(`Unexpected error occured while getting templates. (${error.status}:${error.statusText})`);\r\n })).finally(() => {\r\n self.spinnerService.hideBusy();\r\n });\r\n }\r\n\r\n private outPutPayLoad(value: any): { value: any } {\r\n return { value: value };\r\n }\r\n\r\n /*** ng.IController and ng.IDoCheck methods ***/\r\n $onChanges?(onChangesObj: IOnChangesObject): void {\r\n }\r\n\r\n $onInit(): void {\r\n }\r\n\r\n $onDestroy(): void {\r\n }\r\n\r\n oldCustomerId: number;\r\n oldSelectedTemplateId: number;\r\n\r\n $doCheck(): void {\r\n if (this.oldCustomerId != this.customerId) {\r\n this.oldCustomerId = this.customerId;\r\n if (this.customerId != undefined) {\r\n this.loadTemplates();\r\n }\r\n }\r\n\r\n if (this.oldSelectedTemplateId != this.selectedTemplateId) {\r\n this.oldSelectedTemplateId = this.selectedTemplateId;\r\n if (this.selectedTemplateId != undefined) {\r\n //this.loadTemplates();\r\n }\r\n }\r\n\r\n if (this.reload != undefined && this.reload === true) {\r\n this.reloadInternal = this.reload;\r\n this.reload = undefined;\r\n this.loadTemplates();\r\n }\r\n }\r\n\r\n uiOnParamsChanged(newValues: any, $transition$: Transition): void {\r\n }\r\n\r\n /*** Bindings properties ***/\r\n trans: Transition;\r\n customerId: number;\r\n selectedTemplateId: number;\r\n reload: boolean;\r\n\r\n /*** Bindings callbacks ***/\r\n onTemplateSelected: (param: { templateId: number, readonly: boolean }) => ng.IPromise;\r\n}\r\n\r\nexport default class OrderingTemplateTemplateSelectComponent implements ng.IComponentOptions {\r\n bindings?: { [boundProperty: string]: string };\r\n templateUrl: string;\r\n controller: ng.Injectable;\r\n\r\n constructor() {\r\n this.controller = OrderingTemplateTemplateSelectController;\r\n this.templateUrl = './dist/app/ordering/ordering-template-template-select.template.html';\r\n this.bindings = {\r\n trans: '<',\r\n customerId: '<',\r\n selectedTemplateId: '<',\r\n reload: '=',\r\n onTemplateSelected: '&'\r\n }\r\n }\r\n}","import * as angular from \"angular\";\r\nimport { IModalScope, IModalService } from \"angular-ui-bootstrap\";\r\nimport { module, IOnChangesObject, IChangesObject } from \"angular\";\r\nimport { Transition, TransitionService } from \"@uirouter/angularjs\";\r\nimport HtmlStorageService from \"../services/HtmlStorageService\";\r\nimport IBDate from \"../core/IBDate\";\r\nimport IHttpPromiseError from \"../core/IHttpPromiseError\";\r\nimport SpinnerService from \"../services/SpinnerService\";\r\nimport { User } from \"../services/model/User\";\r\nimport { Customer } from \"../services/model/Customer\";\r\nimport { Role } from \"../services/model/Role\";\r\nimport { Permission } from \"../services/model/Permission\";\r\nimport PermissionService from \"../services/PermissionService\";\r\nimport RoleService from \"../services/RoleService\";\r\nimport CustomerService from \"../services/CustomerService\";\r\nimport UserService from \"../services/UserService\";\r\n\r\ntype UiSelectBroadcastEvents =\r\n \"UiSelectPermissionUserRoleAddNewAdd\" | \"UiSelectPermissionUserRoleAddNewRole\" | \"UiSelectPermissionUserRoleAddNewCustomer\";\r\n\r\ntype PermissionUserRoleEvents =\r\n \"PermissionUserRolePermissionsResetSearch\";\r\n\r\nexport class PermissionUserRoleAddEditController implements ng.IController { // ng.IDoCheck IModalScope\r\n static $inject = [\"$http\", \"$rootScope\", \"$scope\", \"$state\", \"$timeout\", \"$q\", \"$transitions\", \"$window\", \"$log\", \"$locale\", \"$uibModal\", \"spinnerService\", \"htmlStorageService\", \"userService\", \"permissionService\", \"roleService\", \"customerService\"];\r\n\r\n constructor(private $http: ng.IHttpService,\r\n private $rootScope: ng.IRootScopeService,\r\n private $scope: ng.IScope,\r\n private $state: angular.ui.IStateService,\r\n private $timeout: ng.ITimeoutService,\r\n private $q: ng.IQService,\r\n private $transitions: TransitionService,\r\n private $window: ng.IWindowService,\r\n private $log: ng.ILogService,\r\n private $locale: ng.ILocaleService,\r\n private $uibModal: IModalService,\r\n private spinnerService: SpinnerService,\r\n private htmlStorageService: HtmlStorageService,\r\n private userService: UserService,\r\n private permissionService: PermissionService,\r\n private roleService: RoleService,\r\n private customerService: CustomerService) {\r\n }\r\n\r\n paginationItems = [{\r\n value: 10,\r\n label: '10'\r\n }, {\r\n value: 15,\r\n label: '15'\r\n },\r\n {\r\n value: 20,\r\n label: '20'\r\n },\r\n {\r\n value: 25,\r\n label: '25'\r\n },\r\n {\r\n value: 30,\r\n label: '30'\r\n }, {\r\n value: 40,\r\n label: '40'\r\n }, {\r\n value: 50,\r\n label: '50'\r\n }, {\r\n value: 99999,\r\n label: 'Alla'\r\n }];\r\n\r\n /*** Pagination Roles ***/\r\n private _selectedPermissionsPaginationItem: { value: number, label: string };\r\n\r\n get selectedPermissionsPaginationItem(): { value: number, label: string } {\r\n if (this._selectedPermissionsPaginationItem == undefined) {\r\n let spi = <{ value: number, label: string }>this.htmlStorageService.getLocalStorageItem(\"lastPaginationItemPermissionUserRolesPage\");\r\n if (spi == undefined) {\r\n this.selectedPermissionsPaginationItem = this.paginationItems[0];\r\n }\r\n else {\r\n this.selectedPermissionsPaginationItem = spi;\r\n }\r\n }\r\n return this._selectedPermissionsPaginationItem;\r\n }\r\n\r\n set selectedPermissionsPaginationItem(item: { value: number, label: string }) {\r\n this._selectedPermissionsPaginationItem = item;\r\n this.htmlStorageService.setLocalStorageItem(\"lastPaginationItemPermissionUserRolesPage\", item);\r\n }\r\n\r\n selectedUser: User;\r\n\r\n customers: Customer[];\r\n filteredCustomers: Customer[] = new Array();\r\n filteredRoles: Role[] = new Array();\r\n filteredPermissions: Permission[] = new Array();\r\n permissions: Permission[];\r\n roles: Role[];\r\n users: User[];\r\n newPermission: Permission;\r\n\r\n get title(): string {\r\n return (this.selectedUser !== undefined) ? `Behörighet för (${this.selectedUser.userName})` : `Laddar behörighet`;\r\n }\r\n\r\n get canAddPermission(): boolean {\r\n if (this.newPermission == undefined || this.newPermission.customerId == undefined || this.newPermission.roleId == undefined) {\r\n return false;\r\n }\r\n\r\n if (this.filteredPermissions.some((value) => value.customerId == this.newPermission.customerId && this.newPermission.roleId == value.roleId)) {\r\n return false;\r\n }\r\n\r\n return true;\r\n }\r\n\r\n addPermission(form: ng.IFormController, event?: KeyboardEvent): void {\r\n if (!this.canAddPermission || (event != undefined && !this.isEnterKey(event))) {\r\n return;\r\n }\r\n\r\n this.spinnerService.showBusy();\r\n let self = this;\r\n\r\n this.permissionService.createPermission(this.newPermission).then((permission: Permission) => {\r\n self.permissions.splice(0, 0, permission);\r\n self.filteredPermissions.splice(0, 0, permission);\r\n self.initialiseNewPermission();\r\n self.filterRoles();\r\n self.filterCustomers();\r\n self.setUiFocus(\"UiSelectPermissionUserRoleAddNewRole\");\r\n }).catch((error: any) => {\r\n let e: IHttpPromiseError = error as IHttpPromiseError;\r\n\r\n if (e.status != undefined) {\r\n self.$log.error(`An unexpected error occured while adding permission for company ${self.selectedUser.companyId}. ${e.status} ${e.statusText}`);\r\n } else {\r\n self.$log.error(`An unexpected error occured while adding permisson for company ${self.selectedUser.companyId}. ${error}`);\r\n }\r\n\r\n throw error;\r\n }).finally(() => {\r\n self.spinnerService.hideBusy();\r\n });\r\n }\r\n\r\n customerSelected(customer: Customer): void {\r\n if (customer == undefined) {\r\n return;\r\n }\r\n\r\n this.setUiFocus(\"UiSelectPermissionUserRoleAddNewAdd\");\r\n }\r\n\r\n editPermission() {\r\n if (this.selectedUser == undefined) {\r\n return;\r\n }\r\n\r\n this.initialiseNewPermission();\r\n this.filterPermissions();\r\n this.filterRoles();\r\n this.filterCustomers();\r\n this.setUiFocus(\"UiSelectPermissionUserRoleAddNewRole\");\r\n }\r\n\r\n isEnterKey(event: KeyboardEvent, preventDefault: boolean = false): boolean {\r\n if ((event.key !== undefined && event.key.toLowerCase() === \"enter\") ||\r\n (event.keyCode !== undefined && event.keyCode === 13) ||\r\n (event.which !== undefined && event.which === 13)) {\r\n if (preventDefault) {\r\n event.preventDefault();\r\n }\r\n return true;\r\n }\r\n\r\n return false;\r\n }\r\n\r\n removePermission(permission: Permission, event?: KeyboardEvent): void {\r\n if (permission == undefined || (event != undefined && !this.isEnterKey(event))) {\r\n return;\r\n }\r\n\r\n this.spinnerService.showBusy();\r\n let self = this;\r\n\r\n this.permissionService.removePermission(permission.id).then(() => {\r\n let index = this.permissions.findIndex((value) => value.id == permission.id);\r\n if (index !== -1) {\r\n self.permissions.splice(index, 1);\r\n }\r\n\r\n index = this.filteredPermissions.findIndex((value) => value.id == permission.id);\r\n if (index !== -1) {\r\n self.filteredPermissions.splice(index, 1);\r\n\r\n self.filterRoles();\r\n self.filterCustomers();\r\n }\r\n\r\n this.setUiFocus(\"UiSelectPermissionUserRoleAddNewRole\");\r\n }).catch((error: any) => {\r\n let e: IHttpPromiseError = error as IHttpPromiseError;\r\n\r\n if (e.status != undefined) {\r\n self.$log.error(`An unexpected error occured while removing permission ${permission.id} for company ${self.selectedUser.companyId}. ${e.status} ${e.statusText}`);\r\n } else {\r\n self.$log.error(`An unexpected error occured while removing permisson ${permission.id} for company ${self.selectedUser.companyId}. ${error}`);\r\n }\r\n\r\n throw error;\r\n }).finally(() => {\r\n self.spinnerService.hideBusy();\r\n });\r\n }\r\n\r\n roleSelected(role: Role): void {\r\n if (role == undefined) {\r\n this.clearFilteredRoles();\r\n return;\r\n }\r\n\r\n this.clearSelectedCustomer();\r\n this.filterCustomers();\r\n\r\n this.setUiFocus(\"UiSelectPermissionUserRoleAddNewCustomer\");\r\n }\r\n\r\n private clearSelectedCustomer(): void {\r\n if (this.newPermission != undefined) {\r\n this.newPermission.customerId == undefined;\r\n }\r\n }\r\n\r\n private clearSelectedRole(): void {\r\n if (this.newPermission != undefined) {\r\n this.newPermission.customerId == undefined;\r\n }\r\n }\r\n\r\n private clearFilteredCustomers(): void {\r\n if (this.filteredCustomers != undefined) {\r\n this.filteredCustomers.length = 0;\r\n }\r\n }\r\n\r\n private clearFilteredPermissions(): void {\r\n if (this.filteredPermissions != undefined) {\r\n this.filteredPermissions.length = 0;\r\n }\r\n\r\n this.broadcastEvent(\"PermissionUserRolePermissionsResetSearch\");\r\n }\r\n\r\n private clearFilteredRoles(): void {\r\n this.clearFilteredCustomers();\r\n\r\n //if (this.newPermission != undefined) {\r\n // this.newPermission.roleId == undefined;\r\n //}\r\n\r\n if (this.filteredRoles != undefined) {\r\n this.filteredRoles.length = 0;\r\n }\r\n }\r\n\r\n private clearLocalParameters(): void {\r\n if (this.customers != undefined) {\r\n this.customers.length = 0;\r\n }\r\n\r\n this.clearFilteredCustomers();\r\n\r\n if (this.roles != undefined) {\r\n this.roles.length = 0;\r\n }\r\n\r\n this.clearFilteredRoles();\r\n\r\n if (this.users != undefined) {\r\n this.users.length = 0;\r\n }\r\n\r\n this.selectedUser = undefined;\r\n\r\n if (this.permissions != undefined) {\r\n this.permissions.length = 0;\r\n }\r\n\r\n this.clearFilteredPermissions();\r\n\r\n // Clear smart table search filter\r\n this.broadcastEvent(\"PermissionUserRolePermissionsResetSearch\");\r\n }\r\n\r\n private filterCustomers(): void {\r\n if (this.newPermission == undefined) {\r\n return;\r\n }\r\n\r\n this.clearFilteredCustomers();\r\n\r\n if (this.newPermission.roleId != undefined) {\r\n let usedCustomers = this.filteredPermissions\r\n .filter((value, index, self) => value.roleId === this.newPermission.roleId, this)\r\n .map((value) => value.customerId);\r\n if (usedCustomers != undefined) {\r\n this.filteredCustomers = angular.copy(this.customers.filter((value) => usedCustomers.indexOf(value.id) === -1));\r\n return;\r\n }\r\n }\r\n\r\n this.filteredCustomers = angular.copy(this.customers);\r\n }\r\n\r\n private filterPermissions(): void {\r\n this.clearFilteredPermissions();\r\n\r\n let fp: Permission[] = this.permissions.filter((value, index, values) => {\r\n return value.userId == this.selectedUser.id;\r\n }, this);\r\n\r\n this.filteredPermissions = fp;\r\n }\r\n\r\n private filterRoles(): void {\r\n this.clearFilteredRoles();\r\n this.filteredRoles = angular.copy(this.roles);\r\n }\r\n\r\n private initialiseNewPermission(): void {\r\n this.newPermission = new Permission();\r\n this.newPermission.companyId = this.selectedUser.companyId;\r\n this.newPermission.userId = this.selectedUser.id;\r\n }\r\n\r\n //private loadCustomers(): ng.IPromise {\r\n // this.spinnerService.showBusy();\r\n // let self = this;\r\n\r\n // return this.customerService.getCustomersByCompany(this.selectedUser.companyId).then((customers: Customer[]) => {\r\n // self.customers = customers;\r\n // }).catch((error: any) => {\r\n // let e: IHttpPromiseError = error as IHttpPromiseError;\r\n\r\n // if (e.status != undefined) {\r\n // self.$log.error(`An unexpected error occured while retrieving customers for permisson roles for company ${self.selectedUser.companyId}. ${e.status} ${e.statusText}`);\r\n // } else {\r\n // self.$log.error(`An unexpected error occured while retrieving customers for permisson roles for company ${self.selectedUser.companyId}. ${error}`);\r\n // }\r\n\r\n // throw error;\r\n // }).finally(() => {\r\n // self.spinnerService.hideBusy();\r\n // });\r\n //}\r\n\r\n //private loadPermissions(): ng.IPromise {\r\n // this.spinnerService.showBusy();\r\n // let self = this;\r\n\r\n // return this.permissionService.getPermissionsByCompany(this.selectedUser.companyId).then((permissions: Permission[]) => {\r\n // self.permissions = permissions;\r\n // }).catch((error: any) => {\r\n // let e: IHttpPromiseError = error as IHttpPromiseError;\r\n\r\n // if (e.status != undefined) {\r\n // self.$log.error(`An unexpected error occured while retrieving permissions for permisson roles for company ${self.selectedUser.companyId}. ${e.status} ${e.statusText}`);\r\n // } else {\r\n // self.$log.error(`An unexpected error occured while retrieving permissions for permisson roles for company ${self.selectedUser.companyId}. ${error}`);\r\n // }\r\n\r\n // throw error;\r\n // }).finally(() => {\r\n // self.spinnerService.hideBusy();\r\n // });\r\n //}\r\n\r\n //private loadRoles(): ng.IPromise {\r\n // this.spinnerService.showBusy();\r\n // let self = this;\r\n\r\n // return this.roleService.getRolesByCompany(self.selectedUser.companyId).then((roles: Role[]) => {\r\n // self.roles = roles;\r\n // }).catch((error: any) => {\r\n // let e: IHttpPromiseError = error as IHttpPromiseError;\r\n\r\n // if (e.status != undefined) {\r\n // self.$log.error(`An unexpected error occured while retrieving roles for permisson roles for company ${self.selectedUser.companyId}. ${e.status} ${e.statusText}`);\r\n // } else {\r\n // self.$log.error(`An unexpected error occured while retrieving roles for permisson roles for company ${self.selectedUser.companyId}. ${error}`);\r\n // }\r\n\r\n // throw error;\r\n // }).finally(() => {\r\n // self.spinnerService.hideBusy();\r\n // });\r\n //}\r\n\r\n private broadcastEvent(event: PermissionUserRoleEvents | UiSelectBroadcastEvents, ...args: any[]): void {\r\n this.$scope.$broadcast(event, args);\r\n }\r\n\r\n private setUiFocus(event: UiSelectBroadcastEvents): void {\r\n this.broadcastEvent(event);\r\n }\r\n\r\n /*** Modal window properties ***/\r\n ok(): void {\r\n this.update();\r\n this.close({ $value: true });\r\n }\r\n\r\n cancel(): void {\r\n this.dismiss({ $value: false });\r\n }\r\n\r\n update(): void {\r\n\r\n }\r\n\r\n /*** ng.IController and ng.IDoCheck methods ***/\r\n $onChanges?(onChangesObj: IOnChangesObject): void {\r\n let c = onChangesObj[\"resolve\"] as IChangesObject<{\r\n user: User,\r\n permissions: Permission[],\r\n customers: Customer[],\r\n roles: Role[]\r\n }>;\r\n if (c != undefined) {\r\n this.selectedUser = c.currentValue.user;\r\n this.permissions = c.currentValue.permissions;\r\n this.customers = c.currentValue.customers;\r\n this.roles = c.currentValue.roles;\r\n\r\n this.editPermission();\r\n\r\n //let self = this;\r\n //this.loadRoles().then(() => self.loadCustomers()).then(() => self.loadPermissions()).then(() => self.editPermission());\r\n //this.loadRoles().then(() => self.loadCustomers()).then(() => self.editPermission());\r\n }\r\n }\r\n\r\n $onInit(): void {\r\n }\r\n\r\n $onDestroy(): void {\r\n }\r\n\r\n $doCheck(): void {\r\n }\r\n\r\n /*** Bindings properties ***/\r\n trans: Transition;\r\n resolve: any;\r\n\r\n /*** Bindings callbacks ***/\r\n close: (param: { $value: any }) => void;\r\n dismiss: (param: { $value: any }) => void;\r\n}\r\n\r\nexport default class PermissionUserRoleAddEditComponent implements ng.IComponentOptions {\r\n bindings?: { [boundProperty: string]: string };\r\n templateUrl: string;\r\n controller: ng.Injectable;\r\n\r\n constructor() {\r\n this.controller = PermissionUserRoleAddEditController;\r\n this.templateUrl = './dist/app/permission/permission-user-role-add-edit.template.html';\r\n this.bindings = {\r\n trans: '<',\r\n resolve: '<',\r\n close: '&',\r\n dismiss: '&'\r\n }\r\n }\r\n}","import { module, IOnChangesObject, IChangesObject } from \"angular\";\r\nimport HtmlStorageService from \"../services/HtmlStorageService\";\r\nimport SpinnerService from \"../services/SpinnerService\";\r\nimport IBDate from \"../core/IBDate\";\r\nimport { Transition, TransitionService } from \"@uirouter/angularjs\";\r\nimport { CalendarDay } from \"../services/model/CalendarDay\";\r\nimport { TemplateInfo } from \"../services/model/TemplateInfo\";\r\nimport OrderingTemplateInfoService from \"../services/OrderingTemplateInfoService\";\r\nimport OrderingService from \"../services/OrderingService\";\r\nimport IHttpPromiseError from \"../core/IHttpPromiseError\";\r\n\r\nexport class OrderingOrderTemplateSelectController implements ng.IController { // ng.IDoCheck\r\n static $inject = [\"$http\", \"$rootScope\", \"$scope\", \"$state\", \"$timeout\", \"$q\", \"$transitions\", \"$interval\", \"$window\", \"$log\", \"spinnerService\", \"htmlStorageService\", \"orderingTemplateInfoService\", \"orderingService\"];\r\n\r\n constructor(private $http: ng.IHttpService,\r\n private $rootScope: ng.IRootScopeService,\r\n private $scope: ng.IScope,\r\n private $state: angular.ui.IStateService,\r\n private $timeout: ng.ITimeoutService,\r\n private $q: ng.IQService,\r\n private $transitions: TransitionService,\r\n private $interval: ng.IIntervalService,\r\n private $window: ng.IWindowService,\r\n private $log: ng.ILogService,\r\n private spinnerService: SpinnerService,\r\n private htmlStorageService: HtmlStorageService,\r\n private orderingTemplateInfoService: OrderingTemplateInfoService,\r\n private orderingService: OrderingService) {\r\n }\r\n\r\n private reloadInternal: boolean;\r\n private templates: TemplateInfo[];\r\n\r\n textHeading: string = `Välj beställningsmall`;\r\n textDeliveryDate: string = `Leveransdatum`;\r\n textDeadline: string = `Stopptid`;\r\n\r\n fixedTemplates: TemplateInfo[];\r\n weekdayTemplates: TemplateInfo[];\r\n userTemplates: TemplateInfo[];\r\n\r\n imageSrcPanel(templateId: number): string {\r\n switch (templateId) {\r\n case -2: return \"dist/assets/images/Template-PreviousOrder.png\";\r\n case -1: return \"dist/assets/images/Template-AllProducts.png\";\r\n case 0: return \"dist/assets/images/Template-Blank.png\";\r\n default: return \"dist/assets/images/Template-User.png\";\r\n }\r\n }\r\n\r\n textColor(templateId: number): string {\r\n switch (templateId) {\r\n case -2: return \"#dadada\";\r\n case -1: return \"#dadada\";\r\n case 0: return \"#626262\";\r\n default: return \"#dadada\";\r\n }\r\n }\r\n\r\n select(templateId: number): void {\r\n this.onTemplateSelected({ value: templateId });\r\n }\r\n\r\n private loadTemplates = () => {\r\n this.spinnerService.showBusy();\r\n let self = this;\r\n this.orderingTemplateInfoService.getAllByCustomerAndDeliveryDate(this.customerId, this.deliveryDate)\r\n .then((p: TemplateInfo[]) => {\r\n self.templates = p;\r\n\r\n self.fixedTemplates = p.filter((template: TemplateInfo, index: number, items: TemplateInfo[]): boolean => {\r\n return template.id <= 0;\r\n });\r\n\r\n self.weekdayTemplates = p.filter((template: TemplateInfo, index: number, items: TemplateInfo[]): boolean => {\r\n return template.id > 0 && template.templateTypeId <= 7;\r\n });\r\n\r\n self.userTemplates = p.filter((template: TemplateInfo, index: number, items: TemplateInfo[]): boolean => {\r\n return template.id > 0 && template.templateTypeId > 7;\r\n });\r\n }).catch(((error: IHttpPromiseError) => {\r\n self.$log.error(`Unexpected error occured while getting templates. (${error.status}:${error.statusText})`);\r\n })).finally(() => {\r\n self.spinnerService.hideBusy();\r\n });\r\n }\r\n\r\n private outPutPayLoad(value: any): { value: any } {\r\n return { value: value };\r\n }\r\n\r\n /*** ng.IController and ng.IDoCheck methods ***/\r\n $onChanges?(onChangesObj: IOnChangesObject): void {\r\n }\r\n\r\n $onInit(): void {\r\n }\r\n\r\n $onDestroy(): void {\r\n }\r\n\r\n oldDeliveryDate: IBDate;\r\n\r\n $doCheck(): void {\r\n if (this.oldDeliveryDate != this.deliveryDate) {\r\n this.oldDeliveryDate = this.deliveryDate;\r\n if (this.deliveryDate != undefined) {\r\n this.loadTemplates();\r\n }\r\n }\r\n }\r\n\r\n uiOnParamsChanged(newValues: any, $transition$: Transition): void {\r\n }\r\n\r\n /*** Bindings properties ***/\r\n trans: Transition;\r\n customerId: number;\r\n deliveryDate: IBDate;\r\n stopTime: IBDate;\r\n\r\n /*** Bindings callbacks ***/\r\n onTemplateSelected: (param: { value: number }) => ng.IPromise;\r\n}\r\n\r\nexport default class OrderingOrderTemplateSelectComponent implements ng.IComponentOptions {\r\n bindings?: { [boundProperty: string]: string };\r\n templateUrl: string;\r\n controller: ng.Injectable;\r\n\r\n constructor() {\r\n this.controller = OrderingOrderTemplateSelectController;\r\n this.templateUrl = './dist/app/ordering/ordering-order-template-select.template.html';\r\n this.bindings = {\r\n trans: '<',\r\n customerId: '<',\r\n deliveryDate: '=',\r\n stopTime: '=',\r\n onTemplateSelected: '&'\r\n }\r\n }\r\n}","/// \r\n/// \r\n/// \r\n\r\nimport { module } from \"angular\";\r\nimport IBDate from \"../core/IBDate\";\r\nimport BaseService from \"../services/base/BaseService\";\r\nimport { Role } from \"./model/Role\";\r\n\r\nexport default class RoleService extends BaseService {\r\n\r\n static $inject = [\"$http\", \"$cacheFactory\", \"$q\", \"$rootScope\", \"$log\", \"appSettings\"];\r\n\r\n constructor($http: ng.IHttpService,\r\n $cacheFactory: ng.ICacheFactoryService,\r\n $q: ng.IQService,\r\n $rootScope: ng.IRootScopeService,\r\n $log: ng.ILogService,\r\n appSettings: any,\r\n apiUrlFragment: string) {\r\n super($http, $cacheFactory, $q, $rootScope, $log, appSettings, apiUrlFragment);\r\n this.baseUrl = `${appSettings.SERVICE_URL}/api/v1.0`;\r\n }\r\n\r\n getRolesByCompany(companyId: number): ng.IPromise {\r\n return this.getAllByUrlPart(`${this.apiUrlFragment}/Company/${companyId}`)\r\n }\r\n\r\n public static Factory($http: ng.IHttpService,\r\n $cacheFactory: ng.ICacheFactoryService,\r\n $q: ng.IQService,\r\n $rootScope: ng.IRootScopeService,\r\n $log: ng.ILogService,\r\n appSettings: any): RoleService {\r\n return new RoleService($http, $cacheFactory, $q, $rootScope, $log, appSettings, \"roles\");\r\n }\r\n}","/// \r\n/// \r\n/// \r\n\r\nimport { module } from \"angular\";\r\nimport IBDate, { DateCompareGranularities } from \"../core/IBDate\";\r\nimport BaseService from \"../services/base/BaseService\";\r\nimport { ArticleGroup } from \"./model/ArticleGroup\";\r\n\r\nexport default class OrderingArticleGroupService extends BaseService {\r\n\r\n static $inject = [\"$http\", \"$cacheFactory\", \"$q\", \"$rootScope\", \"$log\", \"appSettings\"];\r\n\r\n constructor($http: ng.IHttpService,\r\n $cacheFactory: ng.ICacheFactoryService,\r\n $q: ng.IQService,\r\n $rootScope: ng.IRootScopeService,\r\n $log: ng.ILogService,\r\n appSettings: any,\r\n apiUrlFragment: string) {\r\n super($http, $cacheFactory, $q, $rootScope, $log, appSettings, apiUrlFragment);\r\n this.baseUrl = `${appSettings.SERVICE_URL}/api/v1.0`;\r\n }\r\n\r\n getAllByCustomerAndDeliveryDate(customerId: number, deliveryDate: IBDate): ng.IPromise {\r\n return this.getAllByUrlPart(`${this.apiUrlFragment}/customer/${customerId}/deliverydate/${deliveryDate.toJSONDate()}`);\r\n }\r\n\r\n public static Factory($http: ng.IHttpService,\r\n $cacheFactory: ng.ICacheFactoryService,\r\n $q: ng.IQService,\r\n $rootScope: ng.IRootScopeService,\r\n $log: ng.ILogService,\r\n appSettings: any): OrderingArticleGroupService {\r\n return new OrderingArticleGroupService($http, $cacheFactory, $q, $rootScope, $log, appSettings, \"orderingArticleGroups\");\r\n }\r\n}","/// \r\n/// \r\n/// \r\n/// \r\n\r\nimport { module } from \"angular\";\r\nimport IBDate from \"../core/IBDate\";\r\nimport BaseService from \"../services/base/BaseService\";\r\nimport IHttpPromiseError from \"../core/IHttpPromiseError\";\r\nimport { Information } from \"./model/Information\";\r\n\r\nexport default class InformationService extends BaseService {\r\n\r\n static $inject = [\"$http\", \"$cacheFactory\", \"$q\", \"$rootScope\", \"$log\", \"appSettings\"];\r\n\r\n constructor($http: ng.IHttpService,\r\n $cacheFactory: ng.ICacheFactoryService,\r\n $q: ng.IQService,\r\n $rootScope: ng.IRootScopeService,\r\n $log: ng.ILogService,\r\n appSettings: any,\r\n apiUrlFragment: string) {\r\n super($http, $cacheFactory, $q, $rootScope, $log, appSettings, apiUrlFragment);\r\n this.baseUrl = `${appSettings.SERVICE_URL}/api/v1.0`;\r\n }\r\n\r\n getAllByCompany(companyId: number): ng.IPromise {\r\n return this.getAllByUrlPart(`${this.apiUrlFragment}/Company/${companyId}`);\r\n }\r\n\r\n getAllFilteredByCompanyAndCustomer(companyId: number, customerId: number): ng.IPromise {\r\n return this.getAllByUrlPart(`${this.apiUrlFragment}/Company/${companyId}/Customer/${customerId}`);\r\n }\r\n\r\n getOneById(informationId: number): ng.IPromise {\r\n return this.getOneByUrlPart(`${this.apiUrlFragment}/${informationId}/`);\r\n }\r\n\r\n createInformation(information: Information): ng.IPromise {\r\n var d = this.$q.defer();\r\n\r\n this.$http.post(`${this.url}/`, information).then((response) => {\r\n d.resolve(response.data);\r\n }).catch((error) => {\r\n let e: IHttpPromiseError = error as IHttpPromiseError;\r\n if (e != null && e.status === 401) {\r\n this.raiseEvent(\"invalidToken\");\r\n d.reject();\r\n } else {\r\n d.reject(error);\r\n }\r\n });\r\n\r\n return d.promise;\r\n }\r\n\r\n removeInformation(informationId: number): ng.IPromise {\r\n var d = this.$q.defer();\r\n\r\n this.$http.delete(`${this.url}/${informationId}`).then((response) => {\r\n d.resolve();\r\n }).catch((error) => {\r\n let e: IHttpPromiseError = error as IHttpPromiseError;\r\n if (e != null && e.status === 401) {\r\n this.raiseEvent(\"invalidToken\");\r\n d.reject();\r\n } else {\r\n d.reject(error);\r\n }\r\n });\r\n\r\n return d.promise;\r\n }\r\n\r\n updateInformation(information: Information): ng.IPromise {\r\n var d = this.$q.defer();\r\n\r\n this.$http.put(`${this.url}/${information.id}`, information).then((response) => {\r\n d.resolve();\r\n }).catch((error) => {\r\n let e: IHttpPromiseError = error as IHttpPromiseError;\r\n if (e != null && e.status === 401) {\r\n this.raiseEvent(\"invalidToken\");\r\n d.reject();\r\n } else {\r\n d.reject(error);\r\n }\r\n });\r\n\r\n return d.promise;\r\n }\r\n\r\n public static Factory($http: ng.IHttpService,\r\n $cacheFactory: ng.ICacheFactoryService,\r\n $q: ng.IQService,\r\n $rootScope: ng.IRootScopeService,\r\n $log: ng.ILogService,\r\n appSettings: any): InformationService {\r\n return new InformationService($http, $cacheFactory, $q, $rootScope, $log, appSettings, \"Informations\");\r\n }\r\n}","/// \r\n/// \r\n/// \r\n/// \r\n\r\nimport { module } from \"angular\";\r\nimport IBDate from \"../core/IBDate\";\r\nimport BaseService from \"../services/base/BaseService\";\r\nimport IHttpPromiseError from \"../core/IHttpPromiseError\";\r\nimport { ReturnOrdering } from \"./model/ReturnOrdering\";\r\n\r\nexport default class ReturnOrderingService extends BaseService {\r\n\r\n static $inject = [\"$http\", \"$cacheFactory\", \"$q\", \"$rootScope\", \"$log\", \"appSettings\"];\r\n\r\n constructor($http: ng.IHttpService,\r\n $cacheFactory: ng.ICacheFactoryService,\r\n $q: ng.IQService,\r\n $rootScope: ng.IRootScopeService,\r\n $log: ng.ILogService,\r\n appSettings: any,\r\n apiUrlFragment: string) {\r\n super($http, $cacheFactory, $q, $rootScope, $log, appSettings, apiUrlFragment);\r\n this.baseUrl = `${appSettings.SERVICE_URL}/api/v1.0`;\r\n }\r\n\r\n getAllByCustomer(customerId: number, orderingTypeId: number, deliveryDate: IBDate): ng.IPromise {\r\n return this.getOneByUrlPart(`${this.apiUrlFragment}/Customer/${customerId}/OrderingType/${orderingTypeId}/DeliveryDate/${deliveryDate.toJSONDate()}`);\r\n }\r\n\r\n removeReturnOrdering(returnOrderingId: number): ng.IPromise {\r\n return this.delete(returnOrderingId);\r\n }\r\n\r\n public static Factory($http: ng.IHttpService,\r\n $cacheFactory: ng.ICacheFactoryService,\r\n $q: ng.IQService,\r\n $rootScope: ng.IRootScopeService,\r\n $log: ng.ILogService,\r\n appSettings: any): ReturnOrderingService {\r\n return new ReturnOrderingService($http, $cacheFactory, $q, $rootScope, $log, appSettings, \"returnOrderings\");\r\n }\r\n}","/// \r\n/// \r\n\r\nimport { module, IOnChangesObject, IChangesObject, IPromise } from \"angular\";\r\nimport StateOrderParameters from \"../core/StateOrderParameters\";\r\nimport IBDate, { DateCompareGranularities } from \"../core/IBDate\";\r\nimport SpinnerService from \"../services/SpinnerService\";\r\nimport { IAuthenticatedParameters } from \"../core/StateParameters\";\r\nimport { TransitionService, Transition } from \"@uirouter/angularjs\";\r\nimport { IStateOptions } from \"angular-ui-router\";\r\nimport HtmlStorageService from \"../services/HtmlStorageService\";\r\nimport { Customer } from \"../services/model/Customer\";\r\nimport { CalendarDay } from \"../services/model/CalendarDay\";\r\n\r\nexport enum DisplayMonthDay {\r\n PreviousDay = -1,\r\n CurrentDay = 0,\r\n NextDay = 1,\r\n Sunday = 10,\r\n Monday = 11,\r\n Tuesday = 12,\r\n Wednesday = 13,\r\n Thursday = 14,\r\n Friday = 15,\r\n Saturday = 16\r\n}\r\n\r\nexport class CalendarController implements ng.IController {\r\n static $inject = [\"$http\", \"$rootScope\", \"$scope\", \"$state\", \"$timeout\", \"$q\", \"$transitions\", \"$window\", \"$log\", \"$interval\", \"spinnerService\", \"htmlStorageService\"];\r\n\r\n constructor(private $http: ng.IHttpService,\r\n private $rootScope: ng.IRootScopeService,\r\n private $scope: ng.IScope,\r\n private $state: angular.ui.IStateService,\r\n private $timeout: ng.ITimeoutService,\r\n private $q: ng.IQService,\r\n private $transitions: TransitionService,\r\n private $window: ng.IWindowService,\r\n private $log: ng.ILogService,\r\n private $interval: ng.IIntervalService,\r\n private spinnerService: SpinnerService,\r\n private htmlStorageService: HtmlStorageService) {\r\n this.calendarDays = new Array(42);\r\n this.dayNo = new Array(42);\r\n this.dayStyle = new Array(42);\r\n\r\n this.updateIntervalPromise = $interval(this.updateInverval, ((60 * 1000) * 5));\r\n }\r\n\r\n private updateIntervalPromise: IPromise;\r\n\r\n calendarDays: CalendarDay[];\r\n\r\n dayNo: number[];\r\n dayStyle: string[];\r\n selectedCustomerId: number;\r\n orderStopTime: IBDate;\r\n selectedIndex: number;\r\n todayIndex: number;\r\n\r\n currentYear: number;\r\n currentMonth: number;\r\n currentMonthName: string;\r\n previousMonthName: string;\r\n nextMonthName: string;\r\n\r\n calendarDay(index: number): CalendarDay {\r\n if (this.calendarDays === null || typeof this.calendarDays === \"undefined\") {\r\n return null;\r\n }\r\n\r\n return this.calendarDays[index];\r\n }\r\n\r\n previousMonth(): void {\r\n this.currentMonth--;\r\n\r\n if (this.currentMonth < 0) {\r\n this.currentMonth = 11;\r\n this.currentYear--;\r\n }\r\n\r\n this.updateMonthNames();\r\n this.loadCalendarDays();\r\n }\r\n\r\n nextMonth(): void {\r\n this.currentMonth++;\r\n\r\n if (this.currentMonth > 11) {\r\n this.currentMonth = 0;\r\n this.currentYear++;\r\n }\r\n\r\n this.updateMonthNames();\r\n this.loadCalendarDays();\r\n }\r\n\r\n isSelected(index: number) {\r\n return index === this.selectedIndex;\r\n }\r\n\r\n selectedCalendarDayChanged(index: number): void {\r\n this.selectedIndex = index;\r\n if (this.calendarDays === null || typeof this.calendarDays === \"undefined\") {\r\n return;\r\n }\r\n\r\n this.onSelectedCalendarDayChanged({ value: this.calendarDays[index] });\r\n }\r\n\r\n private updateInverval = () => {\r\n this.loadCalendarDays();\r\n }\r\n\r\n private updateMonthNames() {\r\n var previousMonthNumber = this.currentMonth - 1;\r\n var nextMonthNumber = this.currentMonth + 1;\r\n\r\n if (previousMonthNumber < 0) {\r\n previousMonthNumber = 11;\r\n }\r\n\r\n if (nextMonthNumber > 11) {\r\n nextMonthNumber = 0;\r\n }\r\n\r\n this.currentMonthName = IBDate.getMonthName(this.currentMonth);\r\n this.previousMonthName = IBDate.getMonthName(previousMonthNumber);\r\n this.nextMonthName = IBDate.getMonthName(nextMonthNumber);\r\n }\r\n\r\n private loadCalendarDays(isRefresh?: boolean): void {\r\n let self = this;\r\n if (isRefresh == undefined || isRefresh == false) {\r\n this.spinnerService.showBusy();\r\n }\r\n\r\n this.onLoadCalanderDays({ value: { year: this.currentYear, month: this.currentMonth + 1 } }).then((calendarDays: CalendarDay[]) => {\r\n self.calendarDays = calendarDays;\r\n\r\n var todayDate = IBDate.now();\r\n //if (isRefresh == undefined || isRefresh === false) {\r\n self.selectedIndex = -1;\r\n //}\r\n self.calendarDays.forEach((calendarDay: CalendarDay, index: number) => {\r\n var d = new IBDate(calendarDay.date);\r\n this.dayNo[index] = d.getDate();\r\n\r\n if (this.selectedDate != undefined) {\r\n if (d.equalsTo(self.selectedDate, DateCompareGranularities.Date)) {\r\n self.selectedIndex = index;\r\n }\r\n }\r\n\r\n if (d.equalsTo(todayDate, DateCompareGranularities.Date)) {\r\n self.todayIndex = index;\r\n }\r\n }, self);\r\n }).catch((a: any) => {\r\n self.$log.error(\"Failed to get days: \" + a.toString());\r\n }).finally(() => {\r\n if (isRefresh == undefined || isRefresh == false) {\r\n this.spinnerService.hideBusy();\r\n }\r\n });\r\n }\r\n\r\n private setDisplayDate(): void {\r\n let displayDate: IBDate;\r\n\r\n if (this.displayMonthDay === DisplayMonthDay.PreviousDay || this.displayMonthDay === DisplayMonthDay.CurrentDay || this.displayMonthDay === DisplayMonthDay.NextDay) {\r\n displayDate = new IBDate(this.selectedDate).addDays(this.displayMonthDay);\r\n } else {\r\n let currentDay = this.selectedDate.getDay();\r\n let daysToAddOrSubtract = (this.displayMonthDay) - 10 - currentDay;\r\n displayDate = new IBDate(this.selectedDate).addDays(daysToAddOrSubtract);\r\n }\r\n\r\n this.currentYear = displayDate.getFullYear();\r\n this.currentMonth = displayDate.getMonth();\r\n this.updateMonthNames();\r\n }\r\n\r\n private outPutPayLoad(value: any): { value: any } {\r\n return { value: value };\r\n }\r\n\r\n /*** ng.IController and ng.IDoCheck methods ***/\r\n $onChanges?(onChangesObj: IOnChangesObject): void {\r\n //let changedSysUserId = onChangesObj[\"sysUserId\"] as IChangesObject;\r\n //if (this.sysUserId !== null && typeof this.sysUserId !== \"undefined\") {\r\n // // ...\r\n //}\r\n }\r\n\r\n $doCheck(): void {\r\n if (this.reload != undefined && this.reload === true) {\r\n this.loadCalendarDays();\r\n this.reload = undefined;\r\n }\r\n }\r\n\r\n $onInit(): void {\r\n if (this.selectedDate == undefined) {\r\n this.selectedDate = new IBDate();\r\n this.setDisplayDate();\r\n } else {\r\n this.setDisplayDate();\r\n }\r\n this.loadCalendarDays();\r\n }\r\n\r\n $onDestroy(): void {\r\n if (this.updateIntervalPromise != undefined) {\r\n this.$interval.cancel(this.updateIntervalPromise);\r\n this.updateIntervalPromise = null;\r\n }\r\n }\r\n\r\n /*** Bindings properties ***/\r\n trans: Transition;\r\n displayMonthDay: DisplayMonthDay;\r\n selectedDate: IBDate;\r\n reload: boolean;\r\n\r\n /*** Bindings callbacks ***/\r\n onSelectedCalendarDayChanged: (param: { value: CalendarDay }) => ng.IPromise;\r\n onLoadCalanderDays: (param: { value: { year: number, month: number } }) => ng.IPromise;\r\n}\r\n\r\nexport default class CalendarComponent implements ng.IComponentOptions {\r\n bindings?: { [boundProperty: string]: string };\r\n templateUrl: string;\r\n controller: ng.Injectable;\r\n\r\n constructor() {\r\n this.controller = CalendarController;\r\n this.templateUrl = './dist/app/calendar/calendar.template.html';\r\n this.bindings = {\r\n trans: '<'\r\n , displayMonthDay: '<'\r\n , selectedDate: '<'\r\n , reload: '='\r\n , onSelectedCalendarDayChanged: '&'\r\n , onLoadCalanderDays: '&'\r\n }\r\n //this.bindings = {\r\n // twoWay: '=',\r\n // oneWayString: '@',\r\n // onUpdate: '&'\r\n //}\r\n }\r\n}","/// \r\n/// \r\n/// \r\n/// \r\n\r\nimport { module } from \"angular\";\r\nimport IBDate from \"../core/IBDate\";\r\nimport BaseService from \"../services/base/BaseService\";\r\nimport IHttpPromiseError from \"../core/IHttpPromiseError\";\r\nimport { TemplateInfo } from \"./model/TemplateInfo\";\r\n\r\nexport default class TemplateInfoService extends BaseService {\r\n\r\n static $inject = [\"$http\", \"$cacheFactory\", \"$q\", \"$rootScope\", \"$log\", \"appSettings\"];\r\n\r\n constructor($http: ng.IHttpService,\r\n $cacheFactory: ng.ICacheFactoryService,\r\n $q: ng.IQService,\r\n $rootScope: ng.IRootScopeService,\r\n $log: ng.ILogService,\r\n appSettings: any,\r\n apiUrlFragment: string) {\r\n super($http, $cacheFactory, $q, $rootScope, $log, appSettings, apiUrlFragment);\r\n this.baseUrl = `${appSettings.SERVICE_URL}/api/v1.0`;\r\n }\r\n\r\n getAllByCustomer(customerId: number): ng.IPromise {\r\n return this.getAllByUrlPart(`${this.apiUrlFragment}/Customer/${customerId}`);\r\n }\r\n\r\n public static Factory($http: ng.IHttpService,\r\n $cacheFactory: ng.ICacheFactoryService,\r\n $q: ng.IQService,\r\n $rootScope: ng.IRootScopeService,\r\n $log: ng.ILogService,\r\n appSettings: any): TemplateInfoService {\r\n return new TemplateInfoService($http, $cacheFactory, $q, $rootScope, $log, appSettings, \"TemplateInfos\");\r\n }\r\n}","/// \r\n/// \r\n/// \r\n/// \r\n\r\nimport { module } from \"angular\";\r\nimport IBDate from \"../core/IBDate\";\r\nimport BaseService from \"../services/base/BaseService\";\r\nimport IHttpPromiseError from \"../core/IHttpPromiseError\";\r\nimport { Template } from \"./model/Template\";\r\nimport { CreateTemplateResult } from \"./model/CreateTemplateResult\";\r\n\r\nexport default class TemplateService extends BaseService {\r\n\r\n static $inject = [\"$http\", \"$cacheFactory\", \"$q\", \"$rootScope\", \"$log\", \"appSettings\"];\r\n\r\n constructor($http: ng.IHttpService,\r\n $cacheFactory: ng.ICacheFactoryService,\r\n $q: ng.IQService,\r\n $rootScope: ng.IRootScopeService,\r\n $log: ng.ILogService,\r\n appSettings: any,\r\n apiUrlFragment: string) {\r\n super($http, $cacheFactory, $q, $rootScope, $log, appSettings, apiUrlFragment);\r\n this.baseUrl = `${appSettings.SERVICE_URL}/api/v1.0`;\r\n }\r\n\r\n createTemplateFromOrdering(customerId: number, templateName: string, templateOrderingTypeId: number, fromDeliveryDate: IBDate): ng.IPromise {\r\n return this.createByUrlPartAndResultType(`${this.apiUrlFragment}/Customer/${customerId}/TemplateName/${templateName}/TemplateOrderingType/${templateOrderingTypeId}/FromDeliveryDate/${fromDeliveryDate.toJSONDate()}`,null);\r\n }\r\n\r\n createTemplateFromTemplate(customerId: number, templateName: string, templateOrderingTypeId: number, fromTemplateId: number): ng.IPromise {\r\n return this.createByUrlPartAndResultType(`${this.apiUrlFragment}/Customer/${customerId}/TemplateName/${templateName}/TemplateOrderingType/${templateOrderingTypeId}/FromTemplate/${fromTemplateId}`,null);\r\n }\r\n\r\n getOneByTemplateId(templateId: number): ng.IPromise {\r\n return this.getOneByUrlPart(`${this.apiUrlFragment}/${templateId}`);\r\n }\r\n\r\n getOneByCustomerAndPreviousDeliveryDate(customerId: number, previousDeliveryDate: IBDate): ng.IPromise {\r\n return this.getOneByUrlPart(`${this.apiUrlFragment}/Customer/${customerId}/PreviousDeliveryDate/${previousDeliveryDate.toJSONDate()}`);\r\n }\r\n\r\n deleteTemplate(templateId: number): ng.IPromise {\r\n return this.delete(templateId);\r\n }\r\n\r\n public static Factory($http: ng.IHttpService,\r\n $cacheFactory: ng.ICacheFactoryService,\r\n $q: ng.IQService,\r\n $rootScope: ng.IRootScopeService,\r\n $log: ng.ILogService,\r\n appSettings: any): TemplateService {\r\n return new TemplateService($http, $cacheFactory, $q, $rootScope, $log, appSettings, \"Templates\");\r\n }\r\n}","import { module, IOnChangesObject, IChangesObject } from \"angular\";\r\nimport HtmlStorageService from \"../services/HtmlStorageService\";\r\nimport SpinnerService from \"../services/SpinnerService\";\r\nimport IBDate from \"../core/IBDate\";\r\nimport { Transition, TransitionService } from \"@uirouter/angularjs\";\r\nimport { TemplateRow } from \"../services/model/TemplateRow\";\r\nimport { Template } from \"../services/model/Template\";\r\nimport OrderingTemplateRowService from \"../services/OrderingTemplateRowService\";\r\nimport OrderingTemplateService from \"../services/OrderingTemplateService\";\r\nimport IHttpPromiseError from \"../core/IHttpPromiseError\";\r\nimport OrderingService from \"../services/OrderingService\";\r\nimport { Ordering } from \"../services/model/Ordering\";\r\nimport { IAuthenticatedParameters } from \"../core/StateParameters\";\r\n\r\ntype OrderingOrderOrderingTemplateEvents =\r\n \"OrderingOrderOrderingTemplateResetSearch\";\r\n\r\n\r\nexport class OrderingOrderTemplateController implements ng.IController { // ng.IDoCheck\r\n static $inject = [\"$http\", \"$rootScope\", \"$scope\", \"$state\", \"$timeout\", \"$q\", \"$transitions\", \"$interval\", \"$window\", \"$log\", \"spinnerService\", \"htmlStorageService\", \"orderingService\", \"orderingTemplateRowService\", \"orderingTemplateService\"];\r\n\r\n constructor(private $http: ng.IHttpService,\r\n private $rootScope: ng.IRootScopeService,\r\n private $scope: ng.IScope,\r\n private $state: angular.ui.IStateService,\r\n private $timeout: ng.ITimeoutService,\r\n private $q: ng.IQService,\r\n private $transitions: TransitionService,\r\n private $interval: ng.IIntervalService,\r\n private $window: ng.IWindowService,\r\n private $log: ng.ILogService,\r\n private spinnerService: SpinnerService,\r\n private htmlStorageService: HtmlStorageService,\r\n private orderingService: OrderingService,\r\n private orderingTemplateRowService: OrderingTemplateRowService,\r\n private orderingTemplateService: OrderingTemplateService) {\r\n }\r\n\r\n private _selectedPaginationItem: { value: number, label: string };\r\n paginationItems = [{\r\n value: 10,\r\n label: '10'\r\n }, {\r\n value: 15,\r\n label: '15'\r\n },\r\n {\r\n value: 20,\r\n label: '20'\r\n },\r\n {\r\n value: 25,\r\n label: '25'\r\n },\r\n {\r\n value: 30,\r\n label: '30'\r\n }, {\r\n value: 40,\r\n label: '40'\r\n }, {\r\n value: 50,\r\n label: '50'\r\n }, {\r\n value: 99999,\r\n label: 'Alla'\r\n }];\r\n\r\n get selectedPaginationItem(): { value: number, label: string } {\r\n if (this._selectedPaginationItem == undefined) {\r\n let spi = <{ value: number, label: string }>this.htmlStorageService.getLocalStorageItem(\"lastPaginationItemOrderingOrderTemplate\");\r\n if (spi == undefined) {\r\n this.selectedPaginationItem = this.paginationItems[0];\r\n }\r\n else {\r\n this.selectedPaginationItem = spi;\r\n }\r\n }\r\n return this._selectedPaginationItem;\r\n }\r\n\r\n set selectedPaginationItem(item: { value: number, label: string }) {\r\n this._selectedPaginationItem = item;\r\n this.htmlStorageService.setLocalStorageItem(\"lastPaginationItemOrderingOrderTemplate\", item);\r\n }\r\n\r\n textDeliveryInformation: string = `Leveransinformation`;\r\n textPreviousOrderings: string = `Tidigare beställningar`;\r\n\r\n get textUseTemplate(): string {\r\n return (this.templateId === -2) ? `Använd tidigare beställning` : (this.template == undefined) ? `Använd beställningsmall` : `Använd ${this.template.templateOrderingName}`;\r\n }\r\n\r\n get textTemplateName(): string {\r\n return (this.templateId === -2) ? (this.selectedPreviousOrdering != undefined) ? this.selectedPreviousOrdering.deliveryDate.toLocaleDateString() : undefined : this.template.templateOrderingName;\r\n }\r\n\r\n showPreviousOrderings: boolean;\r\n\r\n previousOrderings: Ordering[];\r\n templateRows: TemplateRow[];\r\n template: Template;\r\n selectedPreviousOrdering: Ordering = undefined;\r\n\r\n sumQuantity: number;\r\n\r\n selectPreviousOrdering(): void {\r\n this.loadTemplateForPreviousOrdering();\r\n this.loadTemplateRowsForPreviousOrdering();\r\n }\r\n\r\n useTemplate(value: boolean): void {\r\n value = !!value;\r\n\r\n let previousDeliveryDate: IBDate = (this.templateId === -2 && this.selectedPreviousOrdering != undefined) ? new IBDate(this.selectedPreviousOrdering.deliveryDate) : undefined;\r\n this.onUseTemplate(this.outPutOnUseTemplatePayLoad(value, previousDeliveryDate));\r\n }\r\n\r\n private broadcastEvent(event: OrderingOrderOrderingTemplateEvents, ...args: any[]): void {\r\n this.$scope.$broadcast(event, args);\r\n }\r\n\r\n private loadPreviousOrderings(): void {\r\n this.spinnerService.showBusy();\r\n let self = this;\r\n this.orderingService.getAllByCustomer(this.customerId).then((orderings: Ordering[]) => {\r\n self.previousOrderings = orderings;\r\n self.showPreviousOrderings = true;\r\n\r\n let today = new Date();\r\n for (var i = 0; i < orderings.length; i++) {\r\n if (orderings[i].deliveryDate < today) {\r\n self.selectedPreviousOrdering = orderings[i];\r\n self.selectPreviousOrdering();\r\n break;\r\n }\r\n }\r\n }).catch((error: IHttpPromiseError) => {\r\n self.$log.error(`Could not retrieve all orderings for customer ${this.customerId} (${error.status}:${error.statusText})`);\r\n }).finally(() => {\r\n self.spinnerService.hideBusy();\r\n });\r\n }\r\n\r\n private loadTemplate(): void {\r\n this.spinnerService.showBusy();\r\n this.template = undefined;\r\n let self = this;\r\n this.orderingTemplateService.getOneByTemplateId(this.templateId).then((template: Template) => {\r\n self.template = template;\r\n }).catch((error: IHttpPromiseError) => {\r\n self.$log.error(`Could not load template ${this.templateId} (${error.status}:${error.statusText})`);\r\n }).finally(() => {\r\n self.spinnerService.hideBusy();\r\n });\r\n }\r\n\r\n private loadTemplateForPreviousOrdering(): void {\r\n this.spinnerService.showBusy();\r\n this.template = undefined;\r\n let self = this;\r\n let previousDeliveryDate: IBDate = new IBDate(this.selectedPreviousOrdering.deliveryDate);\r\n this.orderingTemplateService.getOneByCustomerAndPreviousDeliveryDate(this.customerId, previousDeliveryDate).then((template: Template) => {\r\n self.template = template;\r\n }).catch((error: IHttpPromiseError) => {\r\n self.$log.error(`Could not load template for previous ordering date ${this.selectedPreviousOrdering.deliveryDate.toString()} (${error.status}:${error.statusText})`);\r\n }).finally(() => {\r\n self.spinnerService.hideBusy();\r\n });\r\n }\r\n\r\n private loadTemplateRows(): void {\r\n this.spinnerService.showBusy();\r\n this.templateRows = undefined;\r\n let self = this;\r\n this.orderingTemplateRowService.getAllByTemplateAndDeliveryDate(this.templateId, this.deliveryDate).then((templateRows: TemplateRow[]) => {\r\n self.sumQuantity = 0;\r\n templateRows.forEach((orderingRow, index, rows) => {\r\n this.sumQuantity += (orderingRow.quantity != undefined) ? orderingRow.quantity : 0;\r\n }, this);\r\n self.sumQuantity = self.sumQuantity === 0 ? undefined : self.sumQuantity;\r\n self.templateRows = templateRows;\r\n }).catch((error: IHttpPromiseError) => {\r\n self.$log.error(`Could not load template ${this.templateId} (${error.status}:${error.statusText})`);\r\n }).finally(() => {\r\n self.spinnerService.hideBusy();\r\n });\r\n }\r\n\r\n private loadTemplateRowsForPreviousOrdering(): void {\r\n this.spinnerService.showBusy();\r\n this.templateRows = undefined;\r\n let self = this;\r\n let previousDeliveryDate: IBDate = new IBDate(this.selectedPreviousOrdering.deliveryDate);\r\n this.orderingTemplateRowService.getAllByCustomerAndDeliveryDateAndPreviousDeliveryDate(this.customerId, this.deliveryDate, previousDeliveryDate).then((templateRows: TemplateRow[]) => {\r\n self.sumQuantity = 0;\r\n templateRows.forEach((orderingRow, index, rows) => {\r\n this.sumQuantity += (orderingRow.quantity != undefined) ? orderingRow.quantity : 0;\r\n }, this);\r\n self.sumQuantity = this.sumQuantity === 0 ? undefined : this.sumQuantity;\r\n self.templateRows = templateRows;\r\n }).catch((error: IHttpPromiseError) => {\r\n self.$log.error(`Could not load template ${this.templateId} (${error.status}:${error.statusText})`);\r\n }).finally(() => {\r\n self.spinnerService.hideBusy();\r\n });\r\n }\r\n\r\n private outPutOnUseTemplatePayLoad(value: boolean, previousDeliveryDate: IBDate): { value: boolean, deliveryDate: IBDate } {\r\n return { value: value, deliveryDate: previousDeliveryDate };\r\n }\r\n\r\n private handleTemplateIdChanged(): void {\r\n if (this.templateId != undefined) {\r\n\r\n this.broadcastEvent(\"OrderingOrderOrderingTemplateResetSearch\");\r\n\r\n if (this.templateId > 0) {\r\n this.showPreviousOrderings = false;\r\n this.loadTemplate();\r\n this.loadTemplateRows();\r\n } else if (this.templateId === -2) {\r\n this.loadPreviousOrderings();\r\n }\r\n }\r\n }\r\n\r\n /*** ng.IController and ng.IDoCheck methods ***/\r\n $onChanges?(onChangesObj: IOnChangesObject): void {\r\n let changedTemplateId = onChangesObj[\"templateId\"] as IChangesObject;\r\n if (this.templateId != undefined && changedTemplateId != undefined) {\r\n this.handleTemplateIdChanged();\r\n }\r\n }\r\n\r\n $onInit(): void {\r\n }\r\n\r\n $onDestroy(): void {\r\n }\r\n\r\n //$doCheck(): void {}\r\n\r\n /*** Bindings properties ***/\r\n trans: Transition;\r\n customerId: number;\r\n templateId: number;\r\n deliveryDate: IBDate;\r\n\r\n /*** Bindings callbacks ***/\r\n onUseTemplate: (param: { value: boolean, deliveryDate: IBDate }) => ng.IPromise;\r\n}\r\n\r\nexport default class OrderingOrderTemplateComponent implements ng.IComponentOptions {\r\n bindings?: { [boundProperty: string]: string };\r\n templateUrl: string;\r\n controller: ng.Injectable;\r\n\r\n constructor() {\r\n this.controller = OrderingOrderTemplateController;\r\n this.templateUrl = './dist/app/ordering/ordering-order-template.template.html';\r\n this.bindings = {\r\n trans: '<',\r\n customerId: '<',\r\n templateId: '<',\r\n deliveryDate: '<',\r\n onUseTemplate: '&'\r\n }\r\n }\r\n}","/// \r\n/// \r\n/// \r\n\r\nimport { module } from \"angular\";\r\nimport IBDate from \"../core/IBDate\";\r\nimport BaseService from \"../services/base/BaseService\";\r\nimport { Customer } from \"./model/Customer\";\r\n\r\nexport default class CustomerService extends BaseService {\r\n\r\n static $inject = [\"$http\", \"$cacheFactory\", \"$q\", \"$rootScope\", \"$log\", \"appSettings\"];\r\n\r\n constructor($http: ng.IHttpService,\r\n $cacheFactory: ng.ICacheFactoryService,\r\n $q: ng.IQService,\r\n $rootScope: ng.IRootScopeService,\r\n $log: ng.ILogService,\r\n appSettings: any,\r\n apiUrlFragment: string) {\r\n super($http, $cacheFactory, $q, $rootScope, $log, appSettings, apiUrlFragment);\r\n this.baseUrl = `${appSettings.SERVICE_URL}/api/v1.0`;\r\n }\r\n\r\n public getValidCustomersPerUser(sysUserId: number): ng.IPromise {\r\n return this.getAllByUrlPart(`${this.apiUrlFragment}/User/${sysUserId}/`);\r\n }\r\n\r\n public getCustomerInformation(sysUserId: number, customerId: number): ng.IPromise {\r\n return this.getOneByUrlPart(`${this.apiUrlFragment}/${customerId}/User/${sysUserId}/`);\r\n }\r\n\r\n public getCustomersByCompany(companyId: number): ng.IPromise {\r\n return this.getAllByUrlPart(`${this.apiUrlFragment}/Company/${companyId}/`);\r\n }\r\n\r\n public static Factory($http: ng.IHttpService,\r\n $cacheFactory: ng.ICacheFactoryService,\r\n $q: ng.IQService,\r\n $rootScope: ng.IRootScopeService,\r\n $log: ng.ILogService,\r\n appSettings: any): CustomerService {\r\n return new CustomerService($http, $cacheFactory, $q, $rootScope, $log, appSettings, \"customers\");\r\n }\r\n}","/// \r\n/// \r\n/// \r\n/// \r\n/// \r\n\r\nimport { module } from \"angular\";\r\nimport IBDate from \"./core/IBDate\";\r\nimport ImageHelper from \"./core/ImageHelper\";\r\nimport StateOrderParameters from \"./core/StateOrderParameters\";\r\nimport IStateOrderParameters from \"./core/StateOrderParameters\";\r\nimport SpinnerService from \"./services/SpinnerService\";\r\nimport AuthenticationService from \"./services/AuthenticationService\";\r\nimport HtmlStorageService from \"./services/HtmlStorageService\";\r\nimport CustomerService from \"./services/CustomerService\";\r\nimport CompanyService from \"./services/CompanyService\";\r\nimport { TransitionService } from '@uirouter/angularjs';\r\nimport { IRootStateParameters } from \"./core/StateParameters\";\r\nimport { IStateOptions } from \"angular-ui-router\";\r\nimport { AppInsights } from \"applicationinsights-js\";\r\n\r\n\r\nclass AppController implements ng.IController {\r\n static $inject = [\"$http\", \"$rootScope\", \"$scope\", \"$state\", \"$timeout\", \"$transitions\", \"$window\", \"appSettings\", \"spinnerService\", \"authenticationService\", \"htmlStorageService\", \"customerService\", \"companyService\"];\r\n\r\n constructor(private $http: ng.IHttpService,\r\n private $rootScope: ng.IRootScopeService,\r\n private $scope: ng.IScope,\r\n private $state: angular.ui.IStateService,\r\n private $timeout: ng.ITimeoutService,\r\n private $transitions: TransitionService,\r\n private $window: ng.IWindowService,\r\n private appSettings: any,\r\n private spinnerService: SpinnerService,\r\n private authenticationService: AuthenticationService,\r\n private htmlStorageService: HtmlStorageService,\r\n private customerService: CustomerService,\r\n private companyService: CompanyService) {\r\n\r\n appInsights.trackTrace(\"AppController initialised\");\r\n\r\n this.showBusyIndicator = false;\r\n this.dimBusyIndicator = false;\r\n\r\n this.$window.onbeforeunload = () => {\r\n // How to detect refresh events?\r\n //this.authenticationService.signoutUser(false);\r\n };\r\n\r\n this.$scope.$on(\"busyChanged\", (event: ng.IAngularEvent, args: any[]) => { this.updateBusyIndicator(args[0]); });\r\n this.$scope.$on(\"invalidToken\", (event: ng.IAngularEvent, args: any[]) => { this.onInvalidToken() });\r\n this.$scope.$on(\"authenticationChanged\", (event: ng.IAngularEvent, args: any[]) => { this.updateIsAuthenticated(args[0]); });\r\n }\r\n\r\n private onInvalidToken(): void {\r\n let msg: string = `Invalid token. Redirecting to login page.`;\r\n console.error(msg);\r\n //this.$window.alert(msg);\r\n this.spinnerService.showBusy();\r\n this.authenticationService.signoutUser(true, true);\r\n\r\n this.$state.go(\"root.authenticate\").finally(() => {\r\n this.spinnerService.hideBusy();\r\n });\r\n }\r\n\r\n private updateBusyIndicator(busy: boolean): void {\r\n if (busy) {\r\n if (this.dimBusyPromise != null) {\r\n return;\r\n }\r\n\r\n this.dimBusyPromise = this.$timeout(2500);\r\n\r\n var self = this;\r\n\r\n this.dimBusyPromise.then(p => {\r\n self.dimBusyIndicator = true;\r\n })\r\n .catch(reason => {\r\n self.dimBusyIndicator = false;\r\n });\r\n } else {\r\n if (this.dimBusyPromise != null) {\r\n this.$timeout.cancel(this.dimBusyPromise);\r\n this.dimBusyPromise = null;\r\n }\r\n\r\n this.dimBusyIndicator = false;\r\n }\r\n\r\n this.showBusyIndicator = busy;\r\n }\r\n\r\n private updateIsAuthenticated(authenticated: boolean): void {\r\n\r\n }\r\n\r\n dimBusyPromise: ng.IPromise;\r\n showBusyIndicator: boolean;\r\n dimBusyIndicator: boolean;\r\n}\r\n\r\nexport default class AppComponent implements ng.IComponentOptions {\r\n bindings?: { [boundProperty: string]: string };\r\n templateUrl: string;\r\n controller: ng.Injectable;\r\n\r\n constructor() {\r\n this.controller = AppController;\r\n this.templateUrl = './dist/app/app.template.html';\r\n }\r\n}","/// \r\n/// \r\n\r\nimport { module } from \"angular\";\r\nimport SpinnerService from \"../services/SpinnerService\";\r\n\r\nclass AdministrationDiffDaysController implements ng.IController {\r\n static $inject = [\"$scope\", \"spinnerService\"];\r\n\r\n constructor(private $scope: ng.IScope,\r\n private spinnerService: SpinnerService) {\r\n\r\n }\r\n\r\n title: string = \"Avvikande dagar...\";\r\n}\r\n\r\nexport default class AdministrationDiffDaysComponent implements ng.IComponentOptions {\r\n bindings?: { [boundProperty: string]: string };\r\n templateUrl: string;\r\n controller: ng.Injectable;\r\n\r\n constructor() {\r\n this.controller = AdministrationDiffDaysController;\r\n this.templateUrl = './dist/app/administration/administration-diff-days.template.html';\r\n }\r\n}","import { TrackedModel } from \"./TrackedModel\";\r\n\r\n export class File extends TrackedModel {\r\n /**\r\n * Constraints\r\n * Required\r\n */\r\n public companyId: number;\r\n /**\r\n * Constraints\r\n * Required\r\n */\r\n public data: number[];\r\n /**\r\n * Constraints\r\n * Required\r\n * StringLength: 4\r\n */\r\n public fileExtension: string;\r\n /**\r\n * Constraints\r\n * Required\r\n * StringLength: 300\r\n */\r\n public fileName: string;\r\n /**\r\n * Constraints\r\n * Required\r\n */\r\n public fileTypeId: number;\r\n public fromOrderSystem: boolean;\r\n /**\r\n * Constraints\r\n * Optional\r\n */\r\n public metaData: { [key: string]: string; };\r\n}","/// \r\n/// \r\n\r\nimport { module } from \"angular\";\r\nimport SpinnerService from \"../services/SpinnerService\";\r\n\r\nclass SupportController implements ng.IController {\r\n static $inject = [\"$scope\", \"spinnerService\"];\r\n\r\n constructor(private $scope: ng.IScope,\r\n private spinnerService: SpinnerService) {\r\n\r\n }\r\n\r\n //title: string = \"Supportsida\";\r\n}\r\n\r\nexport default class SupportComponent implements ng.IComponentOptions {\r\n bindings?: { [boundProperty: string]: string };\r\n templateUrl: string;\r\n controller: ng.Injectable;\r\n\r\n constructor() {\r\n this.controller = SupportController;\r\n this.templateUrl = './dist/app/support/support.template.html';\r\n }\r\n}","/// \r\n\r\nimport IHttpPromiseError from \"../../core/IHttpPromiseError\";\r\n\r\nexport default class BaseService {\r\n static $inject = [\"$http\", \"$cacheFactory\", \"$q\", \"$rootScope\", \"$log\"];\r\n\r\n protected baseUrl: string;\r\n\r\n constructor(protected $http: ng.IHttpService,\r\n protected $cacheFactory: ng.ICacheFactoryService,\r\n protected $q: ng.IQService,\r\n protected $rootScope: ng.IRootScopeService,\r\n protected $log: ng.ILogService,\r\n appSettings: any,\r\n protected apiUrlFragment: string) {\r\n this.baseUrl = `${appSettings.SERVICE_URL}/api`;\r\n }\r\n\r\n protected get url(): string {\r\n return `${this.baseUrl}/${this.apiUrlFragment}`;\r\n }\r\n\r\n protected getOneByUrlPart(urlPart: string): ng.IPromise {\r\n var d = this.$q.defer();\r\n let self = this;\r\n\r\n this.$http.get(`${this.baseUrl}/${urlPart}`).then(response => {\r\n d.resolve(response.data);\r\n }).catch(error => {\r\n let e: IHttpPromiseError = error as IHttpPromiseError;\r\n if (e != null && e.status === 401) {\r\n this.raiseEvent(\"invalidToken\");\r\n d.reject();\r\n }\r\n else {\r\n let errorMsg: string = `An error occurred while getting one by url part. Url ${self.baseUrl}/${urlPart}. Error ${error}.`;\r\n self.$log.error(errorMsg);\r\n d.reject(error);\r\n }\r\n });\r\n\r\n return d.promise;\r\n }\r\n\r\n protected getOneByTypeAndUrlPart(urlPart: string): ng.IPromise {\r\n var d = this.$q.defer();\r\n let self = this;\r\n\r\n this.$http.get(`${this.baseUrl}/${urlPart}`).then(response => {\r\n d.resolve(response.data);\r\n }).catch(error => {\r\n let e: IHttpPromiseError = error as IHttpPromiseError;\r\n if (e != null && e.status === 401) {\r\n this.raiseEvent(\"invalidToken\");\r\n d.reject();\r\n }\r\n else {\r\n let errorMsg: string = `An error occurred while getting one by url part. Url ${self.baseUrl}/${urlPart}. Error ${error}.`;\r\n self.$log.error(errorMsg);\r\n d.reject(error);\r\n }\r\n });\r\n\r\n return d.promise;\r\n }\r\n\r\n protected getAllByUrlPart(urlPart: string): ng.IPromise {\r\n var d = this.$q.defer();\r\n let self = this;\r\n\r\n this.$http.get(`${this.baseUrl}/${urlPart}`).then(response => {\r\n d.resolve(response.data);\r\n }).catch(error => {\r\n let e: IHttpPromiseError = error as IHttpPromiseError;\r\n if (e != null && e.status === 401) {\r\n self.raiseEvent(\"invalidToken\");\r\n d.reject();\r\n } else {\r\n let errorMsg: string = `An error occurred while getting all by url part. Url ${self.baseUrl}/${urlPart}. Error ${error}.`;\r\n self.$log.error(errorMsg);\r\n\r\n d.reject(error);\r\n }\r\n });\r\n\r\n return d.promise;\r\n }\r\n\r\n protected create(item: T): ng.IPromise {\r\n var d = this.$q.defer();\r\n let self = this;\r\n\r\n this.$http.post(`${this.url}/`, item).then((response) => {\r\n d.resolve(response.data);\r\n }).catch((error) => {\r\n let e: IHttpPromiseError = error as IHttpPromiseError;\r\n if (e != null && e.status === 401) {\r\n this.raiseEvent(\"invalidToken\");\r\n d.reject();\r\n } else {\r\n let errorMsg: string = `An error occurred while creating a new item. Url ${self.url}. Error ${error}.`;\r\n self.$log.error(errorMsg);\r\n\r\n d.reject(error);\r\n }\r\n });\r\n\r\n return d.promise;\r\n }\r\n\r\n protected createByUrlPart(urlPart: string, item: T): ng.IPromise {\r\n var d = this.$q.defer();\r\n let self = this;\r\n\r\n this.$http.post(`${this.baseUrl}/${urlPart}`, item).then((response) => {\r\n d.resolve(response.data);\r\n }).catch((error) => {\r\n let e: IHttpPromiseError = error as IHttpPromiseError;\r\n if (e != null && e.status === 401) {\r\n this.raiseEvent(\"invalidToken\");\r\n d.reject();\r\n } else {\r\n let errorMsg: string = `An error occurred while creating a new item. Url ${self.baseUrl}/${urlPart}. Error ${error}.`;\r\n self.$log.error(errorMsg);\r\n\r\n d.reject(error);\r\n }\r\n });\r\n\r\n return d.promise;\r\n }\r\n\r\n protected createByUrlPartAndResultType(urlPart: string, item: T): ng.IPromise {\r\n var d = this.$q.defer();\r\n let self = this;\r\n\r\n this.$http.post(`${this.baseUrl}/${urlPart}`, item).then(response => {\r\n d.resolve(response.data);\r\n }).catch(error => {\r\n let e: IHttpPromiseError = error as IHttpPromiseError;\r\n if (e != null && e.status === 401) {\r\n self.raiseEvent(\"invalidToken\");\r\n d.reject();\r\n } else {\r\n let errorMsg: string = `An error occurred while invoking post by url part. Url ${self.baseUrl}/${urlPart}. Error ${error}.`;\r\n self.$log.error(errorMsg);\r\n\r\n d.reject(error);\r\n }\r\n });\r\n\r\n return d.promise;\r\n }\r\n\r\n protected patch(id:number, patch: any, urlPath?: string): ng.IPromise {\r\n var d = this.$q.defer();\r\n let self = this;\r\n\r\n let up = (urlPath == undefined) ? `${this.url}/${id}` : `${this.url}/${id}/${urlPath}/`;\r\n\r\n this.$http.patch(up, patch).then((response) => {\r\n d.resolve();\r\n }).catch((error) => {\r\n let e: IHttpPromiseError = error as IHttpPromiseError;\r\n if (e != null && e.status === 401) {\r\n this.raiseEvent(\"invalidToken\");\r\n d.reject();\r\n } else {\r\n let errorMsg: string = `An error occurred while updating an item. Url ${self.url}/${id}. Error ${error}.`;\r\n self.$log.error(errorMsg);\r\n\r\n d.reject(error);\r\n }\r\n });\r\n\r\n return d.promise;\r\n }\r\n\r\n protected update(id: number, item: T, urlPath?:string): ng.IPromise {\r\n var d = this.$q.defer();\r\n let self = this;\r\n\r\n let up = (urlPath == undefined) ? `${this.url}/${id}` : `${this.url}/${id}/${urlPath}/`;\r\n\r\n this.$http.put(up, item).then((response) => {\r\n d.resolve();\r\n }).catch((error) => {\r\n let e: IHttpPromiseError = error as IHttpPromiseError;\r\n if (e != null && e.status === 401) {\r\n this.raiseEvent(\"invalidToken\");\r\n d.reject();\r\n } else {\r\n let errorMsg: string = `An error occurred while updating an item. Url ${self.url}/${id}. Error ${error}.`;\r\n self.$log.error(errorMsg);\r\n\r\n d.reject(error);\r\n }\r\n });\r\n\r\n return d.promise;\r\n }\r\n\r\n protected updateByUrlPart(urlPart: string, item: T): ng.IPromise {\r\n var d = this.$q.defer();\r\n let self = this;\r\n\r\n this.$http.put(`${this.baseUrl}/${urlPart}`, item).then((response) => {\r\n d.resolve();\r\n }).catch((error) => {\r\n let e: IHttpPromiseError = error as IHttpPromiseError;\r\n if (e != null && e.status === 401) {\r\n this.raiseEvent(\"invalidToken\");\r\n d.reject();\r\n } else {\r\n let errorMsg: string = `An error occurred while updating an item. Url ${self.baseUrl}/${urlPart}. Error ${error}.`;\r\n self.$log.error(errorMsg);\r\n\r\n d.reject(error);\r\n }\r\n });\r\n\r\n return d.promise;\r\n }\r\n\r\n protected putByUrlPart(urlPart: string, item: any): ng.IPromise {\r\n var d = this.$q.defer();\r\n let self = this;\r\n\r\n this.$http.put(`${this.baseUrl}/${urlPart}`, item).then((response) => {\r\n d.resolve(response.data);\r\n }).catch((error) => {\r\n let e: IHttpPromiseError = error as IHttpPromiseError;\r\n if (e != null && e.status === 401) {\r\n this.raiseEvent(\"invalidToken\");\r\n d.reject();\r\n } else {\r\n let errorMsg: string = `An error occurred while sending an item. Url ${self.baseUrl}/${urlPart}. Error ${error}.`;\r\n self.$log.error(errorMsg);\r\n\r\n d.reject(error);\r\n }\r\n });\r\n\r\n return d.promise;\r\n }\r\n\r\n protected delete(id: number): ng.IPromise {\r\n var d = this.$q.defer();\r\n let self = this;\r\n\r\n this.$http.delete(`${this.url}/${id}`).then((response) => {\r\n d.resolve();\r\n }).catch((error) => {\r\n let e: IHttpPromiseError = error as IHttpPromiseError;\r\n if (e != null && e.status === 401) {\r\n this.raiseEvent(\"invalidToken\");\r\n d.reject();\r\n } else {\r\n let errorMsg: string = `An error occurred while deleting an item. Url ${self.url}/${id}. Error ${error}.`;\r\n self.$log.error(errorMsg);\r\n d.reject(error);\r\n }\r\n });\r\n\r\n return d.promise;\r\n }\r\n\r\n protected raiseEvent(eventName: string, ...args: any[]): void {\r\n this.$rootScope.$broadcast(eventName, args);\r\n }\r\n}","String.prototype.padStart = function (targetLength: number, padString: string): string {\r\n let s = String(this);\r\n if (targetLength <= s.length) {\r\n return s;\r\n }\r\n\r\n return `${padString.repeat(targetLength - s.length)}${s}`;\r\n}\r\n\r\nNumber.prototype.padStart = function (targetLength: number, padString: string): string {\r\n let s = Number(this).toString();\r\n if (targetLength <= s.length) {\r\n return s;\r\n }\r\n\r\n return `${padString.repeat(targetLength - s.length)}${s}`;\r\n}\r\n\r\nexport default class IbUtcDateDirective implements ng.IDirective {\r\n public restrict: string = \"A\";\r\n public require: string = \"ngModel\";\r\n public replace: boolean = false;\r\n public scope: boolean = false;\r\n\r\n //https://gist.github.com/CMCDragonkai/6282750\r\n\r\n constructor() { }\r\n\r\n static Name: string = 'ibUtcDate';\r\n\r\n public link: ng.IDirectiveLinkFn = (scope: ng.IScope, element: ng.IAugmentedJQuery, attributes: ng.IAttributes, ngModelController: ng.INgModelController) => {\r\n ngModelController.$parsers.push(function (data: string | Date) {\r\n //convert data from view format to model format\r\n\r\n if (data == undefined || data === \"\") {\r\n return null;\r\n }\r\n\r\n if (typeof data === \"string\") {\r\n let parts = data.split(\"-\");\r\n if (parts.length != 3) {\r\n return;\r\n }\r\n\r\n return Date.UTC(Number(parts[0]), Number(parts[1]), Number(parts[2]));\r\n }\r\n\r\n if (Object.prototype.toString.call(data) !== \"[object Date]\") {\r\n let d = data;\r\n return Date.UTC(d.getFullYear(), d.getMonth(), d.getDate());\r\n }\r\n\r\n return null;\r\n });\r\n\r\n ngModelController.$formatters.push(function (data: string | Date) {\r\n //convert data from model format to view format\r\n\r\n if (data == undefined || data === \"\") {\r\n return null;\r\n }\r\n\r\n if (Object.prototype.toString.call(data) !== \"[object Date]\") {\r\n return null;\r\n }\r\n\r\n let d = data;\r\n\r\n return `${d.getUTCFullYear().padStart(2, \"0\")}-${d.getUTCMonth().padStart(2, \"0\")}-${d.getUTCDate().padStart(2, \"0\")}`;\r\n });\r\n };\r\n\r\n public static Factory(): ng.IDirectiveFactory {\r\n let d = () => new IbUtcDateDirective();\r\n //d.$inject = ['$timeout', 'stConfig'];\r\n return d;\r\n }\r\n}","/// \r\n/// \r\n/// \r\n/// \r\n\r\nimport { module } from \"angular\";\r\nimport IBDate from \"../core/IBDate\";\r\nimport BaseService from \"../services/base/BaseService\";\r\nimport IHttpPromiseError from \"../core/IHttpPromiseError\";\r\nimport { TemplateRow } from \"./model/TemplateRow\";\r\n\r\nexport default class OrderingTemplateRowService extends BaseService {\r\n static $inject = [\"$http\", \"$cacheFactory\", \"$q\", \"$rootScope\", \"$log\", \"appSettings\"];\r\n\r\n constructor($http: ng.IHttpService,\r\n $cacheFactory: ng.ICacheFactoryService,\r\n $q: ng.IQService,\r\n $rootScope: ng.IRootScopeService,\r\n $log: ng.ILogService,\r\n appSettings: any,\r\n apiUrlFragment: string) {\r\n super($http, $cacheFactory, $q, $rootScope, $log, appSettings, apiUrlFragment);\r\n this.baseUrl = `${appSettings.SERVICE_URL}/api/v1.0`;\r\n }\r\n\r\n getAllByCustomerAndDeliveryDateAndPreviousDeliveryDate(customerId: number, deliveryDate: IBDate, previousDeliveryDate: IBDate): ng.IPromise {\r\n return this.getAllByUrlPart(`${this.apiUrlFragment}/Customer/${customerId}/DeliveryDate/${deliveryDate.toJSONDate()}/PreviousDeliveryDate/${previousDeliveryDate.toJSONDate()}`);\r\n }\r\n\r\n getAllByTemplateAndDeliveryDate(templateId: number, deliveryDate: IBDate): ng.IPromise {\r\n return this.getAllByUrlPart(`${this.apiUrlFragment}/Template/${templateId}/DeliveryDate/${deliveryDate.toJSONDate()}`);\r\n }\r\n\r\n public static Factory($http: ng.IHttpService,\r\n $cacheFactory: ng.ICacheFactoryService,\r\n $q: ng.IQService,\r\n $rootScope: ng.IRootScopeService,\r\n $log: ng.ILogService,\r\n appSettings: any): OrderingTemplateRowService {\r\n return new OrderingTemplateRowService($http, $cacheFactory, $q, $rootScope, $log, appSettings, \"OrderingTemplateRows\");\r\n }\r\n}","/// \r\n/// \r\n\r\nimport { module, IOnChangesObject } from \"angular\";\r\nimport SpinnerService from \"../services/SpinnerService\";\r\nimport { Transition } from \"@uirouter/angularjs\";\r\nimport { IAuthenticatedParameters, INavigationParamenters } from \"../core/StateParameters\";\r\nimport { SubSystem } from \"../services/model/SubSystem\";\r\n\r\nclass NavigationSecondNavItemController implements ng.IController {\r\n static $inject = [\"$scope\", \"spinnerService\"];\r\n\r\n constructor(private $scope: ng.IScope,\r\n private spinnerService: SpinnerService) {\r\n }\r\n\r\n trans: Transition;\r\n subSystem: SubSystem;\r\n\r\n $onInit?(): void {\r\n //let params = this.trans.params() as INavigationParamenters;\r\n //this.subSystem = params.subSystem;\r\n }\r\n\r\n $onChanges?(onChangesObj: IOnChangesObject): void {\r\n if (this.subSystem !== null && typeof this.subSystem !== \"undefined\") {\r\n\r\n }\r\n }\r\n}\r\n\r\nexport default class NavigationSecondNavItemComponent implements ng.IComponentOptions {\r\n bindings?: { [boundProperty: string]: string };\r\n templateUrl: string;\r\n controller: ng.Injectable;\r\n\r\n constructor() {\r\n this.controller = NavigationSecondNavItemController;\r\n this.templateUrl = './dist/app/navigation/navigation-second-nav-item.template.html';\r\n this.bindings = {\r\n trans: '<',\r\n subSystem: '<'\r\n }\r\n //this.bindings = {\r\n // twoWay: '=',\r\n // oneWayString: '@',\r\n // onUpdate: '&'\r\n //}\r\n }\r\n}","import * as angular from \"angular\";\r\nimport { IModalScope } from \"angular-ui-bootstrap\";\r\nimport { module, IOnChangesObject, IChangesObject } from \"angular\";\r\nimport { Transition, TransitionService } from \"@uirouter/angularjs\";\r\nimport HtmlStorageService from \"../services/HtmlStorageService\";\r\nimport IBDate from \"../core/IBDate\";\r\nimport IHttpPromiseError from \"../core/IHttpPromiseError\";\r\nimport SpinnerService from \"../services/SpinnerService\";\r\nimport { User } from \"../services/model/User\";\r\nimport UserService from \"../services/UserService\";\r\nimport { Company } from \"../services/model/Company\";\r\nimport CompanyService from \"../services/CompanyService\";\r\nimport CountryService from \"../services/CountryService\";\r\nimport BranchService from \"../services/BranchService\";\r\nimport { Branch } from \"../services/model/Branch\";\r\nimport { Country } from \"../services/model/Country\";\r\nimport { FileMetaData } from \"../services/model/FileMetaData\";\r\nimport { FileType } from \"../services/model/FileType\";\r\nimport { FileGroupType } from \"../services/model/FileGroupType\";\r\nimport FileService from \"../services/FileService\";\r\nimport { File as IbFile } from \"../services/model/File\";\r\nimport { FileTypes } from \"../services/model/FileTypes\";\r\n\r\ntype UiFocusBroadcastEvents = \"\";\r\n\r\nexport class AdministrationFileUploadController implements ng.IController { // ng.IDoCheck IModalScope\r\n static $inject = [\r\n \"$http\",\r\n \"$rootScope\",\r\n \"$scope\",\r\n \"$state\",\r\n \"$timeout\",\r\n \"$q\",\r\n \"$transitions\",\r\n \"$interval\",\r\n \"$window\",\r\n \"$document\",\r\n \"$log\",\r\n \"$locale\",\r\n \"$sce\",\r\n \"spinnerService\",\r\n \"htmlStorageService\",\r\n \"fileService\",\r\n \"companyService\"\r\n ];\r\n\r\n constructor(private $http: ng.IHttpService,\r\n private $rootScope: ng.IRootScopeService,\r\n private $scope: ng.IScope,\r\n private $state: angular.ui.IStateService,\r\n private $timeout: ng.ITimeoutService,\r\n private $q: ng.IQService,\r\n private $transitions: TransitionService,\r\n private $interval: ng.IIntervalService,\r\n private $window: ng.IWindowService,\r\n private $document: ng.IDocumentService,\r\n private $log: ng.ILogService,\r\n private $locale: ng.ILocaleService,\r\n private $sce: ng.ISCEService,\r\n private spinnerService: SpinnerService,\r\n private htmlStorageService: HtmlStorageService,\r\n private fileService: FileService,\r\n private companyService: CompanyService) {\r\n\r\n $scope.$on('modal.closing', function (event, reason, closed) {\r\n switch (reason) {\r\n // clicked outside\r\n //case \"backdrop click\":\r\n // message = \"Any changes will be lost, are you sure?\";\r\n // break;\r\n\r\n // cancel button\r\n case \"cancel\":\r\n case \"escape key press\":\r\n {\r\n var message = \"Fönstret kommer att stängas. Ej sparade ändringar kommer att försvinna. Vill du stänga fönstret?\";\r\n if (!$window.confirm(message)) {\r\n event.preventDefault();\r\n }\r\n return;\r\n }\r\n }\r\n });\r\n }\r\n\r\n companyId: number;\r\n files: FileMetaData[];\r\n fileTypes: FileType[];\r\n fileGroupTypes: FileGroupType[];\r\n\r\n fileName: string;\r\n selectedFile: File;\r\n previewDataUrl;\r\n fileArrayBuffer: ArrayBuffer;\r\n\r\n isCompanyLogo: boolean;\r\n\r\n get previewTrustedResourceUrl(): string {\r\n return this.$sce.trustAsResourceUrl(this.previewDataUrl);\r\n }\r\n\r\n get selectFileName(): string {\r\n if (this.selectedFile == undefined) {\r\n return `Välj fil att ladda upp`;\r\n } else {\r\n return this.selectedFile.name;\r\n }\r\n }\r\n\r\n get title(): string {\r\n return `Ladda upp ny fil`;\r\n }\r\n\r\n get saveTitle(): string {\r\n if (this.companyId == undefined) {\r\n return '';\r\n }\r\n\r\n return `Ladda upp`;\r\n }\r\n\r\n isCompanyLogoChanged(): void {\r\n if (this.isCompanyLogo == false) {\r\n this.fileName = '';\r\n }\r\n\r\n let self = this;\r\n self.spinnerService.showBusy();\r\n\r\n let img = new Image();\r\n img.src = this.$window.URL.createObjectURL(this.selectedFile);\r\n img.onload = function () {\r\n var width = img.naturalWidth,\r\n height = img.naturalHeight;\r\n self.$window.URL.revokeObjectURL(img.src);\r\n if (height > 100 || height < 30) {\r\n // Invalid\r\n self.$window.alert(`Bildens höjd (${height}px) är utanför gränserna för en logga. Min bredd är 30px och max bredd är 100px`);\r\n } else {\r\n // Valid\r\n self.fileName = `Företagslogga`;\r\n }\r\n self.spinnerService.hideBusy();\r\n }\r\n }\r\n\r\n isCompanyLogoValid: boolean;\r\n\r\n isEnterKey(event: KeyboardEvent, preventDefault: boolean = false): boolean {\r\n if ((event.key !== undefined && event.key.toLowerCase() === \"enter\") ||\r\n (event.keyCode !== undefined && event.keyCode === 13) ||\r\n (event.which !== undefined && event.which === 13)) {\r\n if (preventDefault) {\r\n event.preventDefault();\r\n }\r\n return true;\r\n }\r\n\r\n return false;\r\n }\r\n\r\n fileSelected(): void {\r\n if (this.selectedFile == undefined) {\r\n return;\r\n }\r\n }\r\n\r\n acceptMimeTypes(): string {\r\n if (this.fileTypes == undefined || this.fileTypes.length === 0) {\r\n return \"\";\r\n }\r\n\r\n let mimeTypes = this.fileTypes.map((type) => type.contentType).join(\",\");\r\n return mimeTypes;\r\n }\r\n\r\n isImage(): boolean {\r\n if (this.selectedFile == undefined) {\r\n return false;\r\n }\r\n\r\n return this.selectedFile.type.indexOf('image/jpeg') >= 0 || this.selectedFile.type.indexOf('image/png') >= 0;\r\n }\r\n\r\n isPdf(): boolean {\r\n if (this.selectedFile == undefined) {\r\n return false;\r\n }\r\n\r\n return this.selectedFile.type.indexOf('pdf') >= 0;\r\n }\r\n\r\n isValidFileType(): boolean {\r\n return this.isImage() || this.isPdf();\r\n }\r\n\r\n private convertExtensionToFileType(): FileTypes {\r\n let extension = this.getFileExtension();\r\n\r\n switch (extension) {\r\n\r\n case \"jpeg\":\r\n case \"jpg\": {\r\n return FileTypes.Jpg;\r\n }\r\n\r\n case \"png\": {\r\n return FileTypes.Png;\r\n }\r\n\r\n case \"pdf\": {\r\n return FileTypes.Pdf;\r\n }\r\n\r\n default:\r\n return undefined;\r\n }\r\n }\r\n\r\n private getFileExtension(): string {\r\n return this.selectedFile.type.substr(this.selectedFile.type.lastIndexOf('/') + 1);\r\n }\r\n\r\n private upLoad(form: ng.IFormController): ng.IPromise {\r\n if (this.companyId == undefined || form == undefined || form.$invalid == true || this.fileArrayBuffer == undefined || this.fileArrayBuffer.byteLength === 0) {\r\n return;\r\n }\r\n\r\n let self = this;\r\n self.spinnerService.showBusy();\r\n\r\n let file = new IbFile();\r\n file.id = 0;\r\n file.companyId = this.companyId;\r\n let data = new Uint8Array(this.fileArrayBuffer);\r\n file.data = Array.from(data);\r\n file.fileExtension = this.getFileExtension();\r\n file.fileName = this.fileName;\r\n file.fileTypeId = this.convertExtensionToFileType();\r\n file.fromOrderSystem = false;\r\n\r\n return this.fileService.createFile(file).then((fileMetaData: FileMetaData) => {\r\n self.files.splice(0, 0, fileMetaData);\r\n\r\n // TODO: update if is loggo\r\n if (self.isCompanyLogo != undefined && self.isCompanyLogo) {\r\n return self.setIsCompanyLogo(fileMetaData);\r\n }\r\n }).catch((error: any) => {\r\n let e: IHttpPromiseError = error as IHttpPromiseError;\r\n if (e.status != undefined) {\r\n self.$log.error(`An unexpected error occured while uploading file (${this.selectedFile.name}). ${e.status} ${e.statusText}`);\r\n } else {\r\n self.$log.error(`An unexpected error occured while uploading file (${this.selectedFile.name}). ${error}`);\r\n }\r\n throw error;\r\n }).finally(() => {\r\n self.spinnerService.hideBusy();\r\n });\r\n }\r\n\r\n private setIsCompanyLogo(fileMetaData: FileMetaData): ng.IPromise {\r\n let self = this;\r\n self.spinnerService.showBusy();\r\n return self.companyService.setCompanyLogo(this.companyId, fileMetaData.id)\r\n .catch((error: any) => {\r\n let e: IHttpPromiseError = error as IHttpPromiseError;\r\n if (e.status != undefined) {\r\n self.$log.error(`An unexpected error occured while updating is company logo for file (${fileMetaData.id}). ${e.status} ${e.statusText}`);\r\n } else {\r\n self.$log.error(`An unexpected error occured while updating is company logo for file (${fileMetaData.id}). ${error}`);\r\n }\r\n throw error;\r\n }).finally(() => {\r\n self.spinnerService.hideBusy();\r\n });\r\n }\r\n\r\n private broadcastEvent(event: UiFocusBroadcastEvents, ...args: any[]): void {\r\n this.$scope.$broadcast(event, args);\r\n }\r\n\r\n private setUiFocus(event: UiFocusBroadcastEvents): void {\r\n this.broadcastEvent(event);\r\n }\r\n\r\n /*** Modal window properties ***/\r\n ok(form: ng.IFormController): void {\r\n let self = this;\r\n this.upLoad(form).then(() => self.close({ $value: { action: 'ok', isCompanyLogo: this.isCompanyLogo } }));\r\n }\r\n\r\n cancel(): void {\r\n this.close({ $value: { action: 'cancel', isCompanyLogo: this.isCompanyLogo } });\r\n }\r\n\r\n /*** ng.IController and ng.IDoCheck methods ***/\r\n $onChanges?(onChangesObj: IOnChangesObject): void {\r\n let c = onChangesObj[\"resolve\"] as IChangesObject<{\r\n company: number,\r\n files: FileMetaData[],\r\n fileTypes: FileType[],\r\n fileGroupTypes: FileGroupType[]\r\n }>;\r\n\r\n if (c != undefined) {\r\n this.companyId = c.currentValue.company;\r\n this.files = c.currentValue.files;\r\n this.fileTypes = c.currentValue.fileTypes;\r\n this.fileGroupTypes = c.currentValue.fileGroupTypes;\r\n }\r\n }\r\n\r\n $onInit(): void {\r\n let self = this;\r\n //this.loadBranches().then(() => self.loadCountries());\r\n }\r\n\r\n $onDestroy(): void {\r\n }\r\n\r\n $doCheck(): void {\r\n }\r\n\r\n /*** Bindings properties ***/\r\n trans: Transition;\r\n resolve: any;\r\n\r\n /*** Bindings callbacks ***/\r\n close: (param: { $value: { action: string, isCompanyLogo: boolean } }) => void;\r\n dismiss: (param: { $value: any }) => void;\r\n}\r\n\r\nexport default class AdministrationFileUploadComponent implements ng.IComponentOptions {\r\n bindings?: { [boundProperty: string]: string };\r\n templateUrl: string;\r\n controller: ng.Injectable;\r\n\r\n constructor() {\r\n this.controller = AdministrationFileUploadController;\r\n this.templateUrl = './dist/app/administration/administration-file-upload.template.html';\r\n this.bindings = {\r\n trans: '<',\r\n resolve: '<',\r\n close: '&',\r\n dismiss: '&'\r\n }\r\n }\r\n}","/// \r\n/// \r\n\r\nimport { module } from \"angular\";\r\nimport SpinnerService from \"../services/SpinnerService\";\r\n\r\nclass AdministrationHolidaysController implements ng.IController {\r\n static $inject = [\"$scope\", \"spinnerService\"];\r\n\r\n constructor(private $scope: ng.IScope,\r\n private spinnerService: SpinnerService) {\r\n\r\n }\r\n\r\n title: string = \"Helgdagar...\";\r\n}\r\n\r\nexport default class AdministrationHolidaysComponent implements ng.IComponentOptions {\r\n bindings?: { [boundProperty: string]: string };\r\n templateUrl: string;\r\n controller: ng.Injectable;\r\n\r\n constructor() {\r\n this.controller = AdministrationHolidaysController;\r\n this.templateUrl = './dist/app/administration/administration-holidays.template.html';\r\n }\r\n}","import { module, IOnChangesObject, IChangesObject } from \"angular\";\r\nimport HtmlStorageService from \"../services/HtmlStorageService\";\r\nimport SpinnerService from \"../services/SpinnerService\";\r\nimport IBDate from \"../core/IBDate\";\r\nimport { Transition, TransitionService } from \"@uirouter/angularjs\";\r\nimport IHttpPromiseError from \"../core/IHttpPromiseError\";\r\nimport * as angular from \"angular\";\r\nimport { IModalScope } from \"angular-ui-bootstrap\";\r\nimport AdministrationInformationCustomerGroupService from \"../services/AdministrationInformationCustomerGroupService\";\r\nimport AdministrationInformationCustomerService from \"../services/AdministrationInformationCustomerService\";\r\nimport InformationService from \"../services/InformationService\";\r\nimport { CustomerGroup } from \"../services/model/CustomerGroup\";\r\nimport { Customer } from \"../services/model/Customer\";\r\nimport { Information } from \"../services/model/Information\";\r\n\r\nexport class AdministrationInformationPageAddEditController implements ng.IController { // ng.IDoCheck IModalScope\r\n static $inject = [\"$http\", \"$rootScope\", \"$scope\", \"$state\", \"$timeout\", \"$q\", \"$transitions\", \"$interval\", \"$window\", \"$log\", \"$locale\", \"spinnerService\", \"htmlStorageService\", \"administrationInformationCustomerGroupService\", \"administrationInformationCustomerService\", \"informationService\"];\r\n\r\n constructor(private $http: ng.IHttpService,\r\n private $rootScope: ng.IRootScopeService,\r\n private $scope: ng.IScope,\r\n private $state: angular.ui.IStateService,\r\n private $timeout: ng.ITimeoutService,\r\n private $q: ng.IQService,\r\n private $transitions: TransitionService,\r\n private $interval: ng.IIntervalService,\r\n private $window: ng.IWindowService,\r\n private $log: ng.ILogService,\r\n private $locale: ng.ILocaleService,\r\n private spinnerService: SpinnerService,\r\n private htmlStorageService: HtmlStorageService,\r\n private administrationInformationCustomerGroupService: AdministrationInformationCustomerGroupService,\r\n private administrationInformationCustomerService: AdministrationInformationCustomerService,\r\n private informationService: InformationService) {\r\n }\r\n\r\n companyId: number;\r\n customerId: number;\r\n customerGroups: CustomerGroup[];\r\n customers: Customer[];\r\n information: Information;\r\n\r\n ok(): void {\r\n this.updateInformation();\r\n this.close({ $value: true });\r\n }\r\n\r\n cancel(): void {\r\n this.dismiss({ $value: false });\r\n }\r\n\r\n customerSelected(customer: Customer): void {\r\n if (customer != undefined) {\r\n this.information.customerName = customer.customerName;\r\n }\r\n }\r\n\r\n customerGroupSelected(customerGroup: CustomerGroup): void {\r\n if (customerGroup != undefined) {\r\n this.information.customerGroupName = customerGroup.customerGroupName;\r\n }\r\n }\r\n\r\n informationHeadingChanged(editor, html, text, content, delta, oldDelta, source): void {\r\n\r\n }\r\n\r\n updateInformation(): void {\r\n this.spinnerService.showBusy();\r\n let self = this;\r\n\r\n if (this.information.customerGroupId == undefined) {\r\n this.information.customerGroupName = '';\r\n }\r\n\r\n if (this.information.customerId == undefined) {\r\n this.information.customerName = '';\r\n }\r\n\r\n this.informationService.updateInformation(this.information).then(() => {\r\n\r\n }).catch((error: any) => {\r\n let e: IHttpPromiseError = error as IHttpPromiseError;\r\n\r\n if (e.status != undefined) {\r\n self.$log.error(`An unexpected error occured while updateing an information item. ${e.status} ${e.statusText}`);\r\n } else {\r\n self.$log.error(`An unexpected error occured while updateing an information item. ${error}`);\r\n }\r\n\r\n // Display error message?\r\n }).finally(() => {\r\n self.spinnerService.hideBusy();\r\n });\r\n }\r\n\r\n private loadCustomers(): void {\r\n this.spinnerService.showBusy();\r\n let self = this;\r\n this.administrationInformationCustomerService.getAllByCompany(this.companyId).then((customers: Customer[]) => {\r\n self.customers = customers;\r\n }).catch((error: any) => {\r\n let e: IHttpPromiseError = error as IHttpPromiseError;\r\n\r\n if (e.status != undefined) {\r\n self.$log.error(`An unexpected error occured while retrieving a return/complaint. ${e.status} ${e.statusText}`);\r\n } else {\r\n self.$log.error(`An unexpected error occured while retrieving a return/complaint. ${error}`);\r\n }\r\n\r\n // Display error message?\r\n }).finally(() => {\r\n self.spinnerService.hideBusy();\r\n });\r\n }\r\n\r\n private loadCustomerGroups(): void {\r\n this.spinnerService.showBusy();\r\n let self = this;\r\n this.administrationInformationCustomerGroupService.getAllByCompany(this.companyId).then((customerGroups: CustomerGroup[]) => {\r\n self.customerGroups = customerGroups;\r\n }).catch((error: any) => {\r\n let e: IHttpPromiseError = error as IHttpPromiseError;\r\n\r\n if (e.status != undefined) {\r\n self.$log.error(`An unexpected error occured while retrieving a return/complaint. ${e.status} ${e.statusText}`);\r\n } else {\r\n self.$log.error(`An unexpected error occured while retrieving a return/complaint. ${error}`);\r\n }\r\n\r\n // Display error message?\r\n }).finally(() => {\r\n self.spinnerService.hideBusy();\r\n });\r\n }\r\n\r\n /*** ng.IController and ng.IDoCheck methods ***/\r\n $onChanges?(onChangesObj: IOnChangesObject): void {\r\n let c = onChangesObj[\"resolve\"] as IChangesObject<{\r\n companyId: number,\r\n customerId: number,\r\n information: Information\r\n }>;\r\n if (c != undefined) {\r\n this.companyId = c.currentValue.companyId;\r\n this.customerId = c.currentValue.customerId;\r\n this.information = c.currentValue.information;\r\n\r\n this.loadCustomers();\r\n this.loadCustomerGroups();\r\n }\r\n }\r\n\r\n $onInit(): void {\r\n }\r\n\r\n $onDestroy(): void {\r\n }\r\n\r\n $doCheck(): void {\r\n //if (this.oldOrdering != this.ordering) {\r\n // this.oldOrdering = this.ordering;\r\n\r\n // this.clearLocalParameters();\r\n\r\n // if (this.ordering != undefined) {\r\n // this.loadOrderingRows();\r\n // if (!this.isReadOnly()) {\r\n // this.loadArticleGroups();\r\n // this.loadArticles();\r\n // }\r\n // } else {\r\n // this.orderingRows = undefined;\r\n // }\r\n //}\r\n }\r\n\r\n /*** Bindings properties ***/\r\n trans: Transition;\r\n resolve: any;\r\n\r\n /*** Bindings callbacks ***/\r\n close: (param: { $value: any }) => void;\r\n dismiss: (param: { $value: any }) => void;\r\n}\r\n\r\nexport default class AdministrationInformationPageAddEditComponent implements ng.IComponentOptions {\r\n bindings?: { [boundProperty: string]: string };\r\n templateUrl: string;\r\n controller: ng.Injectable;\r\n\r\n constructor() {\r\n this.controller = AdministrationInformationPageAddEditController;\r\n this.templateUrl = './dist/app/administration/administration-information-page-add-edit.template.html';\r\n this.bindings = {\r\n trans: '<',\r\n resolve: '<',\r\n close: '&',\r\n dismiss: '&'\r\n }\r\n }\r\n}","import IbDecimalToCommaFilter from \"./decimal-comma-number.filter\";\r\n\r\nexport interface IbDecimalCommaDirectiveParameters {\r\n fractionSize?: number\r\n}\r\n\r\nexport default class IbDecimalCommaDirective implements ng.IDirective {\r\n public restrict: string = \"A\";\r\n public require: string = \"ngModel\";\r\n public replace: boolean = false;\r\n public scope: boolean = true;\r\n\r\n //https://gist.github.com/CMCDragonkai/6282750\r\n\r\n constructor() { }\r\n\r\n public link: ng.IDirectiveLinkFn = (scope: ng.IScope, element: ng.IAugmentedJQuery, attributes: ng.IAttributes, ngModelController: ng.INgModelController) => {\r\n\r\n\r\n //element.on('key')\r\n\r\n ngModelController.$parsers.push(function (data: string | number) {\r\n //convert data from view format to model format\r\n\r\n if (data == undefined || data === \"\") {\r\n return null;\r\n }\r\n\r\n let params: IbDecimalCommaDirectiveParameters = scope.$eval(attributes.ibDecimalComma);\r\n\r\n if (typeof data === \"number\") {\r\n if (params != undefined && params.fractionSize != undefined) {\r\n data = Number(data.toFixed(params.fractionSize));\r\n }\r\n //element.val(data.toString().replace(\".\",\",\"));\r\n return data;\r\n }\r\n\r\n let result = Number(data.replace(\",\", \".\"));\r\n if (params != undefined && params.fractionSize != undefined) {\r\n result = Number(result.toFixed(params.fractionSize));\r\n }\r\n\r\n //element.val(result);\r\n return result;\r\n });\r\n\r\n ngModelController.$formatters.push(function (data: string | number) {\r\n //convert data from model format to view format\r\n\r\n let params: IbDecimalCommaDirectiveParameters = scope.$eval(attributes.ibDecimalComma);\r\n\r\n if (typeof data === \"string\") {\r\n data = Number(data);\r\n }\r\n\r\n let converter = IbDecimalToCommaFilter.Factory();\r\n data = converter(data, (params != undefined) ? params.fractionSize : undefined);\r\n\r\n return data;\r\n });\r\n };\r\n\r\n public static Factory(): ng.IDirectiveFactory {\r\n let d = () => new IbDecimalCommaDirective();\r\n //d.$inject = ['$timeout', 'stConfig'];\r\n return d;\r\n }\r\n}","import { module, element, bootstrap, isArray } from \"angular\";\r\nimport { TransitionService, TransitionOptions, StateDeclaration, StateObject } from \"@uirouter/angularjs\";\r\n\r\nimport { IRootStateParameters } from \"./core/StateParameters\";\r\nimport IBDate from \"./core/IBDate\";\r\n\r\n/* Import services */\r\nimport AdministrationInformationCustomerGroupService from \"./services/AdministrationInformationCustomerGroupService\";\r\nimport AdministrationInformationCustomerService from \"./services/AdministrationInformationCustomerService\";\r\nimport AuthenticationService from \"./services/AuthenticationService\";\r\nimport BranchService from \"./services/BranchService\";\r\nimport CompanyService from \"./services/CompanyService\";\r\nimport CountryService from \"./services/CountryService\";\r\nimport CustomerService from \"./services/CustomerService\";\r\nimport FileGroupService from \"./services/FileGroupTypeService\";\r\nimport FileService from \"./services/FileService\";\r\nimport FileTypeService from \"./services/FileTypeService\";\r\nimport HistoryTypeService from \"./services/HistoryTypeService\";\r\nimport HtmlStorageService from \"./services/HtmlStorageService\";\r\nimport InformationService from \"./services/InformationService\";\r\nimport ImportExportService from \"./services/ImportExportService\";\r\nimport OrderingArticleGroupService from \"./services/OrderingArticleGroupService\";\r\nimport OrderingArticleInformationService from \"./services/OrderingArticleInformationService\";\r\nimport OrderingArticleService from \"./services/OrderingArticleService\";\r\nimport OrderingCalendarDayService from \"./services/OrderingCalendarDayService\";\r\nimport OrderingRowService from \"./services/OrderingRowService\";\r\nimport OrderingService from \"./services/OrderingService\";\r\nimport OrderingTemplateInfoService from \"./services/OrderingTemplateInfoService\";\r\nimport OrderingTemplateRowService from \"./services/OrderingTemplateRowService\";\r\nimport OrderingTemplateService from \"./services/OrderingTemplateService\";\r\nimport PermissionService from \"./services/PermissionService\";\r\nimport ReturnArticleGroupService from \"./services/ReturnArticleGroupService\";\r\nimport ReturnArticleService from \"./services/ReturnArticleService\";\r\nimport ReturnCalendarDayService from \"./services/ReturnCalendarDayService\";\r\nimport ReturnOrderingRowService from \"./services/ReturnOrderingRowService\";\r\nimport ReturnOrderingService from \"./services/ReturnOrderingService\";\r\nimport ReturnReasonTypeService from \"./services/ReturnReasonTypeService\";\r\nimport RoleService from \"./services/RoleService\";\r\nimport SpinnerService from \"./services/SpinnerService\";\r\nimport StopTimeArticleGroupService from \"./services/StopTimeArticleGroupService\";\r\nimport StopTimeCustomerGroupService from \"./services/StopTimeCustomerGroupService\";\r\nimport StopTimeDivergentDateService from \"./services/StopTimeDivergentDateService\";\r\nimport StopTimeReturnOrderingService from \"./services/StopTimeReturnOrderingService\";\r\nimport StopTimeDateService from \"./services/StopTimeDateService\";\r\nimport StopTimeService from \"./services/StopTimeService\";\r\nimport SubSystemService from \"./services/SubSystemService\";\r\nimport TemplateArticleGroupService from \"./services/TemplateArticleGroupService\";\r\nimport TemplateArticleInformationService from \"./services/TemplateArticleInformationService\";\r\nimport TemplateArticleService from \"./services/TemplateArticleService\";\r\nimport TemplateInfoService from \"./services/TemplateInfoService\";\r\nimport TemplateOrderingTypeService from \"./services/TemplateOrderingTypeService\";\r\nimport TemplateRowService from \"./services/TemplateRowService\";\r\nimport TemplateService from \"./services/TemplateService\";\r\nimport TransferOptionService from \"./services/TransferOptionService\";\r\nimport UserService from \"./services/UserService\";\r\nimport WeekdayService from \"./services/WeekdayService\";\r\n\r\n/* Import components */\r\nimport AppComponent from \"./app.component\";\r\n\r\nimport AdministrationNavigationComponent from \"./administration/administration-navigation.component\";\r\nimport AdministrationAdminCompanyComponent from \"./administration/administration-admin-company.component\"\r\nimport AdministrationDiffDaysComponent from \"./administration/administration-diff-days.component\";\r\nimport AdministrationFileComponent from \"./administration/administration-file.component\";\r\nimport AdministrationFileUploadComponent from \"./administration/administration-file-upload.component\";\r\nimport AdministrationHolidaysComponent from \"./administration/administration-holidays.component\";\r\nimport AdministrationInformationPageAddEditComponent from \"./administration/administration-information-page-add-edit.component\";\r\nimport AdministrationInformationPageComponent from \"./administration/administration-information-page.component\";\r\nimport AdministrationInitCompanyComponent from \"./administration/administration-init-company.component\";\r\nimport AdministrationInitCompanyAddEditComponent from \"./administration/administration-init-company-add-edit.component\";\r\nimport AdministrationInitCompanyImportExportLogComponent from \"./administration/administration-init-company-import-export-log.component\";\r\nimport AdministrationStopTimeComponent from \"./administration/administration-stop-time.component\";\r\n\r\nimport AuthenticationComponent from \"./authentication/authentication.component\";\r\n\r\nimport CalendarComponent from \"./calendar/calendar.component\";\r\nimport CalendarDayComponent from \"./calendar/calendar-day.component\";\r\n\r\nimport CustomerSelectComponent from \"./customer-select/customer-select.component\";\r\n\r\nimport HeaderComponent from \"./header/header.component\";\r\n\r\nimport InformationComponent from \"./information/information.component\";\r\n\r\nimport OrderingNavigationComponent from \"./ordering/ordering-navigation.component\";\r\nimport OrderingOrderComponent from \"./ordering/ordering-order.component\";\r\nimport OrderingOrderOrdering1Component from \"./ordering/ordering-order-ordering.component1\";\r\nimport OrderingOrderOrderingArticleInformationComponent from \"./ordering/ordering-order-ordering-article-information.component\";\r\nimport OrderingOrderTemplateComponent from \"./ordering/ordering-order-template.component\";\r\nimport OrderingOrderTemplateSelectComponent from \"./ordering/ordering-order-template-select.component\";\r\n\r\nimport OrderingReturnComponent from \"./ordering/ordering-return.component\";\r\nimport OrderingReturnReturnComponent from \"./ordering/ordering-return-return.component\";\r\nimport OrderingReturnReturnReasonComponent from \"./ordering/ordering-return-return-reason.component\";\r\n\r\nimport OrderingComplaintComponent from \"./ordering/ordering-complaint.component\";\r\nimport OrderingTemplateComponent from \"./ordering/ordering-template.component\";\r\nimport OrderingTemplateTemplateArticleInformationComponent from \"./ordering/ordering-template-template-article-information.component\";\r\nimport OrderingTemplateTemplateSelectComponent from \"./ordering/ordering-template-template-select.component\";\r\nimport OrderingTemplateTemplateComponent from \"./ordering/ordering-template-template.component\";\r\n\r\nimport NavigationSecondNavItem from \"./navigation/navigation-second-nav-item\";\r\n\r\nimport PermissionNavigationComponent from \"./permission/permission-navigation.component\";\r\nimport PermissionRoleComponent from \"./permission/permission-role.component\";\r\nimport PermissionUserComponent from \"./permission/permission-user.component\";\r\nimport PermissionUserAddEditComponent from \"./permission/permission-user-edit.component\";\r\nimport PermissionUserRoleAddEditComponent from \"./permission/permission-user-role-add-edit.component\";\r\n\r\nimport RemainingNavigationComponent from \"./remaining/remaining-navigation.component\";\r\nimport RemainingStoreComponent from \"./remaining/remaining-store.component\";\r\nimport RemainingFollowUpComponent from \"./remaining/remaining-follow-up.component\";\r\n\r\nimport ShowFileDialogComponent from \"./core/show-file-dialog.component\";\r\n\r\nimport SupportComponent from \"./support/support.component\";\r\n\r\nimport SettingsComponent from \"./settings/settings.component\";\r\n\r\nimport WarningDialogComponent from \"./core/warning-dialog.component\";\r\n\r\n\r\n/* Import directivs */\r\nimport SmartTableFocusSelectRowDirective from \"./smart-table/smart-table-focus-select-row.directive\";\r\nimport SmartTableResetSearchOnDirective from \"./smart-table/smart-table-reset-search-on.directive\";\r\nimport IbBindObjectDirective from \"./core/bind-object.directive\";\r\nimport IbDecimalCommaDirective from \"./core/decimal-comma-number.directive\";\r\nimport IbInputIncrementDecrementNumberDirective from \"./core/input-increment-decrement-number.directive\";\r\nimport IbInputSelectFileDirective from \"./core/input-select-file.directive\";\r\nimport IbUtcDateDirective from \"./core/utc-date.directive\";\r\n\r\n/* Import filters */\r\nimport IbDecimalToCommaFilter from \"./core/decimal-comma-number.filter\";\r\nimport IbFilterByFilter from \"./core/filter-by.filter\";\r\n\r\ninterface ISmartTableSelectRowController {\r\n select(row, mode): any;\r\n}\r\n\r\ninterface ISmartTableSelectRowScope extends ng.IScope {\r\n row: any;\r\n}\r\n\r\nfunction convertJsonDateStringsToDate(input) {\r\n if (typeof input !== \"object\") {\r\n return;\r\n }\r\n\r\n if (isArray(input)) {\r\n for (var i = 0; i < input.length; i++) {\r\n convertJsonDateStringsToDate(input[i]);\r\n }\r\n }\r\n\r\n // https://stackoverflow.com/questions/206384/how-do-i-format-a-microsoft-json-date\r\n // We only match for yyyy-mm-ddThh:mm:ss\r\n // We assume that all dates are ISO 8601. Accourding to standard it should be a Z at the end....\r\n let regEx: RegExp = /^(\\d{4})-(\\d{2})-(\\d{2})T(\\d{2}):(\\d{2}):(\\d{2})(.(\\d{4}))?Z?$/i;\r\n\r\n for (let key in input) {\r\n if (!input.hasOwnProperty(key)) {\r\n // Skip inherited properties\r\n continue;\r\n }\r\n\r\n let value = input[key];\r\n let match: RegExpMatchArray;\r\n if (typeof value === \"string\" && (match = value.match(regEx))) {\r\n let ibDate: Date = new Date(Date.UTC(\r\n parseInt(match[1]),\r\n parseInt(match[2]) - 1,\r\n parseInt(match[3]),\r\n parseInt(match[4]),\r\n parseInt(match[5]),\r\n parseInt(match[6]),\r\n parseInt((match.length >= 8 && typeof match[7] !== 'undefined' ? match[7] : \"0\"))\r\n ));\r\n\r\n input[key] = ibDate;\r\n } else if (typeof value === \"object\") {\r\n // Recurse into object\r\n convertJsonDateStringsToDate(value);\r\n }\r\n }\r\n}\r\n\r\n/* Import directives */\r\n\r\n//\"angular-ui-bootstrap\": \"^2.5.6\",\r\n\r\nexport let app = module(\"app\", [\r\n \"ui.router\",\r\n \"ui.select\",\r\n \"ngSanitize\",\r\n \"ngMessages\",\r\n \"ui.bootstrap\",\r\n \"ngResource\",\r\n \"ui.router\",\r\n \"ui.select\",\r\n \"ui.validate\",\r\n \"ngSanitize\",\r\n \"smart-table\",\r\n \"ngQuill\"\r\n /*,\"ngAnimate\"*/])\r\n //.config(($animateProvider: angular.animate.IAnimateProvider) => {\r\n // // http://davidchin.me/blog/disable-nganimate-for-selected-elements/\r\n // // https://github.com/angular-ui/ui-select/issues/1201\r\n // // https://github.com/angular-ui/ui-select/issues/859\r\n // // class=\"ng-animate-disabled\"\r\n // $animateProvider.classNameFilter(/^(?:(?!ng-animate-disabled).)*$/);\r\n //})\r\n .constant(\"appSettings\",\r\n {\r\n //SERVICE_URL: \"http://localhost:63355\"\r\n //SERVICE_URL: \"https://ib-api-development.pcs.se\" // Development\r\n //SERVICE_URL: \"https://ib-api-staging.pcs.se\"\r\n SERVICE_URL: \"https://ib-api.pcs.se\"\r\n //, INSTRUMENTATION_KEY: \"69981369-7713-4f2e-bcd6-ca4c642dcd0a\" // Development\r\n , INSTRUMENTATION_KEY: \"fedffb0c-cef8-4097-8ac3-2dde2e9bf477\" // Production\r\n })\r\n .config(($stateProvider: ng.ui.IStateProvider, $urlRouterProvider: ng.ui.IUrlRouterProvider, $httpProvider: ng.IHttpProvider, $sceDelegateProvider: ng.ISCEDelegateProvider, $transitionsProvider: TransitionService, appSettings: any) => {\r\n\r\n appInsights.downloadAndSetup({ instrumentationKey: appSettings.INSTRUMENTATION_KEY });\r\n\r\n if (!isArray($httpProvider.defaults.transformResponse)) {\r\n $httpProvider.defaults.transformResponse = [$httpProvider.defaults.transformResponse];\r\n }\r\n\r\n // Convert JSON date strings to JavaScript Date\r\n $httpProvider.defaults.transformResponse.push(function (responseData) {\r\n convertJsonDateStringsToDate(responseData);\r\n return responseData;\r\n });\r\n\r\n $sceDelegateProvider.resourceUrlWhitelist([\r\n // Allow same origin resource loads.\r\n 'self'\r\n //, 'http://localhost:3517/**'\r\n , 'http://localhost:63355/**'\r\n , 'https://localhost:44314/**'\r\n , 'http://localhost:57272/**'\r\n , 'https://ib.pcs.se/**'\r\n , 'https://ib-staging.pcs.se/**'\r\n , 'https://ib-development.pcs.se/**'\r\n , 'https://ib-api.pcs.se/**'\r\n , 'https://ib-api-staging.pcs.se/**'\r\n , 'https://ib-api-development.pcs.se/**'\r\n , 'https://pcs-ib-api-staging.azurewebsites.net/**'\r\n , 'https://pcs-ib-api-development.azurewebsites.net/**'\r\n , 'https://ib-files.pcs.se/**'\r\n , 'https://ib-files-staging.pcs.se/**'\r\n , 'https://ib-files-development.pcs.se/**'\r\n ]);\r\n\r\n $transitionsProvider.onBefore({}, trans => {\r\n // Automatically resolve $transition$ object.\r\n trans.addResolvable({ token: \"trans\", resolveFn: () => trans });\r\n\r\n let spinnerService = trans.injector().get('spinnerService');\r\n spinnerService.showBusy();\r\n });\r\n\r\n $transitionsProvider.onSuccess({}, trans => {\r\n let spinnerService = trans.injector().get('spinnerService');\r\n spinnerService.hideBusy();\r\n });\r\n\r\n $transitionsProvider.onError({}, trans => {\r\n let spinnerService = trans.injector().get('spinnerService');\r\n spinnerService.hideBusy();\r\n });\r\n\r\n $transitionsProvider.onBefore({ entering: 'root.authenticated.**' }, trans => {\r\n let auth: AuthenticationService = trans.injector().get('authenticationService');\r\n if (!auth.isAuthenticated()) {\r\n return trans.router.stateService.target('root.authenticate');\r\n }\r\n\r\n // Save state parameters for reload purposes\r\n //let stofrom = trans.$from() as StateObject;\r\n //let stdfrom = trans.from() as StateDeclaration;\r\n //let stoTo = trans.$to() as StateObject;\r\n //let params = trans.params();\r\n\r\n let htmlStorageService: HtmlStorageService = trans.injector().get('htmlStorageService');\r\n let toStateName: string = null;\r\n let toParams = trans.params(\"to\") as IRootStateParameters;\r\n let isReload: boolean = false;\r\n\r\n if (toParams === null || typeof toParams === \"undefined\" || toParams.username === null || typeof toParams.username === \"undefined\") {\r\n isReload = true;\r\n htmlStorageService.setSessionStorageItem(\"isReload\", isReload);\r\n auth.setAuthenticatedAfterReload();\r\n toStateName = htmlStorageService.getSessionStorageItem(\"toStateName\");\r\n toParams = htmlStorageService.getSessionStorageItem(\"toParams\");\r\n } else {\r\n htmlStorageService.setSessionStorageItem(\"toParams\", toParams);\r\n let stdTo = trans.to() as StateDeclaration;\r\n if (stdTo !== null && typeof stdTo !== \"undefined\") {\r\n htmlStorageService.setSessionStorageItem(\"toStateName\", stdTo.name);\r\n }\r\n }\r\n\r\n let t = trans.redirectedFrom();\r\n if (isReload && t === null) {\r\n let transOptions: TransitionOptions = {\r\n redirectedFrom: trans,\r\n };\r\n let s = trans.router.stateService.target(toStateName, toParams, transOptions);\r\n return s;\r\n }\r\n });\r\n\r\n // For any unmatched url, redirect to /default\r\n $urlRouterProvider.otherwise(\"/\");\r\n\r\n // Set up the states\r\n $stateProvider\r\n .state(\"root\", {\r\n url: \"\",\r\n abstract: true\r\n })\r\n .state(\"root.authenticate\", {\r\n url: \"/\",\r\n views: {\r\n 'content@': {\r\n component: \"ibAuthenticationComponent\"\r\n }\r\n },\r\n })\r\n .state(\"root.authenticated\", {\r\n abstract: true,\r\n views: {\r\n 'header@': {\r\n component: \"ibHeaderComponent\"\r\n }\r\n },\r\n params: {\r\n username: {\r\n value: null,\r\n dynamic: true\r\n },\r\n sysUserId: {\r\n value: null,\r\n dynamic: true\r\n },\r\n customerId: {\r\n value: null,\r\n dynamic: true\r\n },\r\n companyId: {\r\n value: null,\r\n dynamic: true\r\n }\r\n },\r\n onEnter: ($state: angular.ui.IStateService,\r\n $stateParams: ng.ui.IStateParamsService,\r\n htmlStorageService: HtmlStorageService,\r\n authenticationService: AuthenticationService) => {\r\n }\r\n })\r\n .state(\"root.authenticated.start\", {\r\n url: \"/start\",\r\n views: {\r\n 'content@': {\r\n component: \"ibInformationComponent\"\r\n }\r\n },\r\n onEnter: ($state: angular.ui.IStateService,\r\n $stateParams: ng.ui.IStateParamsService,\r\n htmlStorageService: HtmlStorageService,\r\n authenticationService: AuthenticationService) => {\r\n\r\n }\r\n })\r\n .state(\"root.authenticated.support\", {\r\n url: \"/support\",\r\n views: {\r\n 'content@': {\r\n component: \"ibSupportComponent\"\r\n }\r\n },\r\n onEnter: ($state: angular.ui.IStateService,\r\n $stateParams: ng.ui.IStateParamsService,\r\n htmlStorageService: HtmlStorageService,\r\n authenticationService: AuthenticationService) => {\r\n\r\n }\r\n })\r\n .state(\"root.authenticated.administration\", {\r\n abstract: true,\r\n url: \"/administration\",\r\n views: {\r\n 'navigation@root.authenticated': {\r\n component: \"ibAdministrationNavigationComponent\"\r\n }\r\n },\r\n params: {\r\n subSystem: null\r\n },\r\n onEnter: ($state: angular.ui.IStateService,\r\n $stateParams: ng.ui.IStateParamsService,\r\n htmlStorageService: HtmlStorageService,\r\n authenticationService: AuthenticationService) => {\r\n\r\n }\r\n })\r\n .state(\"root.authenticated.administration.init-company\", {\r\n url: \"/init-company\",\r\n views: {\r\n 'content@': {\r\n component: \"ibAdministrationInitCompanyComponent\"\r\n }\r\n },\r\n onEnter: ($state: angular.ui.IStateService,\r\n $stateParams: ng.ui.IStateParamsService,\r\n htmlStorageService: HtmlStorageService,\r\n authenticationService: AuthenticationService) => {\r\n\r\n }\r\n })\r\n .state(\"root.authenticated.administration.holidays\", {\r\n url: \"/holidays\",\r\n views: {\r\n 'content@': {\r\n component: \"ibAdministrationHolidaysComponent\"\r\n }\r\n },\r\n onEnter: ($state: angular.ui.IStateService,\r\n $stateParams: ng.ui.IStateParamsService,\r\n htmlStorageService: HtmlStorageService,\r\n authenticationService: AuthenticationService) => {\r\n\r\n }\r\n })\r\n .state(\"root.authenticated.administration.diff-days\", {\r\n url: \"/diff-days\",\r\n views: {\r\n 'content@': {\r\n component: \"ibAdministrationDiffDaysComponent\"\r\n }\r\n },\r\n onEnter: ($state: angular.ui.IStateService,\r\n $stateParams: ng.ui.IStateParamsService,\r\n htmlStorageService: HtmlStorageService,\r\n authenticationService: AuthenticationService) => {\r\n\r\n }\r\n })\r\n .state(\"root.authenticated.administration.stop-time\", {\r\n url: \"/stop-time\",\r\n views: {\r\n 'content@': {\r\n component: \"ibAdministrationStopTimeComponent\"\r\n }\r\n },\r\n onEnter: ($state: angular.ui.IStateService,\r\n $stateParams: ng.ui.IStateParamsService,\r\n htmlStorageService: HtmlStorageService,\r\n authenticationService: AuthenticationService) => {\r\n\r\n }\r\n })\r\n .state(\"root.authenticated.administration.admin-company\", {\r\n url: \"/admin-company\",\r\n views: {\r\n 'content@': {\r\n component: \"ibAdministrationAdminCompanyComponent\"\r\n }\r\n },\r\n onEnter: ($state: angular.ui.IStateService,\r\n $stateParams: ng.ui.IStateParamsService,\r\n htmlStorageService: HtmlStorageService,\r\n authenticationService: AuthenticationService) => {\r\n\r\n }\r\n })\r\n .state(\"root.authenticated.administration.admin-information-page\", {\r\n url: \"/admin-information-page\",\r\n views: {\r\n 'content@': {\r\n component: \"ibAdministrationInformationPageComponent\"\r\n }\r\n },\r\n onEnter: ($state: angular.ui.IStateService,\r\n $stateParams: ng.ui.IStateParamsService,\r\n htmlStorageService: HtmlStorageService,\r\n authenticationService: AuthenticationService) => {\r\n }\r\n })\r\n .state(\"root.authenticated.administration.admin-files\", {\r\n url: \"/admin-files\",\r\n views: {\r\n 'content@': {\r\n component: \"ibAdministrationFileComponent\"\r\n }\r\n },\r\n onEnter: ($state: angular.ui.IStateService,\r\n $stateParams: ng.ui.IStateParamsService,\r\n htmlStorageService: HtmlStorageService,\r\n authenticationService: AuthenticationService) => {\r\n }\r\n })\r\n .state(\"root.authenticated.ordering\", {\r\n abstract: true,\r\n url: \"/ordering\",\r\n views: {\r\n 'navigation@root.authenticated': {\r\n component: \"ibOrderingNavigationComponent\"\r\n }\r\n },\r\n params: {\r\n subSystem: null\r\n },\r\n onEnter: ($state: angular.ui.IStateService,\r\n $stateParams: ng.ui.IStateParamsService,\r\n htmlStorageService: HtmlStorageService,\r\n authenticationService: AuthenticationService) => {\r\n\r\n }\r\n })\r\n .state(\"root.authenticated.ordering.order\", {\r\n url: \"/order\",\r\n views: {\r\n 'content@': {\r\n component: \"ibOrderingOrderComponent\"\r\n }\r\n },\r\n onEnter: ($state: angular.ui.IStateService,\r\n $stateParams: ng.ui.IStateParamsService,\r\n htmlStorageService: HtmlStorageService,\r\n authenticationService: AuthenticationService) => {\r\n\r\n }\r\n })\r\n .state(\"root.authenticated.ordering.template\", {\r\n url: \"/template\",\r\n views: {\r\n 'content@': {\r\n component: \"ibOrderingTemplateComponent\"\r\n }\r\n },\r\n onEnter: ($state: angular.ui.IStateService,\r\n $stateParams: ng.ui.IStateParamsService,\r\n htmlStorageService: HtmlStorageService,\r\n authenticationService: AuthenticationService) => {\r\n\r\n }\r\n })\r\n .state(\"root.authenticated.ordering.return\", {\r\n url: \"/return\",\r\n views: {\r\n 'content@': {\r\n component: \"ibOrderingReturnComponent\"\r\n }\r\n },\r\n params: {\r\n orderingTypeId: 2\r\n },\r\n onEnter: ($state: angular.ui.IStateService,\r\n $stateParams: ng.ui.IStateParamsService,\r\n htmlStorageService: HtmlStorageService,\r\n authenticationService: AuthenticationService) => {\r\n\r\n }\r\n })\r\n .state(\"root.authenticated.ordering.complaint\", {\r\n url: \"/complaint\",\r\n views: {\r\n 'content@': {\r\n component: \"ibOrderingReturnComponent\"\r\n }\r\n },\r\n params: {\r\n orderingTypeId: 3\r\n },\r\n onEnter: ($state: angular.ui.IStateService,\r\n $stateParams: ng.ui.IStateParamsService,\r\n htmlStorageService: HtmlStorageService,\r\n authenticationService: AuthenticationService) => {\r\n\r\n }\r\n })\r\n .state(\"root.authenticated.settings\", {\r\n url: \"/settings\",\r\n views: {\r\n 'content@': {\r\n component: \"ibSettingsComponent\"\r\n }\r\n }\r\n })\r\n .state(\"root.authenticated.permission\", {\r\n abstract: true,\r\n url: \"/permission\",\r\n views: {\r\n 'navigation@root.authenticated': {\r\n component: \"ibPermissionNavigationComponent\"\r\n }\r\n },\r\n params: {\r\n subSystem: null\r\n },\r\n onEnter: ($state: angular.ui.IStateService,\r\n $stateParams: ng.ui.IStateParamsService,\r\n htmlStorageService: HtmlStorageService,\r\n authenticationService: AuthenticationService) => {\r\n\r\n }\r\n })\r\n .state(\"root.authenticated.permission.role\", {\r\n url: \"/role\",\r\n views: {\r\n 'content@': {\r\n component: \"ibPermissionRoleComponent\"\r\n }\r\n },\r\n onEnter: ($state: angular.ui.IStateService,\r\n $stateParams: ng.ui.IStateParamsService,\r\n htmlStorageService: HtmlStorageService,\r\n authenticationService: AuthenticationService) => {\r\n\r\n }\r\n })\r\n .state(\"root.authenticated.permission.user\", {\r\n url: \"/user\",\r\n views: {\r\n 'content@': {\r\n component: \"ibPermissionUserComponent\"\r\n }\r\n },\r\n onEnter: ($state: angular.ui.IStateService,\r\n $stateParams: ng.ui.IStateParamsService,\r\n htmlStorageService: HtmlStorageService,\r\n authenticationService: AuthenticationService) => {\r\n\r\n }\r\n })\r\n .state(\"root.authenticated.remaining\", {\r\n abstract: true,\r\n url: \"/remaining\",\r\n views: {\r\n 'navigation@root.authenticated': {\r\n component: \"ibRemainingNavigationComponent\"\r\n }\r\n },\r\n params: {\r\n subSystem: null\r\n },\r\n onEnter: ($state: angular.ui.IStateService,\r\n $stateParams: ng.ui.IStateParamsService,\r\n htmlStorageService: HtmlStorageService,\r\n authenticationService: AuthenticationService) => {\r\n\r\n }\r\n })\r\n .state(\"root.authenticated.remaining.store\", {\r\n url: \"/store\",\r\n views: {\r\n 'content@': {\r\n component: \"ibRemainingStoreComponent\"\r\n }\r\n },\r\n onEnter: ($state: angular.ui.IStateService,\r\n $stateParams: ng.ui.IStateParamsService,\r\n htmlStorageService: HtmlStorageService,\r\n authenticationService: AuthenticationService) => {\r\n\r\n }\r\n })\r\n .state(\"root.authenticated.remaining.follow-up\", {\r\n url: \"/follow-up\",\r\n views: {\r\n 'content@': {\r\n component: \"ibRemainingFollowUpComponent\"\r\n }\r\n },\r\n onEnter: ($state: angular.ui.IStateService,\r\n $stateParams: ng.ui.IStateParamsService,\r\n htmlStorageService: HtmlStorageService,\r\n authenticationService: AuthenticationService) => {\r\n\r\n }\r\n });\r\n})\r\n .component(\"ibAppComponent\", new AppComponent())\r\n .component(\"ibAdministrationNavigationComponent\", new AdministrationNavigationComponent())\r\n .component(\"ibAdministrationAdminCompanyComponent\", new AdministrationAdminCompanyComponent())\r\n .component(\"ibAdministrationDiffDaysComponent\", new AdministrationDiffDaysComponent())\r\n .component(\"ibAdministrationFileComponent\", new AdministrationFileComponent())\r\n .component(\"ibAdministrationFileUploadComponent\", new AdministrationFileUploadComponent())\r\n .component(\"ibAdministrationHolidaysComponent\", new AdministrationHolidaysComponent())\r\n .component(\"ibAdministrationInformationPageAddEditComponent\", new AdministrationInformationPageAddEditComponent())\r\n .component(\"ibAdministrationInformationPageComponent\", new AdministrationInformationPageComponent())\r\n .component(\"ibAdministrationInitCompanyComponent\", new AdministrationInitCompanyComponent())\r\n .component(\"ibAdministrationInitCompanyAddEditComponent\", new AdministrationInitCompanyAddEditComponent())\r\n .component(\"ibAdministrationInitCompanyImportExportLogComponent\", new AdministrationInitCompanyImportExportLogComponent())\r\n .component(\"ibAdministrationStopTimeComponent\", new AdministrationStopTimeComponent())\r\n .component(\"ibAuthenticationComponent\", new AuthenticationComponent())\r\n .component(\"ibCalendar\", new CalendarComponent())\r\n .component(\"ibCalendarDay\", new CalendarDayComponent())\r\n .component(\"ibCustomerSelect\", new CustomerSelectComponent())\r\n .component(\"ibHeaderComponent\", new HeaderComponent())\r\n .component(\"ibInformationComponent\", new InformationComponent())\r\n .component(\"ibNavigationSecondNavItem\", new NavigationSecondNavItem())\r\n\r\n .component(\"ibOrderingNavigationComponent\", new OrderingNavigationComponent())\r\n .component(\"ibOrderingOrderComponent\", new OrderingOrderComponent())\r\n .component(\"ibOrderingOrderOrdering1\", new OrderingOrderOrdering1Component)\r\n .component(\"ibOrderingOrderOrderingArticleInformationComponent\", new OrderingOrderOrderingArticleInformationComponent)\r\n .component(\"ibOrderingOrderTemplate\", new OrderingOrderTemplateComponent)\r\n .component(\"ibOrderingOrderTemplateSelect\", new OrderingOrderTemplateSelectComponent)\r\n .component(\"ibOrderingReturnComponent\", new OrderingReturnComponent())\r\n .component(\"ibOrderingReturnReturn\", new OrderingReturnReturnComponent())\r\n .component(\"ibOrderingReturnReturnReason\", new OrderingReturnReturnReasonComponent())\r\n .component(\"ibOrderingComplaintComponent\", new OrderingComplaintComponent())\r\n .component(\"ibOrderingTemplateComponent\", new OrderingTemplateComponent())\r\n .component(\"ibOrderingTemplateTemplateArticleInformationComponent\", new OrderingTemplateTemplateArticleInformationComponent())\r\n .component(\"ibOrderingTemplateTemplateSelect\", new OrderingTemplateTemplateSelectComponent())\r\n .component(\"ibOrderingTemplateTemplate\", new OrderingTemplateTemplateComponent())\r\n\r\n .component(\"ibPermissionNavigationComponent\", new PermissionNavigationComponent())\r\n .component(\"ibPermissionRoleComponent\", new PermissionRoleComponent())\r\n .component(\"ibPermissionUserComponent\", new PermissionUserComponent)\r\n .component(\"ibPermissionUserAddEditComponent\", new PermissionUserAddEditComponent)\r\n .component(\"ibPermissionUserRoleAddEditComponent\", new PermissionUserRoleAddEditComponent)\r\n\r\n .component(\"ibRemainingNavigationComponent\", new RemainingNavigationComponent())\r\n .component(\"ibRemainingStoreComponent\", new RemainingStoreComponent())\r\n .component(\"ibRemainingFollowUpComponent\", new RemainingFollowUpComponent())\r\n .component(ShowFileDialogComponent.Name, new ShowFileDialogComponent())\r\n .component(\"ibSupportComponent\", new SupportComponent())\r\n .component(\"ibSettingsComponent\", new SettingsComponent())\r\n .component(WarningDialogComponent.Name, new WarningDialogComponent())\r\n\r\n .factory(\"administrationInformationCustomerGroupService\", AdministrationInformationCustomerGroupService.Factory)\r\n .factory(\"administrationInformationCustomerService\", AdministrationInformationCustomerService.Factory)\r\n .factory(\"authenticationService\", AuthenticationService.Factory)\r\n .factory(\"branchService\", BranchService.Factory)\r\n .factory(\"companyService\", CompanyService.Factory)\r\n .factory(\"countryService\", CountryService.Factory)\r\n .factory(\"customerService\", CustomerService.Factory)\r\n .factory(\"fileGroupService\", FileGroupService.Factory)\r\n .factory(\"fileService\", FileService.Factory)\r\n .factory(\"fileTypeService\", FileTypeService.Factory)\r\n .factory(\"historyTypeService\", HistoryTypeService.Factory)\r\n .factory(\"htmlStorageService\", HtmlStorageService.Factory)\r\n .factory(\"informationService\", InformationService.Factory)\r\n .factory(\"importExportService\", ImportExportService.Factory)\r\n .factory(\"orderingArticleGroupService\", OrderingArticleGroupService.Factory)\r\n .factory(\"orderingArticleInformationService\", OrderingArticleInformationService.Factory)\r\n .factory(\"orderingArticleService\", OrderingArticleService.Factory)\r\n .factory(\"orderingCalendarDayService\", OrderingCalendarDayService.Factory)\r\n .factory(\"orderingRowService\", OrderingRowService.Factory)\r\n .factory(\"orderingService\", OrderingService.Factory)\r\n .factory(\"orderingTemplateInfoService\", OrderingTemplateInfoService.Factory)\r\n .factory(\"orderingTemplateRowService\", OrderingTemplateRowService.Factory)\r\n .factory(\"orderingTemplateService\", OrderingTemplateService.Factory)\r\n .factory(\"permissionService\", PermissionService.Factory)\r\n .factory(\"returnArticleGroupService\", ReturnArticleGroupService.Factory)\r\n .factory(\"returnArticleService\", ReturnArticleService.Factory)\r\n .factory(\"returnCalendarDayService\", ReturnCalendarDayService.Factory)\r\n .factory(\"returnOrderingRowService\", ReturnOrderingRowService.Factory)\r\n .factory(\"returnOrderingService\", ReturnOrderingService.Factory)\r\n .factory(\"returnReasonTypeService\", ReturnReasonTypeService.Factory)\r\n .factory(\"roleService\", RoleService.Factory)\r\n .factory(\"spinnerService\", SpinnerService.Factory)\r\n .factory(\"stopTimeArticleGroupService\", StopTimeArticleGroupService.Factory)\r\n .factory(\"stopTimeCustomerGroupService\", StopTimeCustomerGroupService.Factory)\r\n .factory(\"stopTimeDivergentDateService\", StopTimeDivergentDateService.Factory)\r\n .factory(\"stopTimeReturnOrderingService\", StopTimeReturnOrderingService.Factory)\r\n .factory(\"stopTimeDateService\", StopTimeDateService.Factory)\r\n .factory(\"stopTimeService\", StopTimeService.Factory)\r\n .factory(\"subSystemService\", SubSystemService.Factory)\r\n .factory(\"templateArticleGroupService\", TemplateArticleGroupService.Factory)\r\n .factory(\"templateArticleInformationService\", TemplateArticleInformationService.Factory)\r\n .factory(\"templateArticleService\", TemplateArticleService.Factory)\r\n .factory(\"templateInfoService\", TemplateInfoService.Factory)\r\n .factory(\"templateOrderingTypeService\", TemplateOrderingTypeService.Factory)\r\n .factory(\"templateRowService\", TemplateRowService.Factory)\r\n .factory(\"templateService\", TemplateService.Factory)\r\n .factory(\"transferOptionService\", TransferOptionService.Factory)\r\n .factory(\"userService\", UserService.Factory)\r\n .factory(\"weekdayService\", WeekdayService.Factory)\r\n\r\n .filter(\"ibDecimalComma\", IbDecimalToCommaFilter.Factory)\r\n .filter(\"ibFilterBy\", IbFilterByFilter.Factory)\r\n\r\n .directive(IbBindObjectDirective.Name, IbBindObjectDirective.Factory())\r\n .directive(\"ibDecimalComma\", IbDecimalCommaDirective.Factory())\r\n .directive('stFocusSelectRow', SmartTableFocusSelectRowDirective.Factory())\r\n .directive('stResetSearchOn', SmartTableResetSearchOnDirective.Factory())\r\n .directive(IbInputIncrementDecrementNumberDirective.Name, IbInputIncrementDecrementNumberDirective.Factory())\r\n .directive(IbInputSelectFileDirective.Name, IbInputSelectFileDirective.Factory())\r\n .directive(IbUtcDateDirective.Name, IbUtcDateDirective.Factory())\r\n .directive('stFocusSelectRow1', ['$timeout', 'stConfig', ($timeout: ng.ITimeoutService, stConfig) => ({\r\n restrict: \"A\",\r\n require: '^stTable',\r\n link(scope, elem: ng.IAugmentedJQuery, attributes: ng.IAttributes, ctrl) {\r\n elem.on('click', (e: JQueryEventObject) => {\r\n e.stopPropagation();\r\n });\r\n\r\n elem.on('focus', (e: JQueryEventObject) => {\r\n //let p = element.parent();\r\n //do {\r\n // if(p.)\r\n //} while (p != undefined)\r\n let tr = e.currentTarget.closest('tr');\r\n if (tr != undefined) {\r\n\r\n let t = element(tr);\r\n let mode = t.attr('stSelectMode') || stConfig.select.mode;\r\n\r\n if (!t.hasClass(stConfig.select.selectedClass)) {\r\n $timeout(() => {\r\n (ctrl as any).select((scope as any).row, mode);\r\n });\r\n }\r\n }\r\n });\r\n }\r\n })])\r\n .directive('stSelectRow2', ['$timeout', 'stConfig', function ($timeout: ng.ITimeoutService, stConfig) {\r\n return {\r\n restrict: 'A',\r\n require: '^stTable',\r\n scope: {\r\n row: '=stSelectRow2'\r\n },\r\n\r\n link: function (scope, element, attr, ctrl) {\r\n var mode = attr.stSelectMode || stConfig.select.mode;\r\n element.bind('click', function () {\r\n $timeout(() => {\r\n let c = ctrl as ISmartTableSelectRowController;\r\n let s = scope as ISmartTableSelectRowScope;\r\n c.select(s.row, mode);\r\n });\r\n });\r\n\r\n scope.$watch('row.isSelected', function (newValue) {\r\n if (newValue === true) {\r\n element.addClass(stConfig.select.selectedClass);\r\n } else {\r\n element.removeClass(stConfig.select.selectedClass);\r\n }\r\n });\r\n }\r\n };\r\n }])\r\n .directive(\"focusOn\", $timeout => (scope, element, attrs) => {\r\n scope.$on((attrs as any).focusOn, e => {\r\n $timeout(() => {\r\n element[0].focus();\r\n });\r\n });\r\n })\r\n .directive(\"ibNextOnEnter\", () => ({\r\n restrict: \"A\",\r\n link($scope, selem, attrs) {\r\n selem.bind(\"keydown\", e => {\r\n var code = e.keyCode || e.which;\r\n if (code === 13) {\r\n e.preventDefault();\r\n var pageElems = document.querySelectorAll(\"input, select, textarea\");\r\n var elem = e.srcElement;\r\n var focusNext = false;\r\n var len = pageElems.length;\r\n for (let i = 0; i < len; i++) {\r\n var pe = pageElems[i];\r\n if (focusNext) {\r\n if ((pe as any).style.display !== \"none\") {\r\n (pe as any).focus();\r\n break;\r\n }\r\n } else if (pe === elem) {\r\n focusNext = true;\r\n }\r\n }\r\n }\r\n });\r\n }\r\n }));\r\n\r\nelement(document).ready(() => {\r\n bootstrap(document, ['app']);\r\n});","/// \r\n/// \r\n\r\nimport { module } from \"angular\";\r\nimport SpinnerService from \"../services/SpinnerService\";\r\nimport AuthenticationService from \"../services/AuthenticationService\";\r\nimport HtmlStorageService from \"../services/HtmlStorageService\";\r\nimport UserService from \"../services/UserService\";\r\nimport { TransitionService, Transition } from \"@uirouter/angularjs\";\r\nimport { IRootStateParameters } from \"../core/StateParameters\";\r\nimport CustomerService from \"../services/CustomerService\";\r\nimport CompanyService from \"../services/CompanyService\";\r\nimport ImageHelper from \"../core/ImageHelper\";\r\nimport { User } from \"../services/model/User\";\r\nimport { Company } from \"../services/model/Company\";\r\nimport SubSystemService from \"../services/SubSystemService\";\r\nimport { SubSystem } from \"../services/model/SubSystem\";\r\nimport * as Collections from \"typescript-collections\";\r\nimport { SubSystemFunction } from \"../services/model/SubSystemFunction\";\r\n\r\nclass HeaderController implements ng.IController {\r\n private _isHeaderNavigationCollapsed: boolean;\r\n //private _companyId: number;\r\n //private _sysUserId: number;\r\n private _username: string;\r\n private _logoText: string;\r\n private _logoBase64EncodedSrc: string;\r\n private _logoUrl: string;\r\n private _state: angular.ui.IStateService;\r\n private _isAuthenticated: boolean = false;\r\n\r\n static $inject = [\"$http\", \"$rootScope\", \"$scope\", \"$state\", \"$timeout\", \"$q\", \"$transitions\", \"$window\", \"$log\", \"spinnerService\", \"htmlStorageService\", \"authenticationService\", \"customerService\", \"companyService\", \"userService\", \"subSystemService\"];\r\n\r\n constructor(private $http: ng.IHttpService,\r\n private $rootScope: ng.IRootScopeService,\r\n private $scope: ng.IScope,\r\n private $state: angular.ui.IStateService,\r\n private $timeout: ng.ITimeoutService,\r\n private $q: ng.IQService,\r\n private $transitions: TransitionService,\r\n private $window: ng.IWindowService,\r\n private $log: ng.ILogService,\r\n private spinnerService: SpinnerService,\r\n private htmlStorageService: HtmlStorageService,\r\n private authenticationService: AuthenticationService,\r\n private customerService: CustomerService,\r\n private companyService: CompanyService,\r\n private userService: UserService,\r\n private subSystemService: SubSystemService) {\r\n\r\n this.createSubSystemsMappings();\r\n\r\n this._state = $state;\r\n this.$scope.$on(\"authenticationChanged\", (event: ng.IAngularEvent, args: any[]) => { this.updateIsAuthenticated(args[0]); });\r\n }\r\n\r\n trans: Transition;\r\n\r\n sysUserId: number;\r\n companyId: number;\r\n lastCustomerId: number;\r\n customerId: number;\r\n subSystems: SubSystem[];\r\n\r\n get username(): string {\r\n return this._username;\r\n }\r\n\r\n get logoText(): string {\r\n return this._logoText;\r\n }\r\n\r\n get logoBase64EncodedSrc(): string {\r\n return this._logoBase64EncodedSrc;\r\n }\r\n\r\n get logoUrl(): string {\r\n return this._logoUrl;\r\n }\r\n\r\n get state(): angular.ui.IStateService {\r\n return this._state;\r\n }\r\n\r\n get isAuthenticated(): boolean {\r\n return this._isAuthenticated;\r\n }\r\n\r\n get isHeaderNavigationCollapsed(): boolean {\r\n return this._isHeaderNavigationCollapsed;\r\n }\r\n set isHeaderNavigationCollapsed(value: boolean) {\r\n this._isHeaderNavigationCollapsed = value;\r\n }\r\n\r\n subSystemsNavigationMap: Collections.Dictionary = new Collections.Dictionary();\r\n subSystemFunctionsMap: Collections.Dictionary = new Collections.Dictionary();\r\n\r\n private createSubSystemsMappings(): void {\r\n /**************************************************************\r\n sysfunctionid\tlabel\tsubSystemId\tsubSystemlabel\r\n 1\tOrdering\t1\tOrdering\r\n 2\tReturn\t 1\tOrdering\r\n 3\tComplain\t1\tOrdering\r\n 9\tTemplate\t1\tOrdering\r\n ****************************************************************/\r\n this.subSystemsNavigationMap.setValue(1, { uisref: \"root.authenticated.ordering\", uisrefactive: \"'root.authenticated.ordering'\" });\r\n this.subSystemFunctionsMap.setValue(1, { uisref: \"root.authenticated.ordering.order\" });\r\n this.subSystemFunctionsMap.setValue(2, { uisref: \"root.authenticated.ordering.return\" });\r\n this.subSystemFunctionsMap.setValue(3, { uisref: \"root.authenticated.ordering.complaint\" });\r\n this.subSystemFunctionsMap.setValue(9, { uisref: \"root.authenticated.ordering.template\" });\r\n\r\n /**************************************************************\r\n sysfunctionid label\tsubSystemId\tsubSystemlabel\r\n 10\tInitCompany\t 2\tAdministration\r\n 11\tHolidays \t 2\tAdministration\r\n 12\tDiffDays \t 2\tAdministration\r\n 13\tStoptime \t 2\tAdministration\r\n 6\tAdmCompany \t 2\tAdministration\r\n 15\tInformationPage\t 2\tAdministration\r\n 16 Files 2 Administration\r\n 19 Import Beställningar 2 Administration\r\n ***************************************************************/\r\n this.subSystemsNavigationMap.setValue(2, { uisref: \"root.authenticated.administration\", uisrefactive: \"'root.authenticated.administration'\" });\r\n this.subSystemFunctionsMap.setValue(10, { uisref: \"root.authenticated.administration.init-company\" });\r\n this.subSystemFunctionsMap.setValue(11, { uisref: \"root.authenticated.administration.holidays\" });\r\n this.subSystemFunctionsMap.setValue(12, { uisref: \"root.authenticated.administration.diff-days\" });\r\n this.subSystemFunctionsMap.setValue(13, { uisref: \"root.authenticated.administration.stop-time\" });\r\n this.subSystemFunctionsMap.setValue(6, { uisref: \"root.authenticated.administration.admin-company\" });\r\n this.subSystemFunctionsMap.setValue(15, { uisref: \"root.authenticated.administration.admin-information-page\" });\r\n this.subSystemFunctionsMap.setValue(16, { uisref: \"root.authenticated.administration.admin-files\" });\r\n\r\n /**************************************************************\r\n sysfunctionid\tlabel\tsubSystemId\tsubSystemlabel\r\n 4\tUser\t3\tSequrity\r\n 5\tRole\t3\tSequrity\r\n ***************************************************************/\r\n this.subSystemsNavigationMap.setValue(3, { uisref: \"root.authenticated.permission\", uisrefactive: \"'root.authenticated.permission'\" });\r\n this.subSystemFunctionsMap.setValue(4, { uisref: \"root.authenticated.permission.user\" });\r\n this.subSystemFunctionsMap.setValue(5, { uisref: \"root.authenticated.permission.role\" });\r\n\r\n\r\n /**************************************************************\r\n sysfunctionid\tlabel\tsubSystemId\tsubSystemlabel\r\n 7\tStore\t 4\tRemaining\r\n 8\tFollow-up\t4\tRemaining\r\n ***************************************************************/\r\n this.subSystemsNavigationMap.setValue(4, { uisref: \"root.authenticated.remaining\", uisrefactive: \"'root.authenticated.remaining'\" });\r\n this.subSystemFunctionsMap.setValue(7, { uisref: \"root.authenticated.remaining.store\" });\r\n this.subSystemFunctionsMap.setValue(8, { uisref: \"root.authenticated.remaining.follow-up\" });\r\n }\r\n\r\n customerChanged(customerId: number): ng.IPromise {\r\n this.customerId = customerId;\r\n let d = this.$q.defer();\r\n\r\n if (this.subSystems !== null && typeof this.subSystems !== \"undefined\") {\r\n this.subSystems.length = 0;\r\n }\r\n let self = this;\r\n\r\n this.subSystemService.getSubSystems(this.sysUserId, this.customerId).then((subSystems: SubSystem[]) => {\r\n\r\n subSystems.forEach((item) => {\r\n item.subSystemFunctions.forEach((subSystemFunction) => {\r\n if (subSystemFunction.isDefault && this.subSystemFunctionsMap.containsKey(subSystemFunction.id)) {\r\n item.uisref = this.subSystemFunctionsMap.getValue(subSystemFunction.id).uisref;\r\n item.uisref += `({subSystem:subSystem})`;\r\n }\r\n if (this.subSystemFunctionsMap.containsKey(subSystemFunction.id)){\r\n subSystemFunction.uisref = this.subSystemFunctionsMap.getValue(subSystemFunction.id).uisref;\r\n }\r\n });\r\n\r\n if (this.subSystemsNavigationMap.containsKey(item.id)) {\r\n item.uisrefactive = this.subSystemsNavigationMap.getValue(item.id).uisrefactive;\r\n }\r\n });\r\n\r\n this.subSystems = subSystems;\r\n d.resolve();\r\n }).catch(error => {\r\n let msg: string = `An error occurred while getting sys sub systems`;\r\n self.$log.error(`${msg} ${error}`);\r\n d.reject();\r\n });\r\n\r\n return d.promise;\r\n }\r\n\r\n signoutUser(): void {\r\n this.authenticationService.signoutUser();\r\n }\r\n\r\n $onInit(): void {\r\n this.updateIsAuthenticated(this.authenticationService.isAuthenticated());\r\n\r\n let rootParams: IRootStateParameters = this.trans.params() as IRootStateParameters;\r\n\r\n this.setUsername(rootParams.username);\r\n\r\n this.spinnerService.showBusy();\r\n let self = this;\r\n this.userService.getUser(this.username).then((user: User) => {\r\n if (user === null || typeof user === \"undefined\") {\r\n let errorMsg: string = `An error occurred. User object was null.`;\r\n self.$log.error(errorMsg);\r\n }\r\n\r\n this.setCompanyId(user);\r\n this.setSysUserId(user);\r\n this.setLastCustomerId(user);\r\n\r\n this.spinnerService.showBusy();\r\n this.companyService.getCompany(user.companyId).then((company: Company) => {\r\n if (company === null || typeof company === \"undefined\") {\r\n let errorMsg: string = `An error occurred. Company object was null.`;\r\n self.$log.error(errorMsg);\r\n }\r\n\r\n this.setLogoText(company);\r\n this.setLogoBase64EncodedSrc(company);\r\n this.setLogoUrl(company);\r\n }).catch(error => {\r\n let msg: string = `An error occurred while getting company info`;\r\n self.$log.error(`${msg} ${error}`);\r\n }).finally(() => {\r\n this.spinnerService.hideBusy();\r\n });\r\n }).catch(error => {\r\n // TODO: error log?, Sign out?\r\n self.$log.error(`An error occurred while getting user information ${error}`);\r\n }).finally(() => {\r\n this.spinnerService.hideBusy();\r\n });\r\n }\r\n\r\n private setCompanyId(user: User): void {\r\n this.companyId = user.companyId;\r\n }\r\n\r\n private setSysUserId(user: User): void {\r\n this.sysUserId = user.sysUserId;\r\n }\r\n\r\n private setUsername(value: string): void {\r\n this._username = value;\r\n }\r\n\r\n private setLastCustomerId(user: User) {\r\n this.lastCustomerId = user.lastCustomerId;\r\n }\r\n\r\n private setLogoText(company: Company): void {\r\n this._logoText = company.companyName;\r\n }\r\n\r\n private setLogoBase64EncodedSrc(company: Company): void {\r\n if (company.logo) {\r\n this._logoBase64EncodedSrc = ImageHelper.createBase64ImageSrcString(company.logo);\r\n return;\r\n }\r\n this._logoBase64EncodedSrc = null;\r\n }\r\n\r\n private setLogoUrl(company: Company): void {\r\n if (!company.logo && company.logoUrl != undefined) {\r\n this._logoUrl = company.logoUrl;\r\n return;\r\n }\r\n this._logoUrl = undefined;\r\n }\r\n\r\n private updateIsAuthenticated(authenticated: boolean): void {\r\n // TODO: ?\r\n this._isAuthenticated = authenticated;\r\n }\r\n}\r\n\r\nexport default class HeaderComponent implements ng.IComponentOptions {\r\n bindings?: { [boundProperty: string]: string };\r\n templateUrl: string;\r\n controller: ng.Injectable;\r\n\r\n constructor() {\r\n this.controller = HeaderController;\r\n this.templateUrl = './dist/app/header/header.template.html';\r\n this.bindings = {\r\n trans: '<'\r\n }\r\n }\r\n}","/// \r\n/// \r\n/// \r\n/// \r\n\r\nimport { module } from \"angular\";\r\nimport IBDate from \"../core/IBDate\";\r\nimport BaseService from \"../services/base/BaseService\";\r\nimport IHttpPromiseError from \"../core/IHttpPromiseError\";\r\nimport { ReturnReasonType } from \"./model/ReturnReasonType\";\r\n\r\n\r\nexport default class ReturnReasonTypeService extends BaseService {\r\n\r\n static $inject = [\"$http\", \"$cacheFactory\", \"$q\", \"$rootScope\", \"$log\", \"appSettings\"];\r\n\r\n constructor($http: ng.IHttpService,\r\n $cacheFactory: ng.ICacheFactoryService,\r\n $q: ng.IQService,\r\n $rootScope: ng.IRootScopeService,\r\n $log: ng.ILogService,\r\n appSettings: any,\r\n apiUrlFragment: string) {\r\n super($http, $cacheFactory, $q, $rootScope, $log, appSettings, apiUrlFragment);\r\n this.baseUrl = `${appSettings.SERVICE_URL}/api/v1.0`;\r\n }\r\n\r\n getAllByCustomer(customerId: number, orderingTypeId: number): ng.IPromise {\r\n return this.getAllByUrlPart(`${this.apiUrlFragment}/Customer/${customerId}/OrderingType/${orderingTypeId}`);\r\n }\r\n\r\n public static Factory($http: ng.IHttpService,\r\n $cacheFactory: ng.ICacheFactoryService,\r\n $q: ng.IQService,\r\n $rootScope: ng.IRootScopeService,\r\n $log: ng.ILogService,\r\n appSettings: any): ReturnReasonTypeService {\r\n return new ReturnReasonTypeService($http, $cacheFactory, $q, $rootScope, $log, appSettings, \"returnReasonTypes\");\r\n }\r\n}","/// \r\n/// \r\n\r\nimport { ArticleGroup } from \"../services/model/ArticleGroup\";\r\nimport { CustomerGroup } from \"../services/model/CustomerGroup\";\r\nimport { IAuthenticatedParameters } from \"../core/StateParameters\";\r\nimport { IModalService } from \"angular-ui-bootstrap\";\r\nimport { module, IOnChangesObject } from \"angular\";\r\nimport { StopTime } from \"../services/model/StopTime\";\r\nimport { TransitionService, Transition, TargetState } from \"@uirouter/angularjs\";\r\nimport HtmlStorageService from \"../services/HtmlStorageService\";\r\nimport SpinnerService from \"../services/SpinnerService\";\r\nimport StopTimeArticleGroupService from \"../services/StopTimeArticleGroupService\";\r\nimport StopTimeCustomerGroupService from \"../services/StopTimeCustomerGroupService\";\r\nimport StopTimeService from \"../services/StopTimeService\";\r\nimport { StopTimeReturnOrdering } from \"../services/model/StopTimeReturnOrdering\";\r\nimport { StopTimeDate } from \"../services/model/StopTimeDate\";\r\nimport { StopTimeDivergentDate } from \"../services/model/StopTimeDivergentDate\";\r\nimport StopTimeDivergentDateService from \"../services/StopTimeDivergentDateService\";\r\nimport StopTimeReturnOrderingService from \"../services/StopTimeReturnOrderingService\";\r\nimport StopTimeDateService from \"../services/StopTimeDateService\";\r\nimport WeekdayService from \"../services/WeekdayService\";\r\nimport { Weekday } from \"../services/model/Weekday\";\r\nimport * as angular from \"angular\";\r\nimport { ISelected } from \"../services/model/ISelected\";\r\nimport IBDate, { DateCompareGranularities } from \"../core/IBDate\";\r\n\r\ntype StopTimeDateTypes = \"backNoOffWeeks\" | \"stopWeekday\" | \"stopTime\" | \"useLeadTime\";\r\ntype StopTimeDivergentDateTypes = \"deliveryDate\" | \"description\" | \"stopDate\" | \"stopTime\" | \"useLeadTime\";\r\n\r\nclass AdministrationStopTimeController implements ng.IController {\r\n static $inject = [\"$http\", \"$rootScope\", \"$scope\", \"$state\", \"$timeout\", \"$q\", \"$transitions\", \"$window\", \"$log\", \"$locale\", \"$uibModal\", \"spinnerService\", \"htmlStorageService\", \"stopTimeArticleGroupService\", \"stopTimeCustomerGroupService\", \"stopTimeService\", \"stopTimeDivergentDateService\", \"stopTimeReturnOrderingService\", \"stopTimeDateService\", \"weekdayService\"];\r\n\r\n constructor(private $http: ng.IHttpService,\r\n private $rootScope: ng.IRootScopeService,\r\n private $scope: ng.IScope,\r\n private $state: angular.ui.IStateService,\r\n private $timeout: ng.ITimeoutService,\r\n private $q: ng.IQService,\r\n private $transitions: TransitionService,\r\n private $window: ng.IWindowService,\r\n private $log: ng.ILogService,\r\n private $locale: ng.ILocaleService,\r\n private $uibModal: IModalService,\r\n private spinnerService: SpinnerService,\r\n private htmlStorageService: HtmlStorageService,\r\n private stopTimeArticleGroupService: StopTimeArticleGroupService,\r\n private stopTimeCustomerGroupService: StopTimeCustomerGroupService,\r\n private stopTimeService: StopTimeService,\r\n private stopTimeDivergentDateService: StopTimeDivergentDateService,\r\n private stopTimeReturnOrderingService: StopTimeReturnOrderingService,\r\n private stopTimeDateService: StopTimeDateService,\r\n private weekdayService: WeekdayService) {\r\n }\r\n\r\n private articleGroups: ArticleGroup[];\r\n private customerGroups: CustomerGroup[];\r\n\r\n /** Pagination StopTime **/\r\n private _selectedPaginationItemStopTime: { value: number, label: string };\r\n\r\n paginationItemsStopTime = [{\r\n value: 10,\r\n label: '10'\r\n }, {\r\n value: 15,\r\n label: '15'\r\n },\r\n {\r\n value: 20,\r\n label: '20'\r\n },\r\n {\r\n value: 25,\r\n label: '25'\r\n },\r\n {\r\n value: 30,\r\n label: '30'\r\n }, {\r\n value: 40,\r\n label: '40'\r\n }, {\r\n value: 50,\r\n label: '50'\r\n }, {\r\n value: 99999,\r\n label: 'Alla'\r\n }];\r\n\r\n get selectedPaginationItemStopTime(): { value: number, label: string } {\r\n if (this._selectedPaginationItemStopTime == undefined) {\r\n let spi = <{ value: number, label: string }>this.htmlStorageService.getLocalStorageItem(\"lastPaginationItemStopTimeAdministrationStopTime\");\r\n if (spi == undefined) {\r\n this.selectedPaginationItemStopTime = this.paginationItemsStopTime[0];\r\n }\r\n else {\r\n this.selectedPaginationItemStopTime = spi;\r\n }\r\n }\r\n return this._selectedPaginationItemStopTime;\r\n }\r\n\r\n set selectedPaginationItemStopTime(item: { value: number, label: string }) {\r\n this._selectedPaginationItemStopTime = item;\r\n this.htmlStorageService.setLocalStorageItem(\"lastPaginationItemStopTimeAdministrationStopTime\", item);\r\n }\r\n\r\n /** Pagination StopTime Divergent Date **/\r\n private _selectedPaginationItemStopTimeDivergentDate: { value: number, label: string };\r\n\r\n paginationItemsStopTimeDivergentDate = [{\r\n value: 10,\r\n label: '10'\r\n }, {\r\n value: 15,\r\n label: '15'\r\n },\r\n {\r\n value: 20,\r\n label: '20'\r\n },\r\n {\r\n value: 25,\r\n label: '25'\r\n },\r\n {\r\n value: 30,\r\n label: '30'\r\n }, {\r\n value: 40,\r\n label: '40'\r\n }, {\r\n value: 50,\r\n label: '50'\r\n }, {\r\n value: 99999,\r\n label: 'Alla'\r\n }];\r\n\r\n get selectedPaginationItemStopTimeDivergentDate(): { value: number, label: string } {\r\n if (this._selectedPaginationItemStopTimeDivergentDate == undefined) {\r\n let spi = <{ value: number, label: string }>this.htmlStorageService.getLocalStorageItem(\"lastPaginationItemStopTimeDivergentDateAdministrationStopTime\");\r\n if (spi == undefined) {\r\n this.selectedPaginationItemStopTimeDivergentDate = this.paginationItemsStopTimeDivergentDate[0];\r\n }\r\n else {\r\n this.selectedPaginationItemStopTimeDivergentDate = spi;\r\n }\r\n }\r\n return this._selectedPaginationItemStopTimeDivergentDate;\r\n }\r\n\r\n set selectedPaginationItemStopTimeDivergentDate(item: { value: number, label: string }) {\r\n this._selectedPaginationItemStopTimeDivergentDate = item;\r\n this.htmlStorageService.setLocalStorageItem(\"lastPaginationItemStopTimeDivergentDateAdministrationStopTime\", item);\r\n }\r\n\r\n\r\n userName: string;\r\n companyId: number;\r\n customerId: number;\r\n userId: number;\r\n\r\n filteredArticleGroups: ArticleGroup[] = new Array();\r\n filteredCustomerGroups: CustomerGroup[] = new Array();\r\n\r\n stopTimes: StopTime[];\r\n stopTimeDates: StopTimeDate[];\r\n stopTimeDivergentDates: StopTimeDivergentDate[];\r\n stopTimeReturnOrdering: StopTimeReturnOrdering;\r\n\r\n weekdays: Weekday[];\r\n\r\n newStopTimeDivergentDate: StopTimeDivergentDate;\r\n\r\n selectedArticleGroup: ArticleGroup;\r\n selectedCustomerGroup: CustomerGroup;\r\n selectedStopTime: StopTime;\r\n\r\n\r\n get showSelectStopTimeInformation(): boolean {\r\n return this.selectedStopTime == undefined;\r\n }\r\n\r\n textViewEditStopTimeDatesOrDivergentDatesTitle: string = `Välj en stopptid för att visa eller ändra stopptider.`;\r\n\r\n get textStopTimeDatesTitle(): string {\r\n if (this.selectedStopTime == undefined) {\r\n return `Laddar stopptider...`;\r\n }\r\n\r\n if (this.selectedStopTime.customerGroupName == undefined && this.selectedStopTime.articleGroupName == undefined) {\r\n return `Stopptider standard`;\r\n }\r\n\r\n return `Stopptider (${this.selectedStopTime.customerGroupName == undefined ? 'Alla' : this.selectedStopTime.customerGroupName} /\r\n ${this.selectedStopTime.articleGroupName == undefined ? 'Alla' : this.selectedStopTime.articleGroupName})`;\r\n }\r\n\r\n get textStopTimeDivergentDatesTitle(): string {\r\n if (this.selectedStopTime == undefined) {\r\n return `Laddar avvikande stopptider...`;\r\n }\r\n\r\n if (this.selectedStopTime.customerGroupName == undefined && this.selectedStopTime.articleGroupName == undefined) {\r\n return `Avvikande stopptider standard`;\r\n }\r\n\r\n return `Avvikande stopptider (${this.selectedStopTime.customerGroupName == undefined ? 'Alla' : this.selectedStopTime.customerGroupName} /\r\n ${this.selectedStopTime.articleGroupName == undefined ? 'Alla' : this.selectedStopTime.articleGroupName})`;\r\n }\r\n\r\n get canAddStopTime(): boolean {\r\n if (this.selectedCustomerGroup == undefined && this.selectedArticleGroup == undefined) {\r\n return false;\r\n }\r\n\r\n let scg = this.selectedCustomerGroup == undefined ? undefined : this.selectedCustomerGroup.id;\r\n let sag = this.selectedArticleGroup == undefined ? undefined : this.selectedArticleGroup.id;\r\n\r\n let st: StopTime = this.stopTimes.find((stopTime, index, stopTimes) => {\r\n return stopTime.customerGroupId == scg && stopTime.articleGroupId == sag;\r\n }, this);\r\n\r\n if (st != undefined) {\r\n return false;\r\n }\r\n\r\n return true;\r\n }\r\n\r\n get canAddStopTimeDivergentDate(): boolean {\r\n if (this.newStopTimeDivergentDate == undefined ||\r\n this.newStopTimeDivergentDate.companyId == undefined ||\r\n this.newStopTimeDivergentDate.description == undefined ||\r\n this.newStopTimeDivergentDate.deliveryDate == undefined) {\r\n return false;\r\n }\r\n\r\n if (this.newStopTimeDivergentDate.stopDate != undefined && this.newStopTimeDivergentDate.stopDate.valueOf() >= this.newStopTimeDivergentDate.deliveryDate.valueOf()) {\r\n return false;\r\n }\r\n\r\n if (this.newStopTimeDivergentDate.stopDate != undefined && this.newStopTimeDivergentDate.stopTime == undefined) {\r\n return false;\r\n }\r\n\r\n return true;\r\n }\r\n\r\n canRemoveStopTime(stopTime: StopTime): boolean {\r\n return stopTime != undefined && (stopTime.default == undefined || stopTime.default == false);\r\n }\r\n\r\n articleGroupSelected(articleGroup: ArticleGroup): void {\r\n this.selectedArticleGroup = articleGroup;\r\n this.filterCustomerGroups();\r\n }\r\n\r\n customerGroupSelected(customerGroup: CustomerGroup): void {\r\n this.selectedCustomerGroup = customerGroup;\r\n this.filterArticleGroups();\r\n }\r\n\r\n addStopTime(): void {\r\n if (!this.canAddStopTime) {\r\n return;\r\n }\r\n\r\n let newStopTime = new StopTime();\r\n newStopTime.companyId = this.companyId;\r\n newStopTime.articleGroupId = this.selectedArticleGroup == undefined ? undefined : this.selectedArticleGroup.id;\r\n newStopTime.customerGroupId = this.selectedCustomerGroup == undefined ? undefined : this.selectedCustomerGroup.id;\r\n\r\n this.spinnerService.showBusy();\r\n let self = this;\r\n\r\n this.stopTimeService.createStopTime(newStopTime).then((stopTime: StopTime) => {\r\n self.selectedCustomerGroup = undefined;\r\n self.selectedArticleGroup = undefined;\r\n self.stopTimes.splice(0, 0, stopTime);\r\n\r\n self.editStopTime(stopTime);\r\n }).catch(error => {\r\n let msg: string = `An error occurred while creating stop time date. Id ${newStopTime.id}.`;\r\n self.$log.error(`${msg} ${error}`);\r\n throw error;\r\n }).finally(() => {\r\n self.spinnerService.hideBusy();\r\n });\r\n }\r\n\r\n addStopTimeDivergentDate(form: ng.IFormController): void {\r\n if (!this.canAddStopTimeDivergentDate) {\r\n return;\r\n }\r\n\r\n this.spinnerService.showBusy();\r\n let self = this;\r\n\r\n this.stopTimeDivergentDateService.createStopTimeDivergentDate(this.newStopTimeDivergentDate).then((stopTime: StopTimeDivergentDate) => {\r\n self.initialiseNewStopTimeDivergentDate();\r\n self.stopTimeDivergentDates.splice(0, 0, stopTime);\r\n if (form != undefined) {\r\n form.$setPristine();\r\n }\r\n }).catch(error => {\r\n let msg: string = `An error occurred while creating a divergent date stop time date. Id ${this.newStopTimeDivergentDate.id}.`;\r\n self.$log.error(`${msg} ${error}`);\r\n throw error;\r\n }).finally(() => {\r\n self.spinnerService.hideBusy();\r\n });\r\n }\r\n\r\n backNoOffWeeksCharacterKeyDown(event: KeyboardEvent): void {\r\n if (event.key === 'Backspace' ||\r\n event.key === '0' ||\r\n event.key === '1' ||\r\n event.key === '2' ||\r\n event.key === '3' ||\r\n event.key === '4' ||\r\n event.key === '5' ||\r\n event.key === '6' ||\r\n event.key === '7' ||\r\n event.key === '8' ||\r\n event.key === '8') {\r\n return;\r\n }\r\n\r\n event.preventDefault();\r\n event.stopPropagation();\r\n return;\r\n\r\n //if (event.keyCode === 27) {\r\n // (event.currentTarget).value = this.newOrderingRow.quantity.toString();\r\n //}\r\n }\r\n\r\n editStopTime(stopTime: StopTime): void {\r\n if (stopTime == undefined || (this.selectedStopTime != undefined && stopTime.id === this.selectedStopTime.id)) {\r\n return;\r\n }\r\n\r\n this.clearStopTimeDatesAndDivergentDates();\r\n\r\n let self = this;\r\n this.loadStopTimeDates(stopTime.id).then(() => self.loadStopTimeDivergentDates(stopTime.id)).then(() => {\r\n self.selectedStopTime = stopTime;\r\n self.initialiseNewStopTimeDivergentDate();\r\n });\r\n }\r\n\r\n isStopTimeDateRowReadonly(row: StopTimeDate, propertyName: StopTimeDateTypes): boolean {\r\n if (row == undefined) {\r\n return true;\r\n }\r\n\r\n switch (propertyName) {\r\n case \"backNoOffWeeks\": {\r\n return row.stopWeekday == undefined || row.stopTime == undefined;\r\n }\r\n\r\n case \"stopTime\": {\r\n return row.stopWeekday == undefined;\r\n }\r\n\r\n case \"useLeadTime\": {\r\n return row.stopWeekday == undefined || row.stopTime == undefined;\r\n }\r\n\r\n default: {\r\n return false;\r\n }\r\n }\r\n }\r\n\r\n isStopTimeDivergentDateRowReadonly(row: StopTimeDivergentDate, propertyName: StopTimeDivergentDateTypes): boolean {\r\n if (row == undefined) {\r\n return true;\r\n }\r\n\r\n switch (propertyName) {\r\n case \"description\": {\r\n return row.deliveryDate == undefined;\r\n }\r\n\r\n case \"stopDate\": {\r\n return row.deliveryDate == undefined || row.description == undefined;\r\n }\r\n\r\n case \"stopTime\": {\r\n return row.deliveryDate == undefined || row.description == undefined || row.stopDate == undefined;\r\n }\r\n\r\n case \"useLeadTime\": {\r\n return row.deliveryDate == undefined || row.description == undefined || row.stopDate == undefined || row.stopTime == undefined;\r\n }\r\n\r\n default: {\r\n return false;\r\n }\r\n }\r\n }\r\n\r\n removeStopTime(stopTime: StopTime): void {\r\n if (!this.canRemoveStopTime(stopTime)) {\r\n return;\r\n }\r\n\r\n let result = this.$window.confirm(`Vill du tabort stopptiden?`);\r\n if (result == false) {\r\n return;\r\n }\r\n\r\n this.spinnerService.showBusy();\r\n let self = this;\r\n\r\n this.stopTimeService.removeStopTime(stopTime.id).then(() => {\r\n //self.stopTimes.splice(index, 1);\r\n let index = self.stopTimes.indexOf(stopTime);\r\n if (index !== -1) {\r\n self.stopTimes.splice(index, 1);\r\n }\r\n\r\n if (self.selectedStopTime.id == stopTime.id) {\r\n self.selectedStopTime = undefined;\r\n\r\n self.clearStopTimeDatesAndDivergentDates();\r\n }\r\n }).catch(error => {\r\n let msg: string = `An error occurred while removing stop time. Id ${stopTime.id}.`;\r\n self.$log.error(`${msg} ${error}`);\r\n throw error;\r\n }).finally(() => {\r\n self.spinnerService.hideBusy();\r\n });\r\n }\r\n\r\n removeStopTimeDivergentDate(stopTime: StopTimeDivergentDate): void {\r\n let result = this.$window.confirm(`Vill du tabort den avvikande stopptiden?`);\r\n if (result == false) {\r\n return;\r\n }\r\n\r\n this.spinnerService.showBusy();\r\n let self = this;\r\n\r\n this.stopTimeDivergentDateService.removeStopTimeDivergentDate(stopTime.id).then(() => {\r\n let ix = self.stopTimeDivergentDates.indexOf(stopTime);\r\n if (ix !== -1) {\r\n self.stopTimeDivergentDates.splice(ix, 1);\r\n }\r\n }).catch(error => {\r\n let msg: string = `An error occurred while removing divergent stop time date. Id ${stopTime.id}.`;\r\n self.$log.error(`${msg} ${error}`);\r\n throw error;\r\n }).finally(() => {\r\n self.spinnerService.hideBusy();\r\n });\r\n }\r\n\r\n updateNewStopTimeDivergentDate(propertyName: StopTimeDivergentDateTypes): void {\r\n if (propertyName == undefined || this.newStopTimeDivergentDate == undefined) {\r\n return;\r\n }\r\n\r\n switch (propertyName) {\r\n case \"deliveryDate\": {\r\n if (this.newStopTimeDivergentDate.deliveryDate == undefined) {\r\n this.newStopTimeDivergentDate.description = undefined;\r\n this.newStopTimeDivergentDate.stopDate = null;\r\n this.newStopTimeDivergentDate.stopTime = null;\r\n this.newStopTimeDivergentDate.useLeadTime = false;\r\n }\r\n }\r\n\r\n case \"stopDate\": {\r\n if (this.newStopTimeDivergentDate.stopDate == undefined) {\r\n this.newStopTimeDivergentDate.stopTime = null;\r\n this.newStopTimeDivergentDate.useLeadTime = false;\r\n }\r\n }\r\n }\r\n }\r\n\r\n updateStopTimeDate(stopTime: StopTimeDate, propertyName: StopTimeDateTypes): void {\r\n if (stopTime == undefined || propertyName == undefined) {\r\n return;\r\n }\r\n\r\n if (stopTime.stopWeekday === null && propertyName === \"stopWeekday\") {\r\n stopTime.backNoOffWeeks = null;\r\n stopTime.stopTime = null;\r\n stopTime.useLeadTime = false;\r\n }\r\n\r\n if (stopTime.stopWeekday == undefined && propertyName !== \"stopWeekday\") {\r\n return;\r\n }\r\n\r\n if (stopTime.stopWeekday != undefined && stopTime.stopTime == undefined) {\r\n return;\r\n }\r\n\r\n if (propertyName === \"useLeadTime\") {\r\n stopTime.useLeadTime = !stopTime.useLeadTime;\r\n }\r\n\r\n this.spinnerService.showBusy();\r\n let self = this;\r\n\r\n this.stopTimeDateService.updateStopTimeDate(stopTime).then(() => {\r\n }).catch(error => {\r\n let msg: string = `An error occurred while updating stop time date. Id ${stopTime.id}.`;\r\n self.$log.error(`${msg} ${error}`);\r\n throw error;\r\n }).finally(() => {\r\n self.spinnerService.hideBusy();\r\n });\r\n }\r\n\r\n updateStopTimeDivergentDate(stopTime: StopTimeDivergentDate, propertyName: StopTimeDivergentDateTypes): void {\r\n if (stopTime == undefined) {\r\n return;\r\n }\r\n\r\n if (propertyName === \"stopDate\" && stopTime.stopDate == undefined) {\r\n stopTime.stopTime = null;\r\n stopTime.useLeadTime = false;\r\n }\r\n\r\n if (propertyName === \"stopTime\" && stopTime.stopTime == undefined) {\r\n stopTime.useLeadTime = false;\r\n }\r\n\r\n if (propertyName === \"useLeadTime\" && stopTime.stopDate != undefined && stopTime.stopTime != undefined) {\r\n stopTime.useLeadTime = !stopTime.useLeadTime;\r\n }\r\n\r\n if (stopTime.stopDate != undefined && stopTime.stopDate.valueOf() >= stopTime.deliveryDate.valueOf()) {\r\n return;\r\n }\r\n\r\n this.spinnerService.showBusy();\r\n let self = this;\r\n\r\n this.stopTimeDivergentDateService.updateStopTimeDivergentDate(stopTime).then(() => {\r\n }).catch(error => {\r\n let msg: string = `An error occurred while updating divergent stop time date. Id ${stopTime.id}.`;\r\n self.$log.error(`${msg} ${error}`);\r\n throw error;\r\n }).finally(() => {\r\n self.spinnerService.hideBusy();\r\n });\r\n }\r\n\r\n updateStopTimeReturnOrdering(): void {\r\n if (this.stopTimeReturnOrdering == undefined || this.stopTimeReturnOrdering.stopTime == undefined) {\r\n return;\r\n }\r\n\r\n this.spinnerService.showBusy();\r\n let self = this;\r\n\r\n this.stopTimeReturnOrderingService.updateStopTimeReturnOrdering(this.stopTimeReturnOrdering).then(() => {\r\n }).catch(error => {\r\n let msg: string = `An error occurred while updating return stop time. Id ${this.stopTimeReturnOrdering.id}.`;\r\n self.$log.error(`${msg} ${error}`);\r\n throw error;\r\n }).finally(() => {\r\n self.spinnerService.hideBusy();\r\n });\r\n }\r\n\r\n divergentDateDatesValid(deliveryDate: Date, stopDate: Date): boolean {\r\n if (deliveryDate == undefined && stopDate != undefined) {\r\n return false;\r\n }\r\n\r\n if (deliveryDate != undefined && stopDate == undefined) {\r\n return true;\r\n }\r\n\r\n if (deliveryDate != undefined && stopDate != undefined && stopDate.valueOf() >= deliveryDate.valueOf()) {\r\n return false;\r\n }\r\n\r\n return true;\r\n }\r\n\r\n divergentDateDeliveryDateExists(deliveryDate: Date, row: StopTimeDivergentDate): boolean {\r\n if (deliveryDate != undefined && row != undefined) {\r\n //let dd = new IBDate(deliveryDate);\r\n let found = this.stopTimeDivergentDates.find((stopTime, index, stopTimes) => {\r\n return stopTime.id !== row.id && IBDate.equals(deliveryDate, stopTime.deliveryDate, DateCompareGranularities.Date);\r\n });\r\n\r\n if (found != undefined) {\r\n return true;\r\n }\r\n }\r\n\r\n return false;\r\n }\r\n\r\n private clearStopTimeDatesAndDivergentDates(): void {\r\n //if (this.stopTimeDates != undefined) {\r\n // this.stopTimeDates.length = 0;\r\n //}\r\n\r\n //if (this.stopTimeDivergentDates != undefined) {\r\n // this.stopTimeDivergentDates.length = 0;\r\n //}\r\n this.selectedStopTime = undefined;\r\n this.stopTimeDates = undefined;\r\n this.stopTimeDivergentDates = undefined;\r\n }\r\n\r\n private initialiseNewStopTimeDivergentDate(): void {\r\n this.newStopTimeDivergentDate = undefined;\r\n this.newStopTimeDivergentDate = new StopTimeDivergentDate();\r\n this.newStopTimeDivergentDate.companyId = this.companyId;\r\n this.newStopTimeDivergentDate.stopTimeId = this.selectedStopTime.id;\r\n }\r\n\r\n private loadArticleGroups(): ng.IPromise {\r\n this.spinnerService.showBusy();\r\n let self = this;\r\n\r\n return this.stopTimeArticleGroupService.getAllByCompany(this.companyId).then((articleGroups: ArticleGroup[]) => {\r\n self.articleGroups = articleGroups;\r\n }).catch(error => {\r\n let msg: string = `An error occurred while getting stop times`;\r\n self.$log.error(`${msg} ${error}`);\r\n throw error;\r\n }).finally(() => {\r\n this.spinnerService.hideBusy();\r\n });\r\n }\r\n\r\n private loadCustomerGroups(): ng.IPromise {\r\n this.spinnerService.showBusy();\r\n let self = this;\r\n\r\n return this.stopTimeCustomerGroupService.getAllByCompany(this.companyId).then((customerGroups: CustomerGroup[]) => {\r\n self.customerGroups = customerGroups;\r\n }).catch(error => {\r\n let msg: string = `An error occurred while getting stop time customer groups`;\r\n self.$log.error(`${msg} ${error}`);\r\n throw error;\r\n }).finally(() => {\r\n this.spinnerService.hideBusy();\r\n });\r\n }\r\n\r\n private loadStopTimes(): ng.IPromise {\r\n this.spinnerService.showBusy();\r\n let self = this;\r\n\r\n return this.stopTimeService.getAllByCompany(this.companyId).then((stopTimes: StopTime[]) => {\r\n self.stopTimes = stopTimes;\r\n }).catch(error => {\r\n let msg: string = `An error occurred while getting company info`;\r\n self.$log.error(`${msg} ${error}`);\r\n }).finally(() => {\r\n this.spinnerService.hideBusy();\r\n });\r\n }\r\n\r\n private loadStopTimeReturnOrderings(): void {\r\n this.spinnerService.showBusy();\r\n let self = this;\r\n\r\n this.stopTimeReturnOrderingService.getOneByCompany(this.companyId).then((stopTimeReturnOrdering: StopTimeReturnOrdering) => {\r\n self.stopTimeReturnOrdering = stopTimeReturnOrdering;\r\n }).catch(error => {\r\n let msg: string = `An error occurred while getting stop time return ordering`;\r\n self.$log.error(`${msg} ${error}`);\r\n }).finally(() => {\r\n this.spinnerService.hideBusy();\r\n });\r\n }\r\n\r\n private loadStopTimeDivergentDates(stopTimeId: number): ng.IPromise {\r\n this.spinnerService.showBusy();\r\n let self = this;\r\n\r\n self.stopTimeDivergentDates = undefined;\r\n return this.stopTimeDivergentDateService.getAllByStopTime(stopTimeId).then((stopTimeDivergentDates: StopTimeDivergentDate[]) => {\r\n self.stopTimeDivergentDates = stopTimeDivergentDates;\r\n }).catch(error => {\r\n let msg: string = `An error occurred while getting stop time divergent dates`;\r\n self.$log.error(`${msg} ${error}`);\r\n throw error;\r\n }).finally(() => {\r\n this.spinnerService.hideBusy();\r\n });\r\n }\r\n\r\n private loadStopTimeDates(stopTimeId: number): ng.IPromise {\r\n this.spinnerService.showBusy();\r\n let self = this;\r\n\r\n self.stopTimeDates = undefined;\r\n return this.stopTimeDateService.getAllByStopTime(stopTimeId).then((stopTimeDates: StopTimeDate[]) => {\r\n self.stopTimeDates = stopTimeDates;\r\n }).catch(error => {\r\n let msg: string = `An error occurred while getting stop time divergent dates`;\r\n self.$log.error(`${msg} ${error}`);\r\n throw error;\r\n }).finally(() => {\r\n this.spinnerService.hideBusy();\r\n });\r\n }\r\n\r\n private loadWeekdays(): ng.IPromise {\r\n this.spinnerService.showBusy();\r\n let self = this;\r\n\r\n return this.weekdayService.getAllWeekday().then((weekdays: Weekday[]) => {\r\n self.weekdays = weekdays;\r\n }).catch(error => {\r\n let msg: string = `An error occurred while getting weekdays`;\r\n self.$log.error(`${msg} ${error}`);\r\n throw error;\r\n }).finally(() => {\r\n this.spinnerService.hideBusy();\r\n });\r\n }\r\n\r\n private filterArticleGroups(): void {\r\n this.filteredArticleGroups.length = 0;\r\n\r\n // TODO: fix naive implementation. Use object object map\r\n // let dict = {}\r\n // dict[key] = article group / customer group\r\n // dict[key] !== undefined....\r\n //\r\n // or let map = new Map()....\r\n\r\n //if (this.selectedCustomerGroup == undefined && this.selectedArticleGroup == undefined) {\r\n // for (var i = 0; i < this.stopTimes.length; i++) {\r\n // let stopTime = this.stopTimes[i];\r\n // if()\r\n // }\r\n\r\n // return;\r\n //}\r\n\r\n this.filteredArticleGroups = angular.copy(this.articleGroups);\r\n }\r\n\r\n private filterCustomerGroups(): void {\r\n this.filteredCustomerGroups.length = 0;\r\n\r\n // TODO: fix naive implementation. Use object object map\r\n // let dict = {}\r\n // dict[key] = article group / customer group\r\n // dict[key] !== undefined....\r\n //\r\n // or let map = new Map()....\r\n\r\n this.filteredCustomerGroups = angular.copy(this.customerGroups);\r\n }\r\n\r\n private updateAuthenticatedParameters(params: IAuthenticatedParameters): void {\r\n if (params === null || typeof params === \"undefined\") {\r\n return;\r\n }\r\n\r\n if (params.companyId != undefined) {\r\n this.companyId = params.companyId;\r\n }\r\n\r\n if (params.customerId != undefined) {\r\n this.customerId = params.customerId;\r\n }\r\n\r\n if (params.sysUserId != undefined) {\r\n this.userId = params.sysUserId;\r\n }\r\n\r\n if (params.username != undefined) {\r\n this.userName = params.username;\r\n }\r\n\r\n if (this.customerId != undefined && this.companyId != undefined) {\r\n //...\r\n }\r\n }\r\n\r\n /*** ng.IController and ng.IDoCheck methods ***/\r\n $onChanges?(onChangesObj: IOnChangesObject): void {\r\n }\r\n\r\n $onInit(): void {\r\n let params = this.trans.params() as IAuthenticatedParameters;\r\n this.updateAuthenticatedParameters(params);\r\n let self = this;\r\n\r\n this.loadWeekdays().then(() => self.loadStopTimeReturnOrderings());\r\n this.loadArticleGroups().then(() => self.loadCustomerGroups()).then(() => self.loadStopTimes()).then(() => {\r\n self.filterArticleGroups();\r\n self.filterCustomerGroups();\r\n\r\n let d: StopTime = self.stopTimes.find((stopTime, index, stopTimes) => {\r\n return stopTime.default;\r\n }, self);\r\n\r\n if (d != undefined) {\r\n self.editStopTime(d);\r\n }\r\n });\r\n }\r\n\r\n $onDestroy(): void {\r\n }\r\n\r\n $doCheck(): void {\r\n\r\n }\r\n\r\n uiCanExit(transition: Transition): boolean | void | TargetState | Promise {\r\n }\r\n\r\n uiOnParamsChanged(newValues: any, $transition$: Transition): void {\r\n let params = newValues as IAuthenticatedParameters;\r\n this.updateAuthenticatedParameters(params);\r\n }\r\n\r\n /*** Binding properties ***/\r\n trans: Transition;\r\n\r\n /*** Bindings callbacks ***/\r\n //onDayQuantitiesHasValueChanged: () => ng.IPromise;\r\n}\r\n\r\nexport default class AdministrationStopTimeComponent implements ng.IComponentOptions {\r\n bindings?: { [boundProperty: string]: string };\r\n templateUrl: string;\r\n controller: ng.Injectable;\r\n\r\n constructor() {\r\n this.controller = AdministrationStopTimeController;\r\n this.templateUrl = './dist/app/administration/administration-stop-time.template.html';\r\n this.bindings = {\r\n trans: '<'\r\n //, onDayQuantitiesHasValueChanged: '&'\r\n }\r\n }\r\n}","/// \r\n/// \r\n\r\nimport { module, IOnChangesObject } from \"angular\";\r\nimport SpinnerService from \"../services/SpinnerService\";\r\nimport { SubSystem } from \"../services/model/SubSystem\";\r\nimport { Transition } from \"@uirouter/angularjs\";\r\nimport { INavigationParamenters } from \"../core/StateParameters\";\r\n\r\nclass RemainingNavigationController implements ng.IController {\r\n static $inject = [\"$scope\", \"spinnerService\"];\r\n\r\n constructor(private $scope: ng.IScope,\r\n private spinnerService: SpinnerService) {\r\n }\r\n\r\n trans: Transition;\r\n subSystem: SubSystem;\r\n\r\n $onInit?(): void {\r\n let params = this.trans.params() as INavigationParamenters;\r\n this.subSystem = params.subSystem;\r\n }\r\n\r\n $onChanges?(onChangesObj: IOnChangesObject): void {\r\n }\r\n}\r\n\r\nexport default class RemainingNavigationComponent implements ng.IComponentOptions {\r\n bindings?: { [boundProperty: string]: string };\r\n templateUrl: string;\r\n controller: ng.Injectable;\r\n\r\n constructor() {\r\n this.controller = RemainingNavigationController;\r\n this.templateUrl = './dist/app/remaining/remaining-navigation.template.html';\r\n this.bindings = {\r\n trans: '<'\r\n }\r\n }\r\n}","/** File types */\nexport enum FileTypes {\r\n /**\r\n * JPEG. Equals FileTypeId = 1\r\n */\r\n Jpg = 1,\r\n /**\r\n * PDF. Equals FileTypeId = 2\r\n */\r\n Pdf = 2,\r\n /**\r\n * PNG. Equals FileTypeId = 3\r\n */\r\n Png = 3\r\n}","/// \r\n/// \r\n\r\nimport * as angular from \"angular\";\r\nimport { module, IOnChangesObject } from \"angular\";\r\nimport SpinnerService from \"../services/SpinnerService\";\r\nimport { TransitionService, Transition, TargetState } from \"@uirouter/angularjs\";\r\nimport { IModalService } from \"angular-ui-bootstrap\";\r\nimport HtmlStorageService from \"../services/HtmlStorageService\";\r\nimport UserService from \"../services/UserService\";\r\nimport { IAuthenticatedParameters } from \"../core/StateParameters\";\r\nimport { User } from \"../services/model/User\";\r\nimport IHttpPromiseError from \"../core/IHttpPromiseError\";\r\nimport PermissionService from \"../services/PermissionService\";\r\nimport { Permission } from \"../services/model/Permission\";\r\nimport { Branch } from \"../services/model/Branch\";\r\nimport CustomerService from \"../services/CustomerService\";\r\nimport { Role } from \"../services/model/Role\";\r\nimport { Customer } from \"../services/model/Customer\";\r\nimport RoleService from \"../services/RoleService\";\r\n\r\ntype UiSelectBroadcastEvents =\r\n \"UiSelectPermissionRoleXxx\";\r\n\r\ntype PermissionRoleEvents =\r\n \"PermissionRoleUserResetSearch\" |\r\n \"PermissionRolePermissionsResetSearch\";\r\n\r\nclass PermissionRoleController implements ng.IController {\r\n static $inject = [\"$http\", \"$rootScope\", \"$scope\", \"$state\", \"$timeout\", \"$q\", \"$transitions\", \"$window\", \"$log\", \"$locale\", \"$uibModal\", \"spinnerService\", \"htmlStorageService\", \"userService\", \"permissionService\", \"roleService\", \"customerService\"];\r\n\r\n constructor(private $http: ng.IHttpService,\r\n private $rootScope: ng.IRootScopeService,\r\n private $scope: ng.IScope,\r\n private $state: angular.ui.IStateService,\r\n private $timeout: ng.ITimeoutService,\r\n private $q: ng.IQService,\r\n private $transitions: TransitionService,\r\n private $window: ng.IWindowService,\r\n private $log: ng.ILogService,\r\n private $locale: ng.ILocaleService,\r\n private $uibModal: IModalService,\r\n private spinnerService: SpinnerService,\r\n private htmlStorageService: HtmlStorageService,\r\n private userService: UserService,\r\n private permissionService: PermissionService,\r\n private roleService: RoleService,\r\n private customerService: CustomerService) {\r\n }\r\n\r\n /** Pagination Users **/\r\n private _selectedUsersPaginationItem: { value: number, label: string };\r\n\r\n paginationItems = [{\r\n value: 10,\r\n label: '10'\r\n }, {\r\n value: 15,\r\n label: '15'\r\n },\r\n {\r\n value: 20,\r\n label: '20'\r\n },\r\n {\r\n value: 25,\r\n label: '25'\r\n },\r\n {\r\n value: 30,\r\n label: '30'\r\n }, {\r\n value: 40,\r\n label: '40'\r\n }, {\r\n value: 50,\r\n label: '50'\r\n }, {\r\n value: 99999,\r\n label: 'Alla'\r\n }];\r\n\r\n get selectedUsersPaginationItem(): { value: number, label: string } {\r\n if (this._selectedUsersPaginationItem == undefined) {\r\n let spi = <{ value: number, label: string }>this.htmlStorageService.getLocalStorageItem(\"lastPaginationItemPermissionRoleUsersPage\");\r\n if (spi == undefined) {\r\n this.selectedUsersPaginationItem = this.paginationItems[0];\r\n }\r\n else {\r\n this.selectedUsersPaginationItem = spi;\r\n }\r\n }\r\n return this._selectedUsersPaginationItem;\r\n }\r\n\r\n set selectedUsersPaginationItem(item: { value: number, label: string }) {\r\n this._selectedUsersPaginationItem = item;\r\n this.htmlStorageService.setLocalStorageItem(\"lastPaginationItemPermissionRoleUsersPage\", item);\r\n }\r\n\r\n /** Pagination Roles **/\r\n private _selectedPermissionsPaginationItem: { value: number, label: string };\r\n\r\n get selectedPermissionsPaginationItem(): { value: number, label: string } {\r\n if (this._selectedPermissionsPaginationItem == undefined) {\r\n let spi = <{ value: number, label: string }>this.htmlStorageService.getLocalStorageItem(\"lastPaginationItemPermissionRoleRolessPage\");\r\n if (spi == undefined) {\r\n this.selectedPermissionsPaginationItem = this.paginationItems[0];\r\n }\r\n else {\r\n this.selectedPermissionsPaginationItem = spi;\r\n }\r\n }\r\n return this._selectedPermissionsPaginationItem;\r\n }\r\n\r\n set selectedPermissionsPaginationItem(item: { value: number, label: string }) {\r\n this._selectedPermissionsPaginationItem = item;\r\n this.htmlStorageService.setLocalStorageItem(\"lastPaginationItemPermissionRoleRolessPage\", item);\r\n }\r\n\r\n userName: string;\r\n companyId: number;\r\n customerId: number;\r\n userId: number;\r\n\r\n private updateAuthenticatedParameters(params: IAuthenticatedParameters): void {\r\n if (params === null || typeof params === \"undefined\") {\r\n return;\r\n }\r\n\r\n if (params.companyId != undefined) {\r\n this.companyId = params.companyId;\r\n }\r\n\r\n if (params.customerId != undefined) {\r\n this.customerId = params.customerId;\r\n }\r\n\r\n if (params.sysUserId != undefined) {\r\n this.userId = params.sysUserId;\r\n }\r\n\r\n if (params.username != undefined) {\r\n this.userName = params.username;\r\n }\r\n\r\n if (this.companyId != undefined) {\r\n let self = this;\r\n }\r\n }\r\n\r\n /*** ng.IController and ng.IDoCheck methods ***/\r\n $onChanges?(onChangesObj: IOnChangesObject): void {\r\n }\r\n\r\n $onInit(): void {\r\n let params = this.trans.params() as IAuthenticatedParameters;\r\n this.updateAuthenticatedParameters(params);\r\n }\r\n\r\n $onDestroy(): void {\r\n }\r\n\r\n uiOnParamsChanged(newValues: any, $transition$: Transition): void {\r\n let params = newValues as IAuthenticatedParameters;\r\n this.updateAuthenticatedParameters(params);\r\n }\r\n\r\n uiCanExit(transition: Transition): boolean | TargetState | void | Promise {\r\n }\r\n\r\n /*** Binding properties ***/\r\n trans: Transition;\r\n}\r\n\r\nexport default class PermissionRoleComponent implements ng.IComponentOptions {\r\n bindings?: { [boundProperty: string]: string };\r\n templateUrl: string;\r\n controller: ng.Injectable;\r\n\r\n constructor() {\r\n this.controller = PermissionRoleController;\r\n this.templateUrl = './dist/app/permission/permission-role.template.html';\r\n this.bindings = {\r\n trans: '<'\r\n }\r\n }\r\n}","/// \r\n/// \r\n/// \r\n/// \r\n\r\nimport { module } from \"angular\";\r\nimport IBDate from \"../core/IBDate\";\r\nimport BaseService from \"../services/base/BaseService\";\r\nimport IHttpPromiseError from \"../core/IHttpPromiseError\";\r\nimport { ImportExportLog } from \"./model/ImportExportLog\";\r\nimport { DocumentMetaData } from \"./model/documentMetaData\";\r\nimport { ImageMetaData } from \"./model/ImageMetaData\";\r\n\r\nexport default class ImportExportLogService extends BaseService {\r\n\r\n static $inject = [\"$http\", \"$cacheFactory\", \"$q\", \"$rootScope\", \"$log\", \"appSettings\"];\r\n\r\n constructor($http: ng.IHttpService,\r\n $cacheFactory: ng.ICacheFactoryService,\r\n $q: ng.IQService,\r\n $rootScope: ng.IRootScopeService,\r\n $log: ng.ILogService,\r\n appSettings: any,\r\n apiUrlFragment: string) {\r\n super($http, $cacheFactory, $q, $rootScope, $log, appSettings, apiUrlFragment);\r\n this.baseUrl = `${appSettings.SERVICE_URL}/api/v1.0`;\r\n }\r\n\r\n getImportExportLogsByCompany(companyId: number): ng.IPromise {\r\n return this.getAllByUrlPart(`${this.apiUrlFragment}/ImportExportLog/Company/${companyId}`);\r\n }\r\n\r\n public static Factory($http: ng.IHttpService,\r\n $cacheFactory: ng.ICacheFactoryService,\r\n $q: ng.IQService,\r\n $rootScope: ng.IRootScopeService,\r\n $log: ng.ILogService,\r\n appSettings: any): ImportExportLogService {\r\n return new ImportExportLogService($http, $cacheFactory, $q, $rootScope, $log, appSettings, \"export\");\r\n }\r\n}","import { TrackedModel } from \"./TrackedModel\";\r\n\r\nexport class User extends TrackedModel {\r\n /**\r\n * Constraints\r\n * Required\r\n */\r\n public companyId: number;\r\n /**\r\n * Constraints\r\n * Optional\r\n * StringLength: 50\r\n */\r\n public email: string;\r\n /**\r\n * Constraints\r\n * Required\r\n * StringLength: 50\r\n */\r\n public firstName: string;\r\n /**\r\n * Constraints\r\n * Optional\r\n */\r\n public lastCustomerId?: number;\r\n /**\r\n * Constraints\r\n * Required\r\n * StringLength: 50\r\n */\r\n public lastName: string;\r\n /**\r\n * Constraints\r\n * Required\r\n */\r\n public locked: boolean;\r\n /**\r\n * Constraints\r\n * Optional\r\n * StringLength: 20\r\n */\r\n public middleName: string;\r\n /**\r\n * Constraints\r\n * Optional\r\n * StringLength: 50\r\n */\r\n public name: string;\r\n /**\r\n * Constraints\r\n * Optional\r\n */\r\n public oneTimePassword?: boolean;\r\n /**\r\n * Constraints\r\n * Optional\r\n * StringLength: 50\r\n */\r\n public password: string;\r\n /**\r\n * Constraints\r\n * Optional\r\n * StringLength: 20\r\n */\r\n public phone: string;\r\n /**\r\n * Constraints\r\n * Required\r\n */\r\n public superUser: boolean;\r\n /**\r\n * Constraints\r\n * Required\r\n */\r\n public sysUserId: number;\r\n /**\r\n * Constraints\r\n * Required\r\n */\r\n public userId: number;\r\n /**\r\n * Constraints\r\n * Required\r\n * StringLength: 256\r\n */\r\n public userName: string;\r\n}","import { Model } from \"./Model\";\r\n\r\n export class UniqueModel extends Model {\r\n /** \r\n * Constraints\r\n * Required\r\n */\r\n public id: number;\r\n}","import IbDecimalToCommaFilter from \"./decimal-comma-number.filter\";\r\nimport { IModelViewChangeListener } from \"angular\";\r\n\r\nexport interface IbInputSelectFileDirectiveParameters {\r\n dataUrl?: any,\r\n arrayBuffer?: any\r\n}\r\n\r\ntype truthy = 'true' | \"true\" | true | 1;\r\n\r\nexport default class IbInputSelectFileDirective implements ng.IDirective {\r\n public restrict: string = \"A\";\r\n public require: string = \"ngModel\";\r\n public replace: boolean = false;\r\n public scope: boolean = true;\r\n\r\n //https://gist.github.com/CMCDragonkai/6282750\r\n\r\n constructor(private $parse: ng.IParseService) { }\r\n\r\n static Name: string = 'ibInputSelectFileDirective';\r\n\r\n public link: ng.IDirectiveLinkFn = (scope: ng.IScope, element: ng.IAugmentedJQuery, attributes: ng.IAttributes, ngModelController: ng.INgModelController) => {\r\n\r\n let onChange = (e: JQueryEventObject) => {\r\n let input = e.currentTarget as HTMLInputElement;\r\n let params: IbInputSelectFileDirectiveParameters = scope.$eval(attributes.ibInputSelectFileDirective);\r\n\r\n let files = input.files;\r\n let file = files[0];\r\n\r\n //let listeners: IModelViewChangeListener[] = ngModelController.$viewChangeListeners;\r\n\r\n ngModelController.$setViewValue(file, 'change');\r\n\r\n //if (scope != undefined && scope.$parent != undefined && listeners != undefined && listeners.length > 0) {\r\n // for (var i = 0; i < listeners.length; i++) {\r\n // scope.$parent.$apply(function () { listeners[i](); });\r\n // }\r\n //}\r\n\r\n //if (attributes != undefined && attributes.ngChange != undefined) {\r\n // let r = scope.$parent.$eval(attributes.ngChange);\r\n // let r2 = scope.$parent.$apply(attributes.ngChange);\r\n //}\r\n //scope.$apply();\r\n\r\n if (params != undefined && params.dataUrl != undefined) {\r\n let fileReader = new FileReader();\r\n fileReader.onload = () => {\r\n let dataUrl: string | ArrayBuffer = fileReader.result;\r\n scope.$parent.$apply(`${params.dataUrl}='${dataUrl}'`);\r\n };\r\n fileReader.readAsDataURL(file);\r\n }\r\n\r\n if (params != undefined && params.arrayBuffer != undefined) {\r\n let fileReader = new FileReader();\r\n fileReader.onload = () => {\r\n let arrayBuffer: string | ArrayBuffer = fileReader.result;\r\n //let array = new Uint8Array(arrayBuffer);\r\n let getter = this.$parse(params.arrayBuffer);\r\n let setter = getter.assign;\r\n scope.$parent.$apply(setter(scope.$parent, arrayBuffer));\r\n //scope.$parent.$apply(`${params.arrayBuffer}=${arrayBuffer}`);\r\n };\r\n fileReader.readAsArrayBuffer(file);\r\n }\r\n };\r\n\r\n element.on('change', onChange);\r\n scope.$on('destroy', () => element.off('change', onChange));\r\n };\r\n\r\n public static Factory(): ng.IDirectiveFactory {\r\n let d = ($parse: ng.IParseService) => new IbInputSelectFileDirective($parse);\r\n d.$inject = ['$parse'];\r\n return d;\r\n }\r\n}","/// \r\n/// \r\n\r\nimport { module, IOnChangesObject, IPromise } from \"angular\";\r\nimport SpinnerService from \"../services/SpinnerService\";\r\nimport { TransitionService, Transition, TargetState } from \"@uirouter/angularjs\";\r\nimport HtmlStorageService from \"../services/HtmlStorageService\";\r\nimport OrderingCalendarDayService from \"../services/OrderingCalendarDayService\";\r\nimport { CalendarDay } from \"../services/model/CalendarDay\";\r\nimport IBDate from \"../core/IBDate\";\r\nimport { IAuthenticatedParameters } from \"../core/StateParameters\";\r\nimport { DisplayMonthDay } from \"../calendar/calendar.component\";\r\nimport OrderingService from \"../services/OrderingService\";\r\nimport { Ordering } from \"../services/model/Ordering\";\r\nimport IHttpPromiseError from \"../core/IHttpPromiseError\";\r\nimport { OrderingRow } from \"../services/model/OrderingRow\";\r\nimport { CreateOrderingResult } from \"../services/model/CreateOrderingResult\";\r\nimport { IModalService, IModalInstanceService, IModalSettings } from \"angular-ui-bootstrap\";\r\n\r\nclass OrderingOrderController implements ng.IController {\r\n static $inject = [\"$http\", \"$rootScope\", \"$scope\", \"$state\", \"$timeout\", \"$q\", \"$transitions\", \"$window\", \"$log\", \"$uibModal\", \"spinnerService\", \"htmlStorageService\", \"orderingCalendarDayService\", \"orderingService\"];\r\n\r\n constructor(private $http: ng.IHttpService,\r\n private $rootScope: ng.IRootScopeService,\r\n private $scope: ng.IScope,\r\n private $state: angular.ui.IStateService,\r\n private $timeout: ng.ITimeoutService,\r\n private $q: ng.IQService,\r\n private $transitions: TransitionService,\r\n private $window: ng.IWindowService,\r\n private $log: ng.ILogService,\r\n private $uibModal: IModalService,\r\n private spinnerService: SpinnerService,\r\n private htmlStorageService: HtmlStorageService,\r\n private orderingCalendarDayService: OrderingCalendarDayService,\r\n private orderingService: OrderingService) {\r\n }\r\n\r\n private calendarDays: CalendarDay[];\r\n private previousOrderingTemplateDeliveryDate: IBDate;\r\n\r\n textViewEditOrMakeOrdering: string = `Välj ett datum för att visa, ändra eller lägga en beställning.`;\r\n\r\n displayMonthDay: DisplayMonthDay = DisplayMonthDay.NextDay;\r\n selectedDate: IBDate;\r\n\r\n customerId: number;\r\n\r\n reloadCalendar: boolean = undefined;\r\n\r\n selectedCalendarDay: CalendarDay;\r\n selectedDeliveryDate: IBDate;\r\n selectedOrdering: Ordering;\r\n selectedStopTime: IBDate;\r\n selectedTemplateId: number;\r\n\r\n showOrdering: boolean;\r\n showOrderingTemplate: boolean;\r\n showOrderingTemplateSelect: boolean;\r\n\r\n loadCalanderDays(value: { year: number, month: number }): ng.IPromise {\r\n let d = this.$q.defer();\r\n let self = this;\r\n\r\n this.orderingCalendarDayService.getAll(this.customerId, value.year, value.month).then((c: CalendarDay[]) => {\r\n self.calendarDays = c;\r\n d.resolve(c);\r\n }).catch((reason) => {\r\n d.reject(reason);\r\n });\r\n\r\n return d.promise;\r\n }\r\n\r\n selectedCalendarDayChanged(calendarDay: CalendarDay): void {\r\n this.selectedDate = undefined;\r\n this.selectedDeliveryDate = undefined;\r\n this.selectedStopTime = undefined;\r\n this.selectedCalendarDay = undefined;\r\n\r\n if (calendarDay != null) {\r\n this.spinnerService.showBusy();\r\n this.selectedDate = new IBDate(calendarDay.date);\r\n this.selectedCalendarDay = calendarDay;\r\n this.selectedOrdering = undefined;\r\n this.selectedDeliveryDate = new IBDate(calendarDay.date);\r\n\r\n let self = this;\r\n this.orderingService.getOneByCustomerAndDeliveryDate(this.customerId, this.selectedDeliveryDate).then((ordering: Ordering) => {\r\n self.selectedOrdering = ordering;\r\n\r\n self.showOrdering = true;\r\n self.showOrderingTemplate = false;\r\n self.showOrderingTemplateSelect = false;\r\n }).catch((error: any) => {\r\n let e: IHttpPromiseError = error as IHttpPromiseError;\r\n if (e != null && e.status === 404) {\r\n // No ordering exist for the selected customer and date so display select template view\r\n if (calendarDay.stopDateTimeUTC != null) {\r\n self.selectedStopTime = new IBDate(self.selectedCalendarDay.stopDateTimeUTC);\r\n }\r\n\r\n self.showOrderingTemplateSelect = true;\r\n self.showOrdering = false;\r\n self.showOrderingTemplate = false;\r\n\r\n return;\r\n }\r\n\r\n if (e.status != undefined) {\r\n self.$log.error(`An unexpected error occured while retrieving an order. ${e.status} ${e.statusText}`);\r\n } else {\r\n self.$log.error(`An unexpected error occured while retrieving an order. ${error}`);\r\n }\r\n\r\n // Display error message\r\n self.showOrdering = false;\r\n self.showOrderingTemplate = false;\r\n self.showOrderingTemplateSelect = false;\r\n }).finally(() => {\r\n self.spinnerService.hideBusy();\r\n });\r\n }\r\n }\r\n\r\n selectedTemplateChanged(templateId: number): void {\r\n this.selectedTemplateId = templateId;\r\n if (templateId === -1 || templateId === 0) {\r\n this.createOrdering();\r\n } else if (templateId === -2 || templateId > 0) {\r\n this.showOrdering = false;\r\n this.showOrderingTemplateSelect = false;\r\n this.showOrderingTemplate = true;\r\n }\r\n }\r\n\r\n useSelectedTemplate(value: boolean, previousDeliveryDate: IBDate): void {\r\n if (value === true) {\r\n this.previousOrderingTemplateDeliveryDate = previousDeliveryDate;\r\n this.createOrdering();\r\n } else {\r\n this.selectedTemplateId = undefined;\r\n\r\n this.showOrdering = false;\r\n this.showOrderingTemplate = false;\r\n this.showOrderingTemplateSelect = true;\r\n }\r\n }\r\n\r\n placeOrdering(ordering: Ordering): ng.IPromise {\r\n this.spinnerService.showBusy();\r\n let d = this.$q.defer();\r\n let self = this;\r\n\r\n this.orderingService.placeOrdering(ordering.id).then((response) => {\r\n d.resolve();\r\n\r\n self.reloadCalendar = true;\r\n // TODO: Show quittance\r\n }).catch((error: IHttpPromiseError) => {\r\n self.$log.error(`An unexpected error occured while placing order ${ordering.id} (${error.status}:${error.statusText})`);\r\n d.reject(error);\r\n }).finally(() => {\r\n self.spinnerService.hideBusy();\r\n });\r\n\r\n return d.promise;\r\n }\r\n\r\n removeOrdering(ordering: Ordering): ng.IPromise {\r\n this.spinnerService.showBusy();\r\n let d = this.$q.defer();\r\n let self = this;\r\n\r\n this.orderingService.deleteOrdering(ordering.id).then((response) => {\r\n d.resolve();\r\n\r\n self.loadOrderingOrShowTemplateSelect();\r\n self.reloadCalendar = true;\r\n }).catch((error: IHttpPromiseError) => {\r\n self.$log.error(`An unexpected error occured while deleting order ${ordering.id} (${error.status}:${error.statusText})`);\r\n d.reject(error);\r\n }).finally(() => {\r\n self.spinnerService.hideBusy();\r\n });\r\n\r\n return d.promise;\r\n }\r\n\r\n updateOrdering(ordering: Ordering): ng.IPromise {\r\n this.spinnerService.showBusy();\r\n let d = this.$q.defer();\r\n let self = this;\r\n\r\n this.orderingService.updateOrdering(ordering).then(() => {\r\n d.resolve();\r\n\r\n self.loadOrdering();\r\n self.reloadCalendar = true;\r\n }).catch((error: IHttpPromiseError) => {\r\n self.$log.error(`An unexpected error occured while updateing order ${ordering.id} (${error.status}:${error.statusText})`);\r\n d.reject(error);\r\n }).finally(() => {\r\n self.spinnerService.hideBusy();\r\n });\r\n\r\n return d.promise;\r\n }\r\n\r\n mergeOrderingWithTemplate(): ng.IPromise {\r\n this.showOrderingTemplateSelect = true;\r\n this.showOrdering = false;\r\n this.showOrderingTemplate = false;\r\n\r\n return this.$q.resolve();\r\n }\r\n\r\n orderingRowAdded(orderingRow: OrderingRow): ng.IPromise {\r\n this.reloadCalendar = true;\r\n return this.$q.resolve();\r\n }\r\n\r\n orderingRowUpdated(orderingRow: OrderingRow): ng.IPromise {\r\n this.reloadCalendar = true;\r\n return this.$q.resolve();\r\n }\r\n\r\n orderingRowRemoved(orderingRow: OrderingRow): ng.IPromise {\r\n this.reloadCalendar = true;\r\n return this.$q.resolve();\r\n }\r\n\r\n private createOrdering(): void {\r\n this.spinnerService.showBusy();\r\n let prevDate = (this.previousOrderingTemplateDeliveryDate == undefined) ? null : this.previousOrderingTemplateDeliveryDate;\r\n let self = this;\r\n\r\n this.orderingService.createOrderByTemplate(this.selectedTemplateId, this.customerId, this.selectedDeliveryDate, prevDate).then((result: CreateOrderingResult) => {\r\n\r\n if (result != undefined && result.errorMessage != undefined && result.errorMessage.length > 0) {\r\n let message = result.errorMessage.replace(/\\r\\n/g, \"\\r\").replace(/\\r\\r/g, \"\\r\").split(/[\\r]/g);\r\n let errorMessage: string = \"\";\r\n\r\n if (message.length > 0) {\r\n errorMessage += `${message[0]}
`;\r\n for (var i = 1; i < message.length; i++) {\r\n errorMessage += `- ${message[i]}
`;\r\n }\r\n errorMessage += `
`;\r\n }\r\n\r\n let self = this;\r\n let settings: IModalSettings = {\r\n component: 'ibWarningDialogComponent',\r\n size: 'md',\r\n resolve: {\r\n title: (): string => `Information`,\r\n content: (): string => errorMessage\r\n }\r\n };\r\n\r\n let modalInstance: IModalInstanceService = this.$uibModal.open(settings);\r\n\r\n modalInstance.result.then((value) => {\r\n }).finally(() => {\r\n self.previousOrderingTemplateDeliveryDate = undefined;\r\n self.loadOrdering();\r\n self.reloadCalendar = true;\r\n });\r\n\r\n modalInstance.closed.then(() => {\r\n\r\n })\r\n } else {\r\n self.previousOrderingTemplateDeliveryDate = undefined;\r\n self.loadOrdering();\r\n self.reloadCalendar = true;\r\n }\r\n }).catch((error: IHttpPromiseError) => {\r\n self.$log.error(`Could not create order. (${error.status}:${error.statusText})`);\r\n }).finally(() => {\r\n self.spinnerService.hideBusy();\r\n });\r\n }\r\n\r\n private loadOrdering(): void {\r\n this.spinnerService.showBusy();\r\n let self = this;\r\n\r\n this.orderingService.getOneByCustomerAndDeliveryDate(this.customerId, this.selectedDeliveryDate).then((ordering: Ordering) => {\r\n self.selectedOrdering = ordering;\r\n\r\n self.showOrdering = true;\r\n self.showOrderingTemplate = false;\r\n self.showOrderingTemplateSelect = false;\r\n }).catch((error: IHttpPromiseError) => {\r\n self.$log.error(`An unexpected error occured while retrieving an order. ${error.status} ${error.statusText}`);\r\n\r\n // Display error message\r\n self.showOrdering = false;\r\n self.showOrderingTemplate = false;\r\n self.showOrderingTemplateSelect = false;\r\n }).finally(() => {\r\n self.spinnerService.hideBusy();\r\n });\r\n }\r\n\r\n private loadOrderingOrShowTemplateSelect(): void {\r\n this.spinnerService.showBusy();\r\n this.selectedStopTime = undefined;\r\n this.selectedOrdering = undefined;\r\n\r\n let self = this;\r\n this.orderingService.getOneByCustomerAndDeliveryDate(this.customerId, new IBDate(this.selectedCalendarDay.date)).then((ordering: Ordering) => {\r\n self.selectedOrdering = ordering;\r\n\r\n self.showOrdering = true;\r\n self.showOrderingTemplate = false;\r\n self.showOrderingTemplateSelect = false;\r\n }).catch((error: any) => {\r\n let e: IHttpPromiseError = error as IHttpPromiseError;\r\n if (e != null && e.status === 404) {\r\n // No ordering exist for the selected customer and date so display select template view\r\n self.selectedDeliveryDate = new IBDate(self.selectedCalendarDay.date);\r\n if (self.selectedCalendarDay.stopDateTimeUTC != null) {\r\n self.selectedStopTime = new IBDate(self.selectedCalendarDay.stopDateTimeUTC);\r\n }\r\n\r\n self.showOrderingTemplateSelect = true;\r\n self.showOrdering = false;\r\n self.showOrderingTemplate = false;\r\n\r\n return;\r\n }\r\n\r\n if (e.status != undefined) {\r\n self.$log.error(`An unexpected error occured while retrieving an order. ${e.status} ${e.statusText}`);\r\n } else {\r\n self.$log.error(`An unexpected error occured while retrieving an order. ${error}`);\r\n }\r\n\r\n // Display error message\r\n self.showOrdering = false;\r\n self.showOrderingTemplate = false;\r\n self.showOrderingTemplateSelect = false;\r\n }).finally(() => {\r\n self.spinnerService.hideBusy();\r\n });\r\n }\r\n\r\n private updateAuthenticatedParameters(params: IAuthenticatedParameters): void {\r\n if (params === null || typeof params === \"undefined\") {\r\n return;\r\n }\r\n\r\n //if (params.companyId != undefined) {\r\n // this.companyId = params.companyId;\r\n //}\r\n\r\n if (params.customerId != undefined) {\r\n this.customerId = params.customerId;\r\n }\r\n\r\n //if (params.sysUserId != undefined) {\r\n // this.userId = params.sysUserId;\r\n //}\r\n\r\n //if (params.username != undefined) {\r\n // this.userName = params.username;\r\n //}\r\n }\r\n\r\n /*** ng.IController and ng.IDoCheck methods ***/\r\n $onChanges?(onChangesObj: IOnChangesObject): void {\r\n }\r\n\r\n $onInit(): void {\r\n let params = this.trans.params() as IAuthenticatedParameters;\r\n this.updateAuthenticatedParameters(params);\r\n }\r\n\r\n $onDestroy(): void {\r\n }\r\n\r\n uiOnParamsChanged(newValues: any, $transition$: Transition): void {\r\n let params = newValues as IAuthenticatedParameters;\r\n this.updateAuthenticatedParameters(params);\r\n }\r\n\r\n uiCanExit(transition: Transition): boolean | void | TargetState | Promise {\r\n }\r\n\r\n /*** Binding properties ***/\r\n trans: Transition;\r\n}\r\n\r\nexport default class OrderingOrderComponent implements ng.IComponentOptions {\r\n bindings?: { [boundProperty: string]: string };\r\n templateUrl: string;\r\n controller: ng.Injectable;\r\n\r\n constructor() {\r\n this.controller = OrderingOrderController;\r\n this.templateUrl = './dist/app/ordering/ordering-order.template.html';\r\n this.bindings = {\r\n trans: '<'\r\n }\r\n }\r\n}","/// \r\n/// \r\n\r\nimport { module, IOnChangesObject } from \"angular\";\r\nimport SpinnerService from \"../services/SpinnerService\";\r\nimport { IAuthenticatedParameters } from \"../core/StateParameters\";\r\nimport HtmlStorageService from \"../services/HtmlStorageService\";\r\nimport { TransitionService, Transition, TargetState } from \"@uirouter/angularjs\";\r\nimport UserService from \"../services/UserService\";\r\nimport { IModalService, IModalSettings, IModalInstanceService } from \"angular-ui-bootstrap\";\r\nimport { Company } from \"../services/model/Company\";\r\nimport CompanyService from \"../services/CompanyService\";\r\n\r\ntype CompanyAttributeTitleKeys = \"locked\";\r\n\r\ntype AdministrationInitCompanyEvents =\r\n \"AdministrationInitCompanyCompaniesResetSearch\";\r\n\r\nclass AdministrationInitCompanyController implements ng.IController {\r\n static $inject = [\"$http\", \"$rootScope\", \"$scope\", \"$state\", \"$timeout\", \"$q\", \"$transitions\", \"$window\", \"$log\", \"$locale\", \"$uibModal\", \"spinnerService\", \"htmlStorageService\", \"userService\", \"companyService\"];\r\n\r\n constructor(private $http: ng.IHttpService,\r\n private $rootScope: ng.IRootScopeService,\r\n private $scope: ng.IScope,\r\n private $state: angular.ui.IStateService,\r\n private $timeout: ng.ITimeoutService,\r\n private $q: ng.IQService,\r\n private $transitions: TransitionService,\r\n private $window: ng.IWindowService,\r\n private $log: ng.ILogService,\r\n private $locale: ng.ILocaleService,\r\n private $uibModal: IModalService,\r\n private spinnerService: SpinnerService,\r\n private htmlStorageService: HtmlStorageService,\r\n private userService: UserService,\r\n private companyService: CompanyService) {\r\n }\r\n\r\n /** Pagination Users **/\r\n private _selectedCompaniesPaginationItem: { value: number, label: string };\r\n paginationItems = [{\r\n value: 10,\r\n label: '10'\r\n }, {\r\n value: 15,\r\n label: '15'\r\n },\r\n {\r\n value: 20,\r\n label: '20'\r\n },\r\n {\r\n value: 25,\r\n label: '25'\r\n },\r\n {\r\n value: 30,\r\n label: '30'\r\n }, {\r\n value: 40,\r\n label: '40'\r\n }, {\r\n value: 50,\r\n label: '50'\r\n }, {\r\n value: 99999,\r\n label: 'Alla'\r\n }];\r\n get selectedCompaniesPaginationItem(): { value: number, label: string } {\r\n if (this._selectedCompaniesPaginationItem == undefined) {\r\n let spi = <{ value: number, label: string }>this.htmlStorageService.getLocalStorageItem(\"lastPaginationItemAdministrationInitCompanyCompaniesPage\");\r\n if (spi == undefined) {\r\n this._selectedCompaniesPaginationItem = this.paginationItems[0];\r\n }\r\n else {\r\n this._selectedCompaniesPaginationItem = spi;\r\n }\r\n }\r\n return this._selectedCompaniesPaginationItem;\r\n }\r\n set selectedCompaniesPaginationItem(item: { value: number, label: string }) {\r\n this._selectedCompaniesPaginationItem = item;\r\n this.htmlStorageService.setLocalStorageItem(\"lastPaginationItemAdministrationInitCompanyCompaniesPage\", item);\r\n }\r\n\r\n userName: string;\r\n companyId: number;\r\n customerId: number;\r\n userId: number;\r\n\r\n companies: Company[];\r\n selectedCompany: Company;\r\n\r\n addCompany(event?: KeyboardEvent): void {\r\n let self = this;\r\n\r\n let settings: IModalSettings = {\r\n component: 'ibAdministrationInitCompanyAddEditComponent',\r\n size: '',\r\n backdrop: 'static',\r\n resolve: {\r\n isNewCompany: (): boolean => true,\r\n company: (): Company => undefined,\r\n companies: (): Company[] => self.companies\r\n }\r\n };\r\n\r\n let modalInstance: IModalInstanceService = this.$uibModal.open(settings);\r\n modalInstance.result.then((value: any) => {\r\n if (value == undefined) {\r\n return;\r\n }\r\n\r\n if (value == 'cancel') {\r\n self.loadCompanies();\r\n }\r\n });\r\n\r\n modalInstance.closed.then(() => {\r\n //self.calculateUserPermissionCustomer(user);\r\n });\r\n }\r\n\r\n editCompany(company: Company, event?: KeyboardEvent): void {\r\n if (event != undefined && !this.isEnterKey(event)) {\r\n return;\r\n }\r\n\r\n let self = this;\r\n\r\n let settings: IModalSettings = {\r\n component: 'ibAdministrationInitCompanyAddEditComponent',\r\n size: '',\r\n backdrop: 'static',\r\n resolve: {\r\n isNewCompany: (): boolean => false,\r\n company: (): Company => company,\r\n companies: (): Company[] => self.companies\r\n }\r\n };\r\n\r\n let modalInstance: IModalInstanceService = this.$uibModal.open(settings);\r\n modalInstance.result.then((value: any) => {\r\n if (value == undefined) {\r\n return;\r\n }\r\n\r\n if (value == 'cancel') {\r\n self.loadCompanies();\r\n }\r\n });\r\n\r\n modalInstance.closed.then(() => {\r\n //self.calculateUserPermissionCustomer(user);\r\n });\r\n }\r\n\r\n getCompanyAttributeTitle(key: CompanyAttributeTitleKeys, row?: Company): string {\r\n if (key == undefined) {\r\n return undefined;\r\n }\r\n\r\n if (key === \"locked\") {\r\n if (row === undefined) {\r\n return `Spärra / låsupp`;\r\n }\r\n\r\n return (row.locked) ? `Spärrad` : `Upplåst`;\r\n }\r\n }\r\n\r\n isEnterKey(event: KeyboardEvent, preventDefault: boolean = false): boolean {\r\n if ((event.key !== undefined && event.key.toLowerCase() === \"enter\") ||\r\n (event.keyCode !== undefined && event.keyCode === 13) ||\r\n (event.which !== undefined && event.which === 13)) {\r\n if (preventDefault) {\r\n event.preventDefault();\r\n }\r\n return true;\r\n }\r\n\r\n return false;\r\n }\r\n\r\n showImportExportLog(company: Company, event?: KeyboardEvent): void {\r\n if (event != undefined && !this.isEnterKey(event)) {\r\n return;\r\n }\r\n\r\n let self = this;\r\n let settings: IModalSettings = {\r\n component: 'ibAdministrationInitCompanyImportExportLogComponent',\r\n size: 'xl',\r\n resolve: {\r\n company: (): Company => company\r\n }\r\n };\r\n\r\n let modalInstance: IModalInstanceService = this.$uibModal.open(settings);\r\n modalInstance.result.then((value: any) => {\r\n });\r\n\r\n modalInstance.closed.then(() => {\r\n });\r\n }\r\n\r\n private broadcastEvent(event: AdministrationInitCompanyEvents, ...args: any[]): void {\r\n this.$scope.$broadcast(event, args);\r\n }\r\n\r\n private loadCompanies(): ng.IPromise {\r\n this.spinnerService.showBusy();\r\n let self = this;\r\n\r\n if (this.companies != undefined) {\r\n this.companies.length = 0;\r\n }\r\n\r\n return this.companyService.getCompanies().then((companies: Company[]) => {\r\n // Clear smart table search filter\r\n this.broadcastEvent(\"AdministrationInitCompanyCompaniesResetSearch\");\r\n\r\n self.companies = companies;\r\n }).catch(error => {\r\n let msg: string = `An error occurred while loading companies`;\r\n self.$log.error(`${msg} ${error}`);\r\n throw error;\r\n }).finally(() => {\r\n this.spinnerService.hideBusy();\r\n });\r\n }\r\n\r\n private updateAuthenticatedParameters(params: IAuthenticatedParameters): void {\r\n if (params === null || typeof params === \"undefined\") {\r\n return;\r\n }\r\n\r\n if (params.companyId != undefined) {\r\n this.companyId = params.companyId;\r\n }\r\n\r\n if (params.customerId != undefined) {\r\n this.customerId = params.customerId;\r\n }\r\n\r\n if (params.sysUserId != undefined) {\r\n this.userId = params.sysUserId;\r\n }\r\n\r\n if (params.username != undefined) {\r\n this.userName = params.username;\r\n }\r\n\r\n this.loadCompanies();\r\n }\r\n\r\n /*** ng.IController and ng.IDoCheck methods ***/\r\n $onChanges?(_onChangesObj: IOnChangesObject): void {\r\n }\r\n\r\n $onInit(): void {\r\n let params = this.trans.params() as IAuthenticatedParameters;\r\n this.updateAuthenticatedParameters(params);\r\n }\r\n\r\n $onDestroy(): void {\r\n }\r\n\r\n $doCheck(): void {\r\n }\r\n\r\n uiCanExit(transition: Transition): boolean | void | TargetState | Promise {\r\n }\r\n\r\n uiOnParamsChanged(newValues: any, $transition$: Transition): void {\r\n let params = newValues as IAuthenticatedParameters;\r\n this.updateAuthenticatedParameters(params);\r\n }\r\n\r\n /*** Binding properties ***/\r\n trans: Transition;\r\n}\r\n\r\nexport default class AdministrationInitCompanyComponent implements ng.IComponentOptions {\r\n bindings?: { [boundProperty: string]: string };\r\n templateUrl: string;\r\n controller: ng.Injectable;\r\n\r\n constructor() {\r\n this.controller = AdministrationInitCompanyController;\r\n this.templateUrl = './dist/app/administration/administration-init-company.template.html';\r\n this.bindings = {\r\n trans: '<'\r\n }\r\n }\r\n}","import * as angular from \"angular\";\r\nimport { module, IOnChangesObject, IChangesObject } from \"angular\";\r\nimport { IModalService, IModalSettings, IModalInstanceService } from \"angular-ui-bootstrap\";\r\nimport HtmlStorageService from \"../services/HtmlStorageService\";\r\nimport SpinnerService from \"../services/SpinnerService\";\r\nimport IBDate from \"../core/IBDate\";\r\nimport { Transition, TransitionService } from \"@uirouter/angularjs\";\r\nimport OrderingService from \"../services/OrderingService\";\r\nimport OrderingRowService from \"../services/OrderingRowService\";\r\nimport IHttpPromiseError, { IHttpPromiseBadrequestError } from \"../core/IHttpPromiseError\";\r\nimport { OrderingRow } from \"../services/model/OrderingRow\";\r\nimport { Ordering } from \"../services/model/Ordering\";\r\nimport OrderingArticleGroupService from \"../services/OrderingArticleGroupService\";\r\nimport OrderingArticleService from \"../services/OrderingArticleService\";\r\nimport { ArticleGroup } from \"../services/model/ArticleGroup\";\r\nimport { Article } from \"../services/model/Article\";\r\nimport { CheckOrderingRowQuantity } from \"../services/model/CheckOrderingRowQuantity\";\r\n\r\ntype UiSelectBroadcastEvents =\r\n \"UiSelectOrderingOrderOrderingArticle\" |\r\n \"UiSelectOrderingOrderOrderingArticleGroup\" |\r\n \"UiSelectOrderingOrderOrderingQuantity\" |\r\n \"UiSelectOrderingOrderOrderingAdd\";\r\n\r\ntype OrderingOrderOrderingEvents =\r\n \"OrderingOrderOrderingResetSearch\";\r\n\r\nexport class OrderingOrderOrdering1Controller implements ng.IController { // ng.IDoCheck\r\n static $inject = [\"$http\", \"$rootScope\", \"$scope\", \"$state\", \"$timeout\", \"$q\", \"$transitions\", \"$interval\", \"$window\", \"$log\", \"$locale\", \"$uibModal\", \"spinnerService\", \"htmlStorageService\", \"orderingService\", \"orderingRowService\", \"orderingArticleGroupService\", \"orderingArticleService\"];\r\n\r\n constructor(private $http: ng.IHttpService,\r\n private $rootScope: ng.IRootScopeService,\r\n private $scope: ng.IScope,\r\n private $state: angular.ui.IStateService,\r\n private $timeout: ng.ITimeoutService,\r\n private $q: ng.IQService,\r\n private $transitions: TransitionService,\r\n private $interval: ng.IIntervalService,\r\n private $window: ng.IWindowService,\r\n private $log: ng.ILogService,\r\n private $locale: ng.ILocaleService,\r\n private $uibModal: IModalService,\r\n private spinnerService: SpinnerService,\r\n private htmlStorageService: HtmlStorageService,\r\n private orderingService: OrderingService,\r\n private orderingRowService: OrderingRowService,\r\n private orderingArticleGroupService: OrderingArticleGroupService,\r\n private orderingArticleService: OrderingArticleService) {\r\n }\r\n\r\n private oldOrdering: Ordering;\r\n private _selectedPaginationItem: { value: number, label: string };\r\n\r\n paginationItems = [{\r\n value: 10,\r\n label: '10'\r\n }, {\r\n value: 15,\r\n label: '15'\r\n },\r\n {\r\n value: 20,\r\n label: '20'\r\n },\r\n {\r\n value: 25,\r\n label: '25'\r\n },\r\n {\r\n value: 30,\r\n label: '30'\r\n }, {\r\n value: 40,\r\n label: '40'\r\n }, {\r\n value: 50,\r\n label: '50'\r\n }, {\r\n value: 99999,\r\n label: 'Alla'\r\n }];\r\n\r\n get selectedPaginationItem(): { value: number, label: string } {\r\n if (this._selectedPaginationItem == undefined) {\r\n let spi = <{ value: number, label: string }>this.htmlStorageService.getLocalStorageItem(\"lastPaginationItemOrderingOrderOrdering\");\r\n if (spi == undefined) {\r\n this.selectedPaginationItem = this.paginationItems[0];\r\n }\r\n else {\r\n this.selectedPaginationItem = spi;\r\n }\r\n }\r\n return this._selectedPaginationItem;\r\n }\r\n\r\n set selectedPaginationItem(item: { value: number, label: string }) {\r\n this._selectedPaginationItem = item;\r\n this.htmlStorageService.setLocalStorageItem(\"lastPaginationItemOrderingOrderOrdering\", item);\r\n }\r\n\r\n textDeliveryDate: string = `Leveransdatum`;\r\n textDeadline: string = `Stopptid`;\r\n textDeliveryInformation: string = `Leveransinformation`;\r\n textDeleteOrderingConfirmation: string = `Ta bort din beställning?`;\r\n textPlaceOrderingConfirmation: string = `Godkänn beställningen?`;\r\n textSelectOrderingTemplateConfirmation: string = `Slå samman aktuell beställning med tidigare beställning eller beställningsmall?`;\r\n textDeleteOrderingRowConfirmation: string = `Ta bort beställningsraden?`;\r\n\r\n get textPlaceOrdering(): string {\r\n return (this.orderingRows == undefined || this.hasPendingOrderingRows()) ? `Godkänn` : `Godkänd`;\r\n }\r\n\r\n textDeleteOrdering: string = `Ta bort`;\r\n textMergeOrdering: string = `Hämta`;\r\n\r\n orderingRows: OrderingRow[];\r\n articleGroups: ArticleGroup[];\r\n articles: Article[];\r\n\r\n filteredArticleGroups: ArticleGroup[];\r\n filteredArticles: Article[];\r\n\r\n selectedArticleGroup: ArticleGroup;\r\n selectedArticle: Article;\r\n\r\n newOrderingRow: OrderingRow;\r\n\r\n sumHistQuantity: number;\r\n sumQuantity: number;\r\n sumPrice: number;\r\n\r\n errorMessageAddRowQuantity: string;\r\n warningMessageAddRowQuantity: string;\r\n errorMessageNewOrderingRowStopTimePassed: string;\r\n errorMessageQuantity: {} = {};\r\n warningMessageQuantity: {} = {};\r\n\r\n articleSelected(article: Article): void {\r\n if (article == undefined) {\r\n this.selectedArticle = undefined;\r\n this.newOrderingRow = undefined;\r\n this.errorMessageNewOrderingRowStopTimePassed = undefined;\r\n\r\n return;\r\n }\r\n\r\n if (this.selectedArticleGroup != undefined && this.selectedArticleGroup.id !== article.articleGroupId) {\r\n this.selectedArticleGroup = undefined;\r\n\r\n for (let i = 0; i < this.articleGroups.length - 1; i++) {\r\n if (this.articleGroups[i].id === article.articleGroupId) {\r\n this.articleGroupSelected(this.articleGroups[i]);\r\n this.selectedArticle = article;\r\n break;\r\n }\r\n }\r\n }\r\n\r\n if (!this.verifyNewOrderingRowStoptime(article)) {\r\n return;\r\n }\r\n\r\n if (this.newOrderingRow == undefined || this.newOrderingRow.articleId !== article.id) {\r\n this.newOrderingRow = undefined;\r\n this.newOrderingRow = new OrderingRow();\r\n\r\n // Copy article values\r\n this.newOrderingRow.additionalTextAllowed = article.additionalTextAllowed;\r\n this.newOrderingRow.agreement = article.agreement;\r\n this.newOrderingRow.allowedDecimal = article.allowedDecimal;\r\n this.newOrderingRow.articleGroupId = article.articleGroupId;\r\n this.newOrderingRow.articleGroupName = article.articleGroupName;\r\n this.newOrderingRow.articleGroupNo = article.articleGroupNo;\r\n this.newOrderingRow.articleId = article.id;\r\n this.newOrderingRow.articleName = article.articleName;\r\n this.newOrderingRow.articleNo = article.articleNo;\r\n this.newOrderingRow.articleName = article.articleName;\r\n this.newOrderingRow.price = article.actualPrice;\r\n this.newOrderingRow.quantity = 0;\r\n this.newOrderingRow.specialPrice = article.specialPrice;\r\n this.newOrderingRow.stopDateTimeUTC = article.stopDateTimeUTC;\r\n\r\n // Copy ordering values\r\n this.newOrderingRow.customerId = this.ordering.customerId;\r\n this.newOrderingRow.orderingHeadId = this.ordering.id;\r\n //this.newOrderingRow.orderingStatusId = 1;\r\n }\r\n\r\n this.setUiFocus(\"UiSelectOrderingOrderOrderingQuantity\");\r\n }\r\n\r\n articleGroupSelected(articleGroup: ArticleGroup): void {\r\n this.selectedArticleGroup = (articleGroup == null) ? undefined : articleGroup;\r\n this.selectedArticle = undefined;\r\n this.newOrderingRow = undefined;\r\n this.errorMessageNewOrderingRowStopTimePassed = undefined;\r\n\r\n this.filteredArticles = undefined;\r\n if (articleGroup == undefined) {\r\n this.filteredArticles = angular.copy(this.articles);\r\n this.filteredArticleGroups = angular.copy(this.articleGroups);\r\n return;\r\n }\r\n\r\n if (!this.verifyNewOrderingRowStoptime(articleGroup)) {\r\n return;\r\n }\r\n\r\n this.filteredArticles = this.articles.filter((value: Article, index: number, array: Article[]) => {\r\n return value.articleGroupId == articleGroup.id;\r\n }, this);\r\n\r\n this.setUiFocus(\"UiSelectOrderingOrderOrderingArticle\");\r\n }\r\n\r\n newOrderingRowQuantityKeyDown(event: KeyboardEvent): void {\r\n if ((event.key !== undefined && event.key.toLowerCase() === \"enter\") || (event.keyCode || event.which) === 13) {\r\n this.setUiFocus(\"UiSelectOrderingOrderOrderingAdd\");\r\n event.preventDefault();\r\n return;\r\n }\r\n\r\n //if (event.keyCode === 27) {\r\n // (event.currentTarget).value = this.newOrderingRow.quantity.toString();\r\n //}\r\n }\r\n\r\n newOrderingRowQuantityOldValue: number;\r\n\r\n newOrderingRowQuantityChanged(): void {\r\n this.verifyNewOrderingRowQuantity();\r\n }\r\n\r\n addNewOrderingRow(event?: KeyboardEvent): void {\r\n if ((event != undefined && !((event.key !== undefined && event.key.toLowerCase() === \"enter\") || (event.keyCode || event.which) === 13)) ||\r\n this.newOrderingRow == undefined) {\r\n return;\r\n }\r\n\r\n if (!this.verifyNewOrderingRowStoptime(this.newOrderingRow)) {\r\n return;\r\n }\r\n\r\n this.spinnerService.showBusy();\r\n let self = this;\r\n\r\n this.verifyNewOrderingRowQuantity().then((result: boolean) => {\r\n if (result === true) {\r\n this.orderingRowService.createOrderingRow(self.newOrderingRow).then((orderingRow: OrderingRow) => {\r\n self.newOrderingRow = undefined;\r\n self.selectedArticle = undefined;\r\n if (self.selectedArticleGroup != undefined) {\r\n self.filteredArticles = self.articles.filter((value: Article, index: number, array: Article[]) => {\r\n return value.articleGroupId == self.selectedArticleGroup.id;\r\n }, this);\r\n } else {\r\n self.filteredArticles = angular.copy(self.articles);\r\n }\r\n self.orderingRows.splice(0, 0, orderingRow);\r\n //this.hasPendingOrderingRows();\r\n self.onOrderingRowAdded({ orderingRow: orderingRow }).then(() => { });\r\n // TODO: set focus on article\r\n this.errorMessageAddRowQuantity = undefined;\r\n this.warningMessageAddRowQuantity = undefined;\r\n }).catch((error: any) => {\r\n let e = error as IHttpPromiseBadrequestError;\r\n self.$log.error(`An unexpected error occured while adding new ordering row to order ${this.ordering.id}. (${error.status}:${error.statusText})`)\r\n }).finally(() => {\r\n self.spinnerService.hideBusy();\r\n self.setUiFocus(\"UiSelectOrderingOrderOrderingArticle\");\r\n self.updateSums();\r\n });\r\n } else {\r\n self.spinnerService.hideBusy();\r\n }\r\n }).catch((error: any) => {\r\n }).finally(() => {\r\n //self.spinnerService.hideBusy();\r\n //self.setUiFocus(\"UiSelectOrderingOrderOrderingArticle\");\r\n //self.updateSums();\r\n });\r\n }\r\n\r\n deliveryInformationChanged(): void {\r\n if (this.isReadOnly()) {\r\n return;\r\n }\r\n this.onUpdateOrdering({ ordering: this.ordering }).then(() => { });\r\n }\r\n\r\n loadOrderingRows(): void {\r\n this.spinnerService.showBusy();\r\n let self = this;\r\n\r\n this.orderingRowService.getAllByOrdering(this.ordering.id).then((orderingRows: OrderingRow[]) => {\r\n self.orderingRows = orderingRows;\r\n self.updateSums();\r\n }).catch((error: IHttpPromiseError) => {\r\n self.$log.error(`Could not load ordering rows for ordering ${this.ordering.id} (${error.status}:${error.statusText})`);\r\n }).finally(() => {\r\n self.spinnerService.hideBusy();\r\n });\r\n }\r\n\r\n loadArticles(): void {\r\n this.spinnerService.showBusy();\r\n let self = this;\r\n\r\n this.orderingArticleService.getAllByCustomerAndDeliveryDate(this.ordering.customerId, new IBDate(this.ordering.deliveryDate)).then((articles: Article[]) => {\r\n self.articles = articles;\r\n self.filteredArticles = angular.copy(articles);\r\n }).catch((error: IHttpPromiseError) => {\r\n self.$log.error(`Could not load ordering articles for customer ${this.ordering.customerId} (${error.status}:${error.statusText})`);\r\n }).finally(() => {\r\n self.spinnerService.hideBusy();\r\n });\r\n }\r\n\r\n loadArticleGroups(): void {\r\n this.spinnerService.showBusy();\r\n let self = this;\r\n\r\n this.orderingArticleGroupService.getAllByCustomerAndDeliveryDate(this.ordering.customerId, new IBDate(this.ordering.deliveryDate)).then((articleGroups: ArticleGroup[]) => {\r\n self.articleGroups = articleGroups;\r\n self.filteredArticleGroups = angular.copy(articleGroups);\r\n }).catch((error: IHttpPromiseError) => {\r\n self.$log.error(`Could not load ordering article groups for customer ${this.ordering.customerId} (${error.status}:${error.statusText})`);\r\n }).finally(() => {\r\n self.spinnerService.hideBusy();\r\n });\r\n }\r\n\r\n deleteOrdering(): void {\r\n let result = this.$window.confirm(this.textDeleteOrderingConfirmation);\r\n if (result === true) {\r\n this.onRemoveOrdering({ ordering: this.ordering }).then(() => { });\r\n }\r\n }\r\n\r\n placeOrdering(): void {\r\n let result = this.$window.confirm(this.textPlaceOrderingConfirmation);\r\n if (result === true) {\r\n this.onPlaceOrdering({ ordering: this.ordering }).then(() => {\r\n this.loadOrderingRows();\r\n });\r\n }\r\n }\r\n\r\n hasAdditionalText(orderingRow: OrderingRow): boolean {\r\n return orderingRow != undefined && orderingRow.additionalText != undefined && orderingRow.additionalText.length > 0;\r\n }\r\n\r\n isArticleStoptimePassed(article: Article): boolean {\r\n return article != undefined && article.stopDateTimeUTC.valueOf() < new Date().valueOf();\r\n }\r\n\r\n isArticleGroupStoptimePassed(articleGroup: ArticleGroup): boolean {\r\n return articleGroup != undefined && articleGroup.stopDateTimeUTC.valueOf() < new Date().valueOf();\r\n }\r\n\r\n isReadOnly(): boolean {\r\n return this.isStopTimePassed();\r\n }\r\n\r\n isPlaceOrderingReadOnly(): boolean {\r\n return this.isReadOnly() || !this.hasPendingOrderingRows();\r\n }\r\n\r\n isNewOrderingAgreement(): boolean {\r\n return this.newOrderingRow != undefined && this.isOrderingRowAgreement(this.newOrderingRow);\r\n }\r\n\r\n isNewOrderingRowLocked(): boolean {\r\n return this.newOrderingRow == undefined || (this.newOrderingRow.stopDateTimeUTC.valueOf() < new Date().valueOf());\r\n }\r\n\r\n isNewOrderingRowStoptimePassed(): boolean {\r\n return (this.selectedArticleGroup !== undefined && (this.selectedArticleGroup.stopDateTimeUTC.valueOf() < new Date().valueOf())) ||\r\n (this.selectedArticle != undefined && (this.selectedArticle.stopDateTimeUTC.valueOf() < new Date().valueOf()) ||\r\n (this.newOrderingRow != undefined && (this.newOrderingRow.stopDateTimeUTC.valueOf() < new Date().valueOf())));\r\n }\r\n\r\n isNewOrderingRowSpecialPrice(): boolean {\r\n return this.newOrderingRow != undefined && this.isOrderingRowSpecialPrice(this.newOrderingRow);\r\n }\r\n\r\n isNewOrderingRowAdditionalTextAllowedReadOnly(): boolean {\r\n return this.newOrderingRow == undefined || !this.newOrderingRow.additionalTextAllowed;\r\n }\r\n\r\n isOrderingRowAgreement(orderingRow: OrderingRow): boolean {\r\n return (orderingRow.agreement == undefined) ? false : (!!orderingRow.agreement);\r\n }\r\n\r\n isOrderingRowSpecialPrice(orderingRow: OrderingRow): boolean {\r\n return (orderingRow.specialPrice == undefined) ? false : (!!orderingRow.specialPrice);\r\n }\r\n\r\n isOrderingRowLocked(orderingRow: OrderingRow): boolean {\r\n if (orderingRow == undefined || orderingRow.stopDateTimeUTC == undefined) {\r\n return;\r\n }\r\n return (orderingRow.stopDateTimeUTC.valueOf() < new IBDate().valueOf());\r\n }\r\n\r\n isStopTimePassed(): boolean {\r\n if (this.ordering == undefined) {\r\n return;\r\n }\r\n let stUtc = this.ordering.stopDateTimeUTC;\r\n let now = new IBDate();\r\n\r\n return !!(now.valueOf() > stUtc.valueOf());\r\n }\r\n\r\n selectOrderingTemplate(): void {\r\n let result = this.$window.confirm(this.textSelectOrderingTemplateConfirmation);\r\n if (result === true) {\r\n this.onSelectOrderingTemplate();\r\n }\r\n }\r\n\r\n showPrice(): boolean {\r\n return (this.ordering != undefined) ? this.ordering.showPrice : undefined;\r\n }\r\n\r\n minimumOrdering(orderingRow: OrderingRow): number {\r\n return (orderingRow == undefined || orderingRow.minimumOrdering == undefined) ? 0 : orderingRow.minimumOrdering;\r\n }\r\n\r\n orderingRowQuantityChanged(orderingRow: OrderingRow, oldValue: number): void {\r\n //let index = this.orderingRows.findIndex((value) => value.id === orderingRow.id);\r\n let index = orderingRow.id;\r\n\r\n if (orderingRow.quantity == undefined) {\r\n this.errorMessageQuantity[index] = `Felaktigt nummerformat. Endast siffor, komma eller punkt som decimalavgränsare. Artikel (${orderingRow.articleName}) tillåter maximalt ${orderingRow.allowedDecimal} decimaler.`;\r\n return;\r\n }\r\n\r\n let self = this;\r\n\r\n this.orderingRowService.validateOrderingQuantity(orderingRow, new IBDate(this.ordering.deliveryDate)).then((response: CheckOrderingRowQuantity) => {\r\n if (response !== undefined && response.errorMessage !== null && response.errorMessage !== undefined && response.errorMessage.length > 0) {\r\n if (response.onlyWarning === false) {\r\n this.errorMessageQuantity[index] = response.errorMessage;\r\n this.warningMessageQuantity[index] = undefined;\r\n return;\r\n } else {\r\n this.errorMessageQuantity[index] = undefined;\r\n this.warningMessageQuantity[index] = response.errorMessage;\r\n }\r\n } else {\r\n self.errorMessageQuantity[index] = undefined;\r\n self.warningMessageQuantity[index] = undefined;\r\n }\r\n\r\n if (orderingRow.quantity == undefined || orderingRow.quantity < 0 || (orderingRow.minimumOrdering != undefined && orderingRow.quantity < orderingRow.minimumOrdering)) {\r\n orderingRow.quantity = (orderingRow.minimumOrdering == undefined) ? 0 : orderingRow.minimumOrdering;\r\n }\r\n this.orderingRowService.updateOrderingRow(orderingRow).then(() => {\r\n orderingRow.orderingStatusId = 1;\r\n self.onOrderingRowUpdated({ orderingRow: orderingRow }).then(() => { });\r\n }).catch((error: IHttpPromiseError) => {\r\n orderingRow.quantity = oldValue;\r\n self.$log.error(`Could not update ordering row value. (${error.status}:${error.statusText})`);\r\n }).finally(() => {\r\n self.updateSums();\r\n });\r\n }).catch((error: IHttpPromiseError) => {\r\n self.$log.error(`Could not validate ordering row quantity value. (${error.status}:${error.statusText})`);\r\n });\r\n }\r\n\r\n orderingRowAdditionalTextChanged(orderingRow: OrderingRow, oldValue: string): void {\r\n let self = this;\r\n this.orderingRowService.updateOrderingRow(orderingRow).then(() => {\r\n orderingRow.orderingStatusId = 1;\r\n self.onOrderingRowUpdated({ orderingRow: orderingRow }).then(() => { });\r\n }).catch((error: IHttpPromiseError) => {\r\n orderingRow.additionalText = oldValue;\r\n self.$log.error(`Could not update ordering row value. (${error.status}:${error.statusText})`);\r\n }).finally(() => {\r\n });\r\n }\r\n\r\n removeOrderingRow(orderingRow: OrderingRow): void {\r\n if (this.isOrderingRowLocked(orderingRow)) {\r\n return;\r\n }\r\n\r\n let confirm = this.$window.confirm(this.textDeleteOrderingRowConfirmation);\r\n if (confirm === true) {\r\n this.spinnerService.showBusy();\r\n let self = this;\r\n this.orderingRowService.removeOrderingRow(orderingRow.id).then(() => {\r\n self.onOrderingRowRemoved({ orderingRow: orderingRow }).then(() => { });\r\n let index = self.orderingRows.findIndex((value) => value.id === orderingRow.id);\r\n self.orderingRows.splice(index, 1);\r\n self.updateSums();\r\n }).catch((error: IHttpPromiseError) => {\r\n self.$log.error(`An unexpected error occured while removeing ordering row ${orderingRow.id}:${orderingRow.articleName} from order ${self.ordering.id}. (${error.status}, ${error.statusText})`);\r\n }).finally(() => {\r\n this.spinnerService.hideBusy();\r\n });\r\n }\r\n }\r\n\r\n showOrderingRowInformation(orderingRow: OrderingRow): void {\r\n let self = this;\r\n let settings: IModalSettings = {\r\n component: 'ibOrderingOrderOrderingArticleInformationComponent',\r\n size: 'lg',\r\n resolve: {\r\n customerId: (): number => self.ordering.customerId,\r\n articleId: (): number => orderingRow.articleId,\r\n deliveryDate: (): Date => self.ordering.deliveryDate\r\n }\r\n };\r\n\r\n let modalInstance: IModalInstanceService = this.$uibModal.open(settings);\r\n\r\n modalInstance.result.then((value) => {\r\n });\r\n\r\n modalInstance.closed.then(() => {\r\n })\r\n }\r\n\r\n private broadcastEvent(event: OrderingOrderOrderingEvents | UiSelectBroadcastEvents, ...args: any[]): void {\r\n this.$scope.$broadcast(event, args);\r\n }\r\n\r\n private clearLocalParameters(): void {\r\n this.selectedArticle = undefined;\r\n this.selectedArticleGroup = undefined;\r\n this.filteredArticles = undefined;\r\n this.filteredArticleGroups = undefined;\r\n this.newOrderingRow = undefined;\r\n this.errorMessageAddRowQuantity = undefined;\r\n this.warningMessageAddRowQuantity = undefined;\r\n //this.errorMessageQuantity.length = 0;\r\n\r\n this.broadcastEvent(\"OrderingOrderOrderingResetSearch\");\r\n }\r\n\r\n private hasPendingOrderingRows(): boolean {\r\n return this.orderingRows != undefined && this.orderingRows.filter((r) => r.orderingStatusId === 1).length > 0;\r\n }\r\n\r\n private setUiFocus(event: UiSelectBroadcastEvents): void {\r\n this.broadcastEvent(event);\r\n }\r\n\r\n private updateSums(): void {\r\n this.sumHistQuantity = 0;\r\n this.sumQuantity = 0;\r\n this.sumPrice = 0;\r\n\r\n this.orderingRows.forEach((orderingRow, index, rows) => {\r\n this.sumHistQuantity += (orderingRow.historyQuantity != undefined) ? orderingRow.historyQuantity : 0;\r\n this.sumQuantity += (orderingRow.quantity != undefined) ? orderingRow.quantity : 0;\r\n this.sumPrice += orderingRow.price * ((orderingRow.quantity == undefined) ? 0 : orderingRow.quantity) * ((orderingRow.priceUnits == undefined) ? 1 : orderingRow.priceUnits);\r\n }, this);\r\n\r\n this.sumHistQuantity = this.sumHistQuantity === 0 ? undefined : this.sumHistQuantity;\r\n this.sumQuantity = this.sumQuantity === 0 ? undefined : this.sumQuantity;\r\n this.sumPrice = this.sumPrice === 0 ? undefined : this.sumPrice;\r\n }\r\n\r\n private verifyNewOrderingRowQuantity(): ng.IPromise {\r\n let d = this.$q.defer();\r\n\r\n if (this.newOrderingRow.quantity === undefined) {\r\n this.errorMessageAddRowQuantity = `Felaktigt nummerformat. Endast siffor, komma eller punkt som decimalavgränsare. Artikel (