@quandis/qbo4.messages 4.0.1-CI-20250107-192804 → 4.0.1-CI-20250107-224931

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.
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "author": "Quandis, Inc.",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
- "version": "4.0.1-CI-20250107-192804",
6
+ "version": "4.0.1-CI-20250107-224931",
7
7
  "workspaces": [
8
8
  "code"
9
9
  ],
@@ -2,6 +2,8 @@ declare const QboMessage_base: (new (...args: any[]) => import("@quandis/qbo4.ui
2
2
  export declare class QboMessage extends QboMessage_base {
3
3
  static styles: import("lit").CSSResult[];
4
4
  apiEndpoint: URL;
5
+ display: number;
6
+ start: number;
5
7
  imagePath: any;
6
8
  renderInHost: boolean;
7
9
  show: boolean;
@@ -16,6 +16,8 @@ export class QboMessage extends QboFetchMixin(QboTemplate) {
16
16
  constructor() {
17
17
  super(...arguments);
18
18
  this.apiEndpoint = new URL("api://qbo4/messages/message");
19
+ this.display = 25;
20
+ this.start = 0;
19
21
  this.imagePath = window.qbo4['imagePath'] ?? '/ui/images/qbo-icons.svg';
20
22
  this.renderInHost = false;
21
23
  this.show = true;
@@ -51,7 +53,13 @@ export class QboMessage extends QboFetchMixin(QboTemplate) {
51
53
  this.payload = {};
52
54
  this.payload['DisplaySize'] = e.detail['display'];
53
55
  this.payload['RecordStart'] = e.detail['start'];
54
- await this.fetchData(this.headers ?? {}, this.payload);
56
+ const currentDisplay = this.display;
57
+ this.display = Number(this.payload['DisplaySize']);
58
+ const currentStart = this.start;
59
+ this.start = Number(this.payload['RecordStart']);
60
+ const count = Number(getArray(this.jsonData)?.[0]?.RecordCount) || 0;
61
+ if (count > 0 && (currentDisplay != this.display || currentStart != this.start))
62
+ await this.fetchData(this.headers ?? {}, this.payload);
55
63
  }
56
64
  view(message, e) {
57
65
  e.preventDefault();
@@ -62,11 +70,9 @@ export class QboMessage extends QboFetchMixin(QboTemplate) {
62
70
  }
63
71
  search(component) {
64
72
  const json = getArray(component.jsonData);
65
- const count = Number(json?.[0]?.RecordCount) || json?.length || 25;
66
- const sorted = json ? json
67
- .filter(item => item?.UpdatedDate)
68
- .sort((a, b) => new Date(b.UpdatedDate).getTime() - new Date(a.UpdatedDate).getTime())
69
- : [];
73
+ const count = Number(json?.[0]?.RecordCount) || json?.length || 0;
74
+ const length = json?.length || 0;
75
+ const jsonPage = length > component.display ? json?.slice(component.start, component.start + component.display) : json;
70
76
  return html `<slot class=${component.show ? '' : 'collapse'}>
71
77
  <h3 class="title">
72
78
  <button type="button" class="expandcollapse" @click="${(e) => component.show = !component.show}">
@@ -90,7 +96,7 @@ export class QboMessage extends QboFetchMixin(QboTemplate) {
90
96
  </tr>
91
97
  </thead>
92
98
  <tbody>
93
- ${json ? json.map(item => html `
99
+ ${jsonPage ? jsonPage.map(item => html `
94
100
  <tr>
95
101
  ${component?.showInline
96
102
  ? html `<td><a href="/api/message/${item.MessageID}" @click=${(e) => component.view(item, e)}>${item.Message ?? item.BodyText}</a></td>`
@@ -132,6 +138,14 @@ __decorate([
132
138
  property({ type: URL }),
133
139
  __metadata("design:type", Object)
134
140
  ], QboMessage.prototype, "apiEndpoint", void 0);
141
+ __decorate([
142
+ property({ type: Number }),
143
+ __metadata("design:type", Object)
144
+ ], QboMessage.prototype, "display", void 0);
145
+ __decorate([
146
+ property({ type: Number }),
147
+ __metadata("design:type", Object)
148
+ ], QboMessage.prototype, "start", void 0);
135
149
  __decorate([
136
150
  property({ type: String }),
137
151
  __metadata("design:type", Object)
@@ -14,6 +14,12 @@ export class QboMessage extends QboFetchMixin(QboTemplate) {
14
14
  @property({ type: URL })
15
15
  apiEndpoint = new URL("api://qbo4/messages/message");
16
16
 
17
+ @property({ type: Number })
18
+ display = 25;
19
+
20
+ @property({ type: Number })
21
+ start = 0;
22
+
17
23
  @property({ type: String })
18
24
  imagePath = window.qbo4['imagePath'] ?? '/ui/images/qbo-icons.svg';
19
25
 
@@ -61,7 +67,15 @@ export class QboMessage extends QboFetchMixin(QboTemplate) {
61
67
 
62
68
  this.payload['DisplaySize'] = e.detail['display'];
63
69
  this.payload['RecordStart'] = e.detail['start'];
64
- await this.fetchData(this.headers ?? {}, this.payload);
70
+
71
+ const currentDisplay: Number = this.display;
72
+ this.display = Number(this.payload['DisplaySize']);
73
+ const currentStart: Number = this.start;
74
+ this.start = Number(this.payload['RecordStart']);
75
+
76
+ const count = Number(getArray(this.jsonData)?.[0]?.RecordCount) || 0;
77
+ if (count > 0 && (currentDisplay != this.display || currentStart != this.start))
78
+ await this.fetchData(this.headers ?? {}, this.payload);
65
79
  }
66
80
 
67
81
  view(message: any, e: Event) {
@@ -76,11 +90,9 @@ export class QboMessage extends QboFetchMixin(QboTemplate) {
76
90
  @template('search')
77
91
  search(component: QboMessage) {
78
92
  const json = getArray(component.jsonData);
79
- const count: number = Number(json?.[0]?.RecordCount) || json?.length || 25;
80
- const sorted = json? json
81
- .filter(item => item?.UpdatedDate)
82
- .sort((a, b) => new Date(b.UpdatedDate).getTime() - new Date(a.UpdatedDate).getTime())
83
- : [];
93
+ const count: number = Number(json?.[0]?.RecordCount) || json?.length || 0;
94
+ const length = json?.length || 0;
95
+ const jsonPage = length > component.display ? json?.slice(component.start, component.start + component.display) : json;
84
96
 
85
97
  return html`<slot class=${component.show ? '' : 'collapse'}>
86
98
  <h3 class="title">
@@ -105,7 +117,7 @@ export class QboMessage extends QboFetchMixin(QboTemplate) {
105
117
  </tr>
106
118
  </thead>
107
119
  <tbody>
108
- ${json ? json.map(item => html`
120
+ ${jsonPage ? jsonPage.map(item => html`
109
121
  <tr>
110
122
  ${component?.showInline
111
123
  ? html`<td><a href="/api/message/${item.MessageID}" @click=${(e) => component.view(item, e)}>${item.Message ?? item.BodyText}</a></td>`