@things-factory/board-ui 6.1.191 → 6.1.195

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 (140) hide show
  1. package/client/actions/permissions.ts +1 -0
  2. package/client/apptools/favorite-tool.ts +123 -0
  3. package/client/board-list/board-importer.ts +138 -0
  4. package/client/board-list/board-tile-list.js +282 -0
  5. package/client/board-list/group-bar.ts +148 -0
  6. package/client/board-list/play-group-bar.js +147 -0
  7. package/client/bootstrap.ts +17 -0
  8. package/client/graphql/board.ts +273 -0
  9. package/client/graphql/favorite-board.ts +25 -0
  10. package/client/graphql/group.ts +138 -0
  11. package/client/graphql/index.ts +4 -0
  12. package/client/graphql/play-group.ts +189 -0
  13. package/client/index.ts +3 -0
  14. package/client/pages/attachment-list-page.ts +142 -0
  15. package/client/pages/board-list-page.js +519 -0
  16. package/client/pages/board-template/board-template-list-page.ts +17 -16
  17. package/client/pages/font-list-page.ts +32 -0
  18. package/client/pages/play-list-page.js +399 -0
  19. package/client/pages/theme/theme-list-page.ts +18 -16
  20. package/client/reducers/permissions.ts +41 -0
  21. package/client/route.ts +16 -0
  22. package/client/viewparts/board-basic-info.ts +669 -0
  23. package/client/viewparts/board-info-link.ts +37 -0
  24. package/client/viewparts/board-info.ts +89 -0
  25. package/client/viewparts/board-versions.ts +157 -0
  26. package/client/viewparts/group-info-basic.ts +258 -0
  27. package/client/viewparts/group-info-import.ts +135 -0
  28. package/client/viewparts/group-info.ts +81 -0
  29. package/client/viewparts/index.ts +3 -0
  30. package/client/viewparts/link-builder.ts +194 -0
  31. package/client/viewparts/play-group-info-basic.ts +258 -0
  32. package/client/viewparts/play-group-info-link.ts +40 -0
  33. package/client/viewparts/play-group-info.ts +81 -0
  34. package/dist-client/actions/permissions.d.ts +1 -0
  35. package/dist-client/actions/permissions.js +2 -0
  36. package/dist-client/actions/permissions.js.map +1 -0
  37. package/dist-client/apptools/favorite-tool.d.ts +26 -0
  38. package/dist-client/apptools/favorite-tool.js +129 -0
  39. package/dist-client/apptools/favorite-tool.js.map +1 -0
  40. package/dist-client/board-list/board-importer.d.ts +6 -0
  41. package/dist-client/board-list/board-importer.js +112 -0
  42. package/dist-client/board-list/board-importer.js.map +1 -0
  43. package/dist-client/board-list/board-tile-list.d.ts +27 -0
  44. package/dist-client/board-list/board-tile-list.js +247 -0
  45. package/dist-client/board-list/board-tile-list.js.map +1 -0
  46. package/dist-client/board-list/group-bar.d.ts +14 -0
  47. package/dist-client/board-list/group-bar.js +141 -0
  48. package/dist-client/board-list/group-bar.js.map +1 -0
  49. package/dist-client/board-list/play-group-bar.d.ts +16 -0
  50. package/dist-client/board-list/play-group-bar.js +128 -0
  51. package/dist-client/board-list/play-group-bar.js.map +1 -0
  52. package/dist-client/bootstrap.js +14 -0
  53. package/dist-client/bootstrap.js.map +1 -1
  54. package/dist-client/graphql/board.d.ts +19 -0
  55. package/dist-client/graphql/board.js +231 -0
  56. package/dist-client/graphql/board.js.map +1 -0
  57. package/dist-client/graphql/favorite-board.d.ts +1 -0
  58. package/dist-client/graphql/favorite-board.js +24 -0
  59. package/dist-client/graphql/favorite-board.js.map +1 -0
  60. package/dist-client/graphql/group.d.ts +6 -0
  61. package/dist-client/graphql/group.js +125 -0
  62. package/dist-client/graphql/group.js.map +1 -0
  63. package/dist-client/graphql/index.d.ts +4 -0
  64. package/dist-client/graphql/index.js +5 -0
  65. package/dist-client/graphql/index.js.map +1 -0
  66. package/dist-client/graphql/play-group.d.ts +7 -0
  67. package/dist-client/graphql/play-group.js +173 -0
  68. package/dist-client/graphql/play-group.js.map +1 -0
  69. package/dist-client/index.d.ts +3 -0
  70. package/dist-client/index.js +3 -0
  71. package/dist-client/index.js.map +1 -1
  72. package/dist-client/pages/attachment-list-page.d.ts +30 -0
  73. package/dist-client/pages/attachment-list-page.js +128 -0
  74. package/dist-client/pages/attachment-list-page.js.map +1 -0
  75. package/dist-client/pages/board-list-page.d.ts +1 -0
  76. package/dist-client/pages/board-list-page.js +447 -0
  77. package/dist-client/pages/board-list-page.js.map +1 -0
  78. package/dist-client/pages/board-template/board-template-list-page.js +15 -16
  79. package/dist-client/pages/board-template/board-template-list-page.js.map +1 -1
  80. package/dist-client/pages/font-list-page.d.ts +10 -0
  81. package/dist-client/pages/font-list-page.js +32 -0
  82. package/dist-client/pages/font-list-page.js.map +1 -0
  83. package/dist-client/pages/play-list-page.d.ts +1 -0
  84. package/dist-client/pages/play-list-page.js +343 -0
  85. package/dist-client/pages/play-list-page.js.map +1 -0
  86. package/dist-client/pages/theme/theme-editors.d.ts +1 -1
  87. package/dist-client/pages/theme/theme-list-page.js +15 -16
  88. package/dist-client/pages/theme/theme-list-page.js.map +1 -1
  89. package/dist-client/reducers/permissions.d.ts +4 -0
  90. package/dist-client/reducers/permissions.js +32 -0
  91. package/dist-client/reducers/permissions.js.map +1 -0
  92. package/dist-client/route.js +12 -0
  93. package/dist-client/route.js.map +1 -1
  94. package/dist-client/tsconfig.tsbuildinfo +1 -1
  95. package/dist-client/viewparts/board-basic-info.d.ts +47 -0
  96. package/dist-client/viewparts/board-basic-info.js +640 -0
  97. package/dist-client/viewparts/board-basic-info.js.map +1 -0
  98. package/dist-client/viewparts/board-info-link.d.ts +7 -0
  99. package/dist-client/viewparts/board-info-link.js +41 -0
  100. package/dist-client/viewparts/board-info-link.js.map +1 -0
  101. package/dist-client/viewparts/board-info.d.ts +12 -0
  102. package/dist-client/viewparts/board-info.js +100 -0
  103. package/dist-client/viewparts/board-info.js.map +1 -0
  104. package/dist-client/viewparts/board-versions.d.ts +12 -0
  105. package/dist-client/viewparts/board-versions.js +153 -0
  106. package/dist-client/viewparts/board-versions.js.map +1 -0
  107. package/dist-client/viewparts/group-info-basic.d.ts +16 -0
  108. package/dist-client/viewparts/group-info-basic.js +247 -0
  109. package/dist-client/viewparts/group-info-basic.js.map +1 -0
  110. package/dist-client/viewparts/group-info-import.d.ts +15 -0
  111. package/dist-client/viewparts/group-info-import.js +137 -0
  112. package/dist-client/viewparts/group-info-import.js.map +1 -0
  113. package/dist-client/viewparts/group-info.d.ts +10 -0
  114. package/dist-client/viewparts/group-info.js +89 -0
  115. package/dist-client/viewparts/group-info.js.map +1 -0
  116. package/dist-client/viewparts/index.d.ts +3 -0
  117. package/dist-client/viewparts/index.js +4 -0
  118. package/dist-client/viewparts/index.js.map +1 -0
  119. package/dist-client/viewparts/link-builder.d.ts +20 -0
  120. package/dist-client/viewparts/link-builder.js +197 -0
  121. package/dist-client/viewparts/link-builder.js.map +1 -0
  122. package/dist-client/viewparts/menu-tools.d.ts +20 -0
  123. package/dist-client/viewparts/menu-tools.js +147 -0
  124. package/dist-client/viewparts/menu-tools.js.map +1 -0
  125. package/dist-client/viewparts/play-group-info-basic.d.ts +16 -0
  126. package/dist-client/viewparts/play-group-info-basic.js +249 -0
  127. package/dist-client/viewparts/play-group-info-basic.js.map +1 -0
  128. package/dist-client/viewparts/play-group-info-link.d.ts +7 -0
  129. package/dist-client/viewparts/play-group-info-link.js +41 -0
  130. package/dist-client/viewparts/play-group-info-link.js.map +1 -0
  131. package/dist-client/viewparts/play-group-info.d.ts +10 -0
  132. package/dist-client/viewparts/play-group-info.js +89 -0
  133. package/dist-client/viewparts/play-group-info.js.map +1 -0
  134. package/package.json +11 -5
  135. package/things-factory.config.js +16 -0
  136. package/translations/en.json +101 -60
  137. package/translations/ja.json +101 -58
  138. package/translations/ko.json +106 -62
  139. package/translations/ms.json +60 -19
  140. package/translations/zh.json +102 -61
