@dssp/supervision 0.0.36 → 1.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.
- package/dist-client/pages/checklist/checklist-view.js +2 -5
- package/dist-client/pages/checklist/checklist-view.js.map +1 -1
- package/dist-client/route.d.ts +1 -1
- package/dist-client/tsconfig.tsbuildinfo +1 -1
- package/dist-server/service/index.d.ts +1 -1
- package/dist-server/tsconfig.tsbuildinfo +1 -1
- package/package.json +13 -13
- package/dist-client/pages/checklist/comment-list-popup copy.d.ts +0 -2
- package/dist-client/pages/checklist/comment-list-popup copy.js +0 -344
- package/dist-client/pages/checklist/comment-list-popup copy.js.map +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dssp/supervision",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "1.0.0-alpha.0",
|
|
4
4
|
"main": "dist-server/index.js",
|
|
5
5
|
"browser": "dist-client/index.js",
|
|
6
6
|
"things-factory": true,
|
|
@@ -27,17 +27,17 @@
|
|
|
27
27
|
"migration:create": "node ../../node_modules/typeorm/cli.js migration:create -d ./server/migrations"
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@dssp/building-complex": "^0.0.
|
|
31
|
-
"@dssp/drawing": "^0.0.
|
|
32
|
-
"@dssp/project": "^0.0.
|
|
33
|
-
"@operato/event-view": "^8.0.0-
|
|
34
|
-
"@operato/graphql": "^8.0.0-
|
|
35
|
-
"@operato/image-marker": "^8.0.0-
|
|
36
|
-
"@operato/input": "^8.0.0-
|
|
37
|
-
"@operato/mini-map": "^8.0.0-
|
|
38
|
-
"@operato/shell": "^8.0.0-
|
|
39
|
-
"@things-factory/auth-base": "^8.0.0-
|
|
40
|
-
"@things-factory/shell": "^8.0.0-
|
|
30
|
+
"@dssp/building-complex": "^1.0.0-alpha.0",
|
|
31
|
+
"@dssp/drawing": "^1.0.0-alpha.0",
|
|
32
|
+
"@dssp/project": "^1.0.0-alpha.0",
|
|
33
|
+
"@operato/event-view": "^8.0.0-beta",
|
|
34
|
+
"@operato/graphql": "^8.0.0-beta",
|
|
35
|
+
"@operato/image-marker": "^8.0.0-beta",
|
|
36
|
+
"@operato/input": "^8.0.0-beta",
|
|
37
|
+
"@operato/mini-map": "^8.0.0-beta",
|
|
38
|
+
"@operato/shell": "^8.0.0-beta",
|
|
39
|
+
"@things-factory/auth-base": "^8.0.0-beta",
|
|
40
|
+
"@things-factory/shell": "^8.0.0-beta"
|
|
41
41
|
},
|
|
42
|
-
"gitHead": "
|
|
42
|
+
"gitHead": "7b8b1a1ab63177487b30c0acb7f2cbc82afe6a0e"
|
|
43
43
|
}
|
|
@@ -1,344 +0,0 @@
|
|
|
1
|
-
import { __decorate, __metadata } from "tslib";
|
|
2
|
-
import '@material/web/icon/icon.js';
|
|
3
|
-
import gql from 'graphql-tag';
|
|
4
|
-
import { client } from '@operato/graphql';
|
|
5
|
-
import { css, html, LitElement } from 'lit';
|
|
6
|
-
import { customElement, property, query, state } from 'lit/decorators.js';
|
|
7
|
-
import { ButtonContainerStyles, ScrollbarStyles } from '@operato/styles';
|
|
8
|
-
import { notify } from '@operato/layout';
|
|
9
|
-
import { store, User } from '@operato/shell';
|
|
10
|
-
import { connect } from 'pwa-helpers/connect-mixin.js';
|
|
11
|
-
import { OxPrompt } from '@operato/popup/ox-prompt.js';
|
|
12
|
-
import './checklist-view';
|
|
13
|
-
let CommentListPopup = class CommentListPopup extends connect(store)(LitElement) {
|
|
14
|
-
constructor() {
|
|
15
|
-
super(...arguments);
|
|
16
|
-
this.checklistItemId = '';
|
|
17
|
-
this.item = { count: 0 };
|
|
18
|
-
this.checklistItemComments = [];
|
|
19
|
-
this.comment = '';
|
|
20
|
-
this.checklistItemCommentCount = 0;
|
|
21
|
-
this.user = {};
|
|
22
|
-
this.page = 1;
|
|
23
|
-
this.loading = false;
|
|
24
|
-
this.hasMoreComments = true;
|
|
25
|
-
}
|
|
26
|
-
render() {
|
|
27
|
-
return html `
|
|
28
|
-
<div body>
|
|
29
|
-
<h3>제품검사에 대한 확인: ${this.checklistItemCommentCount || 0}건</h3>
|
|
30
|
-
|
|
31
|
-
<div comments-container @scroll=${this._onScroll}>
|
|
32
|
-
${this.checklistItemComments.map(comment => {
|
|
33
|
-
return html `
|
|
34
|
-
<div comment-row>
|
|
35
|
-
<div creator-container>
|
|
36
|
-
<span creator><md-icon slot="icon">account_circle</md-icon> ${comment.creator.name}</span>
|
|
37
|
-
<span createdAt>
|
|
38
|
-
<md-icon slot="icon">schedule</md-icon> ${this._formatDate(comment.createdAt)}
|
|
39
|
-
${comment.creator.email === this.user.email
|
|
40
|
-
? html ` <md-icon delete slot="icon" @click=${() => this._deleteComment(comment.id)}>delete</md-icon>`
|
|
41
|
-
: ''}
|
|
42
|
-
</span>
|
|
43
|
-
</div>
|
|
44
|
-
<div comment>${comment.comment}</div>
|
|
45
|
-
</div>
|
|
46
|
-
`;
|
|
47
|
-
})}
|
|
48
|
-
</div>
|
|
49
|
-
|
|
50
|
-
<textarea .value=${this.comment || ''} @input=${this._onInputChange}></textarea>
|
|
51
|
-
|
|
52
|
-
<div button-container>
|
|
53
|
-
<md-elevated-button blue @click=${this._createComment}> <md-icon slot="icon">task</md-icon>저장 </md-elevated-button>
|
|
54
|
-
<md-elevated-button @click=${this._close}> <md-icon slot="icon">cancel</md-icon>취소 </md-elevated-button>
|
|
55
|
-
</div>
|
|
56
|
-
</div>
|
|
57
|
-
`;
|
|
58
|
-
}
|
|
59
|
-
async firstUpdated() {
|
|
60
|
-
var _a;
|
|
61
|
-
this.user = (_a = store.getState().auth) === null || _a === void 0 ? void 0 : _a.user;
|
|
62
|
-
this.comment = '';
|
|
63
|
-
this.page = 1;
|
|
64
|
-
await this._loadComments();
|
|
65
|
-
this._scrollBottom();
|
|
66
|
-
}
|
|
67
|
-
async _loadComments() {
|
|
68
|
-
if (this.loading || !this.hasMoreComments)
|
|
69
|
-
return;
|
|
70
|
-
this.loading = true;
|
|
71
|
-
const response = await client.query({
|
|
72
|
-
query: gql `
|
|
73
|
-
query ChecklistItemComments($pagination: Pagination!, $checklistItemId: String!) {
|
|
74
|
-
checklistItemComments(pagination: $pagination, checklistItemId: $checklistItemId) {
|
|
75
|
-
id
|
|
76
|
-
comment
|
|
77
|
-
creator {
|
|
78
|
-
id
|
|
79
|
-
email
|
|
80
|
-
}
|
|
81
|
-
createdAt
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
checklistItem(id: $checklistItemId) {
|
|
85
|
-
id
|
|
86
|
-
checklistItemCommentCount
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
`,
|
|
90
|
-
variables: {
|
|
91
|
-
checklistItemId: this.checklistItemId,
|
|
92
|
-
pagination: {
|
|
93
|
-
page: this.page,
|
|
94
|
-
limit: 10
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
});
|
|
98
|
-
if (response.errors)
|
|
99
|
-
return;
|
|
100
|
-
const items = response.data.checklistItemComments;
|
|
101
|
-
if (items.length < 10)
|
|
102
|
-
this.hasMoreComments = false;
|
|
103
|
-
this.checklistItemComments = [...items.reverse(), ...this.checklistItemComments];
|
|
104
|
-
this.page += 1;
|
|
105
|
-
this.checklistItemCommentCount = response.data.checklistItem.checklistItemCommentCount;
|
|
106
|
-
this.loading = false;
|
|
107
|
-
}
|
|
108
|
-
// 스크롤이 맨 위에 가까울 때 데이터 요청
|
|
109
|
-
_onScroll() {
|
|
110
|
-
const { scrollTop } = this.commentsContainer;
|
|
111
|
-
if (scrollTop <= 5) {
|
|
112
|
-
this._loadComments();
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
async _createComment() {
|
|
116
|
-
var _a, _b;
|
|
117
|
-
if (!this.comment) {
|
|
118
|
-
notify({ message: '조치사항을 입력해주세요.', level: 'warn' });
|
|
119
|
-
return;
|
|
120
|
-
}
|
|
121
|
-
const response = await client.mutate({
|
|
122
|
-
mutation: gql `
|
|
123
|
-
mutation CreateChecklistItemComment($checklistItemComment: NewChecklistItemComment!) {
|
|
124
|
-
createChecklistItemComment(checklistItemComment: $checklistItemComment) {
|
|
125
|
-
id
|
|
126
|
-
comment
|
|
127
|
-
creator {
|
|
128
|
-
id
|
|
129
|
-
email
|
|
130
|
-
}
|
|
131
|
-
createdAt
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
`,
|
|
135
|
-
variables: {
|
|
136
|
-
checklistItemComment: {
|
|
137
|
-
comment: this.comment,
|
|
138
|
-
checklistItemId: this.checklistItemId
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
});
|
|
142
|
-
if (!response.errors) {
|
|
143
|
-
this.comment = '';
|
|
144
|
-
this.checklistItemComments = [...this.checklistItemComments, Object.assign({}, response.data.createChecklistItemComment)];
|
|
145
|
-
this._scrollBottom();
|
|
146
|
-
this.checklistItemCommentCount++;
|
|
147
|
-
}
|
|
148
|
-
else {
|
|
149
|
-
notify({ message: ((_b = (_a = response.errors) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.message) || '조치사항 등록에 실패하였습니다.', level: 'error' });
|
|
150
|
-
}
|
|
151
|
-
this._dispatchEvent();
|
|
152
|
-
}
|
|
153
|
-
async _deleteComment(commentId) {
|
|
154
|
-
var _a, _b;
|
|
155
|
-
if (await OxPrompt.open({
|
|
156
|
-
title: '조치 사항을 삭제',
|
|
157
|
-
text: '조치 사항을 삭제 하시겠습니까?',
|
|
158
|
-
confirmButton: { text: '삭제' },
|
|
159
|
-
cancelButton: { text: '취소' }
|
|
160
|
-
})) {
|
|
161
|
-
const response = await client.mutate({
|
|
162
|
-
mutation: gql `
|
|
163
|
-
mutation DeleteChecklistItemComment($id: String!) {
|
|
164
|
-
deleteChecklistItemComment(id: $id)
|
|
165
|
-
}
|
|
166
|
-
`,
|
|
167
|
-
variables: {
|
|
168
|
-
id: commentId
|
|
169
|
-
}
|
|
170
|
-
});
|
|
171
|
-
if (!response.errors) {
|
|
172
|
-
this.checklistItemComments = [...this.checklistItemComments.filter(comment => comment.id != commentId)];
|
|
173
|
-
notify({ message: '조치사항을 삭제하였습니다.', level: 'info' });
|
|
174
|
-
}
|
|
175
|
-
else {
|
|
176
|
-
notify({ message: ((_b = (_a = response.errors) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.message) || '조치사항 삭제에 실패하였습니다.', level: 'error' });
|
|
177
|
-
}
|
|
178
|
-
this._dispatchEvent();
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
_close() {
|
|
182
|
-
history.back();
|
|
183
|
-
}
|
|
184
|
-
// Input 요소의 값이 변경될 때 호출되는 콜백 함수
|
|
185
|
-
_onInputChange(event) {
|
|
186
|
-
const target = event.target;
|
|
187
|
-
this.comment = target.value;
|
|
188
|
-
}
|
|
189
|
-
_formatDate(date) {
|
|
190
|
-
const _date = new Date(date.toLocaleString('en-US', { timeZone: 'Asia/Seoul' }));
|
|
191
|
-
const year = _date.getFullYear();
|
|
192
|
-
const month = String(_date.getMonth() + 1).padStart(2, '0');
|
|
193
|
-
const day = String(_date.getDate()).padStart(2, '0');
|
|
194
|
-
const hours = String(_date.getHours()).padStart(2, '0');
|
|
195
|
-
const minutes = String(_date.getMinutes()).padStart(2, '0');
|
|
196
|
-
const seconds = String(_date.getSeconds()).padStart(2, '0');
|
|
197
|
-
return `${year}.${month}.${day} ${hours}:${minutes}:${seconds}`;
|
|
198
|
-
}
|
|
199
|
-
// 댓글 스크롤 맨 밑으로
|
|
200
|
-
async _scrollBottom() {
|
|
201
|
-
setTimeout(() => {
|
|
202
|
-
this.commentsContainer.scrollTop = this.commentsContainer.scrollHeight;
|
|
203
|
-
}, 100);
|
|
204
|
-
}
|
|
205
|
-
// 조치사항 변경 이벤트 디스패치
|
|
206
|
-
_dispatchEvent() {
|
|
207
|
-
this.dispatchEvent(new CustomEvent('change-comment', { detail: { checklistItemId: this.checklistItemId } }));
|
|
208
|
-
}
|
|
209
|
-
};
|
|
210
|
-
CommentListPopup.styles = [
|
|
211
|
-
ButtonContainerStyles,
|
|
212
|
-
ScrollbarStyles,
|
|
213
|
-
css `
|
|
214
|
-
:host {
|
|
215
|
-
display: flex;
|
|
216
|
-
flex-direction: column;
|
|
217
|
-
padding: 15px 20px;
|
|
218
|
-
background-color: var(--md-sys-color-surface);
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
div[body] {
|
|
222
|
-
height: 100%;
|
|
223
|
-
display: flex;
|
|
224
|
-
flex-direction: column;
|
|
225
|
-
gap: 12px;
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
div[comments-container] {
|
|
229
|
-
overflow-y: auto;
|
|
230
|
-
gap: 10px;
|
|
231
|
-
display: flex;
|
|
232
|
-
flex-direction: column;
|
|
233
|
-
flex: 1;
|
|
234
|
-
|
|
235
|
-
div[comment-row] {
|
|
236
|
-
display: flex;
|
|
237
|
-
flex-direction: column;
|
|
238
|
-
|
|
239
|
-
div[creator-container] {
|
|
240
|
-
display: flex;
|
|
241
|
-
justify-content: space-between;
|
|
242
|
-
|
|
243
|
-
span[creator] {
|
|
244
|
-
font-weight: 600;
|
|
245
|
-
display: flex;
|
|
246
|
-
align-items: center;
|
|
247
|
-
gap: 3px;
|
|
248
|
-
}
|
|
249
|
-
span[createdAt] {
|
|
250
|
-
display: flex;
|
|
251
|
-
align-items: center;
|
|
252
|
-
gap: 3px;
|
|
253
|
-
|
|
254
|
-
md-icon[delete] {
|
|
255
|
-
cursor: pointer;
|
|
256
|
-
}
|
|
257
|
-
}
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
div[comment] {
|
|
261
|
-
margin-left: 20px;
|
|
262
|
-
}
|
|
263
|
-
}
|
|
264
|
-
}
|
|
265
|
-
|
|
266
|
-
h3 {
|
|
267
|
-
position: relative;
|
|
268
|
-
color: rgb(5, 149, 229);
|
|
269
|
-
font-size: 17px;
|
|
270
|
-
font-weight: 700;
|
|
271
|
-
background-color: var(--md-sys-color-surface);
|
|
272
|
-
margin-top: 0px;
|
|
273
|
-
margin-bottom: 5px;
|
|
274
|
-
}
|
|
275
|
-
|
|
276
|
-
textarea {
|
|
277
|
-
height: 75px;
|
|
278
|
-
border: 1px solid #ccc;
|
|
279
|
-
}
|
|
280
|
-
|
|
281
|
-
div[button-container] {
|
|
282
|
-
display: flex;
|
|
283
|
-
justify-content: flex-end;
|
|
284
|
-
gap: 10px;
|
|
285
|
-
|
|
286
|
-
md-elevated-button[blue] {
|
|
287
|
-
--md-elevated-button-container-color: #0595e5;
|
|
288
|
-
|
|
289
|
-
--md-elevated-button-label-text-color: #fff;
|
|
290
|
-
--md-elevated-button-hover-label-text-color: #fff;
|
|
291
|
-
--md-elevated-button-pressed-label-text-color: #fff;
|
|
292
|
-
--md-elevated-button-focus-label-text-color: #fff;
|
|
293
|
-
--md-elevated-button-icon-color: #fff;
|
|
294
|
-
--md-elevated-button-hover-icon-color: #fff;
|
|
295
|
-
--md-elevated-button-pressed-icon-color: #fff;
|
|
296
|
-
--md-elevated-button-focus-icon-color: #fff;
|
|
297
|
-
}
|
|
298
|
-
}
|
|
299
|
-
`
|
|
300
|
-
];
|
|
301
|
-
__decorate([
|
|
302
|
-
property({ type: String }),
|
|
303
|
-
__metadata("design:type", String)
|
|
304
|
-
], CommentListPopup.prototype, "checklistItemId", void 0);
|
|
305
|
-
__decorate([
|
|
306
|
-
state(),
|
|
307
|
-
__metadata("design:type", Object)
|
|
308
|
-
], CommentListPopup.prototype, "item", void 0);
|
|
309
|
-
__decorate([
|
|
310
|
-
state(),
|
|
311
|
-
__metadata("design:type", Object)
|
|
312
|
-
], CommentListPopup.prototype, "checklistItemComments", void 0);
|
|
313
|
-
__decorate([
|
|
314
|
-
state(),
|
|
315
|
-
__metadata("design:type", String)
|
|
316
|
-
], CommentListPopup.prototype, "comment", void 0);
|
|
317
|
-
__decorate([
|
|
318
|
-
state(),
|
|
319
|
-
__metadata("design:type", Number)
|
|
320
|
-
], CommentListPopup.prototype, "checklistItemCommentCount", void 0);
|
|
321
|
-
__decorate([
|
|
322
|
-
state(),
|
|
323
|
-
__metadata("design:type", User)
|
|
324
|
-
], CommentListPopup.prototype, "user", void 0);
|
|
325
|
-
__decorate([
|
|
326
|
-
state(),
|
|
327
|
-
__metadata("design:type", Number)
|
|
328
|
-
], CommentListPopup.prototype, "page", void 0);
|
|
329
|
-
__decorate([
|
|
330
|
-
state(),
|
|
331
|
-
__metadata("design:type", Boolean)
|
|
332
|
-
], CommentListPopup.prototype, "loading", void 0);
|
|
333
|
-
__decorate([
|
|
334
|
-
state(),
|
|
335
|
-
__metadata("design:type", Boolean)
|
|
336
|
-
], CommentListPopup.prototype, "hasMoreComments", void 0);
|
|
337
|
-
__decorate([
|
|
338
|
-
query('div[comments-container]'),
|
|
339
|
-
__metadata("design:type", HTMLDivElement)
|
|
340
|
-
], CommentListPopup.prototype, "commentsContainer", void 0);
|
|
341
|
-
CommentListPopup = __decorate([
|
|
342
|
-
customElement('comment-list-popup')
|
|
343
|
-
], CommentListPopup);
|
|
344
|
-
//# sourceMappingURL=comment-list-popup%20copy.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"comment-list-popup copy.js","sourceRoot":"","sources":["../../../client/pages/checklist/comment-list-popup copy.ts"],"names":[],"mappings":";AAAA,OAAO,4BAA4B,CAAA;AACnC,OAAO,GAAG,MAAM,aAAa,CAAA;AAC7B,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAA;AACzC,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,KAAK,CAAA;AAC3C,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AACzE,OAAO,EAAE,qBAAqB,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AACxE,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAA;AACxC,OAAO,EAAE,KAA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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAsFF;CACF,CAAA;AAED;IAAC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;yDAA6B;AAExD;IAAC,KAAK,EAAE;;8CAAyB;AACjC;IAAC,KAAK,EAAE;;+DAAgC;AACxC;IAAC,KAAK,EAAE;;iDAAqB;AAC7B;IAAC,KAAK,EAAE;;mEAAsC;AAC9C;IAAC,KAAK,EAAE;8BAAO,IAAI;8CAAK;AACxB;IAAC,KAAK,EAAE;;8CAAiB;AACzB;IAAC,KAAK,EAAE;;iDAAyB;AACjC;IAAC,KAAK,EAAE;;yDAAgC;AAExC;IAAC,KAAK,CAAC,yBAAyB,CAAC;8BAAqB,cAAc;2DAAA;AAxGhE,gBAAgB;IADrB,aAAa,CAAC,oBAAoB,CAAC;GAC9B,gBAAgB,CAiTrB","sourcesContent":["import '@material/web/icon/icon.js'\nimport gql from 'graphql-tag'\nimport { client } from '@operato/graphql'\nimport { css, html, LitElement } from 'lit'\nimport { customElement, property, query, state } from 'lit/decorators.js'\nimport { ButtonContainerStyles, ScrollbarStyles } from '@operato/styles'\nimport { notify } from '@operato/layout'\nimport { store, User } from '@operato/shell'\nimport { connect } from 'pwa-helpers/connect-mixin.js'\nimport { OxPrompt } from '@operato/popup/ox-prompt.js'\nimport './checklist-view'\n\n@customElement('comment-list-popup')\nclass CommentListPopup extends connect(store)(LitElement) {\n static styles = [\n ButtonContainerStyles,\n ScrollbarStyles,\n css`\n :host {\n display: flex;\n flex-direction: column;\n padding: 15px 20px;\n background-color: var(--md-sys-color-surface);\n }\n\n div[body] {\n height: 100%;\n display: flex;\n flex-direction: column;\n gap: 12px;\n }\n\n div[comments-container] {\n overflow-y: auto;\n gap: 10px;\n display: flex;\n flex-direction: column;\n flex: 1;\n\n div[comment-row] {\n display: flex;\n flex-direction: column;\n\n div[creator-container] {\n display: flex;\n justify-content: space-between;\n\n span[creator] {\n font-weight: 600;\n display: flex;\n align-items: center;\n gap: 3px;\n }\n span[createdAt] {\n display: flex;\n align-items: center;\n gap: 3px;\n\n md-icon[delete] {\n cursor: pointer;\n }\n }\n }\n\n div[comment] {\n margin-left: 20px;\n }\n }\n }\n\n h3 {\n position: relative;\n color: rgb(5, 149, 229);\n font-size: 17px;\n font-weight: 700;\n background-color: var(--md-sys-color-surface);\n margin-top: 0px;\n margin-bottom: 5px;\n }\n\n textarea {\n height: 75px;\n border: 1px solid #ccc;\n }\n\n div[button-container] {\n display: flex;\n justify-content: flex-end;\n gap: 10px;\n\n md-elevated-button[blue] {\n --md-elevated-button-container-color: #0595e5;\n\n --md-elevated-button-label-text-color: #fff;\n --md-elevated-button-hover-label-text-color: #fff;\n --md-elevated-button-pressed-label-text-color: #fff;\n --md-elevated-button-focus-label-text-color: #fff;\n --md-elevated-button-icon-color: #fff;\n --md-elevated-button-hover-icon-color: #fff;\n --md-elevated-button-pressed-icon-color: #fff;\n --md-elevated-button-focus-icon-color: #fff;\n }\n }\n `\n ]\n\n @property({ type: String }) checklistItemId: string = ''\n\n @state() item: any = { count: 0 }\n @state() checklistItemComments: any = []\n @state() comment: string = ''\n @state() checklistItemCommentCount: number = 0\n @state() user: User = {}\n @state() page: number = 1\n @state() loading: boolean = false\n @state() hasMoreComments: boolean = true\n\n @query('div[comments-container]') commentsContainer!: HTMLDivElement\n\n render() {\n return html`\n <div body>\n <h3>제품검사에 대한 확인: ${this.checklistItemCommentCount || 0}건</h3>\n\n <div comments-container @scroll=${this._onScroll}>\n ${this.checklistItemComments.map(comment => {\n return html`\n <div comment-row>\n <div creator-container>\n <span creator><md-icon slot=\"icon\">account_circle</md-icon> ${comment.creator.name}</span>\n <span createdAt>\n <md-icon slot=\"icon\">schedule</md-icon> ${this._formatDate(comment.createdAt)}\n ${comment.creator.email === this.user.email\n ? html` <md-icon delete slot=\"icon\" @click=${() => this._deleteComment(comment.id)}>delete</md-icon>`\n : ''}\n </span>\n </div>\n <div comment>${comment.comment}</div>\n </div>\n `\n })}\n </div>\n\n <textarea .value=${this.comment || ''} @input=${this._onInputChange}></textarea>\n\n <div button-container>\n <md-elevated-button blue @click=${this._createComment}> <md-icon slot=\"icon\">task</md-icon>저장 </md-elevated-button>\n <md-elevated-button @click=${this._close}> <md-icon slot=\"icon\">cancel</md-icon>취소 </md-elevated-button>\n </div>\n </div>\n `\n }\n\n async firstUpdated() {\n this.user = (store.getState() as any).auth?.user\n this.comment = ''\n this.page = 1\n await this._loadComments()\n this._scrollBottom()\n }\n\n private async _loadComments() {\n if (this.loading || !this.hasMoreComments) return\n\n this.loading = true\n\n const response = await client.query({\n query: gql`\n query ChecklistItemComments($pagination: Pagination!, $checklistItemId: String!) {\n checklistItemComments(pagination: $pagination, checklistItemId: $checklistItemId) {\n id\n comment\n creator {\n id\n email\n }\n createdAt\n }\n\n checklistItem(id: $checklistItemId) {\n id\n checklistItemCommentCount\n }\n }\n `,\n variables: {\n checklistItemId: this.checklistItemId,\n pagination: {\n page: this.page,\n limit: 10\n }\n }\n })\n\n if (response.errors) return\n\n const items = response.data.checklistItemComments\n if (items.length < 10) this.hasMoreComments = false\n\n this.checklistItemComments = [...items.reverse(), ...this.checklistItemComments]\n this.page += 1\n this.checklistItemCommentCount = response.data.checklistItem.checklistItemCommentCount\n this.loading = false\n }\n\n // 스크롤이 맨 위에 가까울 때 데이터 요청\n private _onScroll() {\n const { scrollTop } = this.commentsContainer\n if (scrollTop <= 5) {\n this._loadComments()\n }\n }\n\n private async _createComment() {\n if (!this.comment) {\n notify({ message: '조치사항을 입력해주세요.', level: 'warn' })\n return\n }\n\n const response = await client.mutate({\n mutation: gql`\n mutation CreateChecklistItemComment($checklistItemComment: NewChecklistItemComment!) {\n createChecklistItemComment(checklistItemComment: $checklistItemComment) {\n id\n comment\n creator {\n id\n email\n }\n createdAt\n }\n }\n `,\n variables: {\n checklistItemComment: {\n comment: this.comment,\n checklistItemId: this.checklistItemId\n }\n }\n })\n\n if (!response.errors) {\n this.comment = ''\n this.checklistItemComments = [...this.checklistItemComments, { ...response.data.createChecklistItemComment }]\n this._scrollBottom()\n this.checklistItemCommentCount++\n } else {\n notify({ message: response.errors?.[0]?.message || '조치사항 등록에 실패하였습니다.', level: 'error' })\n }\n\n this._dispatchEvent()\n }\n\n private async _deleteComment(commentId: string) {\n if (\n await OxPrompt.open({\n title: '조치 사항을 삭제',\n text: '조치 사항을 삭제 하시겠습니까?',\n confirmButton: { text: '삭제' },\n cancelButton: { text: '취소' }\n })\n ) {\n const response = await client.mutate({\n mutation: gql`\n mutation DeleteChecklistItemComment($id: String!) {\n deleteChecklistItemComment(id: $id)\n }\n `,\n variables: {\n id: commentId\n }\n })\n\n if (!response.errors) {\n this.checklistItemComments = [...this.checklistItemComments.filter(comment => comment.id != commentId)]\n notify({ message: '조치사항을 삭제하였습니다.', level: 'info' })\n } else {\n notify({ message: response.errors?.[0]?.message || '조치사항 삭제에 실패하였습니다.', level: 'error' })\n }\n\n this._dispatchEvent()\n }\n }\n\n private _close() {\n history.back()\n }\n\n // Input 요소의 값이 변경될 때 호출되는 콜백 함수\n private _onInputChange(event: InputEvent) {\n const target = event.target as HTMLInputElement\n this.comment = target.value\n }\n\n private _formatDate(date) {\n const _date = new Date(date.toLocaleString('en-US', { timeZone: 'Asia/Seoul' }))\n\n const year = _date.getFullYear()\n const month = String(_date.getMonth() + 1).padStart(2, '0')\n const day = String(_date.getDate()).padStart(2, '0')\n const hours = String(_date.getHours()).padStart(2, '0')\n const minutes = String(_date.getMinutes()).padStart(2, '0')\n const seconds = String(_date.getSeconds()).padStart(2, '0')\n\n return `${year}.${month}.${day} ${hours}:${minutes}:${seconds}`\n }\n\n // 댓글 스크롤 맨 밑으로\n private async _scrollBottom() {\n setTimeout(() => {\n this.commentsContainer.scrollTop = this.commentsContainer.scrollHeight\n }, 100)\n }\n\n // 조치사항 변경 이벤트 디스패치\n _dispatchEvent() {\n this.dispatchEvent(new CustomEvent('change-comment', { detail: { checklistItemId: this.checklistItemId } }))\n }\n}\n"]}
|