@social-mail/social-mail-client 1.2.374 → 1.2.375
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/public/store/Store.pack.js +53 -6
- package/dist/public/store/Store.pack.js.map +1 -1
- package/dist/public/store/Store.pack.min.js +2 -2
- package/dist/public/store/Store.pack.min.js.map +1 -1
- package/dist/public/store/StoreItemListView.d.ts +8 -3
- package/dist/public/store/StoreItemListView.d.ts.map +1 -1
- package/dist/public/store/StoreItemListView.js +53 -6
- package/dist/public/store/StoreItemListView.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/public/store/StoreItemListView.tsx +39 -3
package/package.json
CHANGED
|
@@ -6,13 +6,14 @@ import AtomRepeater from "@web-atoms/web-controls/dist/basic/AtomRepeater";
|
|
|
6
6
|
import InfiniteRepeater from "../../common/controls/repeater/InfiniteRepeater";
|
|
7
7
|
import InjectProperty from "@web-atoms/core/dist/core/InjectProperty";
|
|
8
8
|
import EntityService from "../../services/EntityService";
|
|
9
|
-
import { AppFile, IStoreItem, IStoreTag, ITag, StoreItem, StoreMediaFile, StoreTag } from "../../model/model";
|
|
9
|
+
import { AppFile, IStoreItem, IStoreItemTag, IStoreTag, ITag, StoreItem, StoreMediaFile, StoreTag } from "../../model/model";
|
|
10
10
|
import { Sql } from "../../common/Sql";
|
|
11
11
|
import { apiPath } from "../../common/apiPath";
|
|
12
12
|
import SocialMailApp from "../../common/SocialMailApp";
|
|
13
13
|
import { formatPrice } from "../../common/currency";
|
|
14
14
|
import { ContentPage } from "@web-atoms/web-controls/dist/mobile-app/MobileApp";
|
|
15
15
|
import { storeItemLink } from "./storeItemLink";
|
|
16
|
+
import Action from "@web-atoms/core/dist/view-model/Action";
|
|
16
17
|
|
|
17
18
|
styled.css `
|
|
18
19
|
|
|
@@ -108,6 +109,10 @@ export default class StoreItemListView extends AtomControl {
|
|
|
108
109
|
|
|
109
110
|
items: IStoreItem[] = [];
|
|
110
111
|
|
|
112
|
+
tags: IStoreTag[] = [];
|
|
113
|
+
|
|
114
|
+
version = 0;
|
|
115
|
+
|
|
111
116
|
@InjectProperty
|
|
112
117
|
entityService: EntityService;
|
|
113
118
|
|
|
@@ -121,11 +126,17 @@ export default class StoreItemListView extends AtomControl {
|
|
|
121
126
|
|
|
122
127
|
this.render(<div data-shopping-cart-list="shopping-cart-list">
|
|
123
128
|
<header>
|
|
129
|
+
<AtomRepeater
|
|
130
|
+
class="search-tags"
|
|
131
|
+
items={this.tags}
|
|
132
|
+
itemRenderer={(x) => <div data-layout="row"> <label text={`${x.tag.label} (${x.count})`}/> <i data-click-event="remove-tag" class="fas fa-times-circle"/> </div>}
|
|
133
|
+
/>
|
|
124
134
|
<input type="search" value={Bind.twoWaysImmediate(() => this.search)}/>
|
|
125
135
|
<AtomRepeater
|
|
126
136
|
class="tags"
|
|
127
|
-
items={Bind.oneWayAsync((c, e, cancelToken) => this.searchTags(this.search, cancelToken), { default: [] })}
|
|
137
|
+
items={Bind.oneWayAsync((c, e, cancelToken) => this.searchTags(this.search, cancelToken, this.version), { default: [] })}
|
|
128
138
|
itemRenderer={(x: IStoreTag) => <label text={`${x.tag.label} (${x.count})`}/>}
|
|
139
|
+
data-click-event="select-tag"
|
|
129
140
|
/>
|
|
130
141
|
</header>
|
|
131
142
|
<AtomRepeater
|
|
@@ -136,6 +147,7 @@ export default class StoreItemListView extends AtomControl {
|
|
|
136
147
|
this.searchItems({
|
|
137
148
|
start,
|
|
138
149
|
search: this.search,
|
|
150
|
+
version: this.version,
|
|
139
151
|
cancelToken
|
|
140
152
|
})
|
|
141
153
|
)}
|
|
@@ -167,7 +179,22 @@ export default class StoreItemListView extends AtomControl {
|
|
|
167
179
|
|
|
168
180
|
}
|
|
169
181
|
|
|
170
|
-
|
|
182
|
+
@Action({ onEvent: "remove-tag"})
|
|
183
|
+
removeTag(tag: IStoreTag) {
|
|
184
|
+
this.tags.remove(tag);
|
|
185
|
+
this.version++;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
@Action({ onEvent: "select-tag"})
|
|
189
|
+
selectTag(tag: IStoreTag) {
|
|
190
|
+
if(this.tags.find((t) => t.tagID === tag.tagID)) {
|
|
191
|
+
return;
|
|
192
|
+
}
|
|
193
|
+
this.tags.add(tag);
|
|
194
|
+
this.version++;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
async searchTags(search: string, cancelToken, v): Promise<any> {
|
|
171
198
|
let q = this.entityService.query(StoreTag, "storeQuery");
|
|
172
199
|
if (search) {
|
|
173
200
|
search = search.trim().toLocaleLowerCase() + "%";
|
|
@@ -177,6 +204,10 @@ export default class StoreItemListView extends AtomControl {
|
|
|
177
204
|
&& x.count > 0
|
|
178
205
|
);
|
|
179
206
|
}
|
|
207
|
+
if (this.tags.length) {
|
|
208
|
+
const ids = this.tags.map((t) => t.tagID);
|
|
209
|
+
q = q.where({ ids }, (p) => (x) => ! Sql.in(x.tagID, p.ids));
|
|
210
|
+
}
|
|
180
211
|
const tags = await q
|
|
181
212
|
.orderByDescending((x) => x.count)
|
|
182
213
|
.include((x) => x.tag)
|
|
@@ -199,6 +230,7 @@ export default class StoreItemListView extends AtomControl {
|
|
|
199
230
|
start,
|
|
200
231
|
search = "",
|
|
201
232
|
size = 50,
|
|
233
|
+
version = 0,
|
|
202
234
|
cancelToken
|
|
203
235
|
}) {
|
|
204
236
|
let q = this.entityService.query(StoreItem, "storeQuery")
|
|
@@ -219,6 +251,10 @@ export default class StoreItemListView extends AtomControl {
|
|
|
219
251
|
|| Sql.text.like(t.tag.parent.lowerCaseName, p.lowerSearch)))
|
|
220
252
|
);
|
|
221
253
|
}
|
|
254
|
+
if (this.tags.length) {
|
|
255
|
+
const ids = this.tags.map((t) => t.tagID);
|
|
256
|
+
q = q.where({ ids}, (p) => (x) => x.storeItemTags.some((st) => Sql.in(st.tagID, p.ids)));
|
|
257
|
+
}
|
|
222
258
|
const items = await q.orderByDescending((x) => x.storeItemID)
|
|
223
259
|
.include((x) => [
|
|
224
260
|
x.storeItemPrices,
|