web-mojo 2.2.57 → 2.2.58
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/dist/admin.cjs.js +1 -1
- package/dist/admin.cjs.js.map +1 -1
- package/dist/admin.es.js +1 -10105
- package/dist/admin.es.js.map +1 -1
- package/dist/auth.cjs.js +1 -1
- package/dist/auth.es.js +1 -588
- package/dist/auth.es.js.map +1 -1
- package/dist/charts.cjs.js +1 -1
- package/dist/charts.es.js +1 -571
- package/dist/charts.es.js.map +1 -1
- package/dist/chunks/ChatView-CqkYoMmr.js +2 -0
- package/dist/chunks/{ChatView-9k6xBWXk.js.map → ChatView-CqkYoMmr.js.map} +1 -1
- package/dist/chunks/{ChatView-CdtuCDYm.js → ChatView-DFN9xt0c.js} +2 -2
- package/dist/chunks/{ChatView-CdtuCDYm.js.map → ChatView-DFN9xt0c.js.map} +1 -1
- package/dist/chunks/Collection-1sPoIFvQ.js +2 -0
- package/dist/chunks/{Collection-DaiL0uGl.js.map → Collection-1sPoIFvQ.js.map} +1 -1
- package/dist/chunks/{Collection-CxbNKOas.js → Collection-DSBRXpwK.js} +2 -2
- package/dist/chunks/{Collection-CxbNKOas.js.map → Collection-DSBRXpwK.js.map} +1 -1
- package/dist/chunks/{ContextMenu-ClwHEbbD.js → ContextMenu-BWy7WqF4.js} +2 -2
- package/dist/chunks/{ContextMenu-ClwHEbbD.js.map → ContextMenu-BWy7WqF4.js.map} +1 -1
- package/dist/chunks/ContextMenu-BvniQz-N.js +3 -0
- package/dist/chunks/{ContextMenu-sgvgSACY.js.map → ContextMenu-BvniQz-N.js.map} +1 -1
- package/dist/chunks/DataView--nUWtq6r.js +2 -0
- package/dist/chunks/{DataView-Dzo0jbs2.js.map → DataView--nUWtq6r.js.map} +1 -1
- package/dist/chunks/{DataView-1xh3GFeC.js → DataView-CK3Z0TJH.js} +2 -2
- package/dist/chunks/{DataView-1xh3GFeC.js.map → DataView-CK3Z0TJH.js.map} +1 -1
- package/dist/chunks/Dialog-BcgSR01Z.js +2 -0
- package/dist/chunks/{Dialog-DOGDalUq.js.map → Dialog-BcgSR01Z.js.map} +1 -1
- package/dist/chunks/{Dialog-CQlTDhZS.js → Dialog-DwCTFV6O.js} +2 -2
- package/dist/chunks/{Dialog-CQlTDhZS.js.map → Dialog-DwCTFV6O.js.map} +1 -1
- package/dist/chunks/FormPlugins-DvQ-G5J5.js +2 -0
- package/dist/chunks/{FormPlugins-DY6e88YT.js.map → FormPlugins-DvQ-G5J5.js.map} +1 -1
- package/dist/chunks/{FormView-DaKA4Sys.js → FormView-CRmEReTC.js} +3 -3
- package/dist/chunks/{FormView-DaKA4Sys.js.map → FormView-CRmEReTC.js.map} +1 -1
- package/dist/chunks/FormView-OLA7t-yv.js +3 -0
- package/dist/chunks/{FormView-Dz3mYasQ.js.map → FormView-OLA7t-yv.js.map} +1 -1
- package/dist/chunks/ListView-6JQ6tRXs.js +2 -0
- package/dist/chunks/{ListView-X5w5jf51.js.map → ListView-6JQ6tRXs.js.map} +1 -1
- package/dist/chunks/{ListView-CDzKIpd8.js → ListView-DVStKiMi.js} +2 -2
- package/dist/chunks/{ListView-CDzKIpd8.js.map → ListView-DVStKiMi.js.map} +1 -1
- package/dist/chunks/{MetricsCountryMapView-Dx2cw7ya.js → MetricsCountryMapView-CnAEbUw_.js} +2 -2
- package/dist/chunks/{MetricsCountryMapView-Dx2cw7ya.js.map → MetricsCountryMapView-CnAEbUw_.js.map} +1 -1
- package/dist/chunks/MetricsCountryMapView-J067qrrt.js +2 -0
- package/dist/chunks/{MetricsCountryMapView-B2xz6zUw.js.map → MetricsCountryMapView-J067qrrt.js.map} +1 -1
- package/dist/chunks/{MetricsMiniChartWidget-CBuso0OE.js → MetricsMiniChartWidget-BeD1slGs.js} +2 -2
- package/dist/chunks/{MetricsMiniChartWidget-CBuso0OE.js.map → MetricsMiniChartWidget-BeD1slGs.js.map} +1 -1
- package/dist/chunks/MetricsMiniChartWidget-x2gFjHOU.js +2 -0
- package/dist/chunks/{MetricsMiniChartWidget-DvKd7Qrk.js.map → MetricsMiniChartWidget-x2gFjHOU.js.map} +1 -1
- package/dist/chunks/PDFViewer-CsyKn-gh.js +2 -0
- package/dist/chunks/{PDFViewer-EJ9cOfPF.js.map → PDFViewer-CsyKn-gh.js.map} +1 -1
- package/dist/chunks/{PDFViewer-ofMGdSaj.js → PDFViewer-DSa4BZCm.js} +2 -2
- package/dist/chunks/{PDFViewer-ofMGdSaj.js.map → PDFViewer-DSa4BZCm.js.map} +1 -1
- package/dist/chunks/Rest-DHbszkuP.js +2 -0
- package/dist/chunks/Rest-DHbszkuP.js.map +1 -0
- package/dist/chunks/Rest-Ds9e8tN8.js +2 -0
- package/dist/chunks/Rest-Ds9e8tN8.js.map +1 -0
- package/dist/chunks/TokenManager-D6SjKgPZ.js +2 -0
- package/dist/chunks/{TokenManager-DoN9e6q6.js.map → TokenManager-D6SjKgPZ.js.map} +1 -1
- package/dist/chunks/{TokenManager-Gqvj7SDX.js → TokenManager-REbha1Le.js} +2 -2
- package/dist/chunks/{TokenManager-Gqvj7SDX.js.map → TokenManager-REbha1Le.js.map} +1 -1
- package/dist/chunks/WebApp-CULZpO_0.js +2 -0
- package/dist/chunks/{WebApp-6qvqmOts.js.map → WebApp-CULZpO_0.js.map} +1 -1
- package/dist/chunks/{WebApp-_dgpwtFw.js → WebApp-DovLtA60.js} +2 -2
- package/dist/chunks/{WebApp-_dgpwtFw.js.map → WebApp-DovLtA60.js.map} +1 -1
- package/dist/chunks/WebSocketClient-B-wc3mez.js +2 -0
- package/dist/chunks/{WebSocketClient-DG2olXpH.js.map → WebSocketClient-B-wc3mez.js.map} +1 -1
- package/dist/chunks/{WebSocketClient-MFkFlSue.js → WebSocketClient-BdZ9QYll.js} +2 -2
- package/dist/chunks/{WebSocketClient-MFkFlSue.js.map → WebSocketClient-BdZ9QYll.js.map} +1 -1
- package/dist/chunks/version-CU1HG1XH.js +2 -0
- package/dist/chunks/version-CU1HG1XH.js.map +1 -0
- package/dist/chunks/{version-BVADfTA5.js → version-DaB1uXvO.js} +2 -2
- package/dist/chunks/{version-BVADfTA5.js.map → version-DaB1uXvO.js.map} +1 -1
- package/dist/css/web-mojo.css +1 -1
- package/dist/docit.cjs.js +1 -1
- package/dist/docit.es.js +1 -957
- package/dist/docit.es.js.map +1 -1
- package/dist/index.cjs.js +1 -1
- package/dist/index.es.js +1 -3252
- package/dist/index.es.js.map +1 -1
- package/dist/lightbox.cjs.js +1 -1
- package/dist/lightbox.es.js +1 -3737
- package/dist/lightbox.es.js.map +1 -1
- package/dist/loader.umd.js +2 -2
- package/dist/map.cjs.js +1 -1
- package/dist/map.es.js +1 -1032
- package/dist/map.es.js.map +1 -1
- package/dist/mojo-auth.es.js +338 -0
- package/dist/mojo-auth.umd.js +1 -0
- package/dist/timeline.cjs.js +1 -1
- package/dist/timeline.es.js +1 -224
- package/dist/timeline.es.js.map +1 -1
- package/dist/web-mojo.lite.iife.js +14 -3
- package/dist/web-mojo.lite.iife.js.map +1 -1
- package/dist/web-mojo.lite.iife.min.js +6 -6
- package/dist/web-mojo.lite.iife.min.js.map +1 -1
- package/package.json +2 -2
- package/dist/chunks/ChatView-9k6xBWXk.js +0 -7632
- package/dist/chunks/Collection-DaiL0uGl.js +0 -1014
- package/dist/chunks/ContextMenu-sgvgSACY.js +0 -1535
- package/dist/chunks/DataView-Dzo0jbs2.js +0 -862
- package/dist/chunks/Dialog-DOGDalUq.js +0 -1579
- package/dist/chunks/FormPlugins-DY6e88YT.js +0 -124
- package/dist/chunks/FormView-Dz3mYasQ.js +0 -8636
- package/dist/chunks/ListView-X5w5jf51.js +0 -495
- package/dist/chunks/MetricsCountryMapView-B2xz6zUw.js +0 -1054
- package/dist/chunks/MetricsMiniChartWidget-DvKd7Qrk.js +0 -3283
- package/dist/chunks/PDFViewer-EJ9cOfPF.js +0 -946
- package/dist/chunks/Rest-CgSjfMaU.js +0 -2
- package/dist/chunks/Rest-CgSjfMaU.js.map +0 -1
- package/dist/chunks/Rest-W-sPfGh9.js +0 -4375
- package/dist/chunks/Rest-W-sPfGh9.js.map +0 -1
- package/dist/chunks/TokenManager-DoN9e6q6.js +0 -1423
- package/dist/chunks/WebApp-6qvqmOts.js +0 -1386
- package/dist/chunks/WebSocketClient-DG2olXpH.js +0 -209
- package/dist/chunks/version-OyPGnx30.js +0 -38
- package/dist/chunks/version-OyPGnx30.js.map +0 -1
|
@@ -1,495 +0,0 @@
|
|
|
1
|
-
import { V as View } from "./Rest-W-sPfGh9.js";
|
|
2
|
-
import { C as Collection } from "./Collection-DaiL0uGl.js";
|
|
3
|
-
class ListViewItem extends View {
|
|
4
|
-
constructor(options = {}) {
|
|
5
|
-
super({
|
|
6
|
-
className: "list-view-item",
|
|
7
|
-
...options
|
|
8
|
-
});
|
|
9
|
-
this.selected = false;
|
|
10
|
-
this.index = options.index ?? 0;
|
|
11
|
-
this.listView = options.listView ?? null;
|
|
12
|
-
if (!this.template) {
|
|
13
|
-
this.template = `
|
|
14
|
-
<div class="list-item-content" data-action="select">
|
|
15
|
-
{{#model}}
|
|
16
|
-
{{#id}}<span class="item-id">{{id}}</span>{{/id}}
|
|
17
|
-
{{#name}}<span class="item-name">{{name}}</span>{{/name}}
|
|
18
|
-
{{#title}}<span class="item-title">{{title}}</span>{{/title}}
|
|
19
|
-
{{#label}}<span class="item-label">{{label}}</span>{{/label}}
|
|
20
|
-
{{#description}}<p class="item-description">{{description}}</p>{{/description}}
|
|
21
|
-
{{/model}}
|
|
22
|
-
{{^model}}
|
|
23
|
-
<span class="item-empty">No data</span>
|
|
24
|
-
{{/model}}
|
|
25
|
-
</div>
|
|
26
|
-
`;
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* Handle item selection action
|
|
31
|
-
*/
|
|
32
|
-
async onActionSelect(event, _element) {
|
|
33
|
-
event.stopPropagation();
|
|
34
|
-
if (this.selected) {
|
|
35
|
-
this.deselect();
|
|
36
|
-
} else {
|
|
37
|
-
this.select();
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
/**
|
|
41
|
-
* Select this item
|
|
42
|
-
*/
|
|
43
|
-
select() {
|
|
44
|
-
if (this.selected) return;
|
|
45
|
-
this.selected = true;
|
|
46
|
-
this.addClass("selected");
|
|
47
|
-
this.emit("item:select", {
|
|
48
|
-
item: this,
|
|
49
|
-
model: this.model,
|
|
50
|
-
index: this.index,
|
|
51
|
-
data: this.model?.toJSON ? this.model.toJSON() : this.model
|
|
52
|
-
});
|
|
53
|
-
if (this.listView) {
|
|
54
|
-
this.listView.emit("item:select", {
|
|
55
|
-
item: this,
|
|
56
|
-
model: this.model,
|
|
57
|
-
index: this.index,
|
|
58
|
-
data: this.model?.toJSON ? this.model.toJSON() : this.model
|
|
59
|
-
});
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
/**
|
|
63
|
-
* Deselect this item
|
|
64
|
-
*/
|
|
65
|
-
deselect() {
|
|
66
|
-
if (!this.selected) return;
|
|
67
|
-
this.selected = false;
|
|
68
|
-
this.removeClass("selected");
|
|
69
|
-
this.emit("item:deselect", {
|
|
70
|
-
item: this,
|
|
71
|
-
model: this.model,
|
|
72
|
-
index: this.index,
|
|
73
|
-
data: this.model?.toJSON ? this.model.toJSON() : this.model
|
|
74
|
-
});
|
|
75
|
-
if (this.listView) {
|
|
76
|
-
this.listView.emit("item:deselect", {
|
|
77
|
-
item: this,
|
|
78
|
-
model: this.model,
|
|
79
|
-
index: this.index,
|
|
80
|
-
data: this.model?.toJSON ? this.model.toJSON() : this.model
|
|
81
|
-
});
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
/**
|
|
85
|
-
* Handle click events on the item
|
|
86
|
-
*/
|
|
87
|
-
async onActionDefault(action, _event, _element) {
|
|
88
|
-
this.emit("item:click", {
|
|
89
|
-
item: this,
|
|
90
|
-
model: this.model,
|
|
91
|
-
index: this.index,
|
|
92
|
-
action,
|
|
93
|
-
data: this.model?.toJSON ? this.model.toJSON() : this.model
|
|
94
|
-
});
|
|
95
|
-
if (this.listView) {
|
|
96
|
-
this.listView.emit("item:click", {
|
|
97
|
-
item: this,
|
|
98
|
-
model: this.model,
|
|
99
|
-
index: this.index,
|
|
100
|
-
action,
|
|
101
|
-
data: this.model?.toJSON ? this.model.toJSON() : this.model
|
|
102
|
-
});
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
/**
|
|
106
|
-
* Set the item's index in the list
|
|
107
|
-
*/
|
|
108
|
-
setIndex(index) {
|
|
109
|
-
this.index = index;
|
|
110
|
-
this.element.setAttribute("data-index", index);
|
|
111
|
-
return this;
|
|
112
|
-
}
|
|
113
|
-
/**
|
|
114
|
-
* Update the item's selection state
|
|
115
|
-
*/
|
|
116
|
-
setSelected(selected) {
|
|
117
|
-
if (selected) {
|
|
118
|
-
this.select();
|
|
119
|
-
} else {
|
|
120
|
-
this.deselect();
|
|
121
|
-
}
|
|
122
|
-
return this;
|
|
123
|
-
}
|
|
124
|
-
/**
|
|
125
|
-
* Override destroy to clean up references
|
|
126
|
-
*/
|
|
127
|
-
async destroy() {
|
|
128
|
-
this.listView = null;
|
|
129
|
-
await super.destroy();
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
class ListView extends View {
|
|
133
|
-
constructor(options = {}) {
|
|
134
|
-
super({
|
|
135
|
-
className: "list-view",
|
|
136
|
-
template: `
|
|
137
|
-
<div class="list-view-container">
|
|
138
|
-
{{#loading}}
|
|
139
|
-
<div class="list-loading">
|
|
140
|
-
<div class="spinner-border spinner-border-sm" role="status">
|
|
141
|
-
<span class="visually-hidden">Loading...</span>
|
|
142
|
-
</div>
|
|
143
|
-
Loading...
|
|
144
|
-
</div>
|
|
145
|
-
{{/loading}}
|
|
146
|
-
{{^loading}}
|
|
147
|
-
{{#isEmpty}}
|
|
148
|
-
<div class="list-empty">
|
|
149
|
-
{{emptyMessage}}
|
|
150
|
-
</div>
|
|
151
|
-
{{/isEmpty}}
|
|
152
|
-
{{^isEmpty}}
|
|
153
|
-
<div class="list-items" data-container="items"></div>
|
|
154
|
-
{{/isEmpty}}
|
|
155
|
-
{{/loading}}
|
|
156
|
-
</div>
|
|
157
|
-
`,
|
|
158
|
-
...options
|
|
159
|
-
});
|
|
160
|
-
this.collection = null;
|
|
161
|
-
this.itemViews = /* @__PURE__ */ new Map();
|
|
162
|
-
this.selectedItems = /* @__PURE__ */ new Set();
|
|
163
|
-
this.itemTemplate = options.itemTemplate || null;
|
|
164
|
-
this.itemClass = options.itemClass || ListViewItem;
|
|
165
|
-
this.selectionMode = options.selectionMode || "none";
|
|
166
|
-
this.emptyMessage = options.emptyMessage || "No items to display";
|
|
167
|
-
this.loading = false;
|
|
168
|
-
this.isEmpty = true;
|
|
169
|
-
}
|
|
170
|
-
/**
|
|
171
|
-
* Override onInit to set up initial state
|
|
172
|
-
*/
|
|
173
|
-
async onInit() {
|
|
174
|
-
this._initCollection(this.options.collection || this.options.Collection);
|
|
175
|
-
}
|
|
176
|
-
/**
|
|
177
|
-
* Initialize the collection
|
|
178
|
-
*/
|
|
179
|
-
_initCollection(collectionOrClass) {
|
|
180
|
-
if (!collectionOrClass) {
|
|
181
|
-
console.log("Collection not provided");
|
|
182
|
-
return;
|
|
183
|
-
}
|
|
184
|
-
if (collectionOrClass instanceof Collection) {
|
|
185
|
-
this.setCollection(collectionOrClass);
|
|
186
|
-
} else if (typeof collectionOrClass === "function") {
|
|
187
|
-
const collection = new collectionOrClass();
|
|
188
|
-
this.setCollection(collection);
|
|
189
|
-
} else if (Array.isArray(collectionOrClass)) {
|
|
190
|
-
const collection = new Collection(null, {}, collectionOrClass);
|
|
191
|
-
this.setCollection(collection);
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
/**
|
|
195
|
-
* Set the collection for this list view
|
|
196
|
-
*/
|
|
197
|
-
setCollection(collection) {
|
|
198
|
-
if (this.collection === collection) return this;
|
|
199
|
-
if (this.collection) {
|
|
200
|
-
this.collection.off("add", this._onModelsAdded, this);
|
|
201
|
-
this.collection.off("remove", this._onModelsRemoved, this);
|
|
202
|
-
this.collection.off("reset", this._onCollectionReset, this);
|
|
203
|
-
this.collection.off("fetch:start", this._onFetchStart, this);
|
|
204
|
-
this.collection.off("fetch:end", this._onFetchEnd, this);
|
|
205
|
-
}
|
|
206
|
-
this.collection = collection;
|
|
207
|
-
if (this.options.defaultQuery && !this.options.collectionParams) {
|
|
208
|
-
this.collection.params = { ...this.collection.params, ...this.options.defaultQuery };
|
|
209
|
-
}
|
|
210
|
-
if (this.options.collectionParams) {
|
|
211
|
-
this.collection.params = { ...this.collection.params, ...this.options.collectionParams };
|
|
212
|
-
}
|
|
213
|
-
if (this.collection) {
|
|
214
|
-
this.collection.on("add", this._onModelsAdded, this);
|
|
215
|
-
this.collection.on("remove", this._onModelsRemoved, this);
|
|
216
|
-
this.collection.on("reset", this._onCollectionReset, this);
|
|
217
|
-
this.collection.on("fetch:start", this._onFetchStart, this);
|
|
218
|
-
this.collection.on("fetch:end", this._onFetchEnd, this);
|
|
219
|
-
this._buildItems();
|
|
220
|
-
}
|
|
221
|
-
return this;
|
|
222
|
-
}
|
|
223
|
-
async _renderChildren() {
|
|
224
|
-
await super._renderChildren();
|
|
225
|
-
const itemsContainer = this.getChildElement("items");
|
|
226
|
-
if (!itemsContainer) {
|
|
227
|
-
return;
|
|
228
|
-
}
|
|
229
|
-
this.forEachItem((item, index) => {
|
|
230
|
-
itemsContainer.appendChild(item.element);
|
|
231
|
-
item.render(false);
|
|
232
|
-
});
|
|
233
|
-
}
|
|
234
|
-
/**
|
|
235
|
-
* Build item views for all models in collection
|
|
236
|
-
*/
|
|
237
|
-
_buildItems() {
|
|
238
|
-
this._clearItems();
|
|
239
|
-
if (!this.collection || this.collection.isEmpty()) {
|
|
240
|
-
this.isEmpty = true;
|
|
241
|
-
this.emit("list:empty");
|
|
242
|
-
return;
|
|
243
|
-
}
|
|
244
|
-
this.isEmpty = false;
|
|
245
|
-
this.collection.forEach((model, index) => {
|
|
246
|
-
this._createItemView(model, index);
|
|
247
|
-
});
|
|
248
|
-
this.emit("list:loaded", { count: this.collection.length() });
|
|
249
|
-
if (this.isMounted()) {
|
|
250
|
-
this.render();
|
|
251
|
-
}
|
|
252
|
-
}
|
|
253
|
-
/**
|
|
254
|
-
* Create an item view for a model
|
|
255
|
-
* The itemTemplate is passed as the template option to the itemClass constructor
|
|
256
|
-
*/
|
|
257
|
-
_createItemView(model, index) {
|
|
258
|
-
if (this.itemViews.has(model.id)) return;
|
|
259
|
-
const itemView = new this.itemClass({
|
|
260
|
-
model,
|
|
261
|
-
index,
|
|
262
|
-
listView: this,
|
|
263
|
-
template: this.itemTemplate
|
|
264
|
-
// Pass the itemTemplate to the item view
|
|
265
|
-
});
|
|
266
|
-
this.itemViews.set(model.id, itemView);
|
|
267
|
-
itemView.on("item:select", this._onItemSelect.bind(this));
|
|
268
|
-
itemView.on("item:deselect", this._onItemDeselect.bind(this));
|
|
269
|
-
return itemView;
|
|
270
|
-
}
|
|
271
|
-
/**
|
|
272
|
-
* Clear all item views
|
|
273
|
-
*/
|
|
274
|
-
_clearItems() {
|
|
275
|
-
this.forEachItem((itemView) => {
|
|
276
|
-
this.removeChild(itemView.id);
|
|
277
|
-
});
|
|
278
|
-
this.itemViews.clear();
|
|
279
|
-
this.selectedItems.clear();
|
|
280
|
-
}
|
|
281
|
-
/**
|
|
282
|
-
* Handle models added to collection
|
|
283
|
-
*/
|
|
284
|
-
_onModelsAdded(event) {
|
|
285
|
-
const { models } = event;
|
|
286
|
-
models.forEach((model) => {
|
|
287
|
-
const index = this.collection.models.indexOf(model);
|
|
288
|
-
this._createItemView(model, index);
|
|
289
|
-
});
|
|
290
|
-
this.isEmpty = this.collection.isEmpty();
|
|
291
|
-
if (!this.loading && this.isMounted()) {
|
|
292
|
-
this.render();
|
|
293
|
-
}
|
|
294
|
-
}
|
|
295
|
-
/**
|
|
296
|
-
* Handle models removed from collection
|
|
297
|
-
*/
|
|
298
|
-
_onModelsRemoved(event) {
|
|
299
|
-
const { models } = event;
|
|
300
|
-
models.forEach((model) => {
|
|
301
|
-
const itemView = this.itemViews.get(model.id);
|
|
302
|
-
if (itemView) {
|
|
303
|
-
this.removeChild(itemView.id);
|
|
304
|
-
this.itemViews.delete(model.id);
|
|
305
|
-
this.selectedItems.delete(model.id);
|
|
306
|
-
}
|
|
307
|
-
});
|
|
308
|
-
this.isEmpty = this.collection.isEmpty();
|
|
309
|
-
if (!this.loading && this.isMounted()) {
|
|
310
|
-
this.render();
|
|
311
|
-
}
|
|
312
|
-
if (this.isEmpty) {
|
|
313
|
-
this.emit("list:empty");
|
|
314
|
-
}
|
|
315
|
-
}
|
|
316
|
-
/**
|
|
317
|
-
* Handle collection reset
|
|
318
|
-
*/
|
|
319
|
-
_onCollectionReset(_event) {
|
|
320
|
-
this._buildItems();
|
|
321
|
-
}
|
|
322
|
-
/**
|
|
323
|
-
* Handle fetch start
|
|
324
|
-
*/
|
|
325
|
-
_onFetchStart() {
|
|
326
|
-
this.loading = true;
|
|
327
|
-
if (this.isMounted()) {
|
|
328
|
-
this.render();
|
|
329
|
-
}
|
|
330
|
-
}
|
|
331
|
-
/**
|
|
332
|
-
* Handle fetch end
|
|
333
|
-
*/
|
|
334
|
-
_onFetchEnd() {
|
|
335
|
-
this.loading = false;
|
|
336
|
-
if (this.isMounted()) {
|
|
337
|
-
this.render();
|
|
338
|
-
}
|
|
339
|
-
}
|
|
340
|
-
/**
|
|
341
|
-
* Handle item selection
|
|
342
|
-
*/
|
|
343
|
-
_onItemSelect(event) {
|
|
344
|
-
const { model, item } = event;
|
|
345
|
-
if (this.selectionMode === "none") {
|
|
346
|
-
item.deselect();
|
|
347
|
-
return;
|
|
348
|
-
}
|
|
349
|
-
if (this.selectionMode === "single") {
|
|
350
|
-
this.itemViews.forEach((view, id) => {
|
|
351
|
-
if (id !== model.id && view.selected) {
|
|
352
|
-
view.deselect();
|
|
353
|
-
}
|
|
354
|
-
});
|
|
355
|
-
this.selectedItems.clear();
|
|
356
|
-
}
|
|
357
|
-
this.selectedItems.add(model.id);
|
|
358
|
-
this.emit("selection:change", {
|
|
359
|
-
selected: Array.from(this.selectedItems),
|
|
360
|
-
item,
|
|
361
|
-
model
|
|
362
|
-
});
|
|
363
|
-
}
|
|
364
|
-
/**
|
|
365
|
-
* Handle item deselection
|
|
366
|
-
*/
|
|
367
|
-
_onItemDeselect(event) {
|
|
368
|
-
const { model } = event;
|
|
369
|
-
this.selectedItems.delete(model.id);
|
|
370
|
-
this.emit("selection:change", {
|
|
371
|
-
selected: Array.from(this.selectedItems),
|
|
372
|
-
item: event.item,
|
|
373
|
-
model
|
|
374
|
-
});
|
|
375
|
-
}
|
|
376
|
-
/**
|
|
377
|
-
* Get selected items
|
|
378
|
-
*/
|
|
379
|
-
getSelectedItems() {
|
|
380
|
-
const selected = [];
|
|
381
|
-
this.selectedItems.forEach((id) => {
|
|
382
|
-
const itemView = this.itemViews.get(id);
|
|
383
|
-
if (itemView) {
|
|
384
|
-
selected.push({
|
|
385
|
-
view: itemView,
|
|
386
|
-
model: itemView.model,
|
|
387
|
-
data: itemView.model?.toJSON ? itemView.model.toJSON() : itemView.model
|
|
388
|
-
});
|
|
389
|
-
}
|
|
390
|
-
});
|
|
391
|
-
return selected;
|
|
392
|
-
}
|
|
393
|
-
/**
|
|
394
|
-
* Iterate over each item view in the list
|
|
395
|
-
* @param {function} callback - Function to execute for each item (itemView, model, index)
|
|
396
|
-
* @param {object} thisArg - Optional value to use as this when executing callback
|
|
397
|
-
* @returns {ListView} Returns the ListView for chaining
|
|
398
|
-
*/
|
|
399
|
-
forEachItem(callback, thisArg) {
|
|
400
|
-
if (typeof callback !== "function") {
|
|
401
|
-
throw new TypeError("Callback must be a function");
|
|
402
|
-
}
|
|
403
|
-
let index = 0;
|
|
404
|
-
this.itemViews.forEach((itemView, modelId) => {
|
|
405
|
-
callback.call(thisArg, itemView, itemView.model, index++);
|
|
406
|
-
});
|
|
407
|
-
return this;
|
|
408
|
-
}
|
|
409
|
-
/**
|
|
410
|
-
* Clear selection
|
|
411
|
-
*/
|
|
412
|
-
clearSelection() {
|
|
413
|
-
this.forEachItem((itemView) => {
|
|
414
|
-
if (itemView.selected) {
|
|
415
|
-
itemView.deselect();
|
|
416
|
-
}
|
|
417
|
-
});
|
|
418
|
-
this.selectedItems.clear();
|
|
419
|
-
this.emit("selection:change", {
|
|
420
|
-
selected: []
|
|
421
|
-
});
|
|
422
|
-
}
|
|
423
|
-
/**
|
|
424
|
-
* Select item by model ID
|
|
425
|
-
*/
|
|
426
|
-
selectItem(modelId) {
|
|
427
|
-
const itemView = this.itemViews.get(modelId);
|
|
428
|
-
if (itemView) {
|
|
429
|
-
itemView.select();
|
|
430
|
-
}
|
|
431
|
-
return this;
|
|
432
|
-
}
|
|
433
|
-
/**
|
|
434
|
-
* Deselect item by model ID
|
|
435
|
-
*/
|
|
436
|
-
deselectItem(modelId) {
|
|
437
|
-
const itemView = this.itemViews.get(modelId);
|
|
438
|
-
if (itemView) {
|
|
439
|
-
itemView.deselect();
|
|
440
|
-
}
|
|
441
|
-
return this;
|
|
442
|
-
}
|
|
443
|
-
/**
|
|
444
|
-
* Set or update the item template
|
|
445
|
-
* @param {string} template - New template string for items
|
|
446
|
-
* @param {boolean} rerender - Whether to re-render existing items with new template
|
|
447
|
-
* @returns {ListView} Returns the ListView for chaining
|
|
448
|
-
*/
|
|
449
|
-
setItemTemplate(template, rerender = false) {
|
|
450
|
-
this.itemTemplate = template;
|
|
451
|
-
if (rerender && this.itemViews.size > 0) {
|
|
452
|
-
this.forEachItem((itemView) => {
|
|
453
|
-
itemView.setTemplate(template);
|
|
454
|
-
if (itemView.isMounted()) {
|
|
455
|
-
itemView.render();
|
|
456
|
-
}
|
|
457
|
-
});
|
|
458
|
-
}
|
|
459
|
-
return this;
|
|
460
|
-
}
|
|
461
|
-
async onAfterMount() {
|
|
462
|
-
await super.onAfterMount();
|
|
463
|
-
if (this.collection && (this.options.fetchOnMount || !this.collection.lastFetchTime)) {
|
|
464
|
-
this.collection.fetch();
|
|
465
|
-
}
|
|
466
|
-
}
|
|
467
|
-
/**
|
|
468
|
-
* Refresh the list (re-fetch if collection supports it)
|
|
469
|
-
*/
|
|
470
|
-
async refresh() {
|
|
471
|
-
if (this.collection && this.collection.restEnabled) {
|
|
472
|
-
return await this.collection.fetch();
|
|
473
|
-
}
|
|
474
|
-
this._buildItems();
|
|
475
|
-
}
|
|
476
|
-
/**
|
|
477
|
-
* Override destroy to clean up
|
|
478
|
-
*/
|
|
479
|
-
async destroy() {
|
|
480
|
-
if (this.collection) {
|
|
481
|
-
this.collection.off("add", this._onModelsAdded, this);
|
|
482
|
-
this.collection.off("remove", this._onModelsRemoved, this);
|
|
483
|
-
this.collection.off("reset", this._onCollectionReset, this);
|
|
484
|
-
this.collection.off("fetch:start", this._onFetchStart, this);
|
|
485
|
-
this.collection.off("fetch:end", this._onFetchEnd, this);
|
|
486
|
-
}
|
|
487
|
-
this._clearItems();
|
|
488
|
-
await super.destroy();
|
|
489
|
-
}
|
|
490
|
-
}
|
|
491
|
-
export {
|
|
492
|
-
ListView as L,
|
|
493
|
-
ListViewItem as a
|
|
494
|
-
};
|
|
495
|
-
//# sourceMappingURL=ListView-X5w5jf51.js.map
|