@operato/app 1.5.22 → 1.5.23

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/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@operato/app",
3
3
  "description": "WebApplication production supporting components following open-wc recommendations",
4
4
  "author": "heartyoh",
5
- "version": "1.5.22",
5
+ "version": "1.5.23",
6
6
  "main": "dist/src/index.js",
7
7
  "module": "dist/src/index.js",
8
8
  "exports": {
@@ -24,6 +24,7 @@
24
24
  "./grist-editor/ox-grist-renderer-crontab.js": "./dist/src/grist-editor/ox-grist-renderer-crontab.js",
25
25
  "./grist-editor/ox-grist-editor-json.js": "./dist/src/grist-editor/ox-grist-editor-json.js",
26
26
  "./grist-editor/ox-grist-editor-code.js": "./dist/src/grist-editor/ox-grist-editor-code.js",
27
+ "./grist-editor/ox-grist-editor-permission.js": "./dist/src/grist-editor/ox-grist-editor-permission.js",
27
28
  "./grist-editor/ox-grist-editor-resource-object.js": "./dist/src/grist-editor/ox-grist-editor-resource-object.js",
28
29
  "./grist-editor/ox-grist-editor-resource-object-legacy.js": "./dist/src/grist-editor/ox-grist-editor-resource-object-legacy.js",
29
30
  "./grist-editor/ox-grist-editor-resource-code.js": "./dist/src/grist-editor/ox-grist-editor-resource-code.js",
@@ -83,6 +84,9 @@
83
84
  "grist-editor/ox-grist-editor-code.js": [
84
85
  "dist/src/grist-editor/ox-grist-editor-code.d.ts"
85
86
  ],
87
+ "grist-editor/ox-grist-editor-permission.js": [
88
+ "dist/src/grist-editor/ox-grist-editor-permission.d.ts"
89
+ ],
86
90
  "grist-editor/ox-grist-editor-resource-object.js": [
87
91
  "dist/src/grist-editor/ox-grist-editor-resource-object.d.ts"
88
92
  ],
@@ -125,15 +129,15 @@
125
129
  "@material/mwc-button": "^0.27.0",
126
130
  "@material/mwc-icon": "^0.27.0",
127
131
  "@material/mwc-icon-button": "^0.27.0",
128
- "@operato/attachment": "^1.5.22",
129
- "@operato/data-grist": "^1.5.22",
130
- "@operato/font": "^1.5.22",
132
+ "@operato/attachment": "^1.5.23",
133
+ "@operato/data-grist": "^1.5.23",
134
+ "@operato/font": "^1.5.23",
131
135
  "@operato/form": "^1.4.77",
132
136
  "@operato/graphql": "^1.4.76",
133
137
  "@operato/i18n": "^1.5.14",
134
- "@operato/input": "^1.5.22",
138
+ "@operato/input": "^1.5.23",
135
139
  "@operato/layout": "^1.5.15",
136
- "@operato/property-editor": "^1.5.22",
140
+ "@operato/property-editor": "^1.5.23",
137
141
  "@operato/shell": "^1.4.87",
138
142
  "@operato/styles": "^1.4.64",
139
143
  "@operato/utils": "^1.4.64",
@@ -178,5 +182,5 @@
178
182
  "prettier --write"
179
183
  ]
180
184
  },
181
- "gitHead": "dda168c26e7909faefab9a6e21abf96751e59b7d"
185
+ "gitHead": "5532e5a79ac76b18ae01301b5e1ca8228b709c70"
182
186
  }
