@things-factory/operato-gangsters 5.0.12 → 6.0.0-alpha.0

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.
Files changed (91) hide show
  1. package/_index.html +2 -0
  2. package/attachments/89740d46-f778-473a-bfdf-183f8fbf232a.jpg +0 -0
  3. package/client/{bootstrap.js → bootstrap.ts} +3 -3
  4. package/client/{index.js → index.ts} +0 -0
  5. package/client/{menu.js → menu.ts} +1 -3
  6. package/client/pages/{main.js → main.ts} +6 -10
  7. package/client/pages/weekly-report/{weekly-report-importer.js → weekly-report-importer.ts} +29 -35
  8. package/client/pages/weekly-report/{weekly-report-list-page.js → weekly-report-list-page.ts} +11 -15
  9. package/client/pages/{weekly-report-calendar-evt-provider.js → weekly-report-calendar-evt-provider.ts} +0 -0
  10. package/client/pages/{weekly-report-calendar.js → weekly-report-calendar.ts} +7 -11
  11. package/client/pages/{weekly-report-editor.js → weekly-report-editor.ts} +30 -30
  12. package/client/pages/{weekly-report-preview-popup.js → weekly-report-preview-popup.ts} +6 -26
  13. package/client/{route.js → route.ts} +4 -4
  14. package/client/tsconfig.json +12 -0
  15. package/db.sqlite +0 -0
  16. package/dist-server/service/weekly-report/weekly-report-mutation.js +5 -5
  17. package/dist-server/service/weekly-report/weekly-report-mutation.js.map +1 -1
  18. package/dist-server/service/weekly-report/weekly-report-query.js +10 -12
  19. package/dist-server/service/weekly-report/weekly-report-query.js.map +1 -1
  20. package/dist-server/service/weekly-report/weekly-report.js +4 -5
  21. package/dist-server/service/weekly-report/weekly-report.js.map +1 -1
  22. package/dist-server/tsconfig.tsbuildinfo +1 -1
  23. package/logs/.08636eb59927f12972f6774f5947c8507b3564c2-audit.json +45 -15
  24. package/logs/.5e5d741d8b7784a2fbad65eedc0fd46946aaf6f2-audit.json +27 -162
  25. package/logs/application-2022-09-10-16.log +4 -0
  26. package/logs/application-2022-09-11-01.log +1 -0
  27. package/logs/application-2022-09-11-07.log +8 -0
  28. package/logs/application-2022-09-11-08.log +11 -0
  29. package/logs/application-2022-09-11-15.log +25 -0
  30. package/logs/application-2022-09-11-16.log +10 -0
  31. package/logs/application-2022-09-11-17.log +2 -0
  32. package/logs/application-2022-09-12-00.log +5 -0
  33. package/logs/application-2022-09-12-01.log +1 -0
  34. package/logs/application-2022-09-12-04.log +4 -0
  35. package/logs/application-2022-09-12-13.log +1 -0
  36. package/logs/{connections-2022-07-19-22.log → connections-2022-08-30-13.log} +0 -0
  37. package/logs/{connections-2022-07-19-23.log → connections-2022-08-31-16.log} +0 -0
  38. package/logs/{connections-2022-07-20-02.log → connections-2022-09-01-00.log} +0 -0
  39. package/logs/{connections-2022-07-20-03.log → connections-2022-09-10-16.log} +0 -0
  40. package/logs/{connections-2022-07-20-13.log → connections-2022-09-11-07.log} +0 -0
  41. package/logs/{connections-2022-07-20-23.log → connections-2022-09-11-08.log} +0 -0
  42. package/logs/{connections-2022-07-21-15.log → connections-2022-09-11-15.log} +0 -0
  43. package/logs/connections-2022-09-11-16.log +3 -0
  44. package/logs/{connections-2022-07-23-13.log → connections-2022-09-12-04.log} +0 -0
  45. package/logs/system/.050e96f424c54afacced2d436003f7771ec24af7-audit.json +15 -0
  46. package/logs/system/.5915db68070510a16ec3f93d919498ebd2566e0d-audit.json +15 -0
  47. package/logs/system/.95b3738c5d9d64fa5cd906ebbb7177c928caf40a-audit.json +15 -0
  48. package/logs/system/scenario-get-my-issues-2022-08-18-07.log +31168 -0
  49. package/logs/system/scenario-github-issues-2022-09-11-16.log +31291 -0
  50. package/logs/system/scenario-publish-2022-08-17-16.log +2442 -0
  51. package/package.json +38 -34
  52. package/server/service/weekly-report/weekly-report-mutation.ts +15 -14
  53. package/server/service/weekly-report/weekly-report-query.ts +10 -11
  54. package/server/tsconfig.json +9 -0
  55. package/{things-factory.config.js → things-factory.config.ts} +0 -0
  56. package/client/actions/main.js +0 -1
  57. package/client/reducers/main.js +0 -17
  58. package/logs/application-2022-07-31-16.log +0 -18
  59. package/logs/application-2022-07-31-17.log +0 -12
  60. package/logs/application-2022-07-31-18.log +0 -24
  61. package/logs/application-2022-08-01-11.log +0 -6
  62. package/logs/application-2022-08-01-21.log +0 -4
  63. package/logs/connections-2022-07-23-14.log +0 -0
  64. package/logs/connections-2022-07-23-15.log +0 -0
  65. package/logs/connections-2022-07-23-16.log +0 -0
  66. package/logs/connections-2022-07-23-17.log +0 -0
  67. package/logs/connections-2022-07-23-18.log +0 -0
  68. package/logs/connections-2022-07-23-19.log +0 -0
  69. package/logs/connections-2022-07-23-20.log +0 -0
  70. package/logs/connections-2022-07-23-21.log +0 -0
  71. package/logs/connections-2022-07-23-22.log +0 -0
  72. package/logs/connections-2022-07-23-23.log +0 -0
  73. package/logs/connections-2022-07-24-00.log +0 -0
  74. package/logs/connections-2022-07-24-01.log +0 -0
  75. package/logs/connections-2022-07-24-09.log +0 -0
  76. package/logs/connections-2022-07-24-11.log +0 -0
  77. package/logs/connections-2022-07-24-13.log +0 -0
  78. package/logs/connections-2022-07-25-11.log +0 -0
  79. package/logs/connections-2022-07-25-12.log +0 -0
  80. package/logs/connections-2022-07-25-13.log +0 -0
  81. package/logs/connections-2022-07-25-20.log +0 -0
  82. package/logs/connections-2022-07-26-13.log +0 -0
  83. package/logs/connections-2022-07-26-14.log +0 -0
  84. package/logs/connections-2022-07-26-15.log +0 -0
  85. package/logs/connections-2022-07-26-16.log +0 -0
  86. package/logs/connections-2022-07-31-16.log +0 -0
  87. package/logs/connections-2022-07-31-17.log +0 -0
  88. package/logs/connections-2022-07-31-18.log +0 -0
  89. package/logs/connections-2022-08-01-11.log +0 -0
  90. package/logs/connections-2022-08-01-21.log +0 -0
  91. package/tsconfig.json +0 -9
