@things-factory/board-ui 6.1.48 → 6.1.55

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.
@@ -7,7 +7,8 @@ export class ColorMapEditor extends OxGristEditorValueMap {
7
7
  get options() {
8
8
  return {
9
9
  name: `Color Map : ${this.record.name}`,
10
- valuetype: 'color'
10
+ valuetype: 'color',
11
+ objectified: true
11
12
  }
12
13
  }
13
14
  }
@@ -7,7 +7,8 @@ export class ColorRangesEditor extends OxGristEditorValueRanges {
7
7
  get options() {
8
8
  return {
9
9
  name: `Color Ranges : ${this.record.name}`,
10
- valuetype: 'color'
10
+ valuetype: 'color',
11
+ objectified: true
11
12
  }
12
13
  }
13
14
  }
@@ -0,0 +1,260 @@
1
+ import '@operato/data-grist'
2
+
3
+ import { CommonButtonStyles, CommonGristStyles, ScrollbarStyles } from '@operato/styles'
4
+ import { PageView, store } from '@operato/shell'
5
+ import { css, html } from 'lit'
6
+ import { customElement, property, query } from 'lit/decorators.js'
7
+ import { ScopedElementsMixin } from '@open-wc/scoped-elements'
8
+ import { ColumnConfig, DataGrist, FetchOption, SortersControl } from '@operato/data-grist'
9
+ import { client } from '@operato/graphql'
10
+ import { i18next, localize } from '@operato/i18n'
11
+ import { notify, openPopup } from '@operato/layout'
12
+ import { OxPopup } from '@operato/popup'
13
+
14
+ import { connect } from 'pwa-helpers/connect-mixin'
15
+ import gql from 'graphql-tag'
16
+
17
+ @customElement('board-template-list-page')
18
+ export class BoardTemplateListPage extends connect(store)(localize(i18next)(ScopedElementsMixin(PageView))) {
19
+ static styles = [
20
+ ScrollbarStyles,
21
+ CommonGristStyles,
22
+ css`
23
+ :host {
24
+ display: flex;
25
+
26
+ width: 100%;
27
+
28
+ --grid-record-emphasized-background-color: red;
29
+ --grid-record-emphasized-color: yellow;
30
+ }
31
+ `
32
+ ]
33
+
34
+ @property({ type: Object }) gristConfig: any
35
+
36
+ @query('ox-grist') private grist!: DataGrist
37
+ @query('#sorter-control') private sortersControl!: OxPopup
38
+
39
+ get context() {
40
+ return {
41
+ search: {
42
+ handler: (search: string) => {
43
+ this.grist.searchText = search
44
+ },
45
+ placeholder: i18next.t('title.board-template list'),
46
+ value: this.grist.searchText
47
+ },
48
+ filter: {
49
+ handler: () => {
50
+ this.grist.toggleHeadroom()
51
+ }
52
+ },
53
+ help: 'board-service/board-template',
54
+ actions: [
55
+ {
56
+ title: i18next.t('button.save'),
57
+ action: this._updateBoardTemplate.bind(this),
58
+ ...CommonButtonStyles.save
59
+ },
60
+ {
61
+ title: i18next.t('button.delete'),
62
+ action: this._deleteBoardTemplate.bind(this),
63
+ ...CommonButtonStyles.delete
64
+ }
65
+ ]
66
+ }
67
+ }
68
+
69
+ render() {
70
+ return html`
71
+ <ox-grist mode="CARD" .config=${this.gristConfig} .fetchHandler=${this.fetchHandler.bind(this)}>
72
+ <div slot="headroom">
73
+ <div id="filters">
74
+ <ox-filters-form autofocus></ox-filters-form>
75
+ </div>
76
+
77
+ <div id="sorters">
78
+ Sort
79
+ <mwc-icon
80
+ @click=${e => {
81
+ const target = e.currentTarget
82
+ this.sortersControl.open({
83
+ right: 0,
84
+ top: target.offsetTop + target.offsetHeight
85
+ })
86
+ }}
87
+ >expand_more</mwc-icon
88
+ >
89
+ <ox-popup id="sorter-control">
90
+ <ox-sorters-control> </ox-sorters-control>
91
+ </ox-popup>
92
+ </div>
93
+ </div>
94
+ </ox-grist>
95
+ `
96
+ }
97
+
98
+ async pageInitialized(lifecycle: any) {
99
+ this.gristConfig = {
100
+ list: {
101
+ fields: ['name', 'description'],
102
+ details: ['active', 'updatedAt']
103
+ },
104
+ columns: [
105
+ { type: 'gutter', gutterName: 'sequence' },
106
+ { type: 'gutter', gutterName: 'row-selector', multiple: true },
107
+ {
108
+ type: 'string',
109
+ name: 'name',
110
+ header: i18next.t('field.name'),
111
+ record: {
112
+ editable: true
113
+ },
114
+ filter: 'search',
115
+ sortable: true,
116
+ width: 150
117
+ },
118
+ {
119
+ type: 'string',
120
+ name: 'description',
121
+ header: i18next.t('field.description'),
122
+ record: {
123
+ editable: true
124
+ },
125
+ filter: 'search',
126
+ width: 200
127
+ },
128
+ {
129
+ type: 'resource-object',
130
+ name: 'updater',
131
+ header: i18next.t('field.updater'),
132
+ record: {
133
+ editable: false
134
+ },
135
+ sortable: true,
136
+ width: 120
137
+ },
138
+ {
139
+ type: 'datetime',
140
+ name: 'updatedAt',
141
+ header: i18next.t('field.updated_at'),
142
+ record: {
143
+ editable: false
144
+ },
145
+ sortable: true,
146
+ width: 180
147
+ }
148
+ ],
149
+ rows: {
150
+ selectable: {
151
+ multiple: true
152
+ }
153
+ },
154
+ sorters: [
155
+ {
156
+ name: 'name'
157
+ }
158
+ ]
159
+ }
160
+ }
161
+
162
+ async pageUpdated(changes: any, lifecycle: any) {
163
+ if (this.active) {
164
+ // do something here when this page just became as active
165
+ }
166
+ }
167
+
168
+ async fetchHandler({ page = 1, limit = 100, sortings = [], filters = [] }: FetchOption) {
169
+ const response = await client.query({
170
+ query: gql`
171
+ query ($filters: [Filter!], $pagination: Pagination, $sortings: [Sorting!]) {
172
+ responses: boardTemplates(filters: $filters, pagination: $pagination, sortings: $sortings) {
173
+ items {
174
+ id
175
+ name
176
+ description
177
+ state
178
+ model
179
+ thumbnail
180
+ updater {
181
+ id
182
+ name
183
+ }
184
+ updatedAt
185
+ }
186
+ total
187
+ }
188
+ }
189
+ `,
190
+ variables: {
191
+ filters,
192
+ pagination: { page, limit },
193
+ sortings
194
+ }
195
+ })
196
+
197
+ return {
198
+ total: response.data.responses.total || 0,
199
+ records: response.data.responses.items || []
200
+ }
201
+ }
202
+
203
+ async _deleteBoardTemplate() {
204
+ if (confirm(i18next.t('text.sure_to_x', { x: i18next.t('text.delete') }))) {
205
+ const ids = this.grist.selected.map(record => record.id)
206
+ if (ids && ids.length > 0) {
207
+ const response = await client.mutate({
208
+ mutation: gql`
209
+ mutation ($ids: [String!]!) {
210
+ deleteBoardTemplates(ids: $ids)
211
+ }
212
+ `,
213
+ variables: {
214
+ ids
215
+ }
216
+ })
217
+
218
+ if (!response.errors) {
219
+ this.grist.fetch()
220
+ notify({
221
+ message: i18next.t('text.info_x_successfully', { x: i18next.t('text.delete') })
222
+ })
223
+ }
224
+ }
225
+ }
226
+ }
227
+
228
+ async _updateBoardTemplate() {
229
+ let patches = this.grist.dirtyRecords
230
+ if (patches && patches.length) {
231
+ patches = patches.map(patch => {
232
+ let patchField: any = patch.id ? { id: patch.id } : {}
233
+ const dirtyFields = patch.__dirtyfields__
234
+ for (let key in dirtyFields) {
235
+ patchField[key] = dirtyFields[key].after
236
+ }
237
+ patchField.cuFlag = patch.__dirty__
238
+
239
+ return patchField
240
+ })
241
+
242
+ const response = await client.mutate({
243
+ mutation: gql`
244
+ mutation ($patches: [BoardTemplatePatch!]!) {
245
+ updateMultipleBoardTemplate(patches: $patches) {
246
+ name
247
+ }
248
+ }
249
+ `,
250
+ variables: {
251
+ patches
252
+ }
253
+ })
254
+
255
+ if (!response.errors) {
256
+ this.grist.fetch()
257
+ }
258
+ }
259
+ }
260
+ }
@@ -159,7 +159,7 @@ export class ThemeListPage extends connect(store)(localize(i18next)(ScopedElemen
159
159
  width: 120
160
160
  },
161
161
  {
162
- type: 'string',
162
+ type: 'object',
163
163
  name: 'value',
164
164
  header: i18next.t('field.value'),
165
165
  record: {
package/client/route.ts CHANGED
@@ -19,5 +19,9 @@ export default function route(page) {
19
19
  case 'theme-list':
20
20
  import('./pages/theme/theme-list-page')
21
21
  return page
22
+
23
+ case 'board-template-list':
24
+ import('./pages/board-template/board-template-list-page')
25
+ return page
22
26
  }
23
27
  }
@@ -3,5 +3,6 @@ export declare class ColorMapEditor extends OxGristEditorValueMap {
3
3
  get options(): {
4
4
  name: string;
5
5
  valuetype: string;
6
+ objectified: boolean;
6
7
  };
7
8
  }
@@ -5,7 +5,8 @@ let ColorMapEditor = class ColorMapEditor extends OxGristEditorValueMap {
5
5
  get options() {
6
6
  return {
7
7
  name: `Color Map : ${this.record.name}`,
8
- valuetype: 'color'
8
+ valuetype: 'color',
9
+ objectified: true
9
10
  };
10
11
  }
11
12
  };
@@ -1 +1 @@
1
- {"version":3,"file":"color-map-editor.js","sourceRoot":"","sources":["../../client/data-grist/color-map-editor.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AAEjD,OAAO,EAAE,qBAAqB,EAAE,MAAM,oDAAoD,CAAA;AAGnF,IAAM,cAAc,GAApB,MAAM,cAAe,SAAQ,qBAAqB;IACvD,IAAI,OAAO;QACT,OAAO;YACL,IAAI,EAAE,eAAe,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE;YACvC,SAAS,EAAE,OAAO;SACnB,CAAA;IACH,CAAC;CACF,CAAA;AAPY,cAAc;IAD1B,aAAa,CAAC,kBAAkB,CAAC;GACrB,cAAc,CAO1B;SAPY,cAAc","sourcesContent":["import { customElement } from 'lit/decorators.js'\n\nimport { OxGristEditorValueMap } from '@operato/grist-editor/ox-grist-editor-value-map.js'\n\n@customElement('color-map-editor')\nexport class ColorMapEditor extends OxGristEditorValueMap {\n get options() {\n return {\n name: `Color Map : ${this.record.name}`,\n valuetype: 'color'\n }\n }\n}\n"]}
1
+ {"version":3,"file":"color-map-editor.js","sourceRoot":"","sources":["../../client/data-grist/color-map-editor.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AAEjD,OAAO,EAAE,qBAAqB,EAAE,MAAM,oDAAoD,CAAA;AAGnF,IAAM,cAAc,GAApB,MAAM,cAAe,SAAQ,qBAAqB;IACvD,IAAI,OAAO;QACT,OAAO;YACL,IAAI,EAAE,eAAe,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE;YACvC,SAAS,EAAE,OAAO;YAClB,WAAW,EAAE,IAAI;SAClB,CAAA;IACH,CAAC;CACF,CAAA;AARY,cAAc;IAD1B,aAAa,CAAC,kBAAkB,CAAC;GACrB,cAAc,CAQ1B;SARY,cAAc","sourcesContent":["import { customElement } from 'lit/decorators.js'\n\nimport { OxGristEditorValueMap } from '@operato/grist-editor/ox-grist-editor-value-map.js'\n\n@customElement('color-map-editor')\nexport class ColorMapEditor extends OxGristEditorValueMap {\n get options() {\n return {\n name: `Color Map : ${this.record.name}`,\n valuetype: 'color',\n objectified: true\n }\n }\n}\n"]}
@@ -3,5 +3,6 @@ export declare class ColorRangesEditor extends OxGristEditorValueRanges {
3
3
  get options(): {
4
4
  name: string;
5
5
  valuetype: string;
6
+ objectified: boolean;
6
7
  };
7
8
  }
@@ -5,7 +5,8 @@ let ColorRangesEditor = class ColorRangesEditor extends OxGristEditorValueRanges
5
5
  get options() {
6
6
  return {
7
7
  name: `Color Ranges : ${this.record.name}`,
8
- valuetype: 'color'
8
+ valuetype: 'color',
9
+ objectified: true
9
10
  };
10
11
  }
11
12
  };
@@ -1 +1 @@
1
- {"version":3,"file":"color-ranges-editor.js","sourceRoot":"","sources":["../../client/data-grist/color-ranges-editor.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AAEjD,OAAO,EAAE,wBAAwB,EAAE,MAAM,uDAAuD,CAAA;AAGzF,IAAM,iBAAiB,GAAvB,MAAM,iBAAkB,SAAQ,wBAAwB;IAC7D,IAAI,OAAO;QACT,OAAO;YACL,IAAI,EAAE,kBAAkB,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE;YAC1C,SAAS,EAAE,OAAO;SACnB,CAAA;IACH,CAAC;CACF,CAAA;AAPY,iBAAiB;IAD7B,aAAa,CAAC,qBAAqB,CAAC;GACxB,iBAAiB,CAO7B;SAPY,iBAAiB","sourcesContent":["import { customElement } from 'lit/decorators.js'\n\nimport { OxGristEditorValueRanges } from '@operato/grist-editor/ox-grist-editor-value-ranges.js'\n\n@customElement('color-ranges-editor')\nexport class ColorRangesEditor extends OxGristEditorValueRanges {\n get options() {\n return {\n name: `Color Ranges : ${this.record.name}`,\n valuetype: 'color'\n }\n }\n}\n"]}
1
+ {"version":3,"file":"color-ranges-editor.js","sourceRoot":"","sources":["../../client/data-grist/color-ranges-editor.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AAEjD,OAAO,EAAE,wBAAwB,EAAE,MAAM,uDAAuD,CAAA;AAGzF,IAAM,iBAAiB,GAAvB,MAAM,iBAAkB,SAAQ,wBAAwB;IAC7D,IAAI,OAAO;QACT,OAAO;YACL,IAAI,EAAE,kBAAkB,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE;YAC1C,SAAS,EAAE,OAAO;YAClB,WAAW,EAAE,IAAI;SAClB,CAAA;IACH,CAAC;CACF,CAAA;AARY,iBAAiB;IAD7B,aAAa,CAAC,qBAAqB,CAAC;GACxB,iBAAiB,CAQ7B;SARY,iBAAiB","sourcesContent":["import { customElement } from 'lit/decorators.js'\n\nimport { OxGristEditorValueRanges } from '@operato/grist-editor/ox-grist-editor-value-ranges.js'\n\n@customElement('color-ranges-editor')\nexport class ColorRangesEditor extends OxGristEditorValueRanges {\n get options() {\n return {\n name: `Color Ranges : ${this.record.name}`,\n valuetype: 'color',\n objectified: true\n }\n }\n}\n"]}
@@ -0,0 +1,48 @@
1
+ import '@operato/data-grist';
2
+ import { PageView } from '@operato/shell';
3
+ import { FetchOption } from '@operato/data-grist';
4
+ declare const BoardTemplateListPage_base: (new (...args: any[]) => {
5
+ _storeUnsubscribe: import("redux").Unsubscribe;
6
+ connectedCallback(): void;
7
+ disconnectedCallback(): void;
8
+ stateChanged(_state: unknown): void;
9
+ readonly isConnected: boolean;
10
+ }) & (new (...args: any[]) => import("lit").LitElement) & typeof PageView & import("@open-wc/dedupe-mixin").Constructor<import("@open-wc/scoped-elements/types/src/types").ScopedElementsHost>;
11
+ export declare class BoardTemplateListPage extends BoardTemplateListPage_base {
12
+ static styles: import("lit").CSSResult[];
13
+ gristConfig: any;
14
+ private grist;
15
+ private sortersControl;
16
+ get context(): {
17
+ search: {
18
+ handler: (search: string) => void;
19
+ placeholder: string;
20
+ value: string;
21
+ };
22
+ filter: {
23
+ handler: () => void;
24
+ };
25
+ help: string;
26
+ actions: {
27
+ icon: string;
28
+ emphasis: {
29
+ raised: boolean;
30
+ outlined: boolean;
31
+ dense: boolean;
32
+ danger: boolean;
33
+ };
34
+ title: string;
35
+ action: () => Promise<void>;
36
+ }[];
37
+ };
38
+ render(): import("lit-html").TemplateResult<1>;
39
+ pageInitialized(lifecycle: any): Promise<void>;
40
+ pageUpdated(changes: any, lifecycle: any): Promise<void>;
41
+ fetchHandler({ page, limit, sortings, filters }: FetchOption): Promise<{
42
+ total: any;
43
+ records: any;
44
+ }>;
45
+ _deleteBoardTemplate(): Promise<void>;
46
+ _updateBoardTemplate(): Promise<void>;
47
+ }
48
+ export {};
@@ -0,0 +1,249 @@
1
+ import { __decorate, __metadata } from "tslib";
2
+ import '@operato/data-grist';
3
+ import { CommonButtonStyles, CommonGristStyles, ScrollbarStyles } from '@operato/styles';
4
+ import { PageView, store } from '@operato/shell';
5
+ import { css, html } from 'lit';
6
+ import { customElement, property, query } from 'lit/decorators.js';
7
+ import { ScopedElementsMixin } from '@open-wc/scoped-elements';
8
+ import { DataGrist } from '@operato/data-grist';
9
+ import { client } from '@operato/graphql';
10
+ import { i18next, localize } from '@operato/i18n';
11
+ import { notify } from '@operato/layout';
12
+ import { OxPopup } from '@operato/popup';
13
+ import { connect } from 'pwa-helpers/connect-mixin';
14
+ import gql from 'graphql-tag';
15
+ let BoardTemplateListPage = class BoardTemplateListPage extends connect(store)(localize(i18next)(ScopedElementsMixin(PageView))) {
16
+ get context() {
17
+ return {
18
+ search: {
19
+ handler: (search) => {
20
+ this.grist.searchText = search;
21
+ },
22
+ placeholder: i18next.t('title.board-template list'),
23
+ value: this.grist.searchText
24
+ },
25
+ filter: {
26
+ handler: () => {
27
+ this.grist.toggleHeadroom();
28
+ }
29
+ },
30
+ help: 'board-service/board-template',
31
+ actions: [
32
+ Object.assign({ title: i18next.t('button.save'), action: this._updateBoardTemplate.bind(this) }, CommonButtonStyles.save),
33
+ Object.assign({ title: i18next.t('button.delete'), action: this._deleteBoardTemplate.bind(this) }, CommonButtonStyles.delete)
34
+ ]
35
+ };
36
+ }
37
+ render() {
38
+ return html `
39
+ <ox-grist mode="CARD" .config=${this.gristConfig} .fetchHandler=${this.fetchHandler.bind(this)}>
40
+ <div slot="headroom">
41
+ <div id="filters">
42
+ <ox-filters-form autofocus></ox-filters-form>
43
+ </div>
44
+
45
+ <div id="sorters">
46
+ Sort
47
+ <mwc-icon
48
+ @click=${e => {
49
+ const target = e.currentTarget;
50
+ this.sortersControl.open({
51
+ right: 0,
52
+ top: target.offsetTop + target.offsetHeight
53
+ });
54
+ }}
55
+ >expand_more</mwc-icon
56
+ >
57
+ <ox-popup id="sorter-control">
58
+ <ox-sorters-control> </ox-sorters-control>
59
+ </ox-popup>
60
+ </div>
61
+ </div>
62
+ </ox-grist>
63
+ `;
64
+ }
65
+ async pageInitialized(lifecycle) {
66
+ this.gristConfig = {
67
+ list: {
68
+ fields: ['name', 'description'],
69
+ details: ['active', 'updatedAt']
70
+ },
71
+ columns: [
72
+ { type: 'gutter', gutterName: 'sequence' },
73
+ { type: 'gutter', gutterName: 'row-selector', multiple: true },
74
+ {
75
+ type: 'string',
76
+ name: 'name',
77
+ header: i18next.t('field.name'),
78
+ record: {
79
+ editable: true
80
+ },
81
+ filter: 'search',
82
+ sortable: true,
83
+ width: 150
84
+ },
85
+ {
86
+ type: 'string',
87
+ name: 'description',
88
+ header: i18next.t('field.description'),
89
+ record: {
90
+ editable: true
91
+ },
92
+ filter: 'search',
93
+ width: 200
94
+ },
95
+ {
96
+ type: 'resource-object',
97
+ name: 'updater',
98
+ header: i18next.t('field.updater'),
99
+ record: {
100
+ editable: false
101
+ },
102
+ sortable: true,
103
+ width: 120
104
+ },
105
+ {
106
+ type: 'datetime',
107
+ name: 'updatedAt',
108
+ header: i18next.t('field.updated_at'),
109
+ record: {
110
+ editable: false
111
+ },
112
+ sortable: true,
113
+ width: 180
114
+ }
115
+ ],
116
+ rows: {
117
+ selectable: {
118
+ multiple: true
119
+ }
120
+ },
121
+ sorters: [
122
+ {
123
+ name: 'name'
124
+ }
125
+ ]
126
+ };
127
+ }
128
+ async pageUpdated(changes, lifecycle) {
129
+ if (this.active) {
130
+ // do something here when this page just became as active
131
+ }
132
+ }
133
+ async fetchHandler({ page = 1, limit = 100, sortings = [], filters = [] }) {
134
+ const response = await client.query({
135
+ query: gql `
136
+ query ($filters: [Filter!], $pagination: Pagination, $sortings: [Sorting!]) {
137
+ responses: boardTemplates(filters: $filters, pagination: $pagination, sortings: $sortings) {
138
+ items {
139
+ id
140
+ name
141
+ description
142
+ state
143
+ model
144
+ thumbnail
145
+ updater {
146
+ id
147
+ name
148
+ }
149
+ updatedAt
150
+ }
151
+ total
152
+ }
153
+ }
154
+ `,
155
+ variables: {
156
+ filters,
157
+ pagination: { page, limit },
158
+ sortings
159
+ }
160
+ });
161
+ return {
162
+ total: response.data.responses.total || 0,
163
+ records: response.data.responses.items || []
164
+ };
165
+ }
166
+ async _deleteBoardTemplate() {
167
+ if (confirm(i18next.t('text.sure_to_x', { x: i18next.t('text.delete') }))) {
168
+ const ids = this.grist.selected.map(record => record.id);
169
+ if (ids && ids.length > 0) {
170
+ const response = await client.mutate({
171
+ mutation: gql `
172
+ mutation ($ids: [String!]!) {
173
+ deleteBoardTemplates(ids: $ids)
174
+ }
175
+ `,
176
+ variables: {
177
+ ids
178
+ }
179
+ });
180
+ if (!response.errors) {
181
+ this.grist.fetch();
182
+ notify({
183
+ message: i18next.t('text.info_x_successfully', { x: i18next.t('text.delete') })
184
+ });
185
+ }
186
+ }
187
+ }
188
+ }
189
+ async _updateBoardTemplate() {
190
+ let patches = this.grist.dirtyRecords;
191
+ if (patches && patches.length) {
192
+ patches = patches.map(patch => {
193
+ let patchField = patch.id ? { id: patch.id } : {};
194
+ const dirtyFields = patch.__dirtyfields__;
195
+ for (let key in dirtyFields) {
196
+ patchField[key] = dirtyFields[key].after;
197
+ }
198
+ patchField.cuFlag = patch.__dirty__;
199
+ return patchField;
200
+ });
201
+ const response = await client.mutate({
202
+ mutation: gql `
203
+ mutation ($patches: [BoardTemplatePatch!]!) {
204
+ updateMultipleBoardTemplate(patches: $patches) {
205
+ name
206
+ }
207
+ }
208
+ `,
209
+ variables: {
210
+ patches
211
+ }
212
+ });
213
+ if (!response.errors) {
214
+ this.grist.fetch();
215
+ }
216
+ }
217
+ }
218
+ };
219
+ BoardTemplateListPage.styles = [
220
+ ScrollbarStyles,
221
+ CommonGristStyles,
222
+ css `
223
+ :host {
224
+ display: flex;
225
+
226
+ width: 100%;
227
+
228
+ --grid-record-emphasized-background-color: red;
229
+ --grid-record-emphasized-color: yellow;
230
+ }
231
+ `
232
+ ];
233
+ __decorate([
234
+ property({ type: Object }),
235
+ __metadata("design:type", Object)
236
+ ], BoardTemplateListPage.prototype, "gristConfig", void 0);
237
+ __decorate([
238
+ query('ox-grist'),
239
+ __metadata("design:type", DataGrist)
240
+ ], BoardTemplateListPage.prototype, "grist", void 0);
241
+ __decorate([
242
+ query('#sorter-control'),
243
+ __metadata("design:type", OxPopup)
244
+ ], BoardTemplateListPage.prototype, "sortersControl", void 0);
245
+ BoardTemplateListPage = __decorate([
246
+ customElement('board-template-list-page')
247
+ ], BoardTemplateListPage);
248
+ export { BoardTemplateListPage };
249
+ //# sourceMappingURL=board-template-list-page.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"board-template-list-page.js","sourceRoot":"","sources":["../../../client/pages/board-template/board-template-list-page.ts"],"names":[],"mappings":";AAAA,OAAO,qBAAqB,CAAA;AAE5B,OAAO,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AACxF,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAA;AAChD,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,KAAK,CA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EAAE,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAA;gBACtD,MAAM,WAAW,GAAG,KAAK,CAAC,eAAe,CAAA;gBACzC,KAAK,IAAI,GAAG,IAAI,WAAW,EAAE;oBAC3B,UAAU,CAAC,GAAG,CAAC,GAAG,WAAW,CAAC,GAAG,CAAC,CAAC,KAAK,CAAA;iBACzC;gBACD,UAAU,CAAC,MAAM,GAAG,KAAK,CAAC,SAAS,CAAA;gBAEnC,OAAO,UAAU,CAAA;YACnB,CAAC,CAAC,CAAA;YAEF,MAAM,QAAQ,GAAG,MAAM,MAAM,CAAC,MAAM,CAAC;gBACnC,QAAQ,EAAE,GAAG,CAAA;;;;;;SAMZ;gBACD,SAAS,EAAE;oBACT,OAAO;iBACR;aACF,CAAC,CAAA;YAEF,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE;gBACpB,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,CAAA;aACnB;SACF;IACH,CAAC;;AAhPM,4BAAM,GAAG;IACd,eAAe;IACf,iBAAiB;IACjB,GAAG,CAAA;;;;;;;;;KASF;CACF,CAAA;AAED;IAAC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;0DAAiB;AAE5C;IAAC,KAAK,CAAC,UAAU,CAAC;8BAAiB,SAAS;oDAAA;AAC5C;IAAC,KAAK,CAAC,iBAAiB,CAAC;8BAA0B,OAAO;6DAAA;AAnB/C,qBAAqB;IADjC,aAAa,CAAC,0BAA0B,CAAC;GAC7B,qBAAqB,CAkPjC;SAlPY,qBAAqB","sourcesContent":["import '@operato/data-grist'\n\nimport { CommonButtonStyles, CommonGristStyles, ScrollbarStyles } from '@operato/styles'\nimport { PageView, store } from '@operato/shell'\nimport { css, html } from 'lit'\nimport { customElement, property, query } from 'lit/decorators.js'\nimport { ScopedElementsMixin } from '@open-wc/scoped-elements'\nimport { ColumnConfig, DataGrist, FetchOption, SortersControl } from '@operato/data-grist'\nimport { client } from '@operato/graphql'\nimport { i18next, localize } from '@operato/i18n'\nimport { notify, openPopup } from '@operato/layout'\nimport { OxPopup } from '@operato/popup'\n\nimport { connect } from 'pwa-helpers/connect-mixin'\nimport gql from 'graphql-tag'\n\n@customElement('board-template-list-page')\nexport class BoardTemplateListPage extends connect(store)(localize(i18next)(ScopedElementsMixin(PageView))) {\n static styles = [\n ScrollbarStyles,\n CommonGristStyles,\n css`\n :host {\n display: flex;\n\n width: 100%;\n\n --grid-record-emphasized-background-color: red;\n --grid-record-emphasized-color: yellow;\n }\n `\n ]\n\n @property({ type: Object }) gristConfig: any\n\n @query('ox-grist') private grist!: DataGrist\n @query('#sorter-control') private sortersControl!: OxPopup\n\n get context() {\n return {\n search: {\n handler: (search: string) => {\n this.grist.searchText = search\n },\n placeholder: i18next.t('title.board-template list'),\n value: this.grist.searchText\n },\n filter: {\n handler: () => {\n this.grist.toggleHeadroom()\n }\n },\n help: 'board-service/board-template',\n actions: [\n {\n title: i18next.t('button.save'),\n action: this._updateBoardTemplate.bind(this),\n ...CommonButtonStyles.save\n },\n {\n title: i18next.t('button.delete'),\n action: this._deleteBoardTemplate.bind(this),\n ...CommonButtonStyles.delete\n }\n ]\n }\n }\n\n render() {\n return html`\n <ox-grist mode=\"CARD\" .config=${this.gristConfig} .fetchHandler=${this.fetchHandler.bind(this)}>\n <div slot=\"headroom\">\n <div id=\"filters\">\n <ox-filters-form autofocus></ox-filters-form>\n </div>\n\n <div id=\"sorters\">\n Sort\n <mwc-icon\n @click=${e => {\n const target = e.currentTarget\n this.sortersControl.open({\n right: 0,\n top: target.offsetTop + target.offsetHeight\n })\n }}\n >expand_more</mwc-icon\n >\n <ox-popup id=\"sorter-control\">\n <ox-sorters-control> </ox-sorters-control>\n </ox-popup>\n </div>\n </div>\n </ox-grist>\n `\n }\n\n async pageInitialized(lifecycle: any) {\n this.gristConfig = {\n list: {\n fields: ['name', 'description'],\n details: ['active', 'updatedAt']\n },\n columns: [\n { type: 'gutter', gutterName: 'sequence' },\n { type: 'gutter', gutterName: 'row-selector', multiple: true },\n {\n type: 'string',\n name: 'name',\n header: i18next.t('field.name'),\n record: {\n editable: true\n },\n filter: 'search',\n sortable: true,\n width: 150\n },\n {\n type: 'string',\n name: 'description',\n header: i18next.t('field.description'),\n record: {\n editable: true\n },\n filter: 'search',\n width: 200\n },\n {\n type: 'resource-object',\n name: 'updater',\n header: i18next.t('field.updater'),\n record: {\n editable: false\n },\n sortable: true,\n width: 120\n },\n {\n type: 'datetime',\n name: 'updatedAt',\n header: i18next.t('field.updated_at'),\n record: {\n editable: false\n },\n sortable: true,\n width: 180\n }\n ],\n rows: {\n selectable: {\n multiple: true\n }\n },\n sorters: [\n {\n name: 'name'\n }\n ]\n }\n }\n\n async pageUpdated(changes: any, lifecycle: any) {\n if (this.active) {\n // do something here when this page just became as active\n }\n }\n\n async fetchHandler({ page = 1, limit = 100, sortings = [], filters = [] }: FetchOption) {\n const response = await client.query({\n query: gql`\n query ($filters: [Filter!], $pagination: Pagination, $sortings: [Sorting!]) {\n responses: boardTemplates(filters: $filters, pagination: $pagination, sortings: $sortings) {\n items {\n id\n name\n description\n state\n model\n thumbnail\n updater {\n id\n name\n }\n updatedAt\n }\n total\n }\n }\n `,\n variables: {\n filters,\n pagination: { page, limit },\n sortings\n }\n })\n\n return {\n total: response.data.responses.total || 0,\n records: response.data.responses.items || []\n }\n }\n\n async _deleteBoardTemplate() {\n if (confirm(i18next.t('text.sure_to_x', { x: i18next.t('text.delete') }))) {\n const ids = this.grist.selected.map(record => record.id)\n if (ids && ids.length > 0) {\n const response = await client.mutate({\n mutation: gql`\n mutation ($ids: [String!]!) {\n deleteBoardTemplates(ids: $ids)\n }\n `,\n variables: {\n ids\n }\n })\n\n if (!response.errors) {\n this.grist.fetch()\n notify({\n message: i18next.t('text.info_x_successfully', { x: i18next.t('text.delete') })\n })\n }\n }\n }\n }\n\n async _updateBoardTemplate() {\n let patches = this.grist.dirtyRecords\n if (patches && patches.length) {\n patches = patches.map(patch => {\n let patchField: any = patch.id ? { id: patch.id } : {}\n const dirtyFields = patch.__dirtyfields__\n for (let key in dirtyFields) {\n patchField[key] = dirtyFields[key].after\n }\n patchField.cuFlag = patch.__dirty__\n\n return patchField\n })\n\n const response = await client.mutate({\n mutation: gql`\n mutation ($patches: [BoardTemplatePatch!]!) {\n updateMultipleBoardTemplate(patches: $patches) {\n name\n }\n }\n `,\n variables: {\n patches\n }\n })\n\n if (!response.errors) {\n this.grist.fetch()\n }\n }\n }\n}\n"]}