asp-lib 2.1.1 → 2.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,19 +1,30 @@
1
- import { ElementRef, EventEmitter } from '@angular/core';
1
+ import { ElementRef, EventEmitter, OnChanges, SimpleChanges } from '@angular/core';
2
+ import { CompanySelection } from '../services/company-selection.service';
2
3
  import * as i0 from "@angular/core";
3
- export declare class CompanyDropdownComponent {
4
+ export declare class CompanyDropdownComponent implements OnChanges {
4
5
  private elementRef;
5
6
  companies: any[];
7
+ /** True while a company or agency change is being saved; the options can't be picked meanwhile. */
8
+ busy: boolean;
9
+ /** An agency was picked. */
6
10
  optionSelected: EventEmitter<any>;
11
+ /** A company was picked on its own, without one of its agencies. */
12
+ companySelected: EventEmitter<any>;
7
13
  isOpen: boolean;
8
- selectedOption: any;
9
14
  selectedAgency: any;
15
+ selection: CompanySelection | null;
10
16
  fadeInOut: string;
11
17
  isCompanyOpen: boolean;
12
18
  constructor(elementRef: ElementRef);
13
19
  onClick(targetElement: HTMLElement): void;
20
+ ngOnChanges(changes: SimpleChanges): void;
14
21
  ngOnInit(): void;
15
22
  toggleDropdownHandler(): void;
16
- selectCompany(option: any): void;
23
+ hasAgencies(company: any): boolean;
24
+ /** The user works on this company as a whole (no agency picked). */
25
+ isCurrentCompany(company: any): boolean;
26
+ /** Picks the company without opening its agencies. */
27
+ selectCompany(company: any, event: MouseEvent): void;
17
28
  selectAgency(agency: any, company: any): void;
18
29
  toggleOverlayHandler(event: MouseEvent): void;
19
30
  handleDropdownClick(event: MouseEvent): void;
@@ -21,5 +32,5 @@ export declare class CompanyDropdownComponent {
21
32
  toggleSelectCompanysHandler(company: any, event: MouseEvent): void;
22
33
  isSelectedAgency(agency: any, company: any): boolean;
23
34
  static ɵfac: i0.ɵɵFactoryDeclaration<CompanyDropdownComponent, never>;
24
- static ɵcmp: i0.ɵɵComponentDeclaration<CompanyDropdownComponent, "lib-company-dropdown", never, { "companies": { "alias": "companies"; "required": false; }; }, { "optionSelected": "optionSelected"; }, never, never, false, never>;
35
+ static ɵcmp: i0.ɵɵComponentDeclaration<CompanyDropdownComponent, "lib-company-dropdown", never, { "companies": { "alias": "companies"; "required": false; }; "busy": { "alias": "busy"; "required": false; }; }, { "optionSelected": "optionSelected"; "companySelected": "companySelected"; }, never, never, false, never>;
25
36
  }
@@ -4,6 +4,7 @@ import { ServicesConfig } from '../utils/models/ServicesConfig';
4
4
  import { SecurityServices } from '../utils/services/SecurityServicesDefault';
5
5
  import { Observable } from 'rxjs';
6
6
  import { SnackbarService } from '../services/snackbar.service';
7
+ import { CompanySelectionService } from '../services/company-selection.service';
7
8
  import * as i0 from "@angular/core";
8
9
  export interface HeaderShortcut {
9
10
  module: any;
@@ -32,6 +33,7 @@ export declare class HeaderComponent {
32
33
  private route;
33
34
  private cdr;
34
35
  private snackbar;
36
+ private companySelection;
35
37
  appLogo: string;
36
38
  theme: string;
37
39
  showBackButton: boolean;
@@ -90,14 +92,20 @@ export declare class HeaderComponent {
90
92
  inlineModuleList: any[];
91
93
  /** True while the options tree of the selected module is being loaded. */
92
94
  menuLoading: boolean;
95
+ /** True while a company or agency change is being saved, before the page reloads. */
96
+ changingCompany: boolean;
93
97
  private moduleOptionsRequest;
94
98
  dropdownOptionsMenu: DropdownOptions[];
95
- constructor(services: SecurityServices, router: Router, route: ActivatedRoute, cdr: ChangeDetectorRef, snackbar: SnackbarService);
99
+ constructor(services: SecurityServices, router: Router, route: ActivatedRoute, cdr: ChangeDetectorRef, snackbar: SnackbarService, companySelection: CompanySelectionService);
96
100
  ngOnInit(): void;
97
101
  isAuth(): Observable<boolean>;
98
102
  doLogin(): Observable<boolean>;
99
103
  handleOptionSelected(option: any): void;
100
104
  handleCompanySelected(agency: any): void;
105
+ /** A company picked on its own: the user works on the whole company, with no agency. */
106
+ handleCompanyOnlySelected(company: any): void;
107
+ /** Saves the new default company/agency and reloads, so the app starts over with it. */
108
+ private saveDefault;
101
109
  onItemClick(url: any): void;
102
110
  arrowClick($event: MouseEvent): void;
103
111
  onItemModuleSelected(event: any): void;
@@ -0,0 +1,40 @@
1
+ import * as i0 from "@angular/core";
2
+ export interface CompanyAgency {
3
+ id: any;
4
+ agencyName: string;
5
+ agencyCode: string;
6
+ defaultAgency?: boolean;
7
+ }
8
+ /** A company as getCompaniesInfo returns it. Companies without agencies come with no or empty `agencies`. */
9
+ export interface Company {
10
+ /** getCompaniesInfo doesn't send it: companies go by companyCode. */
11
+ id?: any;
12
+ companyName: string;
13
+ companyCode: string;
14
+ icon?: string;
15
+ defaultCompany?: boolean;
16
+ agencies?: CompanyAgency[];
17
+ }
18
+ /** The company the user works on, and its agency: null when the user works on the whole company. */
19
+ export interface CompanySelection {
20
+ company: Company;
21
+ agency: CompanyAgency | null;
22
+ }
23
+ /**
24
+ * Reads the selection out of getCompaniesInfo: the default agency (with its company) first,
25
+ * otherwise the default company with no agency. Null when nothing is marked as default.
26
+ */
27
+ export declare function companySelectionFrom(companies: Company[] | null | undefined): CompanySelection | null;
28
+ /**
29
+ * The user's current company and agency, for the apps that use the header.
30
+ * The header (auto mode) publishes it once it loads the companies, so `selection$`
31
+ * starts with null; changing company reloads the page, so it never changes after that.
32
+ */
33
+ export declare class CompanySelectionService {
34
+ private readonly selectionSubject;
35
+ readonly selection$: import("rxjs").Observable<CompanySelection | null>;
36
+ get selection(): CompanySelection | null;
37
+ setFromCompanies(companies: Company[]): void;
38
+ static ɵfac: i0.ɵɵFactoryDeclaration<CompanySelectionService, never>;
39
+ static ɵprov: i0.ɵɵInjectableDeclaration<CompanySelectionService>;
40
+ }
@@ -18,6 +18,7 @@ export declare class SecurityServices {
18
18
  static readonly CHANGE_PASSWORD = "/security/secure/changePassword";
19
19
  static readonly GET_AUTH_CODE = "/security/secure/getauthcode";
20
20
  static readonly SET_DEFAULT_AGENCY = "/security/secure/setdefault";
21
+ static readonly SET_DEFAULT_COMPANY = "/security/secure/setdefaultcompany";
21
22
  constructor(http: HttpClient);
22
23
  getHistory(baseUrl: string): Observable<Object>;
23
24
  getModulesByUser(baseUrl: string): Observable<Object>;
@@ -32,6 +33,8 @@ export declare class SecurityServices {
32
33
  logOut(baseUrl: string): Observable<Object>;
33
34
  saveHistory(baseUrl: string, option: any): Observable<Object>;
34
35
  setDefaultAgency(baseUrl: string, agencyId: any): Observable<Object>;
36
+ /** Like setDefaultAgency, for a whole company without one of its agencies. Companies have no id: they go by companyCode. */
37
+ setDefaultCompany(baseUrl: string, companyCode: string): Observable<Object>;
35
38
  changePassword(baseUrl: string, cp: any): Observable<Object>;
36
39
  getAuthCode(baseUrl: string): Observable<Object>;
37
40
  static ɵfac: i0.ɵɵFactoryDeclaration<SecurityServices, never>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "asp-lib",
3
- "version": "2.1.1",
3
+ "version": "2.2.0",
4
4
  "peerDependencies": {
5
5
  "@angular/common": ">=16.2.0 <20.0.0",
6
6
  "@angular/core": ">=16.2.0 <20.0.0",
package/public-api.d.ts CHANGED
@@ -13,6 +13,7 @@ export * from './lib/header/header.component';
13
13
  export * from './lib/recents-dropdown/recents-dropdown.component';
14
14
  export * from './lib/notifications/notifications.component';
15
15
  export * from './lib/company-dropdown/company-dropdown.component';
16
+ export * from './lib/services/company-selection.service';
16
17
  export * from './lib/user-dropdown/user-dropdown.component';
17
18
  export * from './lib/radio-group/radio-group.component';
18
19
  export * from './lib/basic-item/basic-item.component';
@@ -0,0 +1,5 @@
1
+ <svg preserveAspectRatio="none" overflow="visible" style="display: block;" width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
2
+ <g id="check">
3
+ <path id="Vector" d="M3 8.5L6.5 12L13 4.5" stroke="#004DA0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
4
+ </g>
5
+ </svg>