package/_index.html CHANGED
@@ -63,6 +63,8 @@
63
63
  font-family: Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol';
64
64
  line-height: 1.5;
65
65
  -webkit-font-smoothing: antialiased;
66
+
67
+ accent-color: var(--primary-color);
66
68
  }
67
69
  </style>
68
70
 
@@ -1,14 +1,14 @@
1
1
  import { html } from 'lit-html'
2
2
 
3
- import { registerDefaultGroups } from '@operato/board/register-default-groups.js'
3
+ import { registerDefaultGroups } from '@operato/board'
4
+ import { navigate, store } from '@operato/shell'
4
5
  import { APPEND_APP_TOOL } from '@things-factory/apptool-base'
5
- import { auth } from '@things-factory/auth-base'
6
+ import { auth } from '@things-factory/auth-base/client'
6
7
  import { setAuthManagementMenus } from '@things-factory/auth-ui'
7
8
  import { appendViewpart, toggleOverlay, TOOL_POSITION, VIEWPART_POSITION } from '@things-factory/layout-base'
8
9
  import { setupMenuPart, updateMenuTemplate } from '@things-factory/lite-menu'
9
10
  import { ADD_MORENDA } from '@things-factory/more-base'
10
11
  import { ADD_SETTING } from '@things-factory/setting-base'
11
- import { navigate, store } from '@things-factory/shell'
12
12
 
13
13
  import { getMenuTemplate } from './menu'
14
14
 
File without changes
@@ -3,8 +3,6 @@ import i18next from 'i18next'
3
3
 
4
4
  import { subscribe } from '@operato/graphql'
5
5
 