@@ -0,0 +1 @@
1
+ export const UPDATE_PERMISSION = 'UPDATE_PERMISSION'
@@ -0,0 +1,123 @@
1
+ import '@material/mwc-icon'
2
+
3
+ import gql from 'graphql-tag'
4
+ import { css, html, LitElement } from 'lit'
5
+ import { customElement, property, state } from 'lit/decorators.js'
6
+ import { connect } from 'pwa-helpers/connect-mixin.js'
7
+
8
+ import { store } from '@operato/shell'
9
+ import { client } from '@operato/graphql'
10
+ import { UPDATE_FAVORITES } from '@things-factory/fav-base'
11
+
12
+ @customElement('favorite-tool')
13
+ export class FavoriteTool extends connect(store)(LitElement) {
14
+ static styles = css`
15
+ :host {
16
+ display: inline-block;
17
+ vertical-align: middle;
18
+ line-height: 0;
19
+ }
20
+
21
+ [favorable] {
22
+ opacity: 0.5;
23
+ }
24
+ `
25
+
26
+ @property({ type: Array }) favorites: any[] = []
27
+ @property({ type: Object }) user: any
28
+ @property({ type: String }) resourceId?: string
29
+ @property({ type: Boolean }) favored?: boolean
30
+ @property({ type: Array }) acceptedPages: any[] = []
31
+
32
+ page: any
33
+
34
+ render() {
35
+ var renderable = (this.acceptedPages || []).indexOf(this.page) !== -1
36
+
37
+ return renderable
38
+ ? html`
39
+ <mwc-icon @click=${this.onClick.bind(this)} ?favorable=${!this.favored}
40
+ >${this.favored ? 'star' : 'star_border'}</mwc-icon
41
+ >
42
+ `
43
+ : html``
44
+ }
45
+
46
+ updated(changes) {
47
+ if (changes.has('user')) {
48
+ this.refreshFavorites()
49
+ }
50
+
51
+ this.favored = (this.favorites || []).includes(this.resourceId)
52
+ }
53
+
54
+ stateChanged(state) {
55
+ this.page = state.route.page
56
+ this.favorites = state.favorite.favorites
57
+ this.user = state.auth.user
58
+ this.resourceId = state.route.resourceId
59
+ }
60
+
61
+ onClick(event) {
62
+ if (!this.resourceId) {
63
+ return
64
+ }
65
+
66
+ if (this.favored) {
67
+ this.removeFavorite(this.resourceId)
68
+ } else {
69
+ this.addFavorite(this.resourceId)
70
+ }
71
+ }
72
+
73
+ async refreshFavorites() {
74
+ if (!this.user || !this.user.email) {
75
+ return
76
+ }
77
+
78
+ const response = await client.query({
79
+ query: gql`
80
+ query {
81
+ myFavorites {
82
+ id
83
+ routing
84
+ }
85
+ }
86
+ `
87
+ })
88
+
89
+ store.dispatch({
90
+ type: UPDATE_FAVORITES,
91
+ favorites: response.data.myFavorites.map(favorite => favorite.routing)
92
+ })
93
+ }
94
+
95
+ async removeFavorite(routing) {
96
+ await client.query({
97
+ query: gql`
98
+ mutation {
99
+ deleteFavorite(routing: "${routing}")
100
+ }
101
+ `
102
+ })
103
+
104
+ this.refreshFavorites()
105
+ }
106
+
107
+ async addFavorite(routing) {
108
+ await client.query({
109
+ query: gql`
110
+ mutation {
111
+ createFavorite(favorite: {
112
+ routing: "${routing}"
113
+ }) {
114
+ id
115
+ routing
116
+ }
117
+ }
118
+ `
119
+ })
120
+
121
+ this.refreshFavorites()
122
+ }
123
+ }
@@ -0,0 +1,138 @@
1
+ import '@operato/board/ox-board-viewer.js'
2
+
3
+ import { BoardViewer } from '@operato/board/ox-board-viewer.js'
4
+
5
+ function setHighlightStyle(dropArea) {
6
+ var style = document.createElement('style')
7
+
8
+ style.type = 'text/css'
9
+ style.innerHTML = `.highlight_me {
10
+ background: orange;
11
+ cursor: pointer;
12
+ }`
13
+
14
+ dropArea.appendChild(style)
15
+ }
16
+
17
+ export default class BoardImporter {
18
+ static import(file, importer) {
19
+ let reader = new FileReader()
20
+ reader.readAsText(file)
21
+ reader.onloadend = () => {
22
+ try {
23
+ let model = JSON.parse(reader.result as any)
24
+ importer(file.name.replace(/\.[^/.]+$/, ''), model)
25
+ } catch (e) {
26
+ console.error('board import failed', e)
27
+ }
28
+ }
29
+ }
30
+
31
+ static preview(file) {
32
+ let reader = new FileReader()
33
+ reader.readAsText(file)
34
+ reader.onloadend = () => {
35
+ try {
36
+ let previewModel = JSON.parse(reader.result as any)
37
+
38
+ var preview = document.createElement('ox-board-viewer') as BoardViewer
39
+
40
+ preview.style.width = '100%'
41
+ preview.style.height = '80%'
42
+ preview.style.margin = '0'
43
+ preview.style.padding = '0'
44
+
45
+ // TODO how to hand over model to previewer
46
+ // preview.model = previewModel
47
+ // preview.provider = provider;
48
+
49
+ var buttons = document.createElement('div')
50
+
51
+ buttons.className = 'buttons'
52
+ buttons.innerHTML = `
53
+ <paper-button dialog-dismiss>Cancel</paper-button>
54
+ <paper-button dialog-confirm autofocus>Accept</paper-button>
55
+ `
56
+
57
+ var dialog = document.createElement('paper-dialog')
58
+
59
+ dialog.style.width = '100%'
60
+ dialog.style.height = '100%'
61
+ dialog.setAttribute('with-backdrop', 'true')
62
+ dialog.setAttribute('auto-fit-on-attach', 'true')
63
+ dialog.setAttribute('always-on-top', 'true')
64
+ dialog.addEventListener('iron-overlay-closed', () => {
65
+ dialog.parentNode!.removeChild(dialog)
66
+ })
67
+
68
+ dialog.appendChild(preview)
69
+ dialog.appendChild(buttons)
70
+ document.body.appendChild(dialog)
71
+
72
+ requestAnimationFrame(() => {
73
+ ;(dialog as any).open()
74
+ })
75
+ } catch (e) {
76
+ console.error('board preview failed', e)
77
+ }
78
+ }
79
+ // let url = 'YOUR URL HERE'
80
+ // let formData = new FormData()
81
+
82
+ // formData.append('file', file)
83
+
84
+ // fetch(url, {
85
+ // method: 'POST',
86
+ // body: formData
87
+ // })
88
+ // .then(() => { /* Done. Inform the user */ })
89
+ // .catch(() => { /* Error. Inform the user */ })
90
+ }
91
+
92
+ static set(dropArea, judge, importer) {
93
+ setHighlightStyle(dropArea)
94
+
95
+ var preventDefaults = e => {
96
+ if (!judge || judge()) {
97
+ e.preventDefault()
98
+ e.stopPropagation()
99
+ }
100
+ }
101
+
102
+ var highlight = e => {
103
+ if (!judge || judge()) {
104
+ dropArea.classList.add('highlight_me')
105
+ }
106
+ }
107
+
108
+ var unhighlight = e => {
109
+ if (!judge || judge()) {
110
+ dropArea.classList.remove('highlight_me')
111
+ }
112
+ }
113
+
114
+ ;['dragenter', 'dragover', 'dragleave', 'drop'].forEach(event => {
115
+ dropArea.addEventListener(event, preventDefaults, false)
116
+ })
117
+ ;['dragenter', 'dragover'].forEach(event => {
118
+ dropArea.addEventListener(event, highlight, false)
119
+ })
120
+ ;['dragleave', 'drop'].forEach(event => {
121
+ dropArea.addEventListener(event, unhighlight, false)
122
+ })
123
+
124
+ dropArea.addEventListener(
125
+ 'drop',
126
+ e => {
127
+ if (!judge || judge()) {
128
+ let dt = e.dataTransfer
129
+ let files = dt.files
130
+
131
+ // [...files].forEach((file) => BoardImporter.preview(file))
132
+ ;[...files].forEach(file => BoardImporter.import(file, importer))
133
+ }
134
+ },
135
+ false
136
+ )
137
+ }
138
+ }
@@ -0,0 +1,282 @@
1
+ import '@operato/board/ox-board-creation-card.js'
2
+ import '@material/mwc-icon'
3
+
4
+ import gql from 'graphql-tag'
5
+ import { css, html, LitElement } from 'lit'
6
+ import { keyed } from 'lit/directives/keyed.js'
7
+
8
+ import { client } from '@things-factory/shell'
9
+
10
+ export default class BoardTileList extends LitElement {
11
+ static get styles() {
12
+ return [
13
+ css`
14
+ :host {
15
+ overflow: auto;
16
+ padding: var(--popup-content-padding);
17
+ display: grid;
18
+
19
+ grid-template-columns: var(--card-list-template);
20
+ grid-auto-rows: var(--card-list-rows-height);
21
+ grid-gap: 20px;
22
+ --mdc-button-horizontal-padding: var(--padding-default);
23
+ }
24
+
25
+ [card] {
26
+ position: relative;
27
+ align-items: center;
28
+ overflow: hidden;
29
+ }
30
+
31
+ [card][create] {
32
+ overflow: visible;
33
+ background-color: initial;
34
+ }
35
+
36
+ [card] > a {
37
+ display: flex;
38
+ }
39
+
40
+ [card]:hover {
41
+ cursor: pointer;
42
+ }
43
+
44
+ [name] {
45
+ text-overflow: ellipsis;
46
+ white-space: nowrap;
47
+ overflow: hidden;
48
+ margin-top: var(--margin-narrow);
49
+ width: calc(100% - 45px);
50
+ color: var(--primary-text-color);
51
+ font-weight: bolder;
52
+ font-size: var(--fontsize-small);
53
+ }
54
+
55
+ img {
56
+ display: block;
57
+
58
+ margin: auto;
59
+ max-width: 100%;
60
+ max-height: 100%;
61
+ }
62
+
63
+ mwc-icon[iconBtn] {
64
+ float: right;
65
+ margin-top: -20px;
66
+ margin-left: 2px;
67
+ color: var(--board-list-star-color);
68
+ font-size: 1.4em;
69
+ }
70
+ mwc-icon[info] {
71
+ color: var(--primary-color);
72
+ }
73
+
74
+ mwc-icon[iconBtn][favored],
75
+ mwc-icon[info]:hover {
76
+ color: var(--board-list-star-active-color);
77
+ }
78
+
79
+ a {
80
+ display: block;
81
+ border-radius: var(--card-list-border-radius);
82
+ border: var(--border-dark-color);
83
+ box-sizing: border-box;
84
+ background-color: var(--card-list-background-color);
85
+ margin: 0px;
86
+ height: calc(100% - 25px);
87
+ }
88
+
89
+ :host > *:hover [info] {
90
+ opacity: 1;
91
+ -webkit-transition: opacity 0.8s;
92
+ -moz-transition: opacity 0.8s;
93
+ -o-transition: opacity 0.8s;
94
+ transition: opacity 0.8s;
95
+ }
96
+
97
+ [draggable='true'] {
98
+ cursor: grab;
99
+ }
100
+
101
+ @media screen and (max-width: 800px), screen and (max-height: 600px) {
102
+ ox-board-creation-card {
103
+ display: none;
104
+ }
105
+ }
106
+ `
107
+ ]
108
+ }
109
+
110
+ static get properties() {
111
+ return {
112
+ creatable: {
113
+ type: Boolean,
114
+ attribute: 'creatable'
115
+ },
116
+ boards: Array,
117
+ favorites: Array,
118
+ groups: Array,
119
+ group: String,
120
+ reorderable: {
121
+ type: Boolean,
122
+ attribute: 'reorderable'
123
+ }
124
+ }
125
+ }
126
+
127
+ draggingItem
128
+
129
+ connectedCallback() {
130
+ super.connectedCallback()
131
+
132
+ if (this.reorderable) {
133
+ this.renderRoot.addEventListener('dragstart', e => {
134
+ // if (!e.target.getAttribute('draggable')) {
135
+ // e.preventDefault()
136
+ // }
137
+
138
+ // this.draggedItem = e.target
139
+ this.draggedItem = e.target.closest('[card]')
140
+ e.dataTransfer.setData('text/plain', e.target.innerHTML)
141
+ })
142
+
143
+ this.renderRoot.addEventListener('dragover', e => {
144
+ e.preventDefault()
145
+ const targetItem = e.target.closest('[card]')
146
+ if (targetItem !== this.draggedItem) {
147
+ const targetRect = targetItem.getBoundingClientRect()
148
+ const mousePos = e.clientX - targetRect.left
149
+
150
+ if (mousePos < targetRect.width / 2) {
151
+ // 마우스 위치가 아이템 좌측 반절에 있을 때
152
+ this.renderRoot.insertBefore(this.draggedItem, targetItem)
153
+ } else {
154
+ // 마우스 위치가 아이템 우측 반절에 있을 때
155
+ this.renderRoot.insertBefore(this.draggedItem, targetItem.nextSibling)
156
+ }
157
+ }
158
+ })
159
+
160
+ this.renderRoot.addEventListener('drop', e => {
161
+ e.preventDefault()
162
+
163
+ const boardIds = Array.from(this.renderRoot.querySelectorAll('[card]'))
164
+ .map(board => board.getAttribute('id'))
165
+ .filter(Boolean)
166
+
167
+ this.dispatchEvent(
168
+ new CustomEvent('reordered', {
169
+ detail: {
170
+ groupId: this.group,
171
+ boardIds
172
+ }
173
+ })
174
+ )
175
+ })
176
+ }
177
+ }
178
+
179
+ render() {
180
+ var boards = this.boards || []
181
+
182
+ return html`
183
+ ${this.creatable
184
+ ? html`
185
+ <ox-board-creation-card
186
+ .groups=${this.groups}
187
+ .defaultGroup=${this.group}
188
+ @create-board=${e => this.onCreateBoard(e)}
189
+ card
190
+ create
191
+ ></ox-board-creation-card>
192
+ `
193
+ : html``}
194
+ ${keyed(
195
+ Date.now(),
196
+ boards.map(
197
+ board =>
198
+ html`
199
+ <div card draggable="true" id=${board.id}>
200
+ <a href="board-viewer/${board.id}"> <img src=${board.thumbnail} /> </a>
201
+
202
+ <div name>${board.name}</div>
203
+ <!-- <div description>${board.description}</div> -->
204
+
205
+ <mwc-icon
206
+ iconBtn
207
+ info
208
+ @click=${e => {
209
+ this.infoBoard(board.id)
210
+ e.preventDefault()
211
+ }}
212
+ >info</mwc-icon
213
+ >
214
+
215
+ ${(this.favorites || []).includes(board.id)
216
+ ? html` <mwc-icon iconBtn favored @click=${e => this.removeFavorite(board.id)}>star</mwc-icon> `
217
+ : html` <mwc-icon iconBtn @click=${e => this.addFavorite(board.id)}>star_border</mwc-icon> `}
218
+ </div>
219
+ `
220
+ )
221
+ )}
222
+ `
223
+ }
224
+
225
+ updated(changes) {
226
+ var creationCard = this.shadowRoot.querySelector('ox-board-creation-card')
227
+ if (creationCard) {
228
+ creationCard.reset()
229
+ }
230
+ }
231
+
232
+ onCreateBoard(e) {
233
+ this.dispatchEvent(
234
+ new CustomEvent('create-board', {
235
+ detail: e.detail
236
+ })
237
+ )
238
+ }
239
+
240
+ infoBoard(boardId) {
241
+ this.dispatchEvent(
242
+ new CustomEvent('info-board', {
243
+ detail: boardId
244
+ })
245
+ )
246
+ }
247
+
248
+ async removeFavorite(boardId) {
249
+ await client.query({
250
+ query: gql`
251
+ mutation {
252
+ deleteFavorite(routing: "${boardId}")
253
+ }
254
+ `
255
+ })
256
+
257
+ this.refreshFavorites()
258
+ }
259
+
260
+ async addFavorite(boardId) {
261
+ await client.query({
262
+ query: gql`
263
+ mutation {
264
+ createFavorite(favorite: {
265
+ routing: "${boardId}"
266
+ }) {
267
+ id
268
+ routing
269
+ }
270
+ }
271
+ `
272
+ })
273
+
274
+ this.refreshFavorites()
275
+ }
276
+
277
+ async refreshFavorites() {
278
+ this.dispatchEvent(new CustomEvent('refresh-favorites'))
279
+ }
280
+ }
281
+
282
+ window.customElements.define('board-tile-list', BoardTileList)
@@ -0,0 +1,148 @@
1
+ import '@material/mwc-icon'
2
+
3
+ import { css, html, LitElement } from 'lit'
4
+ import { customElement, property } from 'lit/decorators.js'
5
+
6
+ import ScrollBooster from 'scrollbooster'
7
+
8
+ import { longpressable } from '@things-factory/utils'
9
+
10
+ @customElement('group-bar')
11
+ export default class GroupBar extends LitElement {
12
+ static styles = [
13
+ css`
14
+ :host {
15
+ background-color: var(--group-bar-background-color);
16
+
17
+ overflow-x: hidden;
18
+ }
19
+
20
+ ul {
21
+ display: flex;
22
+ list-style: none;
23
+ margin: 0;
24
+ padding: 0;
25
+ white-space: nowrap;
26
+ }
27
+
28
+ li {
29
+ display: inline-block;
30
+ padding: 0px 3px;
31
+
32
+ border-bottom: var(--group-bar-line);
33
+ }
34
+
35
+ li[active] {
36
+ border-color: var(--group-bar-active-line-color);
37
+ }
38
+
39
+ li a {
40
+ display: block;
41
+ padding: 5px 4px 1px 4px;
42
+ text-decoration: none;
43
+ font: var(--group-bar-textbutton);
44
+ color: rgba(255, 255, 255, 0.8);
45
+ }
46
+
47
+ li[active] a {
48
+ font: var(--group-bar-textbutton-active);
49
+ color: rgba(255, 255, 255, 1);
50
+ }
51
+
52
+ li[padding] {
53
+ flex: 1;
54
+ }
55
+
56
+ li[add] {
57
+ padding: 5px 4px 1px 4px;
58
+ }
59
+
60
+ li[add] * {
61
+ color: rgba(255, 255, 255, 0.5);
62
+ }
63
+
64
+ mwc-icon {
65
+ vertical-align: middle;
66
+ }
67
+ `
68
+ ]
69
+
70
+ @property({ type: Array }) groups?: any[]
71
+ @property({ type: String }) groupId?: string
72
+ @property({ type: String }) targetPage?: string
73
+
74
+ private __sb?: ScrollBooster
75
+
76
+ render() {
77
+ return html`
78
+ <ul>
79
+ <li ?active=${!this.groupId}>
80
+ <a href=${this.targetPage || ''}><mwc-icon>dashboard</mwc-icon></a>
81
+ </li>
82
+
83
+ <li ?active=${this.groupId === 'favor'}>
84
+ <a href="${this.targetPage}/favor"><mwc-icon>star</mwc-icon></a>
85
+ </li>
86
+
87
+ ${(this.groups || []).map(
88
+ group => html`
89
+ <li ?active=${this.groupId === group.id} @long-press=${e => this.infoGroup(group.id)}>
90
+ <a href=${`${this.targetPage}/${group.id}`}>${group.name}</a>
91
+ </li>
92
+ `
93
+ )}
94
+
95
+ <li padding></li>
96
+
97
+ <li add>
98
+ <mwc-icon @click=${e => this.infoGroup()}>add</mwc-icon>
99
+ </li>
100
+ </ul>
101
+ `
102
+ }
103
+
104
+ infoGroup(groupId?: string) {
105
+ this.dispatchEvent(
106
+ new CustomEvent('info-group', {
107
+ detail: groupId
108
+ })
109
+ )
110
+ }
111
+
112
+ onWheelEvent(e) {
113
+ var delta = Math.max(-1, Math.min(1, e.wheelDelta || -e.detail))
114
+ this.scrollLeft -= delta * 40
115
+
116
+ e.preventDefault()
117
+ }
118
+
119
+ updated(change) {
120
+ if (change.has('groups')) {
121
+ /* groups가 바뀔 때마다, contents의 폭이 달라지므로, 다시 폭을 계산해준다. */
122
+ this.__sb && this.__sb.updateMetrics()
123
+ }
124
+
125
+ if (change.has('groupId')) {
126
+ var active = this.renderRoot.querySelector('li[active]')
127
+ active && active.scrollIntoView()
128
+ }
129
+ }
130
+
131
+ firstUpdated() {
132
+ var scrollTarget = this.renderRoot.querySelector('ul')
133
+
134
+ /* long-press */
135
+ longpressable(scrollTarget)
136
+
137
+ scrollTarget!.addEventListener('mousewheel', this.onWheelEvent.bind(this), false)
138
+
139
+ this.__sb = new ScrollBooster({
140
+ viewport: this,
141
+ content: scrollTarget,
142
+ mode: 'x',
143
+ onUpdate: data => {
144
+ this.scrollLeft = data.position.x
145
+ }
146
+ })
147
+ }
148
+ }