@things-factory/id-rule 0.0.0-stage → 10.1.199
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/dist-client/bootstrap.d.ts +1 -0
- package/dist-client/bootstrap.js +7 -0
- package/dist-client/bootstrap.js.map +1 -0
- package/dist-client/editors/grist-code-input-popup.d.ts +24 -0
- package/dist-client/editors/grist-code-input-popup.js +202 -0
- package/dist-client/editors/grist-code-input-popup.js.map +1 -0
- package/dist-client/editors/grist-code-input.d.ts +12 -0
- package/dist-client/editors/grist-code-input.js +118 -0
- package/dist-client/editors/grist-code-input.js.map +1 -0
- package/dist-client/index.d.ts +0 -0
- package/dist-client/index.js +2 -0
- package/dist-client/index.js.map +1 -0
- package/dist-client/tsconfig.tsbuildinfo +1 -0
- package/dist-server/constants/index.d.ts +1 -0
- package/dist-server/constants/index.js +5 -0
- package/dist-server/constants/index.js.map +1 -0
- package/dist-server/constants/sequence-type.d.ts +3 -0
- package/dist-server/constants/sequence-type.js +7 -0
- package/dist-server/constants/sequence-type.js.map +1 -0
- package/dist-server/controllers/id-generator.d.ts +13 -0
- package/dist-server/controllers/id-generator.js +61 -0
- package/dist-server/controllers/id-generator.js.map +1 -0
- package/dist-server/controllers/index.d.ts +1 -0
- package/dist-server/controllers/index.js +5 -0
- package/dist-server/controllers/index.js.map +1 -0
- package/dist-server/index.d.ts +5 -0
- package/dist-server/index.js +9 -0
- package/dist-server/index.js.map +1 -0
- package/dist-server/migrations/index.d.ts +1 -0
- package/dist-server/migrations/index.js +12 -0
- package/dist-server/migrations/index.js.map +1 -0
- package/dist-server/routes.d.ts +1 -0
- package/dist-server/routes.js +25 -0
- package/dist-server/routes.js.map +1 -0
- package/dist-server/service/doc-number/doc-number-mutation.d.ts +9 -0
- package/dist-server/service/doc-number/doc-number-mutation.js +135 -0
- package/dist-server/service/doc-number/doc-number-mutation.js.map +1 -0
- package/dist-server/service/doc-number/doc-number-query.d.ts +13 -0
- package/dist-server/service/doc-number/doc-number-query.js +170 -0
- package/dist-server/service/doc-number/doc-number-query.js.map +1 -0
- package/dist-server/service/doc-number/doc-number-type.d.ts +41 -0
- package/dist-server/service/doc-number/doc-number-type.js +161 -0
- package/dist-server/service/doc-number/doc-number-type.js.map +1 -0
- package/dist-server/service/doc-number/doc-number.d.ts +29 -0
- package/dist-server/service/doc-number/doc-number.js +175 -0
- package/dist-server/service/doc-number/doc-number.js.map +1 -0
- package/dist-server/service/doc-number/index.d.ts +5 -0
- package/dist-server/service/doc-number/index.js +9 -0
- package/dist-server/service/doc-number/index.js.map +1 -0
- package/dist-server/service/id-rule/id-rule-mutation.d.ts +10 -0
- package/dist-server/service/id-rule/id-rule-mutation.js +50 -0
- package/dist-server/service/id-rule/id-rule-mutation.js.map +1 -0
- package/dist-server/service/id-rule/id-rule-query.d.ts +6 -0
- package/dist-server/service/id-rule/id-rule-query.js +41 -0
- package/dist-server/service/id-rule/id-rule-query.js.map +1 -0
- package/dist-server/service/id-rule/id-rule-types.d.ts +8 -0
- package/dist-server/service/id-rule/id-rule-types.js +34 -0
- package/dist-server/service/id-rule/id-rule-types.js.map +1 -0
- package/dist-server/service/id-rule/id-rule.d.ts +10 -0
- package/dist-server/service/id-rule/id-rule.js +50 -0
- package/dist-server/service/id-rule/id-rule.js.map +1 -0
- package/dist-server/service/id-rule/index.d.ts +5 -0
- package/dist-server/service/id-rule/index.js +9 -0
- package/dist-server/service/id-rule/index.js.map +1 -0
- package/dist-server/service/index.d.ts +8 -0
- package/dist-server/service/index.js +18 -0
- package/dist-server/service/index.js.map +1 -0
- package/dist-server/service/sequence/index.d.ts +4 -0
- package/dist-server/service/sequence/index.js +8 -0
- package/dist-server/service/sequence/index.js.map +1 -0
- package/dist-server/service/sequence/sequence-mutation.d.ts +4 -0
- package/dist-server/service/sequence/sequence-mutation.js +59 -0
- package/dist-server/service/sequence/sequence-mutation.js.map +1 -0
- package/dist-server/service/sequence/sequence.d.ts +12 -0
- package/dist-server/service/sequence/sequence.js +64 -0
- package/dist-server/service/sequence/sequence.js.map +1 -0
- package/dist-server/tsconfig.tsbuildinfo +1 -0
- package/package.json +35 -4
- package/tests/open-doors.test.ts +41 -0
- package/things-factory.config.js +5 -0
- package/translations/en.json +22 -0
- package/translations/es.json +22 -0
- package/translations/ja.json +22 -0
- package/translations/ko.json +22 -0
- package/translations/ms.json +22 -0
- package/translations/zh.json +22 -0
- package/README.md +0 -3
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function bootstrap(): void;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { registerEditor } from '@operato/data-grist';
|
|
2
|
+
import { GristCodeInput } from './editors/grist-code-input';
|
|
3
|
+
export default function bootstrap() {
|
|
4
|
+
/* id-rule 의 GristRenderer는 텍스트와 같으므로, 별도로 정의하지 않음. */
|
|
5
|
+
registerEditor('id-rule', GristCodeInput);
|
|
6
|
+
}
|
|
7
|
+
//# sourceMappingURL=bootstrap.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bootstrap.js","sourceRoot":"","sources":["../client/bootstrap.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAA;AAEpD,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAA;AAE3D,MAAM,CAAC,OAAO,UAAU,SAAS;IAC/B,sDAAsD;IACtD,cAAc,CAAC,SAAS,EAAE,cAAc,CAAC,CAAA;AAC3C,CAAC","sourcesContent":["import { registerEditor } from '@operato/data-grist'\n\nimport { GristCodeInput } from './editors/grist-code-input'\n\nexport default function bootstrap() {\n /* id-rule 의 GristRenderer는 텍스트와 같으므로, 별도로 정의하지 않음. */\n registerEditor('id-rule', GristCodeInput)\n}\n"]}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import '@material/web/button/elevated-button.js';
|
|
2
|
+
import '@operato/i18n/ox-i18n.js';
|
|
3
|
+
import '@operato/input/ox-input-code.js';
|
|
4
|
+
import { LitElement } from 'lit';
|
|
5
|
+
import { ColumnConfig, GristRecord } from '@operato/data-grist';
|
|
6
|
+
import { OxInputCode } from '@operato/input';
|
|
7
|
+
export declare class GristCodeInputPopup extends LitElement {
|
|
8
|
+
static styles: import("lit").CSSResult[];
|
|
9
|
+
value?: string;
|
|
10
|
+
column?: ColumnConfig;
|
|
11
|
+
record?: GristRecord;
|
|
12
|
+
row?: number;
|
|
13
|
+
field?: any;
|
|
14
|
+
_idRule?: any;
|
|
15
|
+
headers?: {
|
|
16
|
+
[header: string]: string;
|
|
17
|
+
};
|
|
18
|
+
ruleEditor: OxInputCode;
|
|
19
|
+
render(): import("lit-html").TemplateResult<1>;
|
|
20
|
+
updated(changed: any): void;
|
|
21
|
+
getRule(): Promise<void>;
|
|
22
|
+
createIdRule(): Promise<any>;
|
|
23
|
+
updateIdRule(): Promise<void>;
|
|
24
|
+
}
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
import { __decorate, __metadata } from "tslib";
|
|
2
|
+
import '@material/web/button/elevated-button.js';
|
|
3
|
+
import '@operato/i18n/ox-i18n.js';
|
|
4
|
+
import '@operato/input/ox-input-code.js';
|
|
5
|
+
import gql from 'graphql-tag';
|
|
6
|
+
import { css, html, LitElement } from 'lit';
|
|
7
|
+
import { customElement, property, query } from 'lit/decorators.js';
|
|
8
|
+
import { i18next } from '@operato/i18n';
|
|
9
|
+
import { client } from '@operato/graphql';
|
|
10
|
+
import { OxInputCode } from '@operato/input';
|
|
11
|
+
const FETCH_ID_RULE_GQL = type => {
|
|
12
|
+
return gql `
|
|
13
|
+
{
|
|
14
|
+
idRule(type:"${type}") {
|
|
15
|
+
id,
|
|
16
|
+
type,
|
|
17
|
+
rule
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
`;
|
|
21
|
+
};
|
|
22
|
+
let GristCodeInputPopup = class GristCodeInputPopup extends LitElement {
|
|
23
|
+
static { this.styles = [
|
|
24
|
+
css `
|
|
25
|
+
:host {
|
|
26
|
+
display: flex;
|
|
27
|
+
flex-direction: column;
|
|
28
|
+
padding: 0;
|
|
29
|
+
align-items: center;
|
|
30
|
+
box-sizing: border-box;
|
|
31
|
+
width: 100%;
|
|
32
|
+
border: 0;
|
|
33
|
+
color: var(--popup-content-color);
|
|
34
|
+
background-color: var(--popup-content-background-color);
|
|
35
|
+
|
|
36
|
+
font: var(--grist-object-editor-font);
|
|
37
|
+
|
|
38
|
+
justify-content: inherit;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
:host * {
|
|
42
|
+
box-sizing: border-box;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
#wrapper {
|
|
46
|
+
flex: 1;
|
|
47
|
+
width: 100%;
|
|
48
|
+
display: flex;
|
|
49
|
+
flex-direction: column;
|
|
50
|
+
padding: 5px;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
#wrapper > h4 {
|
|
54
|
+
margin: 0;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
#wrapper > ul {
|
|
58
|
+
width: 100%;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
#wrapper > ul > li {
|
|
62
|
+
display: flex;
|
|
63
|
+
}
|
|
64
|
+
#wrapper > ul > li > span {
|
|
65
|
+
font-weight: bold;
|
|
66
|
+
flex-basis: 200px;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
#wrapper > ul > li > ox-i18n {
|
|
70
|
+
flex: 1;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
ox-input-code {
|
|
74
|
+
width: 100%;
|
|
75
|
+
flex: 1;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
#footer {
|
|
79
|
+
display: flex;
|
|
80
|
+
justify-content: flex-end;
|
|
81
|
+
}
|
|
82
|
+
`
|
|
83
|
+
]; }
|
|
84
|
+
render() {
|
|
85
|
+
return html `
|
|
86
|
+
<div id="wrapper">
|
|
87
|
+
<h4><ox-i18n msgid="label.arguments"></ox-i18n></h4>
|
|
88
|
+
<ul>
|
|
89
|
+
<li><span>domain</span><ox-i18n msgid="label.argument domain description"></ox-i18n></li>
|
|
90
|
+
<li><span>seed</span><ox-i18n msgid="label.argument seed description"></ox-i18n></li>
|
|
91
|
+
</ul>
|
|
92
|
+
<ox-input-code id="rule-editor" type="text" .value=${(this._idRule || {}).rule}></ox-input-code>
|
|
93
|
+
|
|
94
|
+
<div id="footer">
|
|
95
|
+
<md-elevated-button
|
|
96
|
+
label=${String(i18next.t('button.save'))}
|
|
97
|
+
@click=${(e) => {
|
|
98
|
+
this.updateIdRule();
|
|
99
|
+
}}
|
|
100
|
+
></md-elevated-button>
|
|
101
|
+
</div>
|
|
102
|
+
</div>
|
|
103
|
+
`;
|
|
104
|
+
}
|
|
105
|
+
updated(changed) {
|
|
106
|
+
if (changed.has('value')) {
|
|
107
|
+
if (this.value && typeof this.value === 'string') {
|
|
108
|
+
this.getRule();
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
async getRule() {
|
|
113
|
+
var response = await client.query({
|
|
114
|
+
query: FETCH_ID_RULE_GQL(this.value)
|
|
115
|
+
});
|
|
116
|
+
let idRule = response.data.idRule;
|
|
117
|
+
if (!idRule) {
|
|
118
|
+
idRule = await this.createIdRule();
|
|
119
|
+
}
|
|
120
|
+
this._idRule = idRule;
|
|
121
|
+
this.requestUpdate();
|
|
122
|
+
}
|
|
123
|
+
async createIdRule() {
|
|
124
|
+
var idRule = {
|
|
125
|
+
type: this.value,
|
|
126
|
+
rule: `return ''`
|
|
127
|
+
};
|
|
128
|
+
return (await client.mutate({
|
|
129
|
+
mutation: gql `
|
|
130
|
+
mutation createIdRule($idRule: NewIdRule!) {
|
|
131
|
+
createIdRule(idRule: $idRule) {
|
|
132
|
+
type
|
|
133
|
+
rule
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
`,
|
|
137
|
+
variables: { idRule }
|
|
138
|
+
})).data?.createIdRule;
|
|
139
|
+
}
|
|
140
|
+
async updateIdRule() {
|
|
141
|
+
if (!this._idRule)
|
|
142
|
+
console.error('ID Rule not found');
|
|
143
|
+
const rule = this.ruleEditor.value;
|
|
144
|
+
const type = this._idRule.type;
|
|
145
|
+
const patch = {
|
|
146
|
+
...this._idRule,
|
|
147
|
+
rule
|
|
148
|
+
};
|
|
149
|
+
await client.mutate({
|
|
150
|
+
mutation: gql `
|
|
151
|
+
mutation updateIdRule($type: String!, $patch: IdRulePatch!) {
|
|
152
|
+
updateIdRule(type: $type, patch: $patch) {
|
|
153
|
+
type
|
|
154
|
+
rule
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
`,
|
|
158
|
+
variables: { type, patch }
|
|
159
|
+
});
|
|
160
|
+
this.dispatchEvent(new CustomEvent('close-popup', {
|
|
161
|
+
bubbles: true,
|
|
162
|
+
composed: true
|
|
163
|
+
}));
|
|
164
|
+
}
|
|
165
|
+
};
|
|
166
|
+
__decorate([
|
|
167
|
+
property({ type: String }),
|
|
168
|
+
__metadata("design:type", String)
|
|
169
|
+
], GristCodeInputPopup.prototype, "value", void 0);
|
|
170
|
+
__decorate([
|
|
171
|
+
property({ type: Object }),
|
|
172
|
+
__metadata("design:type", Object)
|
|
173
|
+
], GristCodeInputPopup.prototype, "column", void 0);
|
|
174
|
+
__decorate([
|
|
175
|
+
property({ type: Object }),
|
|
176
|
+
__metadata("design:type", Object)
|
|
177
|
+
], GristCodeInputPopup.prototype, "record", void 0);
|
|
178
|
+
__decorate([
|
|
179
|
+
property({ type: Number }),
|
|
180
|
+
__metadata("design:type", Number)
|
|
181
|
+
], GristCodeInputPopup.prototype, "row", void 0);
|
|
182
|
+
__decorate([
|
|
183
|
+
property({ type: Object }),
|
|
184
|
+
__metadata("design:type", Object)
|
|
185
|
+
], GristCodeInputPopup.prototype, "field", void 0);
|
|
186
|
+
__decorate([
|
|
187
|
+
property({ type: Object }),
|
|
188
|
+
__metadata("design:type", Object)
|
|
189
|
+
], GristCodeInputPopup.prototype, "_idRule", void 0);
|
|
190
|
+
__decorate([
|
|
191
|
+
property({ type: Object }),
|
|
192
|
+
__metadata("design:type", Object)
|
|
193
|
+
], GristCodeInputPopup.prototype, "headers", void 0);
|
|
194
|
+
__decorate([
|
|
195
|
+
query('ox-input-code'),
|
|
196
|
+
__metadata("design:type", OxInputCode)
|
|
197
|
+
], GristCodeInputPopup.prototype, "ruleEditor", void 0);
|
|
198
|
+
GristCodeInputPopup = __decorate([
|
|
199
|
+
customElement('grist-code-input-popup')
|
|
200
|
+
], GristCodeInputPopup);
|
|
201
|
+
export { GristCodeInputPopup };
|
|
202
|
+
//# sourceMappingURL=grist-code-input-popup.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"grist-code-input-popup.js","sourceRoot":"","sources":["../../client/editors/grist-code-input-popup.ts"],"names":[],"mappings":";AAAA,OAAO,yCAAyC,CAAA;AAChD,OAAO,0BAA0B,CAAA;AACjC,OAAO,iCAAiC,CAAA;AAExC,OAAO,GAAG,MAAM,aAAa,CAAA;AAC7B,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,KAAK,CAAA;AAC3C,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAS,MAAM,mBAAmB,CAAA;AAEzE,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AACvC,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAA;AAEzC,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAA;AAE5C,MAAM,iBAAiB,GAAG,IAAI,CAAC,EAAE;IAC/B,OAAO,GAAG,CAAA;;mBAEO,IAAI;;;;;;CAMtB,CAAA;AACD,CAAC,CAAA;AAGM,IAAM,mBAAmB,GAAzB,MAAM,mBAAoB,SAAQ,UAAU;aAC1C,WAAM,GAAG;QACd,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KA0DF;KACF,AA5DY,CA4DZ;IAY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material/web/button/elevated-button.js'\nimport '@operato/i18n/ox-i18n.js'\nimport '@operato/input/ox-input-code.js'\n\nimport gql from 'graphql-tag'\nimport { css, html, LitElement } from 'lit'\nimport { customElement, property, query, state } from 'lit/decorators.js'\n\nimport { i18next } from '@operato/i18n'\nimport { client } from '@operato/graphql'\nimport { ColumnConfig, GristRecord } from '@operato/data-grist'\nimport { OxInputCode } from '@operato/input'\n\nconst FETCH_ID_RULE_GQL = type => {\n return gql`\n {\n idRule(type:\"${type}\") {\n id,\n type,\n rule\n }\n }\n`\n}\n\n@customElement('grist-code-input-popup')\nexport class GristCodeInputPopup extends LitElement {\n static styles = [\n css`\n :host {\n display: flex;\n flex-direction: column;\n padding: 0;\n align-items: center;\n box-sizing: border-box;\n width: 100%;\n border: 0;\n color: var(--popup-content-color);\n background-color: var(--popup-content-background-color);\n\n font: var(--grist-object-editor-font);\n\n justify-content: inherit;\n }\n\n :host * {\n box-sizing: border-box;\n }\n\n #wrapper {\n flex: 1;\n width: 100%;\n display: flex;\n flex-direction: column;\n padding: 5px;\n }\n\n #wrapper > h4 {\n margin: 0;\n }\n\n #wrapper > ul {\n width: 100%;\n }\n\n #wrapper > ul > li {\n display: flex;\n }\n #wrapper > ul > li > span {\n font-weight: bold;\n flex-basis: 200px;\n }\n\n #wrapper > ul > li > ox-i18n {\n flex: 1;\n }\n\n ox-input-code {\n width: 100%;\n flex: 1;\n }\n\n #footer {\n display: flex;\n justify-content: flex-end;\n }\n `\n ]\n\n @property({ type: String }) value?: string\n @property({ type: Object }) column?: ColumnConfig\n @property({ type: Object }) record?: GristRecord\n @property({ type: Number }) row?: number\n @property({ type: Object }) field?: any\n @property({ type: Object }) _idRule?: any\n @property({ type: Object }) headers?: { [header: string]: string }\n\n @query('ox-input-code') ruleEditor!: OxInputCode\n\n render() {\n return html`\n <div id=\"wrapper\">\n <h4><ox-i18n msgid=\"label.arguments\"></ox-i18n></h4>\n <ul>\n <li><span>domain</span><ox-i18n msgid=\"label.argument domain description\"></ox-i18n></li>\n <li><span>seed</span><ox-i18n msgid=\"label.argument seed description\"></ox-i18n></li>\n </ul>\n <ox-input-code id=\"rule-editor\" type=\"text\" .value=${(this._idRule || {}).rule}></ox-input-code>\n\n <div id=\"footer\">\n <md-elevated-button\n label=${String(i18next.t('button.save'))}\n @click=${(e: Event) => {\n this.updateIdRule()\n }}\n ></md-elevated-button>\n </div>\n </div>\n `\n }\n\n updated(changed) {\n if (changed.has('value')) {\n if (this.value && typeof this.value === 'string') {\n this.getRule()\n }\n }\n }\n\n async getRule() {\n var response = await client.query({\n query: FETCH_ID_RULE_GQL(this.value)\n })\n\n let idRule = response.data.idRule\n if (!idRule) {\n idRule = await this.createIdRule()\n }\n\n this._idRule = idRule\n this.requestUpdate()\n }\n\n async createIdRule() {\n var idRule = {\n type: this.value,\n rule: `return ''`\n }\n\n return (\n await client.mutate({\n mutation: gql`\n mutation createIdRule($idRule: NewIdRule!) {\n createIdRule(idRule: $idRule) {\n type\n rule\n }\n }\n `,\n variables: { idRule }\n })\n ).data?.createIdRule\n }\n\n async updateIdRule() {\n if (!this._idRule) console.error('ID Rule not found')\n\n const rule = this.ruleEditor.value\n\n const type = this._idRule.type\n\n const patch = {\n ...this._idRule,\n rule\n }\n\n await client.mutate({\n mutation: gql`\n mutation updateIdRule($type: String!, $patch: IdRulePatch!) {\n updateIdRule(type: $type, patch: $patch) {\n type\n rule\n }\n }\n `,\n variables: { type, patch }\n })\n\n this.dispatchEvent(\n new CustomEvent('close-popup', {\n bubbles: true,\n composed: true\n })\n )\n }\n}\n"]}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import '@material/web/icon/icon.js';
|
|
2
|
+
import { OxGristEditor } from '@operato/data-grist';
|
|
3
|
+
import { OxPopup } from '@operato/popup';
|
|
4
|
+
import './grist-code-input-popup';
|
|
5
|
+
export declare class GristCodeInput extends OxGristEditor {
|
|
6
|
+
static styles: import("lit").CSSResult[];
|
|
7
|
+
headers?: Object;
|
|
8
|
+
popup?: OxPopup | null;
|
|
9
|
+
render(): import("lit-html").TemplateResult<1>;
|
|
10
|
+
firstUpdated(): Promise<void>;
|
|
11
|
+
openPopup(): void;
|
|
12
|
+
}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import { __decorate, __metadata } from "tslib";
|
|
2
|
+
import '@material/web/icon/icon.js';
|
|
3
|
+
import { css, html } from 'lit';
|
|
4
|
+
import { customElement, property } from 'lit/decorators.js';
|
|
5
|
+
import { OxGristEditor } from '@operato/data-grist';
|
|
6
|
+
import { i18next } from '@operato/i18n';
|
|
7
|
+
import './grist-code-input-popup';
|
|
8
|
+
let GristCodeInput = class GristCodeInput extends OxGristEditor {
|
|
9
|
+
static { this.styles = [
|
|
10
|
+
css `
|
|
11
|
+
:host {
|
|
12
|
+
display: flex;
|
|
13
|
+
flex-flow: row nowrap;
|
|
14
|
+
align-items: center;
|
|
15
|
+
|
|
16
|
+
padding: 7px 0px;
|
|
17
|
+
box-sizing: border-box;
|
|
18
|
+
|
|
19
|
+
width: 100%;
|
|
20
|
+
height: 100%;
|
|
21
|
+
|
|
22
|
+
border: 0;
|
|
23
|
+
background-color: transparent;
|
|
24
|
+
|
|
25
|
+
font: var(--grist-object-editor-font);
|
|
26
|
+
color: var(--grist-object-editor-color);
|
|
27
|
+
|
|
28
|
+
justify-content: inherit;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
md-icon {
|
|
32
|
+
width: 20px;
|
|
33
|
+
font-size: 1.5em;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
#popup {
|
|
37
|
+
display: flex;
|
|
38
|
+
overflow: hidden;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
input {
|
|
42
|
+
border: none;
|
|
43
|
+
background-color: transparent;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
input:focus {
|
|
47
|
+
outline: none;
|
|
48
|
+
border: none;
|
|
49
|
+
}
|
|
50
|
+
`
|
|
51
|
+
]; }
|
|
52
|
+
render() {
|
|
53
|
+
return html `
|
|
54
|
+
<input
|
|
55
|
+
type="text"
|
|
56
|
+
.value=${this.value}
|
|
57
|
+
.record=${this.record}
|
|
58
|
+
.column=${this.column}
|
|
59
|
+
.field=${this.column}
|
|
60
|
+
.row=${this.row}
|
|
61
|
+
></input>
|
|
62
|
+
|
|
63
|
+
<md-icon id="more" @click=${e => this.openPopup()}>more_vert</md-icon>
|
|
64
|
+
`;
|
|
65
|
+
}
|
|
66
|
+
async firstUpdated() {
|
|
67
|
+
await this.updateComplete;
|
|
68
|
+
await super.firstUpdated();
|
|
69
|
+
}
|
|
70
|
+
openPopup() {
|
|
71
|
+
if (this.record.__dirty__) {
|
|
72
|
+
document.dispatchEvent(new CustomEvent('notify', {
|
|
73
|
+
detail: {
|
|
74
|
+
level: 'error',
|
|
75
|
+
message: i18next.t('text.please_save_your_modifications_first')
|
|
76
|
+
}
|
|
77
|
+
}));
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
document.dispatchEvent(new CustomEvent('open-popup', {
|
|
81
|
+
detail: {
|
|
82
|
+
template: html `
|
|
83
|
+
<grist-code-input-popup
|
|
84
|
+
.value=${this.value}
|
|
85
|
+
.column=${this.column}
|
|
86
|
+
.record=${this.record}
|
|
87
|
+
.row=${this.row}
|
|
88
|
+
.field=${this.field}
|
|
89
|
+
.headers=${this.headers}
|
|
90
|
+
@close-popup=${e => {
|
|
91
|
+
this.popup?.close();
|
|
92
|
+
this.popup = null;
|
|
93
|
+
}}
|
|
94
|
+
></grist-code-input-popup>
|
|
95
|
+
`,
|
|
96
|
+
options: {
|
|
97
|
+
title: i18next.t('title.ID Rule Editor')
|
|
98
|
+
},
|
|
99
|
+
callback: popup => {
|
|
100
|
+
this.popup = popup;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}));
|
|
104
|
+
}
|
|
105
|
+
};
|
|
106
|
+
__decorate([
|
|
107
|
+
property({ type: Object }),
|
|
108
|
+
__metadata("design:type", Object)
|
|
109
|
+
], GristCodeInput.prototype, "headers", void 0);
|
|
110
|
+
__decorate([
|
|
111
|
+
property({ type: Object }),
|
|
112
|
+
__metadata("design:type", Object)
|
|
113
|
+
], GristCodeInput.prototype, "popup", void 0);
|
|
114
|
+
GristCodeInput = __decorate([
|
|
115
|
+
customElement('grist-code-input')
|
|
116
|
+
], GristCodeInput);
|
|
117
|
+
export { GristCodeInput };
|
|
118
|
+
//# sourceMappingURL=grist-code-input.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"grist-code-input.js","sourceRoot":"","sources":["../../client/editors/grist-code-input.ts"],"names":[],"mappings":";AAAA,OAAO,4BAA4B,CAAA;AAEnC,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,KAAK,CAAA;AAC/B,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AAC3D,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AACnD,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AAGvC,OAAO,0BAA0B,CAAA;AAG1B,IAAM,cAAc,GAApB,MAAM,cAAe,SAAQ,aAAa;aACxC,WAAM,GAAG;QACd,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAwCF;KACF,AA1CY,CA0CZ;IAKD,MAAM;QACJ,OAAO,IAAI,CAAA;;;iBAGE,IAAI,CAAC,KAAK;kBACT,IAAI,CAAC,MAAM;kBACX,IAAI,CAAC,MAAM;iBACZ,IAAI,CAAC,MAAM;eACb,IAAI,CAAC,GAAG;;;kCAGW,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,SAAS,EAAE;KAClD,CAAA;IACH,CAAC;IAED,KAAK,CAAC,YAAY;QAChB,MAAM,IAAI,CAAC,cAAc,CAAA;QACzB,MAAM,KAAK,CAAC,YAAY,EAAE,CAAA;IAC5B,CAAC;IAED,SAAS;QACP,IAAI,IAAI,CAAC,MAAM,CAAC,SAAS,EAAE,CAAC;YAC1B,QAAQ,CAAC,aAAa,CACpB,IAAI,WAAW,CAAC,QAAQ,EAAE;gBACxB,MAAM,EAAE;oBACN,KAAK,EAAE,OAAO;oBACd,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,2CAA2C,CAAC;iBAChE;aACF,CAAC,CACH,CAAA;YAED,OAAM;QACR,CAAC;QAED,QAAQ,CAAC,aAAa,CACpB,IAAI,WAAW,CAAC,YAAY,EAAE;YAC5B,MAAM,EAAE;gBACN,QAAQ,EAAE,IAAI,CAAA;;uBAED,IAAI,CAAC,KAAK;wBACT,IAAI,CAAC,MAAM;wBACX,IAAI,CAAC,MAAM;qBACd,IAAI,CAAC,GAAG;uBACN,IAAI,CAAC,KAAK;yBACR,IAAI,CAAC,OAAO;6BACR,CAAC,CAAC,EAAE;oBACjB,IAAI,CAAC,KAAK,EAAE,KAAK,EAAE,CAAA;oBACnB,IAAI,CAAC,KAAK,GAAG,IAAI,CAAA;gBACnB,CAAC;;WAEJ;gBACD,OAAO,EAAE;oBACP,KAAK,EAAE,OAAO,CAAC,CAAC,CAAC,sBAAsB,CAAC;iBACzC;gBACD,QAAQ,EAAE,KAAK,CAAC,EAAE;oBAChB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAA;gBACpB,CAAC;aACF;SACF,CAAC,CACH,CAAA;IACH,CAAC;;AA/D2B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;8BAAW,MAAM;+CAAA;AAChB;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;6CAAuB;AA9CvC,cAAc;IAD1B,aAAa,CAAC,kBAAkB,CAAC;GACrB,cAAc,CA6G1B","sourcesContent":["import '@material/web/icon/icon.js'\n\nimport { css, html } from 'lit'\nimport { customElement, property } from 'lit/decorators.js'\nimport { OxGristEditor } from '@operato/data-grist'\nimport { i18next } from '@operato/i18n'\nimport { OxPopup } from '@operato/popup'\n\nimport './grist-code-input-popup'\n\n@customElement('grist-code-input')\nexport class GristCodeInput extends OxGristEditor {\n static styles = [\n css`\n :host {\n display: flex;\n flex-flow: row nowrap;\n align-items: center;\n\n padding: 7px 0px;\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 md-icon {\n width: 20px;\n font-size: 1.5em;\n }\n\n #popup {\n display: flex;\n overflow: hidden;\n }\n\n input {\n border: none;\n background-color: transparent;\n }\n\n input:focus {\n outline: none;\n border: none;\n }\n `\n ]\n\n @property({ type: Object }) headers?: Object\n @property({ type: Object }) popup?: OxPopup | null\n\n render() {\n return html`\n <input\n type=\"text\"\n .value=${this.value}\n .record=${this.record}\n .column=${this.column}\n .field=${this.column}\n .row=${this.row}\n ></input>\n\n <md-icon id=\"more\" @click=${e => this.openPopup()}>more_vert</md-icon>\n `\n }\n\n async firstUpdated() {\n await this.updateComplete\n await super.firstUpdated()\n }\n\n openPopup() {\n if (this.record.__dirty__) {\n document.dispatchEvent(\n new CustomEvent('notify', {\n detail: {\n level: 'error',\n message: i18next.t('text.please_save_your_modifications_first')\n }\n })\n )\n\n return\n }\n\n document.dispatchEvent(\n new CustomEvent('open-popup', {\n detail: {\n template: html`\n <grist-code-input-popup\n .value=${this.value}\n .column=${this.column}\n .record=${this.record}\n .row=${this.row}\n .field=${this.field}\n .headers=${this.headers}\n @close-popup=${e => {\n this.popup?.close()\n this.popup = null\n }}\n ></grist-code-input-popup>\n `,\n options: {\n title: i18next.t('title.ID Rule Editor')\n },\n callback: popup => {\n this.popup = popup\n }\n }\n })\n )\n }\n}\n"]}
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../client/index.ts"],"names":[],"mappings":"","sourcesContent":[""]}
|