@social-mail/social-mail-client 1.9.35 → 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.35",
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({