@social-mail/social-mail-client 1.9.34 → 1.9.36

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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@social-mail/social-mail-client",
3
- "version": "1.9.34",
3
+ "version": "1.9.36",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -9,8 +9,14 @@ import EditDomainPage from "./edit/EditDomainPage";
9
9
  import { HostedDomain, IHostedDomain } from "../../../model/model";
10
10
  import AdminCommands from "../../commands/AdminCommands";
11
11
  import EntityService from "../../../services/EntityService";
12
+ import InfiniteRepeater from "../../../common/controls/repeater/InfiniteRepeater";
13
+ import Bind from "@web-atoms/core/dist/core/Bind";
14
+ import { Sql } from "../../../common/Sql";
15
+ import MasterDetailPage from "@web-atoms/web-controls/dist/mobile-app/MasterDetailPage";
12
16
 
13
- export default class DomainListPage extends ContentPage {
17
+ export default class DomainListPage extends MasterDetailPage {
18
+
19
+ search = "";
14
20
 
15
21
  @InjectProperty
16
22
  private adminDomainService: AdminDomainService;
@@ -23,17 +29,24 @@ export default class DomainListPage extends ContentPage {
23
29
  async init() {
24
30
 
25
31
  this.title = "Domains";
26
- this.domains = await this.adminDomainService.list();
27
32
 
28
33
  this.actionRenderer = () => <i data-click-event="add-domain" class="fas fa-plus"/>;
29
34
 
35
+ this.headerRenderer = () => <div>
36
+ <input type="search" value={Bind.twoWaysImmediate(() => this.search)}/>
37
+ </div>;
38
+
30
39
  this.renderer = <div>
31
40
  <AtomRepeater
41
+ data-layout="data-grid"
32
42
  items={this.domains}
43
+ selectOnClick={true}
44
+ data-selection-updated-event="item-selected"
45
+ { ... InfiniteRepeater.pagedItems((start) => (c, e, cancelToken) =>
46
+ this.loadItems({ search: this.search, start, cancelToken })
47
+ )}
33
48
  itemRenderer={(domain) => <div>
34
- <a
35
- data-click-event="route"
36
- href={AdminCommands.openDomain.displayRoute(domain)}>{domain.domain.name}</a>
49
+ <label>{domain.domain.name}</label>
37
50
 
38
51
  <i
39
52
  data-click-event="delete-item"
@@ -44,10 +57,35 @@ export default class DomainListPage extends ContentPage {
44
57
  </div>;
45
58
  }
46
59
 
60
+ async loadItems({ search, start, cancelToken }) {
61
+ let q = this.entityService.query(HostedDomain);
62
+ if (search) {
63
+ search = `${search}%`.toLowerCase();
64
+ q = q.where({ search }, (p) => (x) => Sql.text.like(x.domain.name, p.search));
65
+ }
66
+ return q
67
+ .include((x) => x.domain)
68
+ .orderBy((x) => x.domain.name)
69
+ .toPagedList({
70
+ start,
71
+ size: 10,
72
+ cancelToken
73
+ });
74
+ }
75
+
47
76
  @Action({ onEvent: "add-domain"})
48
77
  async addDomain() {
49
- const domain = await PageNavigator.pushPageForResult(EditDomainPage, {});
78
+ const domain = HostedDomain.create({});
50
79
  this.domains.add(domain);
80
+ this.openDetail(EditDomainPage, { model: domain });
81
+ }
82
+
83
+ @Action({ onEvent: "item-selected" , defer: 10 })
84
+ itemSelected([domain]) {
85
+ if (!domain) {
86
+ return;
87
+ }
88
+ this.openDetail(EditDomainPage, { model: domain });
51
89
  }
52
90
 
53
91
  @Action({
@@ -1,5 +1,5 @@
1
1
  import { ContentPage } from "@web-atoms/web-controls/dist/mobile-app/MobileApp";
2
- import { IContact, IStoreAccount, IStoreItem, IStoreItemFolder, IStoreItemPrice, IStoreJournal, IStoreJournalEntry, IStoreJournalLineItem, StoreJournal, StoreJournalLineItem } from "../../../../model/model";
2
+ import { IContact, IStoreAccount, IStoreItem, IStoreItemFolder, IStoreItemPrice, IStoreJournal, IStoreJournalEntry, IStoreJournalLineItem, StoreItemPrice, StoreJournal, StoreJournalLineItem } from "../../../../model/model";
3
3
  import InjectProperty from "@web-atoms/core/dist/core/InjectProperty";
4
4
  import StoreOrderService from "../../../../services/store/StoreOrderService";
5
5
  import XNode from "@web-atoms/core/dist/core/XNode";
@@ -18,6 +18,7 @@ import Action from "@web-atoms/core/dist/view-model/Action";
18
18
  import FormField from "@web-atoms/web-controls/dist/basic/FormField";
19
19
  import DateField from "@web-atoms/web-controls/dist/basic/DateField";
20
20
  import DateTime from "@web-atoms/date-time/dist/DateTime";
21
+ import EntityService from "../../../../services/EntityService";
21
22
 
22
23
  export default class EditOrderPage extends ContentPage<Partial<IStoreJournal>> {
23
24
 
@@ -29,6 +30,9 @@ export default class EditOrderPage extends ContentPage<Partial<IStoreJournal>> {
29
30
  @InjectProperty
30
31
  storeItemService: StoreItemService;
31
32
 
33
+ @InjectProperty
34
+ entityService: EntityService;
35
+
32
36
  async init() {
33
37
 
34
38
  const storeID = this.parameters.storeID;
@@ -105,9 +109,12 @@ export default class EditOrderPage extends ContentPage<Partial<IStoreJournal>> {
105
109
  (search
106
110
  ? q.where({ search, likeSearch: search + "%" }, (p) => (x) => Sql.text.iLike(x.name, p.likeSearch))
107
111
  : q)
108
- .where({ storeID }, (p) => (x) => x.storeID === p.storeID)
112
+ .where({ storeID }, (p) => (x) => x.storeID === p.storeID
113
+ && x.itemType !== "tax"
114
+ && x.itemType !== "commission")
109
115
  }
110
116
  itemRenderer={(x) => <div text={x.name}></div>}
117
+ event-reference-updated={(ce) => this.onItemUpdated(line, ce.detail)}
111
118
  />
112
119
  <ReferenceEditor
113
120
  label=""
@@ -123,7 +130,9 @@ export default class EditOrderPage extends ContentPage<Partial<IStoreJournal>> {
123
130
  itemRenderer={(x) => <div text={`${x.currency} ${x.amount}`}></div>}
124
131
  />
125
132
 
126
- <input value={Bind.sourceTwoWays(line, (x) => x.source.quantity)}/>
133
+ <input
134
+ event-input={() => line.total = (Number(line.amount) * Number(line.quantity)).toFixed() as any }
135
+ value={Bind.sourceTwoWays(line, (x) => x.source.quantity)}/>
127
136
  <input
128
137
  readOnly={true}
129
138
  value={Bind.source(line, (x) => x.source.amount)}/>
@@ -202,8 +211,25 @@ export default class EditOrderPage extends ContentPage<Partial<IStoreJournal>> {
202
211
  await this.init();
203
212
  }
204
213
 
214
+ async onItemUpdated(line: IStoreJournalLineItem, detail: IStoreItem) {
215
+ // get first active price
216
+ const { storeItemID } = detail;
217
+ const firstPrice = await this.entityService.query(StoreItemPrice)
218
+ .where({ storeItemID }, (p) => (x) => x.storeItemID === p.storeItemID
219
+ && x.active === true
220
+ )
221
+ .firstOrDefault();
222
+ line.itemPrice = firstPrice;
223
+ line.itemPriceID = firstPrice.priceID;
224
+ line.quantity = 1;
225
+ line.amount = Number(firstPrice.amount);
226
+ line.total = (Number(line.amount) * Number(line.quantity)).toFixed(2) as any;
227
+ }
228
+
229
+
205
230
  onItemPriceUpdated(line: IStoreJournalLineItem, detail: IStoreItemPrice): any {
206
231
  line.amount = Number(detail.amount);
232
+ line.total = (Number(line.amount) * Number(line.quantity)).toFixed(2) as any;
207
233
  }
208
234
 
209
235
  async onLineItemDeleted(line: IStoreJournalLineItem) {