@things-factory/work-shift 8.0.0-beta.9 → 8.0.2

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 @@
1
+ export default function bootstrap() {}
File without changes
@@ -0,0 +1,108 @@
1
+ import '@operato/input/ox-input-work-shift.js'
2
+ import '@operato/context/ox-context-page-toolbar.js'
3
+
4
+ import { css, html } from 'lit'
5
+ import { customElement, query, state } from 'lit/decorators.js'
6
+ import gql from 'graphql-tag'
7
+
8
+ import { OxFormField } from '@operato/input'
9
+ import { PageView, store } from '@operato/shell'
10
+ import { CommonHeaderStyles, ScrollbarStyles } from '@operato/styles'
11
+ import { client } from '@operato/graphql'
12
+ import { connect } from 'pwa-helpers/connect-mixin.js'
13
+ import { i18next } from '@operato/i18n'
14
+
15
+ @customElement('work-shift')
16
+ class WorkShift extends connect(store)(PageView) {
17
+ static styles = [
18
+ ScrollbarStyles,
19
+ CommonHeaderStyles,
20
+ css`
21
+ :host {
22
+ background-color: var(--md-sys-color-background);
23
+ padding: var(--spacing-large);
24
+ overflow: auto;
25
+ }
26
+
27
+ ox-input-work-shift {
28
+ overflow-y: auto;
29
+ flex: 1;
30
+ }
31
+ `
32
+ ]
33
+
34
+ @state() private workShifts: any[] = []
35
+
36
+ @query('ox-input-work-shift') private input!: OxFormField
37
+
38
+ get context() {
39
+ return {
40
+ title: i18next.t('title.work-shift'),
41
+ actions: [
42
+ {
43
+ title: i18next.t('button.update'),
44
+ action: this.updateWorkShift.bind(this),
45
+ icon: 'save'
46
+ }
47
+ ],
48
+ help: 'page/work-shift',
49
+ toolbar: false
50
+ }
51
+ }
52
+
53
+ render() {
54
+ return html`
55
+ <div class="header">
56
+ <div class="title">${i18next.t('title.work-shift')}</div>
57
+
58
+ <ox-context-page-toolbar class="actions" .context=${this.context}> </ox-context-page-toolbar>
59
+ </div>
60
+
61
+ <ox-input-work-shift .value=${this.workShifts}></ox-input-work-shift>
62
+ `
63
+ }
64
+
65
+ async pageUpdated(changes, after, before) {
66
+ /* refresh always page revisited */
67
+ if (this.active) {
68
+ const response = await client.query({
69
+ query: gql`
70
+ query {
71
+ workShifts(sortings: [{ name: "fromDate" }, { name: "fromTime" }]) {
72
+ items {
73
+ name
74
+ fromDate
75
+ fromTime
76
+ toDate
77
+ toTime
78
+ }
79
+ }
80
+ }
81
+ `
82
+ })
83
+
84
+ this.workShifts = response.data.workShifts.items
85
+ }
86
+ }
87
+
88
+ private async updateWorkShift() {
89
+ const response = await client.mutate({
90
+ mutation: gql`
91
+ mutation ($patches: [WorkShiftPatch!]!) {
92
+ updateMultipleWorkShift(patches: $patches) {
93
+ name
94
+ fromDate
95
+ fromTime
96
+ toDate
97
+ toTime
98
+ }
99
+ }
100
+ `,
101
+ variables: {
102
+ patches: this.input.value
103
+ }
104
+ })
105
+
106
+ this.workShifts = response.data.updateMultipleWorkShift
107
+ }
108
+ }
@@ -0,0 +1,7 @@
1
+ export default function route(page) {
2
+ switch (page) {
3
+ case 'work-shift':
4
+ import('./pages/work-shift')
5
+ return page
6
+ }
7
+ }
@@ -0,0 +1,13 @@
1
+ {
2
+ "extends": "../../tsconfig-base.json",
3
+ "compilerOptions": {
4
+ "experimentalDecorators": true,
5
+ "skipLibCheck": true,
6
+ "strict": true,
7
+ "declaration": true,
8
+ "module": "esnext",
9
+ "outDir": "../dist-client",
10
+ "baseUrl": "./"
11
+ },
12
+ "include": ["./**/*"]
13
+ }