@things-factory/board-ui 6.1.166 → 6.1.170

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.
@@ -1,341 +0,0 @@
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 { connect } from 'pwa-helpers/connect-mixin';
8
- import gql from 'graphql-tag';
9
- import { ScopedElementsMixin } from '@open-wc/scoped-elements';
10
- import { DataGrist, getEditor, getRenderer } from '@operato/data-grist';
11
- import { client } from '@operato/graphql';
12
- import { i18next, localize } from '@operato/i18n';
13
- import { notify, openPopup } from '@operato/layout';
14
- import { OxPopup } from '@operato/popup';
15
- import { isMobileDevice } from '@operato/utils';
16
- import { ShareImporter } from './share-importer';
17
- // export interface ShareType {
18
- // name: string
19
- // propType: string
20
- // }
21
- // var ShareTypes: { [name: string]: ShareType } = {
22
- // Legend: {
23
- // name: 'Legend',
24
- // propType: 'legend'
25
- // }
26
- // }
27
- let ShareListPage = class ShareListPage extends connect(store)(localize(i18next)(ScopedElementsMixin(PageView))) {
28
- constructor() {
29
- super(...arguments);
30
- this.mode = isMobileDevice() ? 'CARD' : 'GRID';
31
- }
32
- static get scopedElements() {
33
- return {
34
- 'share-importer': ShareImporter
35
- };
36
- }
37
- get context() {
38
- return {
39
- search: {
40
- handler: (search) => {
41
- this.grist.searchText = search;
42
- },
43
- placeholder: i18next.t('title.share list'),
44
- value: this.grist.searchText
45
- },
46
- filter: {
47
- handler: () => {
48
- this.grist.toggleHeadroom();
49
- }
50
- },
51
- help: 'board-service/share',
52
- actions: [
53
- Object.assign({ title: i18next.t('button.save'), action: this._updateShare.bind(this) }, CommonButtonStyles.save),
54
- Object.assign({ title: i18next.t('button.delete'), action: this._deleteShare.bind(this) }, CommonButtonStyles.delete)
55
- ],
56
- exportable: {
57
- name: i18next.t('title.share list'),
58
- data: this.exportHandler.bind(this)
59
- },
60
- importable: {
61
- handler: this.importHandler.bind(this)
62
- }
63
- };
64
- }
65
- render() {
66
- const mode = this.mode || (isMobileDevice() ? 'CARD' : 'GRID');
67
- return html `
68
- <ox-grist .mode=${mode} .config=${this.gristConfig} .fetchHandler=${this.fetchHandler.bind(this)}>
69
- <div slot="headroom">
70
- <div id="filters">
71
- <ox-filters-form autofocus></ox-filters-form>
72
- </div>
73
-
74
- <div id="sorters">
75
- Sort
76
- <mwc-icon
77
- @click=${e => {
78
- const target = e.currentTarget;
79
- this.sortersControl.open({
80
- right: 0,
81
- top: target.offsetTop + target.offsetHeight
82
- });
83
- }}
84
- >expand_more</mwc-icon
85
- >
86
- <ox-popup id="sorter-control">
87
- <ox-sorters-control> </ox-sorters-control>
88
- </ox-popup>
89
- </div>
90
-
91
- <div id="modes">
92
- <mwc-icon @click=${() => (this.mode = 'GRID')} ?active=${mode == 'GRID'}>grid_on</mwc-icon>
93
- <mwc-icon @click=${() => (this.mode = 'LIST')} ?active=${mode == 'LIST'}>format_list_bulleted</mwc-icon>
94
- <mwc-icon @click=${() => (this.mode = 'CARD')} ?active=${mode == 'CARD'}>apps</mwc-icon>
95
- </div>
96
- </div>
97
- </ox-grist>
98
- `;
99
- }
100
- async pageInitialized(lifecycle) {
101
- this.gristConfig = {
102
- list: {
103
- fields: ['name', 'description'],
104
- details: ['active', 'updatedAt']
105
- },
106
- columns: [
107
- { type: 'gutter', gutterName: 'sequence' },
108
- { type: 'gutter', gutterName: 'row-selector', multiple: true },
109
- {
110
- type: 'string',
111
- name: 'name',
112
- header: i18next.t('field.name'),
113
- record: {
114
- editable: true
115
- },
116
- filter: 'search',
117
- sortable: true,
118
- width: 150
119
- },
120
- {
121
- type: 'string',
122
- name: 'description',
123
- header: i18next.t('field.description'),
124
- record: {
125
- editable: true
126
- },
127
- filter: 'search',
128
- width: 200
129
- },
130
- {
131
- type: 'select',
132
- name: 'type',
133
- header: i18next.t('field.type'),
134
- record: {
135
- options: ['', 'legend'],
136
- editable: true
137
- },
138
- width: 120
139
- },
140
- {
141
- type: 'string',
142
- name: 'value',
143
- header: i18next.t('field.value'),
144
- record: {
145
- editor: function (value, column, record, rowIndex, field) {
146
- return getEditor(record.category)(value, column, record, rowIndex, field);
147
- },
148
- renderer: function (value, column, record, rowIndex, field) {
149
- return getRenderer(record.category)(value, column, record, rowIndex, field);
150
- },
151
- editable: true
152
- },
153
- sortable: true,
154
- width: 180
155
- },
156
- {
157
- type: 'resource-object',
158
- name: 'updater',
159
- header: i18next.t('field.updater'),
160
- record: {
161
- editable: false
162
- },
163
- sortable: true,
164
- width: 120
165
- },
166
- {
167
- type: 'datetime',
168
- name: 'updatedAt',
169
- header: i18next.t('field.updated_at'),
170
- record: {
171
- editable: false
172
- },
173
- sortable: true,
174
- width: 180
175
- }
176
- ],
177
- rows: {
178
- selectable: {
179
- multiple: true
180
- }
181
- },
182
- sorters: [
183
- {
184
- name: 'name'
185
- }
186
- ]
187
- };
188
- }
189
- async pageUpdated(changes, lifecycle) {
190
- if (this.active) {
191
- // do something here when this page just became as active
192
- }
193
- }
194
- async fetchHandler({ page = 1, limit = 100, sortings = [], filters = [] }) {
195
- const response = await client.query({
196
- query: gql `
197
- query ($filters: [Filter!], $pagination: Pagination, $sortings: [Sorting!]) {
198
- responses: shares(filters: $filters, pagination: $pagination, sortings: $sortings) {
199
- items {
200
- id
201
- name
202
- description
203
- active
204
- updater {
205
- id
206
- name
207
- }
208
- updatedAt
209
- }
210
- total
211
- }
212
- }
213
- `,
214
- variables: {
215
- filters,
216
- pagination: { page, limit },
217
- sortings
218
- }
219
- });
220
- return {
221
- total: response.data.responses.total || 0,
222
- records: response.data.responses.items || []
223
- };
224
- }
225
- async _deleteShare() {
226
- if (confirm(i18next.t('text.sure_to_x', { x: i18next.t('text.delete') }))) {
227
- const ids = this.grist.selected.map(record => record.id);
228
- if (ids && ids.length > 0) {
229
- const response = await client.mutate({
230
- mutation: gql `
231
- mutation ($ids: [String!]!) {
232
- deleteShares(ids: $ids)
233
- }
234
- `,
235
- variables: {
236
- ids
237
- }
238
- });
239
- if (!response.errors) {
240
- this.grist.fetch();
241
- notify({
242
- message: i18next.t('text.info_x_successfully', { x: i18next.t('text.delete') })
243
- });
244
- }
245
- }
246
- }
247
- }
248
- async _updateShare() {
249
- let patches = this.grist.dirtyRecords;
250
- if (patches && patches.length) {
251
- patches = patches.map(patch => {
252
- let patchField = patch.id ? { id: patch.id } : {};
253
- const dirtyFields = patch.__dirtyfields__;
254
- for (let key in dirtyFields) {
255
- patchField[key] = dirtyFields[key].after;
256
- }
257
- patchField.cuFlag = patch.__dirty__;
258
- return patchField;
259
- });
260
- const response = await client.mutate({
261
- mutation: gql `
262
- mutation ($patches: [SharePatch!]!) {
263
- updateMultipleShare(patches: $patches) {
264
- name
265
- }
266
- }
267
- `,
268
- variables: {
269
- patches
270
- }
271
- });
272
- if (!response.errors) {
273
- this.grist.fetch();
274
- }
275
- }
276
- }
277
- async exportHandler() {
278
- const exportTargets = this.grist.selected.length ? this.grist.selected : this.grist.dirtyData.records;
279
- const targetFieldSet = new Set(['id', 'name', 'description', 'active']);
280
- return exportTargets.map(share => {
281
- let tempObj = {};
282
- for (const field of targetFieldSet) {
283
- tempObj[field] = share[field];
284
- }
285
- return tempObj;
286
- });
287
- }
288
- async importHandler(records) {
289
- const popup = openPopup(html `
290
- <share-importer
291
- .shares=${records}
292
- @imported=${() => {
293
- history.back();
294
- this.grist.fetch();
295
- }}
296
- ></share-importer>
297
- `, {
298
- backdrop: true,
299
- size: 'large',
300
- title: i18next.t('title.import share')
301
- });
302
- popup.onclosed = () => {
303
- this.grist.fetch();
304
- };
305
- }
306
- };
307
- ShareListPage.styles = [
308
- ScrollbarStyles,
309
- CommonGristStyles,
310
- css `
311
- :host {
312
- display: flex;
313
-
314
- width: 100%;
315
-
316
- --grid-record-emphasized-background-color: red;
317
- --grid-record-emphasized-color: yellow;
318
- }
319
- `
320
- ];
321
- __decorate([
322
- property({ type: Object }),
323
- __metadata("design:type", Object)
324
- ], ShareListPage.prototype, "gristConfig", void 0);
325
- __decorate([
326
- property({ type: String }),
327
- __metadata("design:type", String)
328
- ], ShareListPage.prototype, "mode", void 0);
329
- __decorate([
330
- query('ox-grist'),
331
- __metadata("design:type", DataGrist)
332
- ], ShareListPage.prototype, "grist", void 0);
333
- __decorate([
334
- query('#sorter-control'),
335
- __metadata("design:type", OxPopup)
336
- ], ShareListPage.prototype, "sortersControl", void 0);
337
- ShareListPage = __decorate([
338
- customElement('share-list-page')
339
- ], ShareListPage);
340
- export { ShareListPage };
341
- //# sourceMappingURL=share-list-page.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"share-list-page.js","sourceRoot":"","sources":["../../../client/pages/share/share-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,CAAA;AAC/B,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AAClE,OAAO,EAAE,OAAO,EAAE,MAAM,2BAA2B,CAAA;AACnD,OAAO,GAAG,MAAM,aAAa,CAAA;AAC7B,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAA;AAC9D,OAAO,EAAgB,SAAS,EAA+B,SAAS,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAA;AAElH,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAA;AACzC,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AACjD,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA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/styles'\nimport { PageView, store } from '@operato/shell'\nimport { css, html } from 'lit'\nimport { customElement, property, query } from 'lit/decorators.js'\nimport { connect } from 'pwa-helpers/connect-mixin'\nimport gql from 'graphql-tag'\nimport { ScopedElementsMixin } from '@open-wc/scoped-elements'\nimport { ColumnConfig, DataGrist, FetchOption, SortersControl, getEditor, getRenderer } from '@operato/data-grist'\n\nimport { client } from '@operato/graphql'\nimport { i18next, localize } from '@operato/i18n'\nimport { notify, openPopup } from '@operato/layout'\nimport { OxPopup } from '@operato/popup'\nimport { isMobileDevice } from '@operato/utils'\n\nimport { ShareImporter } from './share-importer'\n\n// export interface ShareType {\n// name: string\n// propType: string\n// }\n\n// var ShareTypes: { [name: string]: ShareType } = {\n// Legend: {\n// name: 'Legend',\n// propType: 'legend'\n// }\n// }\n\n@customElement('share-list-page')\nexport class ShareListPage 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 static get scopedElements() {\n return {\n 'share-importer': ShareImporter\n }\n }\n\n @property({ type: Object }) gristConfig: any\n @property({ type: String }) mode: 'CARD' | 'GRID' | 'LIST' = isMobileDevice() ? 'CARD' : 'GRID'\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.share list'),\n value: this.grist.searchText\n },\n filter: {\n handler: () => {\n this.grist.toggleHeadroom()\n }\n },\n help: 'board-service/share',\n actions: [\n {\n title: i18next.t('button.save'),\n action: this._updateShare.bind(this),\n ...CommonButtonStyles.save\n },\n {\n title: i18next.t('button.delete'),\n action: this._deleteShare.bind(this),\n ...CommonButtonStyles.delete\n }\n ],\n exportable: {\n name: i18next.t('title.share list'),\n data: this.exportHandler.bind(this)\n },\n importable: {\n handler: this.importHandler.bind(this)\n }\n }\n }\n\n render() {\n const mode = this.mode || (isMobileDevice() ? 'CARD' : 'GRID')\n\n return html`\n <ox-grist .mode=${mode} .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\n <div id=\"modes\">\n <mwc-icon @click=${() => (this.mode = 'GRID')} ?active=${mode == 'GRID'}>grid_on</mwc-icon>\n <mwc-icon @click=${() => (this.mode = 'LIST')} ?active=${mode == 'LIST'}>format_list_bulleted</mwc-icon>\n <mwc-icon @click=${() => (this.mode = 'CARD')} ?active=${mode == 'CARD'}>apps</mwc-icon>\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: 'select',\n name: 'type',\n header: i18next.t('field.type'),\n record: {\n options: ['', 'legend'],\n editable: true\n },\n width: 120\n },\n {\n type: 'string',\n name: 'value',\n header: i18next.t('field.value'),\n record: {\n editor: function (value, column, record, rowIndex, field) {\n return getEditor(record.category)(value, column, record, rowIndex, field)\n },\n renderer: function (value, column, record, rowIndex, field) {\n return getRenderer(record.category)(value, column, record, rowIndex, field)\n },\n editable: true\n },\n sortable: true,\n width: 180\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: shares(filters: $filters, pagination: $pagination, sortings: $sortings) {\n items {\n id\n name\n description\n active\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 _deleteShare() {\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 deleteShares(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 _updateShare() {\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: [SharePatch!]!) {\n updateMultipleShare(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 async exportHandler() {\n const exportTargets = this.grist.selected.length ? this.grist.selected : this.grist.dirtyData.records\n const targetFieldSet = new Set(['id', 'name', 'description', 'active'])\n\n return exportTargets.map(share => {\n let tempObj = {}\n for (const field of targetFieldSet) {\n tempObj[field] = share[field]\n }\n\n return tempObj\n })\n }\n\n async importHandler(records) {\n const popup = openPopup(\n html`\n <share-importer\n .shares=${records}\n @imported=${() => {\n history.back()\n this.grist.fetch()\n }}\n ></share-importer>\n `,\n {\n backdrop: true,\n size: 'large',\n title: i18next.t('title.import share')\n }\n )\n\n popup.onclosed = () => {\n this.grist.fetch()\n }\n }\n}\n"]}
@@ -1,22 +0,0 @@
1
- import '@operato/data-grist';
2
- import { LitElement } from 'lit';
3
- export declare class ThemeImporter extends LitElement {
4
- static styles: import("lit").CSSResult[];
5
- themes: any[];
6
- columns: {
7
- list: {
8
- fields: string[];
9
- };
10
- pagination: {
11
- infinite: boolean;
12
- };
13
- columns: {
14
- type: string;
15
- name: string;
16
- header: string;
17
- width: number;
18
- }[];
19
- };
20
- render(): import("lit-html").TemplateResult<1>;
21
- save(): Promise<void>;
22
- }
@@ -1,100 +0,0 @@
1
- import { __decorate, __metadata } from "tslib";
2
- import '@operato/data-grist';
3
- import gql from 'graphql-tag';
4
- import { css, html, LitElement } from 'lit';
5
- import { property } from 'lit/decorators.js';
6
- import { client } from '@operato/graphql';
7
- import { i18next } from '@operato/i18n';
8
- import { isMobileDevice } from '@operato/utils';
9
- export class ThemeImporter extends LitElement {
10
- constructor() {
11
- super(...arguments);
12
- this.themes = [];
13
- this.columns = {
14
- list: { fields: ['name', 'description'] },
15
- pagination: { infinite: true },
16
- columns: [
17
- {
18
- type: 'string',
19
- name: 'name',
20
- header: i18next.t('field.name'),
21
- width: 150
22
- },
23
- {
24
- type: 'string',
25
- name: 'description',
26
- header: i18next.t('field.description'),
27
- width: 200
28
- },
29
- {
30
- type: 'checkbox',
31
- name: 'active',
32
- header: i18next.t('field.active'),
33
- width: 60
34
- }
35
- ]
36
- };
37
- }
38
- render() {
39
- return html `
40
- <ox-grist
41
- .mode=${isMobileDevice() ? 'LIST' : 'GRID'}
42
- .config=${this.columns}
43
- .data=${{
44
- records: this.themes
45
- }}
46
- ></ox-grist>
47
-
48
- <div class="button-container">
49
- <mwc-button raised @click="${this.save.bind(this)}">${i18next.t('button.save')}</mwc-button>
50
- </div>
51
- `;
52
- }
53
- async save() {
54
- var _a;
55
- const response = await client.mutate({
56
- mutation: gql `
57
- mutation importThemes($themes: [ThemePatch!]!) {
58
- importThemes(themes: $themes)
59
- }
60
- `,
61
- variables: { themes: this.themes }
62
- });
63
- if ((_a = response.errors) === null || _a === void 0 ? void 0 : _a.length)
64
- return;
65
- this.dispatchEvent(new CustomEvent('imported'));
66
- }
67
- }
68
- ThemeImporter.styles = [
69
- css `
70
- :host {
71
- display: flex;
72
- flex-direction: column;
73
-
74
- background-color: #fff;
75
- }
76
-
77
- ox-grist {
78
- flex: 1;
79
- }
80
-
81
- .button-container {
82
- display: flex;
83
- margin-left: auto;
84
- padding: var(--padding-default);
85
- }
86
-
87
- mwc-button {
88
- margin-left: var(--margin-default);
89
- }
90
- `
91
- ];
92
- __decorate([
93
- property({ type: Array }),
94
- __metadata("design:type", Array)
95
- ], ThemeImporter.prototype, "themes", void 0);
96
- __decorate([
97
- property({ type: Object }),
98
- __metadata("design:type", Object)
99
- ], ThemeImporter.prototype, "columns", void 0);
100
- //# sourceMappingURL=theme-importer.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"theme-importer.js","sourceRoot":"","sources":["../../../client/pages/theme/theme-importer.ts"],"names":[],"mappings":";AAAA,OAAO,qBAAqB,CAAA;AAE5B,OAAO,GAAG,MAAM,aAAa,CAAA;AAC7B,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,UAAU,EAAE,MA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CAAC,IAAI;;QACR,MAAM,QAAQ,GAAG,MAAM,MAAM,CAAC,MAAM,CAAC;YACnC,QAAQ,EAAE,GAAG,CAAA;;;;OAIZ;YACD,SAAS,EAAE,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE;SACnC,CAAC,CAAA;QAEF,IAAI,MAAA,QAAQ,CAAC,MAAM,0CAAE,MAAM;YAAE,OAAM;QAEnC,IAAI,CAAC,aAAa,CAAC,IAAI,WAAW,CAAC,UAAU,CAAC,CAAC,CAAA;IACjD,CAAC;;AAhFM,oBAAM,GAAG;IACd,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;KAqBF;CACF,CAAA;AAED;IAAC,QAAQ,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;;6CAAmB;AAC7C;IAAC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;8CAuB1B","sourcesContent":["import '@operato/data-grist'\n\nimport gql from 'graphql-tag'\nimport { css, html, LitElement } from 'lit'\nimport { property } from 'lit/decorators.js'\n\nimport { client } from '@operato/graphql'\nimport { i18next } from '@operato/i18n'\nimport { isMobileDevice } from '@operato/utils'\n\nexport class ThemeImporter extends LitElement {\n static styles = [\n css`\n :host {\n display: flex;\n flex-direction: column;\n\n background-color: #fff;\n }\n\n ox-grist {\n flex: 1;\n }\n\n .button-container {\n display: flex;\n margin-left: auto;\n padding: var(--padding-default);\n }\n\n mwc-button {\n margin-left: var(--margin-default);\n }\n `\n ]\n\n @property({ type: Array }) themes: any[] = []\n @property({ type: Object }) columns = {\n list: { fields: ['name', 'description'] },\n pagination: { infinite: true },\n columns: [\n {\n type: 'string',\n name: 'name',\n header: i18next.t('field.name'),\n width: 150\n },\n {\n type: 'string',\n name: 'description',\n header: i18next.t('field.description'),\n width: 200\n },\n {\n type: 'checkbox',\n name: 'active',\n header: i18next.t('field.active'),\n width: 60\n }\n ]\n }\n\n render() {\n return html`\n <ox-grist\n .mode=${isMobileDevice() ? 'LIST' : 'GRID'}\n .config=${this.columns}\n .data=${{\n records: this.themes\n }}\n ></ox-grist>\n\n <div class=\"button-container\">\n <mwc-button raised @click=\"${this.save.bind(this)}\">${i18next.t('button.save')}</mwc-button>\n </div>\n `\n }\n\n async save() {\n const response = await client.mutate({\n mutation: gql`\n mutation importThemes($themes: [ThemePatch!]!) {\n importThemes(themes: $themes)\n }\n `,\n variables: { themes: this.themes }\n })\n\n if (response.errors?.length) return\n\n this.dispatchEvent(new CustomEvent('imported'))\n }\n}\n"]}