@quandis/qbo4.ui 4.0.1-CI-20240501-230003 → 4.0.1-CI-20240507-201707

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.
@@ -9,25 +9,67 @@ var __metadata = (this && this.__metadata) || function (k, v) {
9
9
  };
10
10
  import { html, LitElement } from 'lit';
11
11
  import { customElement, property } from 'lit/decorators.js';
12
+ import { elementDateTime } from './Program.js';
13
+ const formEditMap = new Map();
14
+ formEditMap.set('defaultLayout', (component) => {
15
+ return html `<div slot="content">
16
+ <span>Created:</span>
17
+ <br/>
18
+ <span>${elementDateTime(component.CreatedDate)}</span>
19
+ <br/>
20
+ <span>${component.CreatedPerson}</span>
21
+ <br/>
22
+ <br/>
23
+ <span>Updated:</span>
24
+ <br/>
25
+ <span>${elementDateTime(component.UpdatedDate)}</span>
26
+ <br/>
27
+ <span>${component.UpdatedPerson}</span>
28
+ </div>`;
29
+ });
30
+ formEditMap.set('createdLayout', (component) => {
31
+ return html `<div slot="content">
32
+ <span>Created:</span>
33
+ <br/>
34
+ <span>${elementDateTime(component.CreatedDate)}</span>
35
+ <br/>
36
+ <span>${component.CreatedPerson}</span>
37
+ </div>`;
38
+ });
39
+ formEditMap.set('updatedLayout', (component) => {
40
+ return html `<div slot="content">
41
+ <span>Updated:</span>
42
+ <br/>
43
+ <span>${elementDateTime(component.UpdatedDate)}</span>
44
+ <br/>
45
+ <span>${component.UpdatedPerson}</span>
46
+ </div>`;
47
+ });
12
48
  let QboFormEdit = class QboFormEdit extends LitElement {
13
49
  constructor() {
14
50
  super(...arguments);
15
51
  this.buttonPrimaryClass = 'qbo-primary';
16
- this.createdDate = null;
17
- this.createdPerson = null;
52
+ this.data = {};
18
53
  this.divButtonGroupClass = 'qbo-btn-group';
19
54
  this.divFormActionClass = 'qbo-form-actions';
20
55
  this.divSectionHeaderClass = 'qbo-header';
21
56
  this.editLabel = 'Edit';
57
+ this.infoButtonClass = 'qbo-btn-light';
58
+ this.infoIconClass = 'qbo-icon-info';
59
+ this.infoTitle = 'Last Updated';
60
+ this.popoverClass = 'qbo-float-end';
22
61
  this.spanEditClass = 'qbo-icon-edit';
23
- this.updatedDate = null;
24
- this.updatedPerson = null;
62
+ this.type = 'defaultLayout';
25
63
  this.renderInHost = true;
26
64
  }
27
65
  createRenderRoot() {
28
66
  return this.renderInHost ? this : super.createRenderRoot();
29
67
  }
30
68
  render() {
69
+ const data = this.closest('*[apiendpoint]');
70
+ if (this.type == null)
71
+ this.type = 'createdLayout';
72
+ const popover = formEditMap.has(this.type) ? formEditMap.get(this.type)(this.data) : null;
31
73
  return html `<slot>
32
74
  <div class="${this.divSectionHeaderClass}">
33
75
  <hr />
@@ -53,10 +95,11 @@ let QboFormEdit = class QboFormEdit extends LitElement {
53
95
  </li>
54
96
  </ul>
55
97
  </div>
56
- <qbo-popover>
57
- <button type="button" class="btn btn-light float-end" data-bs-toggle="popover" data-bs-placement="left" data-bs-container="body" title="Last Updated" data-bs-html="true" data-bs-content="Created:<br/>${this.createdDate}<br/>${this.createdPerson}<br/><br/>Updated:<br/>${this.updatedDate}<br/>${this.updatedPerson}">
58
- <i class="bi-info"></i>
98
+ <qbo-popover class="${this.popoverClass}">
99
+ <button type="button" class="${this.infoButtonClass}" title="${this.infoTitle}">
100
+ <i class="${this.infoIconClass}"></i>
59
101
  </button>
102
+ ${popover}
60
103
  </qbo-popover>
61
104
  </div>
62
105
  </slot>`;
@@ -67,13 +110,9 @@ __decorate([
67
110
  __metadata("design:type", Object)
68
111
  ], QboFormEdit.prototype, "buttonPrimaryClass", void 0);
69
112
  __decorate([
70
- property({ type: Date }),
113
+ property({ type: Object, attribute: false }),
71
114
  __metadata("design:type", Object)
72
- ], QboFormEdit.prototype, "createdDate", void 0);
73
- __decorate([
74
- property({ type: String }),
75
- __metadata("design:type", Object)
76
- ], QboFormEdit.prototype, "createdPerson", void 0);
115
+ ], QboFormEdit.prototype, "data", void 0);
77
116
  __decorate([
78
117
  property({ type: String }),
79
118
  __metadata("design:type", Object)
@@ -93,15 +132,27 @@ __decorate([
93
132
  __decorate([
94
133
  property({ type: String }),
95
134
  __metadata("design:type", Object)
96
- ], QboFormEdit.prototype, "spanEditClass", void 0);
135
+ ], QboFormEdit.prototype, "infoButtonClass", void 0);
136
+ __decorate([
137
+ property({ type: String }),
138
+ __metadata("design:type", Object)
139
+ ], QboFormEdit.prototype, "infoIconClass", void 0);
97
140
  __decorate([
98
- property({ type: Date }),
141
+ property({ type: String }),
142
+ __metadata("design:type", Object)
143
+ ], QboFormEdit.prototype, "infoTitle", void 0);
144
+ __decorate([
145
+ property({ type: String }),
99
146
  __metadata("design:type", Object)
100
- ], QboFormEdit.prototype, "updatedDate", void 0);
147
+ ], QboFormEdit.prototype, "popoverClass", void 0);
101
148
  __decorate([
102
149
  property({ type: String }),
103
150
  __metadata("design:type", Object)
104
- ], QboFormEdit.prototype, "updatedPerson", void 0);
151
+ ], QboFormEdit.prototype, "spanEditClass", void 0);
152
+ __decorate([
153
+ property(),
154
+ __metadata("design:type", Object)
155
+ ], QboFormEdit.prototype, "type", void 0);
105
156
  __decorate([
106
157
  property({ type: Boolean }),
107
158
  __metadata("design:type", Object)
@@ -1,5 +1,43 @@
1
- import { html, LitElement } from 'lit';
1
+ import { html, LitElement, TemplateResult } from 'lit';
2
2
  import { customElement, property } from 'lit/decorators.js';
3
+ import { elementDateTime } from './Program.js';
4
+
5
+ type TemplateFunction = (component: any) => TemplateResult;
6
+ const formEditMap: Map<string, TemplateFunction> = new Map();
7
+ formEditMap.set('defaultLayout', (component: any) => {
8
+ return html`<div slot="content">
9
+ <span>Created:</span>
10
+ <br/>
11
+ <span>${elementDateTime(component.CreatedDate)}</span>
12
+ <br/>
13
+ <span>${component.CreatedPerson}</span>
14
+ <br/>
15
+ <br/>
16
+ <span>Updated:</span>
17
+ <br/>
18
+ <span>${elementDateTime(component.UpdatedDate)}</span>
19
+ <br/>
20
+ <span>${component.UpdatedPerson}</span>
21
+ </div>`;
22
+ });
23
+ formEditMap.set('createdLayout', (component: any) => {
24
+ return html`<div slot="content">
25
+ <span>Created:</span>
26
+ <br/>
27
+ <span>${elementDateTime(component.CreatedDate)}</span>
28
+ <br/>
29
+ <span>${component.CreatedPerson}</span>
30
+ </div>`;
31
+ });
32
+ formEditMap.set('updatedLayout', (component: any) => {
33
+ return html`<div slot="content">
34
+ <span>Updated:</span>
35
+ <br/>
36
+ <span>${elementDateTime(component.UpdatedDate)}</span>
37
+ <br/>
38
+ <span>${component.UpdatedPerson}</span>
39
+ </div>`;
40
+ });
3
41
 
4
42
  @customElement('qbo-form-edit')
5
43
  export class QboFormEdit extends LitElement {
@@ -7,11 +45,8 @@ export class QboFormEdit extends LitElement {
7
45
  @property({ type: String })
8
46
  buttonPrimaryClass: String | null = 'qbo-primary';
9
47
 
10
- @property({ type: Date })
11
- createdDate = null;
12
-
13
- @property({ type: String })
14
- createdPerson = null;
48
+ @property({ type: Object, attribute: false })
49
+ data: Object = { };
15
50
 
16
51
  @property({ type: String })
17
52
  divButtonGroupClass: String | null = 'qbo-btn-group';
@@ -26,13 +61,22 @@ export class QboFormEdit extends LitElement {
26
61
  editLabel: String | null = 'Edit';
27
62
 
28
63
  @property({ type: String })
29
- spanEditClass: String | null = 'qbo-icon-edit';
64
+ infoButtonClass: String | null = 'qbo-btn-light';
65
+
66
+ @property({ type: String })
67
+ infoIconClass: String | null = 'qbo-icon-info';
30
68
 
31
- @property({ type: Date })
32
- updatedDate = null;
69
+ @property({ type: String })
70
+ infoTitle: String | null = 'Last Updated';
71
+
72
+ @property({ type: String })
73
+ popoverClass: String | null = 'qbo-float-end';
33
74
 
34
75
  @property({ type: String })
35
- updatedPerson = null;
76
+ spanEditClass: String | null = 'qbo-icon-edit';
77
+
78
+ @property()
79
+ type: string | null = 'defaultLayout';
36
80
 
37
81
  @property({ type: Boolean })
38
82
  renderInHost = true;
@@ -42,6 +86,10 @@ export class QboFormEdit extends LitElement {
42
86
  }
43
87
 
44
88
  render() {
89
+ const data : any = this.closest('*[apiendpoint]');
90
+ if (this.type == null) this.type = 'createdLayout'
91
+ const popover = formEditMap.has(this.type) ? formEditMap.get(this.type)!(this.data) : null;
92
+
45
93
  return html`<slot>
46
94
  <div class="${this.divSectionHeaderClass}">
47
95
  <hr />
@@ -67,10 +115,11 @@ export class QboFormEdit extends LitElement {
67
115
  </li>
68
116
  </ul>
69
117
  </div>
70
- <qbo-popover>
71
- <button type="button" class="btn btn-light float-end" data-bs-toggle="popover" data-bs-placement="left" data-bs-container="body" title="Last Updated" data-bs-html="true" data-bs-content="Created:<br/>${this.createdDate}<br/>${this.createdPerson}<br/><br/>Updated:<br/>${this.updatedDate}<br/>${this.updatedPerson}">
72
- <i class="bi-info"></i>
118
+ <qbo-popover class="${this.popoverClass}">
119
+ <button type="button" class="${this.infoButtonClass}" title="${this.infoTitle}">
120
+ <i class="${this.infoIconClass}"></i>
73
121
  </button>
122
+ ${popover}
74
123
  </qbo-popover>
75
124
  </div>
76
125
  </slot>`;
@@ -1,8 +1,20 @@
1
1
  import { LitElement, PropertyValues } from 'lit';
2
2
  export declare class QboPopover extends LitElement {
3
+ contentAtt: string;
4
+ contentStyle: string;
5
+ containerAtt: string;
6
+ containerValue: string;
7
+ defaultContent: string;
8
+ htmlAtt: string;
9
+ htmlValue: string;
10
+ placementAtt: string;
11
+ placementValue: string;
3
12
  selector: string;
13
+ toggleAtt: string;
14
+ toggleValue: string;
4
15
  renderInHost: boolean;
5
16
  createRenderRoot(): HTMLElement | DocumentFragment;
6
- updated(changedProperties: PropertyValues): void;
17
+ connectedCallback(): void;
18
+ firstUpdated(changedProperties: PropertyValues): void;
7
19
  render(): import("lit-html").TemplateResult<1>;
8
20
  }
@@ -13,24 +13,90 @@ import { Popover } from 'bootstrap';
13
13
  let QboPopover = class QboPopover extends LitElement {
14
14
  constructor() {
15
15
  super(...arguments);
16
- this.selector = `[data-bs-toggle="popover"]`;
16
+ this.contentAtt = 'data-bs-content';
17
+ this.contentStyle = 'none';
18
+ this.containerAtt = 'data-bs-container';
19
+ this.containerValue = 'body';
20
+ this.defaultContent = 'No content provided';
21
+ this.htmlAtt = 'data-bs-html';
22
+ this.htmlValue = 'true';
23
+ this.placementAtt = 'data-bs-placement';
24
+ this.placementValue = 'left';
25
+ this.selector = '*[slot=content]';
26
+ this.toggleAtt = 'data-bs-toggle';
27
+ this.toggleValue = 'popover';
17
28
  this.renderInHost = true;
18
29
  }
19
30
  createRenderRoot() {
20
31
  return this.renderInHost ? this : super.createRenderRoot();
21
32
  }
22
- updated(changedProperties) {
23
- /* Enable Popover */
24
- this.renderRoot.querySelectorAll(`${this.selector}`).forEach(function (t) {
25
- new Popover(t);
26
- });
33
+ connectedCallback() {
34
+ super.connectedCallback();
35
+ this.setAttribute(this.toggleAtt, this.toggleValue);
36
+ this.setAttribute(this.placementAtt, this.placementValue);
37
+ this.setAttribute(this.containerAtt, this.containerValue);
38
+ this.setAttribute(this.htmlAtt, this.htmlValue);
39
+ }
40
+ firstUpdated(changedProperties) {
41
+ super.firstUpdated(changedProperties);
42
+ const content = this.querySelector(this.selector);
43
+ if (content instanceof HTMLElement)
44
+ content.style.display = this.contentStyle;
45
+ this.setAttribute(this.contentAtt, content?.innerHTML ?? this.defaultContent);
46
+ new Popover(this);
47
+ }
48
+ render() {
49
+ return html `<slot></slot>`;
27
50
  }
28
- render() { return html `<slot></slot>`; }
29
51
  };
52
+ __decorate([
53
+ property({ type: String }),
54
+ __metadata("design:type", Object)
55
+ ], QboPopover.prototype, "contentAtt", void 0);
56
+ __decorate([
57
+ property({ type: String }),
58
+ __metadata("design:type", Object)
59
+ ], QboPopover.prototype, "contentStyle", void 0);
60
+ __decorate([
61
+ property({ type: String }),
62
+ __metadata("design:type", Object)
63
+ ], QboPopover.prototype, "containerAtt", void 0);
64
+ __decorate([
65
+ property({ type: String }),
66
+ __metadata("design:type", Object)
67
+ ], QboPopover.prototype, "containerValue", void 0);
68
+ __decorate([
69
+ property({ type: String }),
70
+ __metadata("design:type", Object)
71
+ ], QboPopover.prototype, "defaultContent", void 0);
72
+ __decorate([
73
+ property({ type: String }),
74
+ __metadata("design:type", Object)
75
+ ], QboPopover.prototype, "htmlAtt", void 0);
76
+ __decorate([
77
+ property({ type: String }),
78
+ __metadata("design:type", Object)
79
+ ], QboPopover.prototype, "htmlValue", void 0);
80
+ __decorate([
81
+ property({ type: String }),
82
+ __metadata("design:type", Object)
83
+ ], QboPopover.prototype, "placementAtt", void 0);
84
+ __decorate([
85
+ property({ type: String }),
86
+ __metadata("design:type", Object)
87
+ ], QboPopover.prototype, "placementValue", void 0);
30
88
  __decorate([
31
89
  property({ type: String }),
32
90
  __metadata("design:type", Object)
33
91
  ], QboPopover.prototype, "selector", void 0);
92
+ __decorate([
93
+ property({ type: String }),
94
+ __metadata("design:type", Object)
95
+ ], QboPopover.prototype, "toggleAtt", void 0);
96
+ __decorate([
97
+ property({ type: String }),
98
+ __metadata("design:type", Object)
99
+ ], QboPopover.prototype, "toggleValue", void 0);
34
100
  __decorate([
35
101
  property({ type: Boolean }),
36
102
  __metadata("design:type", Object)
@@ -6,7 +6,40 @@ import { Popover } from 'bootstrap';
6
6
  export class QboPopover extends LitElement {
7
7
 
8
8
  @property({ type: String })
9
- selector = `[data-bs-toggle="popover"]`;
9
+ contentAtt = 'data-bs-content';
10
+
11
+ @property({ type: String })
12
+ contentStyle = 'none';
13
+
14
+ @property({ type: String })
15
+ containerAtt = 'data-bs-container';
16
+
17
+ @property({ type: String })
18
+ containerValue = 'body';
19
+
20
+ @property({ type: String })
21
+ defaultContent = 'No content provided';
22
+
23
+ @property({ type: String })
24
+ htmlAtt = 'data-bs-html';
25
+
26
+ @property({ type: String })
27
+ htmlValue = 'true';
28
+
29
+ @property({ type: String })
30
+ placementAtt = 'data-bs-placement';
31
+
32
+ @property({ type: String })
33
+ placementValue = 'left';
34
+
35
+ @property({ type: String })
36
+ selector = '*[slot=content]';
37
+
38
+ @property({ type: String })
39
+ toggleAtt = 'data-bs-toggle';
40
+
41
+ @property({ type: String })
42
+ toggleValue = 'popover';
10
43
 
11
44
  @property({ type: Boolean })
12
45
  renderInHost = true;
@@ -15,12 +48,26 @@ export class QboPopover extends LitElement {
15
48
  return this.renderInHost ? this : super.createRenderRoot();
16
49
  }
17
50
 
18
- updated(changedProperties: PropertyValues) {
19
- /* Enable Popover */
20
- this.renderRoot.querySelectorAll(`${this.selector}`).forEach(function (t) {
21
- new Popover(t);
22
- });
51
+ connectedCallback() {
52
+ super.connectedCallback();
53
+
54
+ this.setAttribute(this.toggleAtt, this.toggleValue);
55
+ this.setAttribute(this.placementAtt, this.placementValue);
56
+ this.setAttribute(this.containerAtt, this.containerValue);
57
+ this.setAttribute(this.htmlAtt, this.htmlValue);
23
58
  }
24
59
 
25
- render() { return html`<slot></slot>`; }
60
+ firstUpdated(changedProperties: PropertyValues) {
61
+ super.firstUpdated(changedProperties);
62
+
63
+ const content = this.querySelector(this.selector);
64
+ if (content instanceof HTMLElement) content.style.display = this.contentStyle;
65
+ this.setAttribute(this.contentAtt, content?.innerHTML ?? this.defaultContent);
66
+
67
+ new Popover(this);
68
+ }
69
+
70
+ render() {
71
+ return html`<slot></slot>`;
72
+ }
26
73
  }
@@ -0,0 +1,15 @@
1
+ import { LitElement } from 'lit';
2
+ export declare class QboSSN extends LitElement {
3
+ apiEndpoint: string;
4
+ contactId: String | null;
5
+ disabled: boolean;
6
+ formControlSmallClass: String | null;
7
+ name: String | null;
8
+ show: boolean;
9
+ ssn: String | null;
10
+ url: String | null;
11
+ renderInHost: boolean;
12
+ createRenderRoot(): HTMLElement | DocumentFragment;
13
+ toggleSSN(): Promise<void>;
14
+ render(): import("lit-html").TemplateResult<1>;
15
+ }
@@ -0,0 +1,106 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ var __metadata = (this && this.__metadata) || function (k, v) {
8
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
9
+ };
10
+ import { html, LitElement } from 'lit';
11
+ import { customElement, property } from 'lit/decorators.js';
12
+ import { services } from '@quandis/qbo4.configuration';
13
+ import { RestApiService } from './RestApiService.js';
14
+ let QboSSN = class QboSSN extends LitElement {
15
+ constructor() {
16
+ super(...arguments);
17
+ this.apiEndpoint = 'qbo';
18
+ this.contactId = null;
19
+ this.disabled = true;
20
+ this.formControlSmallClass = 'qbo-sm';
21
+ this.name = 'USSSN';
22
+ this.show = false;
23
+ this.ssn = null;
24
+ this.url = 'contact/UnmaskSSN';
25
+ this.renderInHost = true;
26
+ }
27
+ createRenderRoot() {
28
+ return this.renderInHost ? this : super.createRenderRoot();
29
+ }
30
+ async toggleSSN() {
31
+ this.show = !this.show;
32
+ if (this.show) {
33
+ const service = services.container.isRegistered(this.apiEndpoint)
34
+ ? services.container.resolve(this.apiEndpoint) : new RestApiService(this.apiEndpoint);
35
+ const json = await service.fetch(`${this.url}`, { ID: `${this.contactId}` });
36
+ this.renderRoot.querySelectorAll('input').forEach(input => {
37
+ if (input instanceof HTMLInputElement) {
38
+ if (json?.ContactCollection?.length > 0 && json.ContactCollection[0].USSSN != null && json.ContactCollection[0].USSSN.length == 9) {
39
+ const ssn = json.ContactCollection[0].USSSN;
40
+ input.value = `${ssn.substring(0, 3)}-${ssn.substring(3, 5)}-${ssn.substring(5, 9)}`;
41
+ this.renderRoot.querySelectorAll('i').forEach(i => {
42
+ i.className = 'bi bi-eye-slash';
43
+ });
44
+ }
45
+ }
46
+ });
47
+ }
48
+ else {
49
+ this.renderRoot.querySelectorAll('input').forEach(input => {
50
+ if (input instanceof HTMLInputElement)
51
+ input.value = `${this.ssn}`;
52
+ this.renderRoot.querySelectorAll('i').forEach(i => {
53
+ i.className = 'bi bi-eye';
54
+ });
55
+ });
56
+ }
57
+ }
58
+ render() {
59
+ return html `<slot>
60
+ <div class="input-group">
61
+ <input type="text" ?disabled=${this.disabled} class="${this.formControlSmallClass}" name="${this.name}" value="${this.ssn}"/>
62
+ <span @click="${this.toggleSSN}" class="input-group-text" style="cursor:pointer;"><i class="bi bi-eye"></i></span>
63
+ </div>
64
+ </slot>`;
65
+ }
66
+ };
67
+ __decorate([
68
+ property({ type: String }),
69
+ __metadata("design:type", Object)
70
+ ], QboSSN.prototype, "apiEndpoint", void 0);
71
+ __decorate([
72
+ property({ type: String }),
73
+ __metadata("design:type", Object)
74
+ ], QboSSN.prototype, "contactId", void 0);
75
+ __decorate([
76
+ property({ type: Boolean }),
77
+ __metadata("design:type", Object)
78
+ ], QboSSN.prototype, "disabled", void 0);
79
+ __decorate([
80
+ property({ type: String }),
81
+ __metadata("design:type", Object)
82
+ ], QboSSN.prototype, "formControlSmallClass", void 0);
83
+ __decorate([
84
+ property({ type: String }),
85
+ __metadata("design:type", Object)
86
+ ], QboSSN.prototype, "name", void 0);
87
+ __decorate([
88
+ property({ type: Boolean }),
89
+ __metadata("design:type", Object)
90
+ ], QboSSN.prototype, "show", void 0);
91
+ __decorate([
92
+ property({ type: String }),
93
+ __metadata("design:type", Object)
94
+ ], QboSSN.prototype, "ssn", void 0);
95
+ __decorate([
96
+ property({ type: String }),
97
+ __metadata("design:type", Object)
98
+ ], QboSSN.prototype, "url", void 0);
99
+ __decorate([
100
+ property({ type: Boolean }),
101
+ __metadata("design:type", Object)
102
+ ], QboSSN.prototype, "renderInHost", void 0);
103
+ QboSSN = __decorate([
104
+ customElement('qbo-ssn')
105
+ ], QboSSN);
106
+ export { QboSSN };
@@ -0,0 +1,80 @@
1
+ import { html, LitElement } from 'lit';
2
+ import { customElement, property } from 'lit/decorators.js';
3
+ import { IApiService } from './IApiService.js';
4
+ import { services } from '@quandis/qbo4.configuration';
5
+ import { RestApiService } from './RestApiService.js';
6
+
7
+ @customElement('qbo-ssn')
8
+ export class QboSSN extends LitElement {
9
+
10
+ @property({ type: String })
11
+ apiEndpoint = 'qbo';
12
+
13
+ @property({ type: String })
14
+ contactId: String | null = null;
15
+
16
+ @property({ type: Boolean })
17
+ disabled = true;
18
+
19
+ @property({ type: String })
20
+ formControlSmallClass: String | null = 'qbo-sm';
21
+
22
+ @property({ type: String })
23
+ name: String | null = 'USSSN';
24
+
25
+ @property({ type: Boolean })
26
+ show = false;
27
+
28
+ @property({ type: String })
29
+ ssn: String | null = null;
30
+
31
+ @property({ type: String })
32
+ url: String | null = 'contact/UnmaskSSN';
33
+
34
+ @property({ type: Boolean })
35
+ renderInHost = true;
36
+
37
+ createRenderRoot() {
38
+ return this.renderInHost ? this : super.createRenderRoot();
39
+ }
40
+
41
+ async toggleSSN() {
42
+ this.show = !this.show;
43
+
44
+ if (this.show) {
45
+ const service: IApiService = services.container.isRegistered(this.apiEndpoint)
46
+ ? services.container.resolve<IApiService>(this.apiEndpoint) : new RestApiService(this.apiEndpoint);
47
+ const json = await service.fetch(`${this.url}`, { ID: `${this.contactId}` });
48
+
49
+ this.renderRoot.querySelectorAll('input').forEach(input => {
50
+ if (input instanceof HTMLInputElement) {
51
+ if (json?.ContactCollection?.length > 0 && json.ContactCollection[0].USSSN != null && json.ContactCollection[0].USSSN.length == 9) {
52
+ const ssn = json.ContactCollection[0].USSSN;
53
+ input.value = `${ssn.substring(0, 3)}-${ssn.substring(3, 5)}-${ssn.substring(5, 9)}`;
54
+
55
+ this.renderRoot.querySelectorAll('i').forEach(i => {
56
+ i.className = 'bi bi-eye-slash';
57
+ });
58
+ }
59
+ }
60
+ });
61
+ } else {
62
+ this.renderRoot.querySelectorAll('input').forEach(input => {
63
+ if (input instanceof HTMLInputElement) input.value = `${this.ssn}`;
64
+
65
+ this.renderRoot.querySelectorAll('i').forEach(i => {
66
+ i.className = 'bi bi-eye';
67
+ });
68
+ });
69
+ }
70
+ }
71
+
72
+ render() {
73
+ return html`<slot>
74
+ <div class="input-group">
75
+ <input type="text" ?disabled=${this.disabled} class="${this.formControlSmallClass}" name="${this.name}" value="${this.ssn}"/>
76
+ <span @click="${this.toggleSSN}" class="input-group-text" style="cursor:pointer;"><i class="bi bi-eye"></i></span>
77
+ </div>
78
+ </slot>`;
79
+ }
80
+ }