@dssp/supervision 0.0.34 → 0.0.35
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/client/pages/checklist/attachment-list-popup.ts +2 -2
- package/dist-client/pages/checklist/attachment-list-popup.js +2 -2
- package/dist-client/pages/checklist/attachment-list-popup.js.map +1 -1
- package/dist-client/tsconfig.tsbuildinfo +1 -1
- package/dist-server/service/checklist-item/checklist-item-query.js +0 -2
- package/dist-server/service/checklist-item/checklist-item-query.js.map +1 -1
- package/dist-server/tsconfig.tsbuildinfo +1 -1
- package/package.json +5 -5
- package/server/service/checklist-item/checklist-item-query.ts +2 -6
|
@@ -108,7 +108,7 @@ class AttachmentListPopup extends connect(store)(LitElement) {
|
|
|
108
108
|
<h3>제품검사에 대한 파일: ${this.checklistItemAttachmentCount || 0}건</h3>
|
|
109
109
|
|
|
110
110
|
<div attachment-container>
|
|
111
|
-
${this.checklistItemAttachments.
|
|
111
|
+
${this.checklistItemAttachments.map(attachment => {
|
|
112
112
|
return html`
|
|
113
113
|
<div attachment-row>
|
|
114
114
|
<div creator-container>
|
|
@@ -251,7 +251,7 @@ class AttachmentListPopup extends connect(store)(LitElement) {
|
|
|
251
251
|
|
|
252
252
|
const attachments = response.data.createAttachments
|
|
253
253
|
|
|
254
|
-
this.checklistItemAttachments = [...this.checklistItemAttachments
|
|
254
|
+
this.checklistItemAttachments = [...attachments, ...this.checklistItemAttachments]
|
|
255
255
|
this.checklistItemAttachmentCount = this.checklistItemAttachmentCount + attachments.length
|
|
256
256
|
}
|
|
257
257
|
|
|
@@ -26,7 +26,7 @@ let AttachmentListPopup = class AttachmentListPopup extends connect(store)(LitEl
|
|
|
26
26
|
<h3>제품검사에 대한 파일: ${this.checklistItemAttachmentCount || 0}건</h3>
|
|
27
27
|
|
|
28
28
|
<div attachment-container>
|
|
29
|
-
${this.checklistItemAttachments.
|
|
29
|
+
${this.checklistItemAttachments.map(attachment => {
|
|
30
30
|
return html `
|
|
31
31
|
<div attachment-row>
|
|
32
32
|
<div creator-container>
|
|
@@ -155,7 +155,7 @@ let AttachmentListPopup = class AttachmentListPopup extends connect(store)(LitEl
|
|
|
155
155
|
}
|
|
156
156
|
});
|
|
157
157
|
const attachments = response.data.createAttachments;
|
|
158
|
-
this.checklistItemAttachments = [...this.checklistItemAttachments
|
|
158
|
+
this.checklistItemAttachments = [...attachments, ...this.checklistItemAttachments];
|
|
159
159
|
this.checklistItemAttachmentCount = this.checklistItemAttachmentCount + attachments.length;
|
|
160
160
|
}
|
|
161
161
|
_formatDate(date) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"attachment-list-popup.js","sourceRoot":"","sources":["../../../client/pages/checklist/attachment-list-popup.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,KAAK,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAA;AAC5C,OAAO,EAAE,OAAO,EAAE,MAAM,8BAA8B,CAAA;AACtD,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAA;AACtD,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AAC3C,OAAO,sBAAsB,CAAA;AAG7B,IAAM,mBAAmB,GAAzB,MAAM,mBAAoB,SAAQ,OAAO,CAAC,KAAK,CAAC,CAAC,UAAU,CAAC;IAA5D;;QAkF8B,oBAAe,G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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KA2EF;CACF,CAAA;AAED;IAAC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;4DAA6B;AAExD;IAAC,KAAK,EAAE;;iDAAyB;AACjC;IAAC,KAAK,EAAE;;qEAAmC;AAC3C;IAAC,KAAK,EAAE;;yEAAyC;AACjD;IAAC,KAAK,EAAE;8BAAO,IAAI;iDAAK;AACxB;IAAC,KAAK,CAAC,2BAA2B,CAAC;8BAAuB,cAAc;gEAAA;AAxFpE,mBAAmB;IADxB,aAAa,CAAC,uBAAuB,CAAC;GACjC,mBAAmB,CA4QxB","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 { openPopup } from '@operato/layout'\nimport './file-preview-popup'\n\n@customElement('attachment-list-popup')\nclass AttachmentListPopup 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[attachment-container] {\n overflow-y: auto;\n gap: 10px;\n display: flex;\n flex-direction: column;\n flex: 1;\n\n div[attachment-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 a[button-download] {\n display: flex;\n color: #000;\n }\n }\n }\n\n a[attachment] {\n margin-left: 20px;\n text-decoration: none;\n color: #000;\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 div[button-container] {\n display: flex;\n justify-content: flex-end;\n gap: 10px;\n }\n `\n ]\n\n @property({ type: String }) checklistItemId: string = ''\n\n @state() item: any = { count: 0 }\n @state() checklistItemAttachments: any = []\n @state() checklistItemAttachmentCount: number = 0\n @state() user: User = {}\n @query('div[attachment-container]') attachmentContainer!: HTMLDivElement\n\n render() {\n return html`\n <div body>\n <h3>제품검사에 대한 파일: ${this.checklistItemAttachmentCount || 0}건</h3>\n\n <div attachment-container>\n ${this.checklistItemAttachments.reverse().map(attachment => {\n return html`\n <div attachment-row>\n <div creator-container>\n <span creator><md-icon slot=\"icon\">account_circle</md-icon> ${attachment.creator.name}</span>\n <span createdAt>\n <md-icon slot=\"icon\">schedule</md-icon> ${this._formatDate(attachment.createdAt)}\n ${attachment.creator.email === this.user.email\n ? html` <md-icon delete slot=\"icon\" @click=${() => this._deleteAttachment(attachment.id)}>delete</md-icon>`\n : ''}\n <a button-download href=${attachment.fullpath} download=${attachment.name}>\n <md-icon slot=\"icon\">download</md-icon></a\n >\n </span>\n </div>\n <a attachment @click=${() => this._onClickPreview(attachment.fullpath)}>${attachment.name}</a>\n </div>\n `\n })}\n </div>\n\n <ox-input-file accept=\"*/*\" multiple=\"true\" hide-filelist @change=${this.onCreateAttachment.bind(this)}></ox-input-file>\n\n <div button-container>\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\n await this._loadAttachments()\n }\n\n private async _loadAttachments() {\n const response = await client.query({\n query: gql`\n query ChecklistItem($id: String!) {\n checklistItem(id: $id) {\n id\n checklistItemAttachmentCount\n checklistItemAttachments {\n id\n name\n fullpath\n creator {\n id\n name\n email\n }\n createdAt\n }\n }\n }\n `,\n variables: {\n id: this.checklistItemId\n }\n })\n\n if (response.errors) return\n\n this.checklistItemAttachments = response.data.checklistItem.checklistItemAttachments || []\n this.checklistItemAttachmentCount = response.data.checklistItem.checklistItemAttachmentCount\n }\n\n private async _deleteAttachment(attachmentId: 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 DeleteAttachment($deleteAttachmentId: String!) {\n deleteAttachment(id: $deleteAttachmentId)\n }\n `,\n variables: {\n deleteAttachmentId: attachmentId\n }\n })\n\n if (!response.errors) {\n this.checklistItemAttachments = [...this.checklistItemAttachments.filter(attachment => attachment.id != attachmentId)]\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 // 파일 변경 시 파일을 저장할 핸들러\n private async onCreateAttachment(e: CustomEvent) {\n const files = e.detail\n\n await this._createAttachments(files)\n\n this._dispatchEvent()\n }\n\n async _createAttachments(files: File[]) {\n const checklistItemId = this.checklistItemId\n\n const response = await client.mutate({\n mutation: gql`\n mutation ($attachments: [NewAttachment!]!) {\n createAttachments(attachments: $attachments) {\n id\n name\n fullpath\n creator {\n id\n name\n email\n }\n createdAt\n }\n }\n `,\n variables: {\n attachments: files.map(file => {\n return { file, refBy: checklistItemId, refType: 'ChecklistItem' }\n })\n },\n context: {\n hasUpload: true\n }\n })\n\n const attachments = response.data.createAttachments\n\n this.checklistItemAttachments = [...this.checklistItemAttachments, ...attachments]\n this.checklistItemAttachmentCount = this.checklistItemAttachmentCount + attachments.length\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 _dispatchEvent() {\n this.dispatchEvent(new CustomEvent('change-attachment', { detail: { checklistItemId: this.checklistItemId } }))\n }\n\n private _onClickPreview(filepath: string) {\n openPopup(html` <file-preview-popup .filepath=${filepath}></file-preview-popup> `, {\n backdrop: true,\n size: 'large',\n title: '미리보기'\n })\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"attachment-list-popup.js","sourceRoot":"","sources":["../../../client/pages/checklist/attachment-list-popup.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,KAAK,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAA;AAC5C,OAAO,EAAE,OAAO,EAAE,MAAM,8BAA8B,CAAA;AACtD,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAA;AACtD,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AAC3C,OAAO,sBAA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M,0BAAM,GAAG;IACd,qBAAqB;IACrB,eAAe;IACf,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KA2EF;CACF,CAAA;AAED;IAAC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;4DAA6B;AAExD;IAAC,KAAK,EAAE;;iDAAyB;AACjC;IAAC,KAAK,EAAE;;qEAAmC;AAC3C;IAAC,KAAK,EAAE;;yEAAyC;AACjD;IAAC,KAAK,EAAE;8BAAO,IAAI;iDAAK;AACxB;IAAC,KAAK,CAAC,2BAA2B,CAAC;8BAAuB,cAAc;gEAAA;AAxFpE,mBAAmB;IADxB,aAAa,CAAC,uBAAuB,CAAC;GACjC,mBAAmB,CA4QxB","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 { openPopup } from '@operato/layout'\nimport './file-preview-popup'\n\n@customElement('attachment-list-popup')\nclass AttachmentListPopup 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[attachment-container] {\n overflow-y: auto;\n gap: 10px;\n display: flex;\n flex-direction: column;\n flex: 1;\n\n div[attachment-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 a[button-download] {\n display: flex;\n color: #000;\n }\n }\n }\n\n a[attachment] {\n margin-left: 20px;\n text-decoration: none;\n color: #000;\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 div[button-container] {\n display: flex;\n justify-content: flex-end;\n gap: 10px;\n }\n `\n ]\n\n @property({ type: String }) checklistItemId: string = ''\n\n @state() item: any = { count: 0 }\n @state() checklistItemAttachments: any = []\n @state() checklistItemAttachmentCount: number = 0\n @state() user: User = {}\n @query('div[attachment-container]') attachmentContainer!: HTMLDivElement\n\n render() {\n return html`\n <div body>\n <h3>제품검사에 대한 파일: ${this.checklistItemAttachmentCount || 0}건</h3>\n\n <div attachment-container>\n ${this.checklistItemAttachments.map(attachment => {\n return html`\n <div attachment-row>\n <div creator-container>\n <span creator><md-icon slot=\"icon\">account_circle</md-icon> ${attachment.creator.name}</span>\n <span createdAt>\n <md-icon slot=\"icon\">schedule</md-icon> ${this._formatDate(attachment.createdAt)}\n ${attachment.creator.email === this.user.email\n ? html` <md-icon delete slot=\"icon\" @click=${() => this._deleteAttachment(attachment.id)}>delete</md-icon>`\n : ''}\n <a button-download href=${attachment.fullpath} download=${attachment.name}>\n <md-icon slot=\"icon\">download</md-icon></a\n >\n </span>\n </div>\n <a attachment @click=${() => this._onClickPreview(attachment.fullpath)}>${attachment.name}</a>\n </div>\n `\n })}\n </div>\n\n <ox-input-file accept=\"*/*\" multiple=\"true\" hide-filelist @change=${this.onCreateAttachment.bind(this)}></ox-input-file>\n\n <div button-container>\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\n await this._loadAttachments()\n }\n\n private async _loadAttachments() {\n const response = await client.query({\n query: gql`\n query ChecklistItem($id: String!) {\n checklistItem(id: $id) {\n id\n checklistItemAttachmentCount\n checklistItemAttachments {\n id\n name\n fullpath\n creator {\n id\n name\n email\n }\n createdAt\n }\n }\n }\n `,\n variables: {\n id: this.checklistItemId\n }\n })\n\n if (response.errors) return\n\n this.checklistItemAttachments = response.data.checklistItem.checklistItemAttachments || []\n this.checklistItemAttachmentCount = response.data.checklistItem.checklistItemAttachmentCount\n }\n\n private async _deleteAttachment(attachmentId: 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 DeleteAttachment($deleteAttachmentId: String!) {\n deleteAttachment(id: $deleteAttachmentId)\n }\n `,\n variables: {\n deleteAttachmentId: attachmentId\n }\n })\n\n if (!response.errors) {\n this.checklistItemAttachments = [...this.checklistItemAttachments.filter(attachment => attachment.id != attachmentId)]\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 // 파일 변경 시 파일을 저장할 핸들러\n private async onCreateAttachment(e: CustomEvent) {\n const files = e.detail\n\n await this._createAttachments(files)\n\n this._dispatchEvent()\n }\n\n async _createAttachments(files: File[]) {\n const checklistItemId = this.checklistItemId\n\n const response = await client.mutate({\n mutation: gql`\n mutation ($attachments: [NewAttachment!]!) {\n createAttachments(attachments: $attachments) {\n id\n name\n fullpath\n creator {\n id\n name\n email\n }\n createdAt\n }\n }\n `,\n variables: {\n attachments: files.map(file => {\n return { file, refBy: checklistItemId, refType: 'ChecklistItem' }\n })\n },\n context: {\n hasUpload: true\n }\n })\n\n const attachments = response.data.createAttachments\n\n this.checklistItemAttachments = [...attachments, ...this.checklistItemAttachments]\n this.checklistItemAttachmentCount = this.checklistItemAttachmentCount + attachments.length\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 _dispatchEvent() {\n this.dispatchEvent(new CustomEvent('change-attachment', { detail: { checklistItemId: this.checklistItemId } }))\n }\n\n private _onClickPreview(filepath: string) {\n openPopup(html` <file-preview-popup .filepath=${filepath}></file-preview-popup> `, {\n backdrop: true,\n size: 'large',\n title: '미리보기'\n })\n }\n}\n"]}
|