6
- var subscriber
7
-
8
6
  async function subscribeActivityInstance() {
9
7
  return await subscribe(
10
8
  {
@@ -29,7 +27,7 @@ async function subscribeActivityInstance() {
29
27
 
30
28
  export function getMenuTemplate(owner) {
31
29
  requestAnimationFrame(async () => {
32
- subscriber = await subscribeActivityInstance()
30
+ const subscriber = await subscribeActivityInstance()
33
31
  })
34
32
 
35
33
  return [
@@ -1,13 +1,15 @@
1
1
  import React from 'react'
2
2
 
3
- import { css, html } from 'lit-element'
3
+ import { css, html } from 'lit'
4
+ import { customElement, property } from 'lit/decorators.js'
4
5
  import { connect } from 'pwa-helpers/connect-mixin.js'
5
6
  import ReactDOM from 'react-dom/client'
6
7
 
8
+ import { PageView, store } from '@operato/shell'
7
9
  import SendbirdApp from '@sendbird/uikit-react/App'
8
- import { PageView, store } from '@things-factory/shell'
9
10
 
10
- class OperatoGangstersMain extends connect(store)(PageView) {
11
+ @customElement('operato-gangsters-main')
12
+ export class OperatoGangstersMain extends connect(store)(PageView) {
11
13
  static get styles() {
12
14
  return [
13
15
  css`
@@ -27,11 +29,7 @@ class OperatoGangstersMain extends connect(store)(PageView) {
27
29
  ]
28
30
  }
29
31
 
30
- static get properties() {
31
- return {
32
- operatoGangsters: String
33
- }
34
- }
32
+ @property({ type: String }) operatoGangsteres = ''
35
33
 
36
34
  render() {
37
35
  return html`<slot></slot>`
@@ -50,5 +48,3 @@ class OperatoGangstersMain extends connect(store)(PageView) {
50
48
  //this.operatoGangsters = state.operatoGangsters.state_main
51
49
  }
52
50
  }
53
-
54
- window.customElements.define('operato-gangsters-main', OperatoGangstersMain)
@@ -2,45 +2,41 @@ import '@operato/data-grist'
2
2
 
3
3
  import gql from 'graphql-tag'
4
4
  import { css, html, LitElement } from 'lit'
5
+ import { customElement, property } from 'lit/decorators.js'
5
6
 
6
7
  import { client } from '@operato/graphql'
7
8
  import { i18next } from '@operato/i18n'
9
+ import { isMobileDevice } from '@operato/utils'
8
10
 
11
+ @customElement('weekly-report-importer')
9
12
  export class WeeklyReportImporter extends LitElement {
10
- static get properties() {
11
- return {
12
- columns: Object,
13
- weeklyReports: Array
14
- }
13
+ @property({ type: Object })
14
+ columns = {
15
+ list: { fields: ['name', 'description'] },
16
+ pagination: { infinite: true },
17
+ columns: [
18
+ {
19
+ type: 'string',
20
+ name: 'name',
21
+ header: i18next.t('field.name'),
22
+ width: 150
23
+ },
24
+ {
25
+ type: 'string',
26
+ name: 'description',
27
+ header: i18next.t('field.description'),
28
+ width: 200
29
+ },
30
+ {
31
+ type: 'checkbox',
32
+ name: 'active',
33
+ header: i18next.t('field.active'),
34
+ width: 60
35
+ }
36
+ ]
15
37
  }
16
38
 
17
- constructor() {
18
- super()
19
- this.columns = {
20
- list: { fields: ['name', 'description'] },
21
- pagination: { infinite: true },
22
- columns: [
23
- {
24
- type: 'string',
25
- name: 'name',
26
- header: i18next.t('field.name'),
27
- width: 150
28
- },
29
- {
30
- type: 'string',
31
- name: 'description',
32
- header: i18next.t('field.description'),
33
- width: 200
34
- },
35
- {
36
- type: 'checkbox',
37
- name: 'active',
38
- header: i18next.t('field.active'),
39
- width: 60
40
- }
41
- ]
42
- }
43
- }
39
+ @property({ type: Array }) weeklyReports = []
44
40
 
45
41
  static get styles() {
46
42
  return [
@@ -95,10 +91,8 @@ export class WeeklyReportImporter extends LitElement {
95
91
  variables: { weeklyReports: this.weeklyReports }
96
92
  })
97
93
 
98
- if (response.error?.length) return
94
+ if (response.errors?.length) return
99
95
 
100
96
  this.dispatchEvent(new CustomEvent('imported'))
101
97
  }
102
98
  }
103
-
104
- window.customElements.define('weekly-report-importer', WeeklyReportImporter)
@@ -1,8 +1,9 @@
1
1
  import '@operato/data-grist'
2
- import './weekly-report-importer.js'
2
+ import './weekly-report-importer'
3
3
 
4
4
  import gql from 'graphql-tag'
5
5
  import { css, html } from 'lit'
6
+ import { customElement, property, query } from 'lit/decorators.js'
6
7
  import { connect } from 'pwa-helpers/connect-mixin'
7
8
 
8
9
  import { client } from '@operato/graphql'
@@ -12,13 +13,14 @@ import { PageView, store } from '@operato/shell'
12
13
  import { CommonButtonStyles, CommonGristStyles, ScrollbarStyles } from '@operato/styles'
13
14
  import { isMobileDevice } from '@operato/utils'
14
15
 
16
+ @customElement('weekly-report-list-page')
15
17
  export class WeeklyReportListPage extends connect(store)(localize(i18next)(PageView)) {
16
- static get properties() {
17
- return {
18
- gristConfig: Object,
19
- mode: String
20
- }
21
- }
18
+ @property({ type: String }) mode = ''
19
+ @property({ type: Object }) gristConfig = {}
20
+
21
+ // TODO(appano1): Add types to Shadow DOM elements
22
+ @query('#sorter-control') sorterController
23
+ @query('ox-grist') grist
22
24
 
23
25
  static get styles() {
24
26
  return [
@@ -78,7 +80,7 @@ export class WeeklyReportListPage extends connect(store)(localize(i18next)(PageV
78
80
  <mwc-icon
79
81
  @click=${e => {
80
82
  const target = e.currentTarget
81
- this.renderRoot.querySelector('#sorter-control').open({
83
+ this.sorterController.open({
82
84
  right: 0,
83
85
  top: target.offsetTop + target.offsetHeight
84
86
  })
@@ -100,10 +102,6 @@ export class WeeklyReportListPage extends connect(store)(localize(i18next)(PageV
100
102
  `
101
103
  }
102
104
 
103
- get grist() {
104
- return this.renderRoot.querySelector('ox-grist')
105
- }
106
-
107
105
  async pageInitialized(lifecycle) {
108
106
  this.gristConfig = {
109
107
  list: {
@@ -288,7 +286,7 @@ export class WeeklyReportListPage extends connect(store)(localize(i18next)(PageV
288
286
  let patches = this.grist.dirtyRecords
289
287
  if (patches && patches.length) {
290
288
  patches = patches.map(patch => {
291
- let patchField = patch.id ? { id: patch.id } : {}
289
+ let patchField: any = patch.id ? { id: patch.id } : {}
292
290
  const dirtyFields = patch.__dirtyfields__
293
291
  for (let key in dirtyFields) {
294
292
  patchField[key] = dirtyFields[key].after
@@ -364,5 +362,3 @@ export class WeeklyReportListPage extends connect(store)(localize(i18next)(PageV
364
362
  }
365
363
  }
366
364
  }
367
-
368
- window.customElements.define('weekly-report-list-page', WeeklyReportListPage)
@@ -1,13 +1,15 @@
1
1
  import '@operato/event-view'
2
2
 
3
- import { css, html } from 'lit-element'
3
+ import { css, html } from 'lit'
4
+ import { customElement, property } from 'lit/decorators.js'
4
5
  import { connect } from 'pwa-helpers/connect-mixin.js'
5
6
 
6
- import { PageView, store } from '@things-factory/shell'
7
+ import { PageView, store } from '@operato/shell'
7
8
 
8
9
  import { WeeklyReportCalendarEventProvider } from './weekly-report-calendar-evt-provider'
9
10
 
10
- class WeeklyReportCalendar extends connect(store)(PageView) {
11
+ @customElement('weekly-report-calendar-page')
12
+ export class WeeklyReportCalendar extends connect(store)(PageView) {
11
13
  static get styles() {
12
14
  return [
13
15
  css`
@@ -31,12 +33,8 @@ class WeeklyReportCalendar extends connect(store)(PageView) {
31
33
  ]
32
34
  }
33
35
 
34
- static get properties() {
35
- return {
36
- itemId: String,
37
- params: Object
38
- }
39
- }
36
+ @property({ type: String }) itemId = ''
37
+ @property({ type: Object }) params = {}
40
38
 
41
39
  render() {
42
40
  return html`
@@ -127,5 +125,3 @@ class WeeklyReportCalendar extends connect(store)(PageView) {
127
125
  */
128
126
  }
129
127
  }
130
-
131
- customElements.define('weekly-report-calendar-page', WeeklyReportCalendar)
@@ -1,14 +1,17 @@
1
1
  import './weekly-report-preview-popup'
2
2
 
3
3
  import gql from 'graphql-tag'
4
- import { css, html } from 'lit-element'
4
+ import { css, html } from 'lit'
5
+ import { customElement, property, query } from 'lit/decorators.js'
5
6
  import { connect } from 'pwa-helpers/connect-mixin.js'
6
7
 
8
+ import { client, gqlContext } from '@operato/graphql'
7
9
  import { i18next } from '@operato/i18n'
8
10
  import { openPopup } from '@operato/layout'
9
- import { client, gqlContext, PageView, store } from '@things-factory/shell'
11
+ import { PageView, store } from '@operato/shell'
10
12
 
11
- class WeeklyReportEditor extends connect(store)(PageView) {
13
+ @customElement('weekly-report-editor-page')
14
+ export class WeeklyReportEditor extends connect(store)(PageView) {
12
15
  static get styles() {
13
16
  return [
14
17
  css`
@@ -30,12 +33,13 @@ class WeeklyReportEditor extends connect(store)(PageView) {
30
33
  ]
31
34
  }
32
35
 
33
- static get properties() {
34
- return {
35
- itemId: String,
36
- params: Object
37
- }
38
- }
36
+ @property({ type: String }) itemId = ''
37
+ @property({ type: Object }) params = {}
38
+
39
+ @query(`[name="this-week-report"]`) thisWeekReportElement
40
+ @query(`[name="next-week-report"]`) nextWeekReportElement
41
+ @query(`[name="issue-report"]`) issueReportElement
42
+ @query(`[name="other-report"]`) otherReportElement
39
43
 
40
44
  render() {
41
45
  return html`
@@ -97,13 +101,13 @@ class WeeklyReportEditor extends connect(store)(PageView) {
97
101
  `
98
102
  }
99
103
 
100
- getReports() {
101
- const thisWeekReport = this.renderRoot.querySelector(`[name="this-week-report"]`).value
102
- const nextWeekReport = this.renderRoot.querySelector(`[name="next-week-report"]`).value
103
- const issueReport = this.renderRoot.querySelector(`[name="issue-report"]`).value
104
- const otherReport = this.renderRoot.querySelector(`[name="other-report"]`).value
105
-
106
- return { thisWeekReport, nextWeekReport, issueReport, otherReport }
104
+ get reports() {
105
+ return {
106
+ thisWeekReport: this.thisWeekReportElement.value,
107
+ nextWeekReport: this.nextWeekReportElement.value,
108
+ issueReport: this.issueReportElement.value,
109
+ otherReport: this.otherReportElement.value
110
+ }
107
111
  }
108
112
 
109
113
  // test event handler
@@ -111,11 +115,12 @@ class WeeklyReportEditor extends connect(store)(PageView) {
111
115
  // const [receivers, title, body, image, url] = ['receivers', 'title', 'body', 'image', 'url'].map(
112
116
  // key => this.renderRoot.querySelector(`[name="${key}"]`).value
113
117
  // )
114
- console.log(this.renderRoot.querySelector(`[name="this-week-report"]`).value)
118
+ const { thisWeekReport } = this.reports
119
+ console.log(thisWeekReport)
115
120
  }
116
121
 
117
122
  onpreview() {
118
- const { thisWeekReport, nextWeekReport, issueReport, otherReport } = this.getReports()
123
+ const { thisWeekReport, nextWeekReport, issueReport, otherReport } = this.reports
119
124
 
120
125
  const popup = openPopup(
121
126
  html`
@@ -146,7 +151,7 @@ class WeeklyReportEditor extends connect(store)(PageView) {
146
151
 
147
152
  // test code
148
153
  const weeks = 10
149
- const { thisWeekReport, nextWeekReport, issueReport, otherReport } = this.getReports()
154
+ const { thisWeekReport, nextWeekReport, issueReport, otherReport } = this.reports
150
155
 
151
156
  const response = await client.mutate({
152
157
  mutation: gql`
@@ -228,7 +233,7 @@ class WeeklyReportEditor extends connect(store)(PageView) {
228
233
 
229
234
  // add an event for the shortcut of 'save'
230
235
  window.addEventListener('keydown', e => {
231
- if ((window.navigator.platform.match('Mac') ? e.metaKey : e.ctrlKey) && e.keyCode == 83) {
236
+ if (e.key === 's' && (e.metaKey || e.ctrlKey)) {
232
237
  e.preventDefault()
233
238
  this.onsave()
234
239
  }
@@ -276,16 +281,13 @@ class WeeklyReportEditor extends connect(store)(PageView) {
276
281
  })
277
282
 
278
283
  if (response.errors) {
279
- this.renderRoot.querySelector(`[name="this-week-report"]`).value = reportTemplate
284
+ this.thisWeekReportElement.value = reportTemplate
280
285
  } else {
281
- this.renderRoot.querySelector(`[name="this-week-report"]`).value =
282
- response.data.weeklyReportByWeeks.thisWeekReport
283
- this.renderRoot.querySelector(`[name="next-week-report"]`).value =
284
- response.data.weeklyReportByWeeks.nextWeekReport
285
-
286
+ this.thisWeekReportElement.value = response.data.weeklyReportByWeeks.thisWeekReport
287
+ this.nextWeekReportElement.value = response.data.weeklyReportByWeeks.nextWeekReport
286
288
  console.log('xxxx: ', response.data.weeklyReportByWeeks)
287
- this.renderRoot.querySelector(`[name="issue-report"]`).value = response.data.weeklyReportByWeeks.issueReport
288
- this.renderRoot.querySelector(`[name="other-report"]`).value = response.data.weeklyReportByWeeks.otherReport
289
+ this.issueReportElement.value = response.data.weeklyReportByWeeks.issueReport
290
+ this.otherReportElement.value = response.data.weeklyReportByWeeks.otherReport
289
291
  }
290
292
 
291
293
  this.itemId = lifecycle.resourceId
@@ -307,5 +309,3 @@ class WeeklyReportEditor extends connect(store)(PageView) {
307
309
  */
308
310
  }
309
311
  }
310
-
311
- customElements.define('weekly-report-editor-page', WeeklyReportEditor)
@@ -1,32 +1,14 @@
1
1
  import { css, html, LitElement } from 'lit'
2
+ import { customElement, property } from 'lit/decorators.js'
2
3
  import { unsafeHTML } from 'lit/directives/unsafe-html.js'
3
4
  import { marked } from 'marked'
4
5
 
6
+ @customElement('weekly-report-preview-popup')
5
7
  export class WeeklyReportPreviewPopup extends LitElement {
6
- static get properties() {
7
- return {
8
- thisWeekReport: {
9
- type: String,
10
- attribute: 'this-week'
11
- },
12
- nextWeekReport: {
13
- type: String,
14
- attribute: 'next-week'
15
- },
16
- issueReport: {
17
- type: String,
18
- attribute: 'issue'
19
- },
20
- otherReport: {
21
- type: String,
22
- attribute: 'other'
23
- }
24
- }
25
- }
26
-
27
- constructor() {
28
- super()
29
- }
8
+ @property({ type: String, attribute: 'this-week' }) thisWeekReport = ''
9
+ @property({ type: String, attribute: 'next-week' }) nextWeekReport = ''
10
+ @property({ type: String, attribute: 'issue' }) issueReport = ''
11
+ @property({ type: String, attribute: 'other' }) otherReport = ''
30
12
 
31
13
  static get styles() {
32
14
  return [
@@ -94,5 +76,3 @@ export class WeeklyReportPreviewPopup extends LitElement {
94
76
  this.dispatchEvent(new CustomEvent('imported'))
95
77
  }
96
78
  }
97
-
98
- window.customElements.define('weekly-report-preview-popup', WeeklyReportPreviewPopup)
@@ -1,4 +1,4 @@
1
- export default function route(page) {
1
+ export default function route(page: string) {
2
2
  switch (page) {
3
3
  case '':
4
4
  return '/todo-list'
@@ -8,15 +8,15 @@ export default function route(page) {
8
8
  return page
9
9
 
10
10
  case 'weekly-report-list':
11
- import('./pages/weekly-report/weekly-report-list-page.js')
11
+ import('./pages/weekly-report/weekly-report-list-page')
12
12
  return page
13
13
 
14
14
  case 'weekly-report-calendar':
15
- import('./pages/weekly-report-calendar.js')
15
+ import('./pages/weekly-report-calendar')
16
16
  return page
17
17
 
18
18
  case 'weekly-report-editor':
19
- import('./pages/weekly-report-editor.js')
19
+ import('./pages/weekly-report-editor')
20
20
  return page
21
21
  }
22
22
  }
@@ -0,0 +1,12 @@
1
+ {
2
+ "extends": "../../tsconfig-base.json",
3
+ "compilerOptions": {
4
+ "experimentalDecorators": true,
5
+ "strict": true,
6
+ "declaration": true,
7
+ "module": "esnext",
8
+ "outDir": "../dist-client",
9
+ "baseUrl": "./"
10
+ },
11
+ "include": ["./**/*"]
12
+ }
package/db.sqlite CHANGED
Binary file
@@ -15,7 +15,7 @@ let WeeklyReportMutation = class WeeklyReportMutation {
15
15
  const { domain, user, tx } = context.state;
16
16
  const repository = tx.getRepository(weekly_report_1.WeeklyReport);
17
17
  const foundReport = await repository.findOne({
18
- where: { domain, reportOwner: user, weeks: weeklyReport.weeks }
18
+ where: { domain: { id: domain.id }, reportOwner: { id: user.id }, weeks: weeklyReport.weeks }
19
19
  });
20
20
  if (foundReport && foundReport.id) {
21
21
  console.log('update: ', Object.assign(Object.assign({ id: foundReport.id }, weeklyReport), { updater: user }));
@@ -37,7 +37,7 @@ let WeeklyReportMutation = class WeeklyReportMutation {
37
37
  const { domain, user, tx } = context.state;
38
38
  const repository = tx.getRepository(weekly_report_1.WeeklyReport);
39
39
  const weeklyReport = await repository.findOne({
40
- where: { domain, id }
40
+ where: { domain: { id: domain.id }, id }
41
41
  });
42
42
  return await repository.save(Object.assign(Object.assign(Object.assign({}, weeklyReport), patch), { updater: user }));
43
43
  }
@@ -57,7 +57,7 @@ let WeeklyReportMutation = class WeeklyReportMutation {
57
57
  if (_updateRecords.length > 0) {
58
58
  for (let i = 0; i < _updateRecords.length; i++) {
59
59
  const newRecord = _updateRecords[i];
60
- const weeklyReport = await weeklyReportRepo.findOne(newRecord.id);
60
+ const weeklyReport = await weeklyReportRepo.findOneBy({ id: newRecord.id });
61
61
  const result = await weeklyReportRepo.save(Object.assign(Object.assign(Object.assign({}, weeklyReport), newRecord), { updater: user }));
62
62
  results.push(Object.assign(Object.assign({}, result), { cuFlag: 'M' }));
63
63
  }
@@ -66,13 +66,13 @@ let WeeklyReportMutation = class WeeklyReportMutation {
66
66
  }
67
67
  async deleteWeeklyReport(id, context) {
68
68
  const { domain, tx } = context.state;
69
- await tx.getRepository(weekly_report_1.WeeklyReport).delete({ domain, id });
69
+ await tx.getRepository(weekly_report_1.WeeklyReport).delete({ domain: { id: domain.id }, id });
70
70
  return true;
71
71
  }
72
72
  async deleteWeeklyReports(ids, context) {
73
73
  const { domain, tx } = context.state;
74
74
  await tx.getRepository(weekly_report_1.WeeklyReport).delete({
75
- domain,
75
+ domain: { id: domain.id },
76
76
  id: (0, typeorm_1.In)(ids)
77
77
  });
78
78
  return true;
@@ -1 +1 @@
1
- {"version":3,"file":"weekly-report-mutation.js","sourceRoot":"","sources":["../../../server/service/weekly-report/weekly-report-mutation.ts"],"names":[],"mappings":";;;;AAAA,+CAAsE;AACtE,qCAA4B;AAI5B,mDAA8C;AAC9C,6DAAyE;AAGzE,IAAa,oBAAoB,GAAjC,MAAa,oBAAoB;IAG/B,KAAK,CAAC,kBAAkB,C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;;+DAWP;AA1KU,oBAAoB;IADhC,IAAA,uBAAQ,EAAC,4BAAY,CAAC;GACV,oBAAoB,CA2KhC;AA3KY,oDAAoB","sourcesContent":["import { Arg, Ctx, Directive, Mutation, Resolver } from 'type-graphql'\nimport { In } from 'typeorm'\n\nimport { sleep } from '@things-factory/utils'\n\nimport { WeeklyReport } from './weekly-report'\nimport { NewWeeklyReport, WeeklyReportPatch } from './weekly-report-type'\n\n@Resolver(WeeklyReport)\nexport class WeeklyReportMutation {\n @Directive('@transaction')\n @Mutation(returns => WeeklyReport, { description: 'To create new WeeklyReport' })\n async createWeeklyReport(\n @Arg('weeklyReport') weeklyReport: NewWeeklyReport,\n @Ctx() context: any\n ): Promise<WeeklyReport> {\n const { domain, user, tx } = context.state\n\n return await tx.getRepository(WeeklyReport).save({\n ...weeklyReport,\n domain,\n reportOwner: user,\n creator: user,\n updater: user\n })\n }\n\n @Directive('@transaction')\n @Mutation(returns => WeeklyReport, { description: 'To save a WeeklyReport' })\n async saveWeeklyReport(\n @Arg('weeklyReport') weeklyReport: NewWeeklyReport,\n @Ctx() context: any\n ): Promise<WeeklyReport> {\n const { domain, user, tx } = context.state\n\n const repository = tx.getRepository(WeeklyReport)\n\n const foundReport = await repository.findOne({\n where: { domain, reportOwner: user, weeks: weeklyReport.weeks }\n })\n\n if (foundReport && foundReport.id) {\n console.log('update: ', {\n id: foundReport.id,\n ...weeklyReport,\n updater: user\n })\n\n return await repository.save({\n id: foundReport.id,\n ...weeklyReport,\n updater: user\n })\n } else {\n return await tx.getRepository(WeeklyReport).save({\n ...weeklyReport,\n domain,\n reportOwner: user,\n creator: user,\n updater: user\n })\n }\n\n return foundReport\n\n // return await tx.getRepository(WeeklyReport).save({\n // ...weeklyReport,\n // domain,\n // reportOwner: user,\n // creator: user,\n // updater: user\n // })\n }\n\n @Directive('@transaction')\n @Mutation(returns => WeeklyReport, { description: 'To modify WeeklyReport information' })\n async updateWeeklyReport(\n @Arg('id') id: string,\n @Arg('patch') patch: WeeklyReportPatch,\n @Ctx() context: any\n ): Promise<WeeklyReport> {\n const { domain, user, tx } = context.state\n\n const repository = tx.getRepository(WeeklyReport)\n const weeklyReport = await repository.findOne({\n where: { domain, id }\n })\n\n return await repository.save({\n ...weeklyReport,\n ...patch,\n updater: user\n })\n }\n\n @Directive('@transaction')\n @Mutation(returns => [WeeklyReport], { description: \"To modify multiple WeeklyReports' information\" })\n async updateMultipleWeeklyReport(\n @Arg('patches', type => [WeeklyReportPatch]) patches: WeeklyReportPatch[],\n @Ctx() context: any\n ): Promise<WeeklyReport[]> {\n const { domain, user, tx } = context.state\n\n let results = []\n const _createRecords = patches.filter((patch: any) => patch.cuFlag.toUpperCase() === '+')\n const _updateRecords = patches.filter((patch: any) => patch.cuFlag.toUpperCase() === 'M')\n const weeklyReportRepo = tx.getRepository(WeeklyReport)\n\n if (_createRecords.length > 0) {\n for (let i = 0; i < _createRecords.length; i++) {\n const newRecord = _createRecords[i]\n\n const result = await weeklyReportRepo.save({\n ...newRecord,\n domain,\n reportOwner: user,\n creator: user,\n updater: user\n })\n\n results.push({ ...result, cuFlag: '+' })\n }\n }\n\n if (_updateRecords.length > 0) {\n for (let i = 0; i < _updateRecords.length; i++) {\n const newRecord = _updateRecords[i]\n const weeklyReport = await weeklyReportRepo.findOne(newRecord.id)\n\n const result = await weeklyReportRepo.save({\n ...weeklyReport,\n ...newRecord,\n updater: user\n })\n\n results.push({ ...result, cuFlag: 'M' })\n }\n }\n\n return results\n }\n\n @Directive('@transaction')\n @Mutation(returns => Boolean, { description: 'To delete WeeklyReport' })\n async deleteWeeklyReport(@Arg('id') id: string, @Ctx() context: any): Promise<boolean> {\n const { domain, tx } = context.state\n\n await tx.getRepository(WeeklyReport).delete({ domain, id })\n return true\n }\n\n @Directive('@transaction')\n @Mutation(returns => Boolean, { description: 'To delete multiple WeeklyReports' })\n async deleteWeeklyReports(@Arg('ids', type => [String]) ids: string[], @Ctx() context: any): Promise<boolean> {\n const { domain, tx } = context.state\n\n await tx.getRepository(WeeklyReport).delete({\n domain,\n id: In(ids)\n })\n\n return true\n }\n\n @Directive('@transaction')\n @Mutation(returns => Boolean, { description: 'To import multiple WeeklyReports' })\n async importWeeklyReports(\n @Arg('weeklyReports', type => [WeeklyReportPatch]) weeklyReports: WeeklyReportPatch[],\n @Ctx() context: any\n ): Promise<boolean> {\n const { domain, tx } = context.state\n\n await Promise.all(\n weeklyReports.map(async (weeklyReport: WeeklyReportPatch) => {\n const createdWeeklyReport: WeeklyReport = await tx.getRepository(WeeklyReport).save({ domain, ...weeklyReport })\n })\n )\n\n return true\n }\n}\n"]}
1
+ {"version":3,"file":"weekly-report-mutation.js","sourceRoot":"","sources":["../../../server/service/weekly-report/weekly-report-mutation.ts"],"names":[],"mappings":";;;;AAAA,+CAAsE;AACtE,qCAA4B;AAE5B,mDAA8C;AAC9C,6DAAyE;AAGzE,IAAa,oBAAoB,GAAjC,MAAa,oBAAoB;IAG/B,KAAK,CAAC,kBAAkB,CACD,YAA6B,EAC3C,OAAwB;QAE/B,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;QAE1C,OAAO,MAAM,EAAE,CAAC,aAAa,CAAC,4BAAY,CAAC,CAAC,IAAI,iCAC3C,YAAY,KACf,MAAM,EACN,WAAW,EAAE,IAAI,EACjB,OAAO,EAAE,IAAI,EACb,OAAO,EAAE,IAAI,IACb,CAAA;IACJ,CAAC;IAID,KAAK,CAAC,gBAAgB,CACC,YAA6B,EAC3C,OAAwB;QAE/B,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;QAE1C,MAAM,UAAU,GAAG,EAAE,CAAC,aAAa,CAAC,4BAAY,CAAC,CAAA;QAEjD,MAAM,WAAW,GAAG,MAAM,UAAU,CAAC,OAAO,CAAC;YAC3C,KAAK,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,MAAM,CAAC,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,mBAAA,IAAA,kBAAG,GAAE,CAAA;;;;sEAyCP;AAID;IAFC,IAAA,wBAAS,EAAC,cAAc,CAAC;IACzB,IAAA,uBAAQ,EAAC,OAAO,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE,WAAW,EAAE,wBAAwB,EAAE,CAAC;IAC9C,mBAAA,IAAA,kBAAG,EAAC,IAAI,CAAC,CAAA;IAAc,mBAAA,IAAA,kBAAG,GAAE,CAAA;;;;8DAKrD;AAID;IAFC,IAAA,wBAAS,EAAC,cAAc,CAAC;IACzB,IAAA,uBAAQ,EAAC,OAAO,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE,WAAW,EAAE,kCAAkC,EAAE,CAAC;IAE/E,mBAAA,IAAA,kBAAG,EAAC,KAAK,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAA;IAC5B,mBAAA,IAAA,kBAAG,GAAE,CAAA;;;;+DAUP;AAID;IAFC,IAAA,wBAAS,EAAC,cAAc,CAAC;IACzB,IAAA,uBAAQ,EAAC,OAAO,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE,WAAW,EAAE,kCAAkC,EAAE,CAAC;IAE/E,mBAAA,IAAA,kBAAG,EAAC,eAAe,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC,sCAAiB,CAAC,CAAC,CAAA;IACjD,mBAAA,IAAA,kBAAG,GAAE,CAAA;;;;+DAWP;AA7KU,oBAAoB;IADhC,IAAA,uBAAQ,EAAC,4BAAY,CAAC;GACV,oBAAoB,CA8KhC;AA9KY,oDAAoB","sourcesContent":["import { Arg, Ctx, Directive, Mutation, Resolver } from 'type-graphql'\nimport { In } from 'typeorm'\n\nimport { WeeklyReport } from './weekly-report'\nimport { NewWeeklyReport, WeeklyReportPatch } from './weekly-report-type'\n\n@Resolver(WeeklyReport)\nexport class WeeklyReportMutation {\n @Directive('@transaction')\n @Mutation(returns => WeeklyReport, { description: 'To create new WeeklyReport' })\n async createWeeklyReport(\n @Arg('weeklyReport') weeklyReport: NewWeeklyReport,\n @Ctx() context: ResolverContext\n ): Promise<WeeklyReport> {\n const { domain, user, tx } = context.state\n\n return await tx.getRepository(WeeklyReport).save({\n ...weeklyReport,\n domain,\n reportOwner: user,\n creator: user,\n updater: user\n })\n }\n\n @Directive('@transaction')\n @Mutation(returns => WeeklyReport, { description: 'To save a WeeklyReport' })\n async saveWeeklyReport(\n @Arg('weeklyReport') weeklyReport: NewWeeklyReport,\n @Ctx() context: ResolverContext\n ): Promise<WeeklyReport> {\n const { domain, user, tx } = context.state\n\n const repository = tx.getRepository(WeeklyReport)\n\n const foundReport = await repository.findOne({\n where: { domain: { id: domain.id }, reportOwner: { id: user.id }, weeks: weeklyReport.weeks }\n })\n\n if (foundReport && foundReport.id) {\n console.log('update: ', {\n id: foundReport.id,\n ...weeklyReport,\n updater: user\n })\n\n return await repository.save({\n id: foundReport.id,\n ...weeklyReport,\n updater: user\n })\n } else {\n return await tx.getRepository(WeeklyReport).save({\n ...weeklyReport,\n domain,\n reportOwner: user,\n creator: user,\n updater: user\n })\n }\n\n return foundReport\n\n // return await tx.getRepository(WeeklyReport).save({\n // ...weeklyReport,\n // domain,\n // reportOwner: user,\n // creator: user,\n // updater: user\n // })\n }\n\n @Directive('@transaction')\n @Mutation(returns => WeeklyReport, { description: 'To modify WeeklyReport information' })\n async updateWeeklyReport(\n @Arg('id') id: string,\n @Arg('patch') patch: WeeklyReportPatch,\n @Ctx() context: ResolverContext\n ): Promise<WeeklyReport> {\n const { domain, user, tx } = context.state\n\n const repository = tx.getRepository(WeeklyReport)\n const weeklyReport = await repository.findOne({\n where: { domain: { id: domain.id }, id }\n })\n\n return await repository.save({\n ...weeklyReport,\n ...patch,\n updater: user\n })\n }\n\n @Directive('@transaction')\n @Mutation(returns => [WeeklyReport], { description: \"To modify multiple WeeklyReports' information\" })\n async updateMultipleWeeklyReport(\n @Arg('patches', type => [WeeklyReportPatch]) patches: WeeklyReportPatch[],\n @Ctx() context: ResolverContext\n ): Promise<WeeklyReport[]> {\n const { domain, user, tx } = context.state\n\n let results = []\n const _createRecords = patches.filter((patch: any) => patch.cuFlag.toUpperCase() === '+')\n const _updateRecords = patches.filter((patch: any) => patch.cuFlag.toUpperCase() === 'M')\n const weeklyReportRepo = tx.getRepository(WeeklyReport)\n\n if (_createRecords.length > 0) {\n for (let i = 0; i < _createRecords.length; i++) {\n const newRecord = _createRecords[i]\n\n const result = await weeklyReportRepo.save({\n ...newRecord,\n domain,\n reportOwner: user,\n creator: user,\n updater: user\n })\n\n results.push({ ...result, cuFlag: '+' })\n }\n }\n\n if (_updateRecords.length > 0) {\n for (let i = 0; i < _updateRecords.length; i++) {\n const newRecord = _updateRecords[i]\n const weeklyReport = await weeklyReportRepo.findOneBy({ id: newRecord.id })\n\n const result = await weeklyReportRepo.save({\n ...weeklyReport,\n ...newRecord,\n updater: user\n })\n\n results.push({ ...result, cuFlag: 'M' })\n }\n }\n\n return results\n }\n\n @Directive('@transaction')\n @Mutation(returns => Boolean, { description: 'To delete WeeklyReport' })\n async deleteWeeklyReport(@Arg('id') id: string, @Ctx() context: ResolverContext): Promise<boolean> {\n const { domain, tx } = context.state\n\n await tx.getRepository(WeeklyReport).delete({ domain: { id: domain.id }, id })\n return true\n }\n\n @Directive('@transaction')\n @Mutation(returns => Boolean, { description: 'To delete multiple WeeklyReports' })\n async deleteWeeklyReports(\n @Arg('ids', type => [String]) ids: string[],\n @Ctx() context: ResolverContext\n ): Promise<boolean> {\n const { domain, tx } = context.state\n\n await tx.getRepository(WeeklyReport).delete({\n domain: { id: domain.id },\n id: In(ids)\n })\n\n return true\n }\n\n @Directive('@transaction')\n @Mutation(returns => Boolean, { description: 'To import multiple WeeklyReports' })\n async importWeeklyReports(\n @Arg('weeklyReports', type => [WeeklyReportPatch]) weeklyReports: WeeklyReportPatch[],\n @Ctx() context: ResolverContext\n ): Promise<boolean> {\n const { domain, tx } = context.state\n\n await Promise.all(\n weeklyReports.map(async (weeklyReport: WeeklyReportPatch) => {\n const createdWeeklyReport: WeeklyReport = await tx.getRepository(WeeklyReport).save({ domain, ...weeklyReport })\n })\n )\n\n return true\n }\n}\n"]}
@@ -1,10 +1,8 @@
1
1
  "use strict";
2
- var _a;
3
2
  Object.defineProperty(exports, "__esModule", { value: true });
4
3
  exports.WeeklyReportQuery = void 0;
5
4
  const tslib_1 = require("tslib");
6
5
  const type_graphql_1 = require("type-graphql");
7
- const typeorm_1 = require("typeorm");
8
6
  const auth_base_1 = require("@things-factory/auth-base");
9
7
  const shell_1 = require("@things-factory/shell");
10
8
  const weekly_report_1 = require("./weekly-report");
@@ -12,33 +10,33 @@ const weekly_report_type_1 = require("./weekly-report-type");
12
10
  let WeeklyReportQuery = class WeeklyReportQuery {
13
11
  async weeklyReport(id, context) {
14
12
  const { domain, user } = context.state;
15
- return await (0, typeorm_1.getRepository)(weekly_report_1.WeeklyReport).findOne({
16
- where: { domain, id, reportOwner: user }
13
+ return await (0, shell_1.getRepository)(weekly_report_1.WeeklyReport).findOne({
14
+ where: { domain: { id: domain.id }, id, reportOwner: { id: user.id } }
17
15
  });
18
16
  }
19
17
  async weeklyReports(params, context) {
20
18
  const { domain } = context.state;
21
19
  const convertedParams = (0, shell_1.convertListParams)(params, { domain, searchables: ['reportOwner', 'weeks'] });
22
- const [items, total] = await (0, typeorm_1.getRepository)(weekly_report_1.WeeklyReport).findAndCount(convertedParams);
20
+ const [items, total] = await (0, shell_1.getRepository)(weekly_report_1.WeeklyReport).findAndCount(convertedParams);
23
21
  return { items, total };
24
22
  }
25
23
  async weeklyReportByWeeks(weeks, context) {
26
24
  const { domain, user } = context.state;
27
- return await (0, typeorm_1.getRepository)(weekly_report_1.WeeklyReport).findOne({
28
- where: { domain, reportOwner: user, weeks }
25
+ return await (0, shell_1.getRepository)(weekly_report_1.WeeklyReport).findOne({
26
+ where: { domain: { id: domain.id }, reportOwner: { id: user.id }, weeks }
29
27
  });
30
28
  }
31
29
  async domain(weeklyReport) {
32
- return await (0, typeorm_1.getRepository)(shell_1.Domain).findOne(weeklyReport.domainId);
30
+ return await (0, shell_1.getRepository)(shell_1.Domain).findOneBy({ id: weeklyReport.domainId });
33
31
  }
34
32
  async reportOwner(weeklyReport) {
35
- return await (0, typeorm_1.getRepository)(auth_base_1.User).findOne(weeklyReport.reportOwnerId);
33
+ return await (0, shell_1.getRepository)(auth_base_1.User).findOneBy({ id: weeklyReport.reportOwnerId });
36
34
  }
37
35
  async updater(weeklyReport) {
38
- return await (0, typeorm_1.getRepository)(auth_base_1.User).findOne(weeklyReport.updaterId);
36
+ return await (0, shell_1.getRepository)(auth_base_1.User).findOneBy({ id: weeklyReport.updaterId });
39
37
  }
40
38
  async creator(weeklyReport) {
41
- return await (0, typeorm_1.getRepository)(auth_base_1.User).findOne(weeklyReport.creatorId);
39
+ return await (0, shell_1.getRepository)(auth_base_1.User).findOneBy({ id: weeklyReport.creatorId });
42
40
  }
43
41
  };
44
42
  tslib_1.__decorate([
@@ -54,7 +52,7 @@ tslib_1.__decorate([
54
52
  tslib_1.__param(0, (0, type_graphql_1.Args)()),
55
53
  tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
56
54
  tslib_1.__metadata("design:type", Function),
57
- tslib_1.__metadata("design:paramtypes", [typeof (_a = typeof shell_1.ListParam !== "undefined" && shell_1.ListParam) === "function" ? _a : Object, Object]),
55
+ tslib_1.__metadata("design:paramtypes", [shell_1.ListParam, Object]),
58
56
  tslib_1.__metadata("design:returntype", Promise)
59
57
  ], WeeklyReportQuery.prototype, "weeklyReports", null);
60
58
  tslib_1.__decorate([