@operato/app 1.0.0-beta.10 → 1.0.0-beta.13
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/CHANGELOG.md +29 -0
- package/demo/data-grist-test.html +1 -1
- package/dist/src/filters-form/filter-resource-select.d.ts +4 -0
- package/dist/src/filters-form/filter-resource-select.js +78 -0
- package/dist/src/filters-form/filter-resource-select.js.map +1 -0
- package/dist/src/filters-form/index.d.ts +1 -0
- package/dist/src/filters-form/index.js +5 -0
- package/dist/src/filters-form/index.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +16 -16
- package/src/filters-form/filter-resource-select.ts +94 -0
- package/src/filters-form/index.ts +6 -0
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,35 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [1.0.0-beta.13](https://github.com/hatiolab/operato/compare/v1.0.0-beta.12...v1.0.0-beta.13) (2022-05-19)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### :bug: Bug Fix
|
|
10
|
+
|
|
11
|
+
* incorrect package.json scripts for storybooks ([8c8c405](https://github.com/hatiolab/operato/commit/8c8c405443247108b9c411b8161c008d9b6a2261))
|
|
12
|
+
* record-view ([ffcb397](https://github.com/hatiolab/operato/commit/ffcb397748efb64ce4e515f733b50f088ea1a093))
|
|
13
|
+
* storybook for inputs ([72f7992](https://github.com/hatiolab/operato/commit/72f7992d902528e3a5ca0f3f0f3897902b6b13bd))
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
## [1.0.0-beta.12](https://github.com/hatiolab/operato/compare/v1.0.0-beta.11...v1.0.0-beta.12) (2022-05-13)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
### :rocket: New Features
|
|
21
|
+
|
|
22
|
+
* storybook started ([90c08c9](https://github.com/hatiolab/operato/commit/90c08c9a15e5fe554baaa1becca07793e8434799))
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
## [1.0.0-beta.11](https://github.com/hatiolab/operato/compare/v1.0.0-beta.10...v1.0.0-beta.11) (2022-05-01)
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
### :rocket: New Features
|
|
30
|
+
|
|
31
|
+
* separated filter-form from data-grist ([21e27f7](https://github.com/hatiolab/operato/commit/21e27f74d3e66d782da4aa75801c39a037627f62))
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
|
|
6
35
|
## [1.0.0-beta.10](https://github.com/hatiolab/operato/compare/v1.0.0-beta.9...v1.0.0-beta.10) (2022-04-28)
|
|
7
36
|
|
|
8
37
|
**Note:** Version bump only for package @operato/app
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import '@operato/input/ox-checkbox.js';
|
|
2
|
+
import '../grist-editor/ox-selector-resource-id';
|
|
3
|
+
import { html } from 'lit-html';
|
|
4
|
+
import { i18next } from '@operato/i18n';
|
|
5
|
+
import { openPopup } from '@operato/layout';
|
|
6
|
+
function openResourceSelector(filter, value, confirmCallback) {
|
|
7
|
+
const { queryName, select, list, basicArgs, valueField = 'id' } = filter.options || {};
|
|
8
|
+
var actualValue;
|
|
9
|
+
if (typeof valueField === 'function') {
|
|
10
|
+
actualValue = valueField(value);
|
|
11
|
+
}
|
|
12
|
+
else {
|
|
13
|
+
actualValue = value === null || value === void 0 ? void 0 : value[valueField];
|
|
14
|
+
}
|
|
15
|
+
var template = html `
|
|
16
|
+
<ox-selector-resource-id
|
|
17
|
+
.value=${actualValue}
|
|
18
|
+
.confirmCallback=${confirmCallback}
|
|
19
|
+
.queryName=${queryName}
|
|
20
|
+
.select=${select}
|
|
21
|
+
.list=${list}
|
|
22
|
+
.basicArgs=${basicArgs}
|
|
23
|
+
.valueField=${valueField}
|
|
24
|
+
></ox-selector-resource-id>
|
|
25
|
+
`;
|
|
26
|
+
const popup = openPopup(template, {
|
|
27
|
+
backdrop: true,
|
|
28
|
+
size: 'large',
|
|
29
|
+
title: i18next.t('title.select_item')
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
export const FilterResourceSelect = (filter, value, owner) => {
|
|
33
|
+
const { name, operator = 'like' } = filter;
|
|
34
|
+
return operator === 'like'
|
|
35
|
+
? html ` <input
|
|
36
|
+
type="text"
|
|
37
|
+
name=${name}
|
|
38
|
+
.value=${value}
|
|
39
|
+
@change=${(e) => {
|
|
40
|
+
const input = e.target;
|
|
41
|
+
input.dispatchEvent(new CustomEvent('filter-change', {
|
|
42
|
+
bubbles: true,
|
|
43
|
+
composed: true,
|
|
44
|
+
detail: {
|
|
45
|
+
name,
|
|
46
|
+
operator,
|
|
47
|
+
value: input.value
|
|
48
|
+
}
|
|
49
|
+
}));
|
|
50
|
+
}}
|
|
51
|
+
/>`
|
|
52
|
+
: operator == 'in'
|
|
53
|
+
? html ``
|
|
54
|
+
: operator === 'eq'
|
|
55
|
+
? html `
|
|
56
|
+
<input
|
|
57
|
+
style="min-width: 100px; min-height: 24px"
|
|
58
|
+
type="text"
|
|
59
|
+
name=${name}
|
|
60
|
+
.value=${value}
|
|
61
|
+
readonly
|
|
62
|
+
@click=${(e) => {
|
|
63
|
+
e.stopPropagation();
|
|
64
|
+
const confirmCallback = (selected) => {
|
|
65
|
+
var { idField = 'id', nameField = 'name', descriptionField = 'description' } = filter.options || {};
|
|
66
|
+
owner.dispatchEvent(new CustomEvent('filter-change', {
|
|
67
|
+
bubbles: true,
|
|
68
|
+
composed: true,
|
|
69
|
+
detail: selected ? selected[idField] : ''
|
|
70
|
+
}));
|
|
71
|
+
};
|
|
72
|
+
openResourceSelector(filter, value, confirmCallback);
|
|
73
|
+
}}
|
|
74
|
+
/>
|
|
75
|
+
`
|
|
76
|
+
: html ``;
|
|
77
|
+
};
|
|
78
|
+
//# sourceMappingURL=filter-resource-select.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"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nimport { FilterConfig, FilterSelectRenderer } from '@operato/form'\nimport { i18next } from '@operato/i18n'\nimport { openPopup } from '@operato/layout'\n\ntype SelectedCallback = (value: { id: string; name: string; description: string }) => void\n\nfunction openResourceSelector(filter: FilterConfig, value: any, confirmCallback: SelectedCallback) {\n const { queryName, select, list, basicArgs, valueField = 'id' } = filter.options || {}\n\n var actualValue\n if (typeof valueField === 'function') {\n actualValue = valueField(value)\n } else {\n actualValue = value?.[valueField]\n }\n\n var template = html`\n <ox-selector-resource-id\n .value=${actualValue}\n .confirmCallback=${confirmCallback}\n .queryName=${queryName}\n .select=${select}\n .list=${list}\n .basicArgs=${basicArgs}\n .valueField=${valueField}\n ></ox-selector-resource-id>\n `\n\n const popup = openPopup(template, {\n backdrop: true,\n size: 'large',\n title: i18next.t('title.select_item')\n })\n}\n\nexport const FilterResourceSelect: FilterSelectRenderer = (filter, value, owner) => {\n const { name, operator = 'like' } = filter\n\n return operator === 'like'\n ? html` <input\n type=\"text\"\n name=${name}\n .value=${value}\n @change=${(e: CustomEvent) => {\n const input = e.target as HTMLInputElement\n input.dispatchEvent(\n new CustomEvent('filter-change', {\n bubbles: true,\n composed: true,\n detail: {\n name,\n operator,\n value: input.value\n }\n })\n )\n }}\n />`\n : operator == 'in'\n ? html``\n : operator === 'eq'\n ? html`\n <input\n style=\"min-width: 100px; min-height: 24px\"\n type=\"text\"\n name=${name}\n .value=${value}\n readonly\n @click=${(e: Event) => {\n e.stopPropagation()\n\n const confirmCallback = (selected?: { [field: string]: any }) => {\n var { idField = 'id', nameField = 'name', descriptionField = 'description' } = filter.options || {}\n\n owner.dispatchEvent(\n new CustomEvent('filter-change', {\n bubbles: true,\n composed: true,\n detail: selected ? selected[idField] : ''\n })\n )\n }\n\n openResourceSelector(filter, value, confirmCallback)\n }}\n />\n `\n : html``\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { registerFilterRenderer } from '@operato/form';
|
|
2
|
+
import { FilterResourceSelect } from './filter-resource-select.js';
|
|
3
|
+
registerFilterRenderer('resource-object', [FilterResourceSelect]);
|
|
4
|
+
registerFilterRenderer('resource-id', [FilterResourceSelect]);
|
|
5
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/filters-form/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,eAAe,CAAA;AAEtD,OAAO,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAA;AAElE,sBAAsB,CAAC,iBAAiB,EAAE,CAAC,oBAAoB,CAAC,CAAC,CAAA;AACjE,sBAAsB,CAAC,aAAa,EAAE,CAAC,oBAAoB,CAAC,CAAC,CAAA","sourcesContent":["import { registerFilterRenderer } from '@operato/form'\n\nimport { FilterResourceSelect } from './filter-resource-select.js'\n\nregisterFilterRenderer('resource-object', [FilterResourceSelect])\nregisterFilterRenderer('resource-id', [FilterResourceSelect])\n"]}
|