@things-factory/board-ui 6.1.118 → 6.1.122

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.
@@ -0,0 +1,14 @@
1
+ import '@operato/board/ox-board-selector.js';
2
+ import './board-renderer';
3
+ import { OxGristEditor } from '@operato/data-grist';
4
+ export declare class LegendEditor extends OxGristEditor {
5
+ static styles: import("lit").CSSResult;
6
+ value: any;
7
+ column: any;
8
+ record: any;
9
+ row?: number;
10
+ popup: any;
11
+ render(): import("lit-html").TemplateResult<1>;
12
+ firstUpdated(): Promise<void>;
13
+ openSelector(): void;
14
+ }
@@ -0,0 +1,108 @@
1
+ import { __decorate, __metadata } from "tslib";
2
+ import '@operato/board/ox-board-selector.js';
3
+ import './board-renderer';
4
+ import { css, html } from 'lit';
5
+ import { customElement, property } from 'lit/decorators.js';
6
+ import { OxGristEditor } from '@operato/data-grist';
7
+ import { i18next } from '@operato/i18n';
8
+ import { openPopup } from '@operato/layout';
9
+ let LegendEditor = class LegendEditor extends OxGristEditor {
10
+ render() {
11
+ var { boardViewerPage } = this.column.record.options || {};
12
+ return html ` <board-renderer .value=${this.value} .boardViewerPage=${boardViewerPage}></board-renderer> `;
13
+ }
14
+ async firstUpdated() {
15
+ this.value = this.record[this.column.name];
16
+ await this.updateComplete;
17
+ this.renderRoot.addEventListener('click', e => {
18
+ e.stopPropagation();
19
+ this.openSelector();
20
+ });
21
+ this.openSelector();
22
+ }
23
+ openSelector() {
24
+ if (this.popup) {
25
+ delete this.popup;
26
+ }
27
+ /*
28
+ * 기존 설정된 보드가 선택된 상태가 되게 하기 위해서는 selector에 value를 전달해줄 필요가 있음.
29
+ * 주의. value는 object일 수도 있고, string일 수도 있다.
30
+ * string인 경우에는 해당 보드의 id로 해석한다.
31
+ */
32
+ var value = this.value || {};
33
+ var template = html `
34
+ <ox-board-selector
35
+ .creatable=${true}
36
+ .value=${this.value}
37
+ @board-selected=${async (e) => {
38
+ var board = e.detail.board;
39
+ this.dispatchEvent(new CustomEvent('field-change', {
40
+ bubbles: true,
41
+ composed: true,
42
+ detail: {
43
+ before: this.value,
44
+ after: this.column.type == 'board' ? board : board.id || '',
45
+ record: this.record,
46
+ column: this.column,
47
+ row: this.row
48
+ }
49
+ }));
50
+ this.popup && this.popup.close();
51
+ }}
52
+ ></ox-board-selector>
53
+ `;
54
+ this.popup = openPopup(template, {
55
+ backdrop: true,
56
+ size: 'large',
57
+ title: i18next.t('title.select board')
58
+ });
59
+ }
60
+ };
61
+ LegendEditor.styles = css `
62
+ :host {
63
+ display: flex;
64
+ flex-flow: row nowrap;
65
+ align-items: center;
66
+
67
+ box-sizing: border-box;
68
+
69
+ width: 100%;
70
+ height: 100%;
71
+
72
+ border: 0;
73
+ background-color: transparent;
74
+
75
+ font: var(--grist-object-editor-font);
76
+ color: var(--grist-object-editor-color);
77
+
78
+ justify-content: inherit;
79
+ }
80
+
81
+ board-renderer {
82
+ display: flex;
83
+ flex: auto;
84
+
85
+ justify-content: inherit;
86
+ }
87
+ `;
88
+ __decorate([
89
+ property({ type: Object }),
90
+ __metadata("design:type", Object)
91
+ ], LegendEditor.prototype, "value", void 0);
92
+ __decorate([
93
+ property({ type: Object }),
94
+ __metadata("design:type", Object)
95
+ ], LegendEditor.prototype, "column", void 0);
96
+ __decorate([
97
+ property({ type: Object }),
98
+ __metadata("design:type", Object)
99
+ ], LegendEditor.prototype, "record", void 0);
100
+ __decorate([
101
+ property({ type: Number }),
102
+ __metadata("design:type", Number)
103
+ ], LegendEditor.prototype, "row", void 0);
104
+ LegendEditor = __decorate([
105
+ customElement('legend-editor')
106
+ ], LegendEditor);
107
+ export { LegendEditor };
108
+ //# sourceMappingURL=legend-editor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"legend-editor.js","sourceRoot":"","sources":["../../client/data-grist/legend-editor.ts"],"names":[],"mappings":";AAAA,OAAO,qCAAqC,CAAA;AAC5C,OAAO,kBAAkB,CAAA;AAEzB,OAAO,EAAE,GA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AAI,CAAC,aAAa,CAChB,IAAI,WAAW,CAAC,cAAc,EAAE;gBAC9B,OAAO,EAAE,IAAI;gBACb,QAAQ,EAAE,IAAI;gBACd,MAAM,EAAE;oBACN,MAAM,EAAE,IAAI,CAAC,KAAK;oBAClB,KAAK,EAAE,IAAI,CAAC,MAAM,CAAC,IAAI,IAAI,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,EAAE,IAAI,EAAE;oBAC3D,MAAM,EAAE,IAAI,CAAC,MAAM;oBACnB,MAAM,EAAE,IAAI,CAAC,MAAM;oBACnB,GAAG,EAAE,IAAI,CAAC,GAAG;iBACd;aACF,CAAC,CACH,CAAA;YAED,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,CAAA;QAClC,CAAC;;KAEJ,CAAA;QAED,IAAI,CAAC,KAAK,GAAG,SAAS,CAAC,QAAQ,EAAE;YAC/B,QAAQ,EAAE,IAAI;YACd,IAAI,EAAE,OAAO;YACb,KAAK,EAAE,OAAO,CAAC,CAAC,CAAC,oBAAoB,CAAC;SACvC,CAAC,CAAA;IACJ,CAAC;;AAjGM,mBAAM,GAAG,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BlB,CAAA;AAED;IAAC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;2CAAW;AACtC;IAAC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;4CAAY;AACvC;IAAC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;4CAAY;AACvC;IAAC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;yCAAa;AAhC7B,YAAY;IADxB,aAAa,CAAC,eAAe,CAAC;GAClB,YAAY,CAmGxB;SAnGY,YAAY","sourcesContent":["import '@operato/board/ox-board-selector.js'\nimport './board-renderer'\n\nimport { css, html, LitElement } from 'lit'\nimport { customElement, property, query } from 'lit/decorators.js'\n\nimport { OxGristEditor } from '@operato/data-grist'\nimport { i18next } from '@operato/i18n'\nimport { openPopup } from '@operato/layout'\n\n@customElement('legend-editor')\nexport class LegendEditor extends OxGristEditor {\n static styles = css`\n :host {\n display: flex;\n flex-flow: row nowrap;\n align-items: center;\n\n box-sizing: border-box;\n\n width: 100%;\n height: 100%;\n\n border: 0;\n background-color: transparent;\n\n font: var(--grist-object-editor-font);\n color: var(--grist-object-editor-color);\n\n justify-content: inherit;\n }\n\n board-renderer {\n display: flex;\n flex: auto;\n\n justify-content: inherit;\n }\n `\n\n @property({ type: Object }) value: any\n @property({ type: Object }) column: any\n @property({ type: Object }) record: any\n @property({ type: Number }) row?: number\n\n popup\n\n render() {\n var { boardViewerPage } = this.column.record.options || {}\n return html` <board-renderer .value=${this.value} .boardViewerPage=${boardViewerPage}></board-renderer> `\n }\n\n async firstUpdated() {\n this.value = this.record[this.column.name]\n\n await this.updateComplete\n\n this.renderRoot.addEventListener('click', e => {\n e.stopPropagation()\n\n this.openSelector()\n })\n\n this.openSelector()\n }\n\n openSelector() {\n if (this.popup) {\n delete this.popup\n }\n\n /*\n * 기존 설정된 보드가 선택된 상태가 되게 하기 위해서는 selector에 value를 전달해줄 필요가 있음.\n * 주의. value는 object일 수도 있고, string일 수도 있다.\n * string인 경우에는 해당 보드의 id로 해석한다.\n */\n var value = this.value || {}\n\n var template = html`\n <ox-board-selector\n .creatable=${true}\n .value=${this.value}\n @board-selected=${async e => {\n var board = e.detail.board\n\n this.dispatchEvent(\n new CustomEvent('field-change', {\n bubbles: true,\n composed: true,\n detail: {\n before: this.value,\n after: this.column.type == 'board' ? board : board.id || '',\n record: this.record,\n column: this.column,\n row: this.row\n }\n })\n )\n\n this.popup && this.popup.close()\n }}\n ></ox-board-selector>\n `\n\n this.popup = openPopup(template, {\n backdrop: true,\n size: 'large',\n title: i18next.t('title.select board')\n })\n }\n}\n"]}
@@ -0,0 +1,22 @@
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
+ }
@@ -0,0 +1,100 @@
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 ShareImporter extends LitElement {
10
+ constructor() {
11
+ super(...arguments);
12
+ this.shares = [];
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.shares
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 importShares($shares: [SharePatch!]!) {
58
+ importShares(shares: $shares)
59
+ }
60
+ `,
61
+ variables: { shares: this.shares }
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
+ ShareImporter.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
+ ], ShareImporter.prototype, "shares", void 0);
96
+ __decorate([
97
+ property({ type: Object }),
98
+ __metadata("design:type", Object)
99
+ ], ShareImporter.prototype, "columns", void 0);
100
+ //# sourceMappingURL=share-importer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"share-importer.js","sourceRoot":"","sources":["../../../client/pages/share/share-importer.ts"],"names":[],"mappings":";AAAA,OAAO,qBAAqB,CAAA;AAE5B,OAAO,GAAG,MAAM,aAAa,CAAA;AAC7B,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,KAAK,CAAA;AAC3C,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AAE5C,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAA;AACzC,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AACvC,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAE/C,MAAM,OAAO,aAAc,SAAQ,UAAU;IAA7C;;QA0B6B,WAAM,GAAU,EAAE,CAAA;QACjB,YAAO,GAAG;YACpC,IAAI,EAAE,EAAE,MAAM,EAAE,CAAC,MAAM,EAAE,aAAa,CAAC,EAAE;YACzC,UAAU,EAAE,EAAE,Q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AA;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 ShareImporter 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 }) shares: 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\n render() {\n return html`\n <ox-grist\n .mode=${isMobileDevice() ? 'LIST' : 'GRID'}\n .config=${this.columns}\n .data=${\n { \n records: this.shares \n }\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 importShares($shares: [SharePatch!]!) {\n importShares(shares: $shares)\n }\n `,\n variables: { shares: this.shares }\n })\n\n if (response.errors?.length) return\n\n this.dispatchEvent(new CustomEvent('imported'))\n }\n}\n\n"]}
@@ -0,0 +1,62 @@
1
+ import '@operato/data-grist';
2
+ import { PageView } from '@operato/shell';
3
+ import { FetchOption } from '@operato/data-grist';
4
+ import { ThemeImporter } from './theme-importer';
5
+ declare const ThemeListPage_base: (new (...args: any[]) => {
6
+ _storeUnsubscribe: import("redux").Unsubscribe;
7
+ connectedCallback(): void;
8
+ disconnectedCallback(): void;
9
+ stateChanged(_state: unknown): void;
10
+ readonly isConnected: boolean;
11
+ }) & (new (...args: any[]) => import("lit").LitElement) & typeof PageView & import("@open-wc/dedupe-mixin").Constructor<import("@open-wc/scoped-elements/types/src/types").ScopedElementsHost>;
12
+ export declare class ThemeListPage extends ThemeListPage_base {
13
+ static styles: import("lit").CSSResult[];
14
+ static get scopedElements(): {
15
+ 'theme-importer': typeof ThemeImporter;
16
+ };
17
+ gristConfig: any;
18
+ mode: 'CARD' | 'GRID' | 'LIST';
19
+ private grist;
20
+ private sortersControl;
21
+ get context(): {
22
+ search: {
23
+ handler: (search: string) => void;
24
+ placeholder: string;
25
+ value: string;
26
+ };
27
+ filter: {
28
+ handler: () => void;
29
+ };
30
+ help: string;
31
+ actions: {
32
+ icon: string;
33
+ emphasis: {
34
+ raised: boolean;
35
+ outlined: boolean;
36
+ dense: boolean;
37
+ danger: boolean;
38
+ };
39
+ title: string;
40
+ action: () => Promise<void>;
41
+ }[];
42
+ exportable: {
43
+ name: string;
44
+ data: () => Promise<{}[]>;
45
+ };
46
+ importable: {
47
+ handler: (records: any) => Promise<void>;
48
+ };
49
+ };
50
+ render(): import("lit-html").TemplateResult<1>;
51
+ pageInitialized(lifecycle: any): Promise<void>;
52
+ pageUpdated(changes: any, lifecycle: any): Promise<void>;
53
+ fetchHandler({ page, limit, sortings, filters }: FetchOption): Promise<{
54
+ total: any;
55
+ records: any;
56
+ }>;
57
+ _deleteTheme(): Promise<void>;
58
+ _updateTheme(): Promise<void>;
59
+ exportHandler(): Promise<{}[]>;
60
+ importHandler(records: any): Promise<void>;
61
+ }
62
+ export {};
@@ -0,0 +1,341 @@
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