@@ -0,0 +1,61 @@
1
+ import './ox-popup-permission-input.js'
2
+
3
+ import { html } from 'lit'
4
+ import { customElement } from 'lit/decorators.js'
5
+
6
+ import { OxGristEditor } from '@operato/data-grist'
7
+ import { i18next } from '@operato/i18n'
8
+ import { openPopup } from '@operato/layout'
9
+
10
+ @customElement('ox-grist-editor-permission')
11
+ export class OxGristEditorPermission extends OxGristEditor {
12
+ get editorTemplate() {
13
+ return html` <div tabindex="0">${this.value || ''}</div> `
14
+ }
15
+
16
+ _onclick(e: Event): void {
17
+ e.stopPropagation()
18
+ this.showEditorPopup()
19
+ }
20
+
21
+ _onkeydown(e: KeyboardEvent): void {
22
+ const key = e.key
23
+ if (key == 'Enter') {
24
+ e.stopPropagation()
25
+ this.showEditorPopup()
26
+ }
27
+ }
28
+
29
+ showEditorPopup() {
30
+ var change = (value: string) => {
31
+ this.dispatchEvent(
32
+ new CustomEvent('field-change', {
33
+ bubbles: true,
34
+ composed: true,
35
+ detail: {
36
+ before: this.value,
37
+ after: value,
38
+ column: this.column,
39
+ record: this.record,
40
+ row: this.row
41
+ }
42
+ })
43
+ )
44
+ }
45
+
46
+ var popup = openPopup(
47
+ html`
48
+ <ox-popup-permission-input
49
+ .value=${this.value}
50
+ .confirmCallback=${change.bind(this)}
51
+ ></ox-popup-permission-input>
52
+ `,
53
+ {
54
+ backdrop: true,
55
+ title: i18next.t('title.edit permission'),
56
+ size: 'small',
57
+ help: 'data-grist/grist-editor/permission'
58
+ }
59
+ )
60
+ }
61
+ }
@@ -0,0 +1,89 @@
1
+ import '@operato/input/ox-input-permission.js'
2
+
3
+ import gql from 'graphql-tag'
4
+ import { css, html, LitElement, PropertyValueMap } from 'lit'
5
+ import { customElement, property, state } from 'lit/decorators.js'
6
+
7
+ import { i18next } from '@operato/i18n'
8
+ import { closePopup } from '@operato/popup'
9
+ import { ScrollbarStyles } from '@operato/styles'
10
+ import { client } from '@operato/graphql'
11
+
12
+ @customElement('ox-popup-permission-input')
13
+ export class OxPopupPermissionInput extends LitElement {
14
+ static styles = [
15
+ ScrollbarStyles,
16
+ css`
17
+ :host {
18
+ display: flex;
19
+ flex-direction: column;
20
+
21
+ background-color: #fff;
22
+
23
+ width: var(--overlay-center-normal-width, 50%);
24
+ height: var(--overlay-center-normal-height, 50%);
25
+ }
26
+
27
+ ox-input-permission {
28
+ flex: 1;
29
+ overflow-y: auto;
30
+ }
31
+
32
+ .button-container {
33
+ display: flex;
34
+ margin-left: auto;
35
+ }
36
+ `
37
+ ]
38
+
39
+ @property({ type: Object }) value?: { category: string; privilege: string; owner: boolean; super: boolean } | null
40
+
41
+ @property({ type: Object }) confirmCallback!: (newval: any) => void
42
+
43
+ @state() privileges: { name: string; category: string; description: string }[] = []
44
+
45
+ render() {
46
+ return html`
47
+ <ox-input-permission .value=${this.value} .privileges=${this.privileges} @change=${this.onChange.bind(this)}>
48
+ </ox-input-permission>
49
+
50
+ <div class="button-container">
51
+ <mwc-button @click=${this.onCancel.bind(this)}>${i18next.t('button.cancel')}</mwc-button>
52
+ <mwc-button @click=${this.onConfirm.bind(this)}>${i18next.t('button.confirm')}</mwc-button>
53
+ </div>
54
+ `
55
+ }
56
+
57
+ async firstUpdated(_changedProperties: PropertyValueMap<any> | Map<PropertyKey, unknown>): Promise<void> {
58
+ const response = await client.query({
59
+ query: gql`
60
+ query privileges {
61
+ privileges {
62
+ items {
63
+ name
64
+ category
65
+ }
66
+ total
67
+ }
68
+ }
69
+ `
70
+ })
71
+
72
+ this.privileges = response.data.privileges.items
73
+ }
74
+
75
+ private onChange(e: CustomEvent) {
76
+ e.stopPropagation()
77
+
78
+ this.value = e.detail
79
+ }
80
+
81
+ private onCancel(e: Event) {
82
+ closePopup(this)
83
+ }
84
+
85
+ private onConfirm(e: Event) {
86
+ this.confirmCallback && this.confirmCallback(this.value)
87
+ closePopup(this)
88
+ }
89
+ }