@dssp/dkpi 1.0.0-alpha.8 → 1.0.0-alpha.81

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 (252) hide show
  1. package/KPI-STATISTICS-SERVICE.md +233 -0
  2. package/_index.html +0 -5
  3. package/assets/favicon.ico +0 -0
  4. package/assets/images/project-image.png +0 -0
  5. package/assets/manifest/apple-1024.png +0 -0
  6. package/assets/manifest/apple-120.png +0 -0
  7. package/assets/manifest/apple-152.png +0 -0
  8. package/assets/manifest/apple-167.png +0 -0
  9. package/assets/manifest/apple-180.png +0 -0
  10. package/assets/manifest/apple-touch-icon.png +0 -0
  11. package/assets/manifest/badge-128x128.png +0 -0
  12. package/assets/manifest/chrome-splashscreen-icon-384x384.png +0 -0
  13. package/assets/manifest/chrome-touch-icon-192x192.png +0 -0
  14. package/assets/manifest/icon-128x128.png +0 -0
  15. package/assets/manifest/icon-192x192.png +0 -0
  16. package/assets/manifest/icon-512x512.png +0 -0
  17. package/assets/manifest/icon-72x72.png +0 -0
  18. package/assets/manifest/icon-96x96.png +0 -0
  19. package/assets/manifest/image-metaog.png +0 -0
  20. package/assets/manifest/maskable_icon.png +0 -0
  21. package/assets/manifest/ms-icon-144x144.png +0 -0
  22. package/assets/manifest/ms-touch-icon-144x144-precomposed.png +0 -0
  23. package/assets/videos/intro.mp4 +0 -0
  24. package/config/config.development.js +2 -1
  25. package/config/config.production.js +2 -1
  26. package/dist-client/bootstrap.d.ts +1 -0
  27. package/dist-client/bootstrap.js +75 -4
  28. package/dist-client/bootstrap.js.map +1 -1
  29. package/dist-client/components/kpi-2d-lookup-chart.d.ts +43 -0
  30. package/dist-client/components/kpi-2d-lookup-chart.js +253 -0
  31. package/dist-client/components/kpi-2d-lookup-chart.js.map +1 -0
  32. package/dist-client/components/kpi-boxplot-chart.d.ts +24 -0
  33. package/dist-client/components/kpi-boxplot-chart.js +291 -0
  34. package/dist-client/components/kpi-boxplot-chart.js.map +1 -0
  35. package/dist-client/components/kpi-lookup-chart.d.ts +53 -0
  36. package/dist-client/components/kpi-lookup-chart.js +430 -0
  37. package/dist-client/components/kpi-lookup-chart.js.map +1 -0
  38. package/dist-client/components/kpi-mini-trend-chart.d.ts +14 -0
  39. package/dist-client/components/kpi-mini-trend-chart.js +148 -0
  40. package/dist-client/components/kpi-mini-trend-chart.js.map +1 -0
  41. package/dist-client/components/kpi-radar-chart.d.ts +17 -0
  42. package/dist-client/components/kpi-radar-chart.js +259 -0
  43. package/dist-client/components/kpi-radar-chart.js.map +1 -0
  44. package/dist-client/components/kpi-single-boxplot-chart.d.ts +25 -0
  45. package/dist-client/components/kpi-single-boxplot-chart.js +398 -0
  46. package/dist-client/components/kpi-single-boxplot-chart.js.map +1 -0
  47. package/dist-client/components/kpi-trend-chart.d.ts +25 -0
  48. package/dist-client/components/kpi-trend-chart.js +220 -0
  49. package/dist-client/components/kpi-trend-chart.js.map +1 -0
  50. package/dist-client/components/sv-pagenation-control.d.ts +18 -0
  51. package/dist-client/components/sv-pagenation-control.js +142 -0
  52. package/dist-client/components/sv-pagenation-control.js.map +1 -0
  53. package/dist-client/entries/auth/checkin.d.ts +38 -0
  54. package/dist-client/entries/auth/checkin.js +546 -0
  55. package/dist-client/entries/auth/checkin.js.map +1 -0
  56. package/dist-client/google-map/common-google-map.d.ts +35 -0
  57. package/dist-client/google-map/common-google-map.js +345 -0
  58. package/dist-client/google-map/common-google-map.js.map +1 -0
  59. package/dist-client/google-map/google-map-loader.d.ts +6 -0
  60. package/dist-client/google-map/google-map-loader.js +23 -0
  61. package/dist-client/google-map/google-map-loader.js.map +1 -0
  62. package/dist-client/icons/menu-icons.d.ts +6 -0
  63. package/dist-client/icons/menu-icons.js +42 -0
  64. package/dist-client/icons/menu-icons.js.map +1 -1
  65. package/dist-client/pages/component/project-update-header.d.ts +1 -0
  66. package/dist-client/pages/component/project-update-header.js +127 -0
  67. package/dist-client/pages/component/project-update-header.js.map +1 -0
  68. package/dist-client/pages/kpi-admin/dssp-kpi-list-page.d.ts +22 -0
  69. package/dist-client/pages/kpi-admin/dssp-kpi-list-page.js +57 -0
  70. package/dist-client/pages/kpi-admin/dssp-kpi-list-page.js.map +1 -0
  71. package/dist-client/pages/kpi-admin/dssp-kpi-overview.d.ts +46 -0
  72. package/dist-client/pages/kpi-admin/dssp-kpi-overview.js +378 -0
  73. package/dist-client/pages/kpi-admin/dssp-kpi-overview.js.map +1 -0
  74. package/dist-client/pages/kpi-admin/kpi-grade-2d-editor.d.ts +20 -0
  75. package/dist-client/pages/kpi-admin/kpi-grade-2d-editor.js +445 -0
  76. package/dist-client/pages/kpi-admin/kpi-grade-2d-editor.js.map +1 -0
  77. package/dist-client/pages/kpi-admin/kpi-system-guide.d.ts +18 -0
  78. package/dist-client/pages/kpi-admin/kpi-system-guide.js +535 -0
  79. package/dist-client/pages/kpi-admin/kpi-system-guide.js.map +1 -0
  80. package/dist-client/pages/kpi-dashboard/cards/kpi-level1-card.d.ts +18 -0
  81. package/dist-client/pages/kpi-dashboard/cards/kpi-level1-card.js +259 -0
  82. package/dist-client/pages/kpi-dashboard/cards/kpi-level1-card.js.map +1 -0
  83. package/dist-client/pages/kpi-dashboard/cards/kpi-level2-comparison.d.ts +22 -0
  84. package/dist-client/pages/kpi-dashboard/cards/kpi-level2-comparison.js +346 -0
  85. package/dist-client/pages/kpi-dashboard/cards/kpi-level2-comparison.js.map +1 -0
  86. package/dist-client/pages/kpi-dashboard/cards/kpi-level3-comparison.d.ts +26 -0
  87. package/dist-client/pages/kpi-dashboard/cards/kpi-level3-comparison.js +433 -0
  88. package/dist-client/pages/kpi-dashboard/cards/kpi-level3-comparison.js.map +1 -0
  89. package/dist-client/pages/kpi-dashboard/components/kpi-chart-toggle.d.ts +8 -0
  90. package/dist-client/pages/kpi-dashboard/components/kpi-chart-toggle.js +78 -0
  91. package/dist-client/pages/kpi-dashboard/components/kpi-chart-toggle.js.map +1 -0
  92. package/dist-client/pages/kpi-dashboard/components/kpi-left-panel.d.ts +38 -0
  93. package/dist-client/pages/kpi-dashboard/components/kpi-left-panel.js +851 -0
  94. package/dist-client/pages/kpi-dashboard/components/kpi-left-panel.js.map +1 -0
  95. package/dist-client/pages/kpi-dashboard/components/kpi-map-panel.d.ts +42 -0
  96. package/dist-client/pages/kpi-dashboard/components/kpi-map-panel.js +316 -0
  97. package/dist-client/pages/kpi-dashboard/components/kpi-map-panel.js.map +1 -0
  98. package/dist-client/pages/kpi-dashboard/components/kpi-region-popup.d.ts +28 -0
  99. package/dist-client/pages/kpi-dashboard/components/kpi-region-popup.js +497 -0
  100. package/dist-client/pages/kpi-dashboard/components/kpi-region-popup.js.map +1 -0
  101. package/dist-client/pages/kpi-dashboard/kpi-alert-panel.d.ts +18 -0
  102. package/dist-client/pages/kpi-dashboard/kpi-alert-panel.js +131 -0
  103. package/dist-client/pages/kpi-dashboard/kpi-alert-panel.js.map +1 -0
  104. package/dist-client/pages/kpi-dashboard/kpi-dashboard-map.d.ts +52 -0
  105. package/dist-client/pages/kpi-dashboard/kpi-dashboard-map.js +798 -0
  106. package/dist-client/pages/kpi-dashboard/kpi-dashboard-map.js.map +1 -0
  107. package/dist-client/pages/kpi-dashboard/kpi-dashboard.d.ts +63 -0
  108. package/dist-client/pages/kpi-dashboard/kpi-dashboard.js +1089 -0
  109. package/dist-client/pages/kpi-dashboard/kpi-dashboard.js.map +1 -0
  110. package/dist-client/pages/kpi-dashboard/kpi-grade-visualization.d.ts +12 -0
  111. package/dist-client/pages/kpi-dashboard/kpi-grade-visualization.js +82 -0
  112. package/dist-client/pages/kpi-dashboard/kpi-grade-visualization.js.map +1 -0
  113. package/dist-client/pages/kpi-dashboard/kpi-history-viewer.d.ts +11 -0
  114. package/dist-client/pages/kpi-dashboard/kpi-history-viewer.js +65 -0
  115. package/dist-client/pages/kpi-dashboard/kpi-history-viewer.js.map +1 -0
  116. package/dist-client/pages/kpi-dashboard/kpi-list-summary.d.ts +13 -0
  117. package/dist-client/pages/kpi-dashboard/kpi-list-summary.js +115 -0
  118. package/dist-client/pages/kpi-dashboard/kpi-list-summary.js.map +1 -0
  119. package/dist-client/pages/kpi-dashboard/kpi-performance-summary.d.ts +15 -0
  120. package/dist-client/pages/kpi-dashboard/kpi-performance-summary.js +147 -0
  121. package/dist-client/pages/kpi-dashboard/kpi-performance-summary.js.map +1 -0
  122. package/dist-client/pages/kpi-dashboard/kpi-value-entry.d.ts +7 -0
  123. package/dist-client/pages/kpi-dashboard/kpi-value-entry.js +86 -0
  124. package/dist-client/pages/kpi-dashboard/kpi-value-entry.js.map +1 -0
  125. package/dist-client/pages/kpi-metric-value/kpi-metric-value-editor-page.d.ts +57 -0
  126. package/dist-client/pages/kpi-metric-value/kpi-metric-value-editor-page.js +719 -0
  127. package/dist-client/pages/kpi-metric-value/kpi-metric-value-editor-page.js.map +1 -0
  128. package/dist-client/pages/kpi-metric-value/kpi-metric-value-importer.d.ts +23 -0
  129. package/dist-client/pages/kpi-metric-value/kpi-metric-value-importer.js +76 -0
  130. package/dist-client/pages/kpi-metric-value/kpi-metric-value-importer.js.map +1 -0
  131. package/dist-client/pages/kpi-metric-value/kpi-metric-value-list-page.d.ts +68 -0
  132. package/dist-client/pages/kpi-metric-value/kpi-metric-value-list-page.js +394 -0
  133. package/dist-client/pages/kpi-metric-value/kpi-metric-value-list-page.js.map +1 -0
  134. package/dist-client/pages/kpi-metric-value/kpi-metric-value-manual-entry-form.d.ts +12 -0
  135. package/dist-client/pages/kpi-metric-value/kpi-metric-value-manual-entry-form.js +174 -0
  136. package/dist-client/pages/kpi-metric-value/kpi-metric-value-manual-entry-form.js.map +1 -0
  137. package/dist-client/pages/kpi-metric-value/kpi-metric-value-manual-entry-page.d.ts +40 -0
  138. package/dist-client/pages/kpi-metric-value/kpi-metric-value-manual-entry-page.js +190 -0
  139. package/dist-client/pages/kpi-metric-value/kpi-metric-value-manual-entry-page.js.map +1 -0
  140. package/dist-client/pages/kpi-value/kpi-value-importer.d.ts +23 -0
  141. package/dist-client/pages/kpi-value/kpi-value-importer.js +93 -0
  142. package/dist-client/pages/kpi-value/kpi-value-importer.js.map +1 -0
  143. package/dist-client/pages/kpi-value/kpi-value-list-page.d.ts +71 -0
  144. package/dist-client/pages/kpi-value/kpi-value-list-page.js +454 -0
  145. package/dist-client/pages/kpi-value/kpi-value-list-page.js.map +1 -0
  146. package/dist-client/pages/project-complete-tabs/pc-tab1-plan.d.ts +61 -0
  147. package/dist-client/pages/project-complete-tabs/pc-tab1-plan.js +766 -0
  148. package/dist-client/pages/project-complete-tabs/pc-tab1-plan.js.map +1 -0
  149. package/dist-client/pages/project-complete-tabs/pc-tab2-rating.d.ts +16 -0
  150. package/dist-client/pages/project-complete-tabs/pc-tab2-rating.js +341 -0
  151. package/dist-client/pages/project-complete-tabs/pc-tab2-rating.js.map +1 -0
  152. package/dist-client/pages/project-complete-tabs/pc-tab3-upload.d.ts +21 -0
  153. package/dist-client/pages/project-complete-tabs/pc-tab3-upload.js +335 -0
  154. package/dist-client/pages/project-complete-tabs/pc-tab3-upload.js.map +1 -0
  155. package/dist-client/pages/project-complete-tabs/pc-tab4-monthly.d.ts +42 -0
  156. package/dist-client/pages/project-complete-tabs/pc-tab4-monthly.js +641 -0
  157. package/dist-client/pages/project-complete-tabs/pc-tab4-monthly.js.map +1 -0
  158. package/dist-client/pages/sv-project-complete.d.ts +25 -0
  159. package/dist-client/pages/sv-project-complete.js +263 -0
  160. package/dist-client/pages/sv-project-complete.js.map +1 -0
  161. package/dist-client/pages/sv-project-completed-list.d.ts +27 -0
  162. package/dist-client/pages/sv-project-completed-list.js +416 -0
  163. package/dist-client/pages/sv-project-completed-list.js.map +1 -0
  164. package/dist-client/pages/sv-project-detail.d.ts +58 -0
  165. package/dist-client/pages/sv-project-detail.js +1418 -0
  166. package/dist-client/pages/sv-project-detail.js.map +1 -0
  167. package/dist-client/pages/sv-project-list.d.ts +174 -0
  168. package/dist-client/pages/sv-project-list.js +578 -0
  169. package/dist-client/pages/sv-project-list.js.map +1 -0
  170. package/dist-client/pages/sv-project-update.d.ts +86 -0
  171. package/dist-client/pages/sv-project-update.js +1331 -0
  172. package/dist-client/pages/sv-project-update.js.map +1 -0
  173. package/dist-client/pages/sv-user-management.d.ts +1 -0
  174. package/dist-client/pages/sv-user-management.js +5 -0
  175. package/dist-client/pages/sv-user-management.js.map +1 -1
  176. package/dist-client/route.d.ts +1 -1
  177. package/dist-client/route.js +50 -2
  178. package/dist-client/route.js.map +1 -1
  179. package/dist-client/shared/complete-api.d.ts +37 -0
  180. package/dist-client/shared/complete-api.js +224 -0
  181. package/dist-client/shared/complete-api.js.map +1 -0
  182. package/dist-client/shared/func.d.ts +2 -0
  183. package/dist-client/shared/func.js +22 -0
  184. package/dist-client/shared/func.js.map +1 -0
  185. package/dist-client/shared/integration-fetch.d.ts +35 -0
  186. package/dist-client/shared/integration-fetch.js +53 -0
  187. package/dist-client/shared/integration-fetch.js.map +1 -0
  188. package/dist-client/themes/dark.css +24 -24
  189. package/dist-client/themes/light.css +23 -23
  190. package/dist-client/tsconfig.tsbuildinfo +1 -1
  191. package/dist-client/viewparts/menu-tools.d.ts +40 -5
  192. package/dist-client/viewparts/menu-tools.js +292 -43
  193. package/dist-client/viewparts/menu-tools.js.map +1 -1
  194. package/dist-server/index.d.ts +2 -0
  195. package/dist-server/index.js +5 -0
  196. package/dist-server/index.js.map +1 -1
  197. package/dist-server/migrations/index.d.ts +1 -0
  198. package/dist-server/migrations/index.js +12 -0
  199. package/dist-server/migrations/index.js.map +1 -0
  200. package/dist-server/scripts/calculate-kpi-scores.d.ts +10 -0
  201. package/dist-server/scripts/calculate-kpi-scores.js +333 -0
  202. package/dist-server/scripts/calculate-kpi-scores.js.map +1 -0
  203. package/dist-server/scripts/load-grade-data-migration.d.ts +14 -0
  204. package/dist-server/scripts/load-grade-data-migration.js +279 -0
  205. package/dist-server/scripts/load-grade-data-migration.js.map +1 -0
  206. package/dist-server/scripts/propagate-parent-kpi-values.d.ts +14 -0
  207. package/dist-server/scripts/propagate-parent-kpi-values.js +786 -0
  208. package/dist-server/scripts/propagate-parent-kpi-values.js.map +1 -0
  209. package/dist-server/scripts/recalculate-by-project-name.d.ts +2 -0
  210. package/dist-server/scripts/recalculate-by-project-name.js +72 -0
  211. package/dist-server/scripts/recalculate-by-project-name.js.map +1 -0
  212. package/dist-server/service/index.d.ts +4 -0
  213. package/dist-server/service/index.js +20 -0
  214. package/dist-server/service/index.js.map +1 -0
  215. package/dist-server/service/kpi-metric-value/index.d.ts +4 -0
  216. package/dist-server/service/kpi-metric-value/index.js +8 -0
  217. package/dist-server/service/kpi-metric-value/index.js.map +1 -0
  218. package/dist-server/service/kpi-metric-value/kpi-metric-value-mutation.d.ts +166 -0
  219. package/dist-server/service/kpi-metric-value/kpi-metric-value-mutation.js +951 -0
  220. package/dist-server/service/kpi-metric-value/kpi-metric-value-mutation.js.map +1 -0
  221. package/dist-server/service/kpi-metric-value/kpi-metric-value-query.d.ts +7 -0
  222. package/dist-server/service/kpi-metric-value/kpi-metric-value-query.js +59 -0
  223. package/dist-server/service/kpi-metric-value/kpi-metric-value-query.js.map +1 -0
  224. package/dist-server/service/kpi-stat/index.d.ts +4 -0
  225. package/dist-server/service/kpi-stat/index.js +8 -0
  226. package/dist-server/service/kpi-stat/index.js.map +1 -0
  227. package/dist-server/service/kpi-stat/kpi-stat-query.d.ts +12 -0
  228. package/dist-server/service/kpi-stat/kpi-stat-query.js +663 -0
  229. package/dist-server/service/kpi-stat/kpi-stat-query.js.map +1 -0
  230. package/dist-server/service/kpi-stat/kpi-stat-types.d.ts +32 -0
  231. package/dist-server/service/kpi-stat/kpi-stat-types.js +180 -0
  232. package/dist-server/service/kpi-stat/kpi-stat-types.js.map +1 -0
  233. package/dist-server/service/kpi-value/index.d.ts +3 -0
  234. package/dist-server/service/kpi-value/index.js +7 -0
  235. package/dist-server/service/kpi-value/index.js.map +1 -0
  236. package/dist-server/service/kpi-value/kpi-value-query.d.ts +8 -0
  237. package/dist-server/service/kpi-value/kpi-value-query.js +63 -0
  238. package/dist-server/service/kpi-value/kpi-value-query.js.map +1 -0
  239. package/dist-server/tsconfig.tsbuildinfo +1 -1
  240. package/kpi-module-service-tests.md +1286 -0
  241. package/kpi-module-test-report.md +676 -0
  242. package/kpi-module-unit-test-detailed-report.md +925 -0
  243. package/kpi-module-unit-tests-detailed.md +1452 -0
  244. package/package.json +69 -55
  245. package/recalculate-batch.sh +64 -0
  246. package/recalculate-projects-range.sh +98 -0
  247. package/schema.graphql +3423 -462
  248. package/things-factory.config.js +12 -1
  249. package/translations/en.json +5 -1
  250. package/translations/ko.json +5 -1
  251. package/views/auth-page.html +0 -1
  252. package/views/public/home.html +0 -1
@@ -0,0 +1,641 @@
1
+ import { __decorate, __metadata } from "tslib";
2
+ import { css, html, LitElement } from 'lit';
3
+ import { customElement, property, state } from 'lit/decorators.js';
4
+ import { client } from '@operato/graphql';
5
+ import { gql } from '@apollo/client';
6
+ import { notify } from '@operato/layout';
7
+ import { OxPrompt } from '@operato/popup';
8
+ import { hasPrivilege } from '@things-factory/auth-base/dist-client';
9
+ import moment from 'moment-timezone';
10
+ import { tenantHeaders } from '@dssp/project/dist-client/shared/domain-context';
11
+ /**
12
+ * 프로젝트 완공 처리 탭 4 — 월별 KPI 데이터 그리드.
13
+ *
14
+ * 데이터 source = `KpiMetric` (periodType=MONTH) + `KpiMetricValue` (그 metric 의
15
+ * 월별 값들). 이전 버전 (DataSet/DataSample) 폐기. KpiMetricValue 의 unique
16
+ * 인덱스 (domain, metric, valueDate, org) 가 (도메인, 프로젝트, 메트릭, 월) 단일 row
17
+ * 정책을 보장.
18
+ *
19
+ * 단방향 흐름:
20
+ * - 탭1/탭2 의 metric 저장 (valueDate=YYYY-MM-01) → 그 월 row 가 여기 자동 노출
21
+ * - 여기서 cell 수정 → 그 metric × 그 월 row 만 update (탭1/탭2 의 "현재값" 영향 없음 —
22
+ * 탭1/탭2 는 KpiMetricValueProvider 가 latest 또는 valueDate-based lookup 으로 동작)
23
+ */
24
+ /** rating 셀렉트로 표시할 metric 인지 판단 — 이름에 '평가' 또는 '이탈' 포함되면 1~5 rating. */
25
+ function isRating(metricName) {
26
+ return /평가|이탈/.test(metricName || '');
27
+ }
28
+ let SvProjectCompleteTab4Monthly = class SvProjectCompleteTab4Monthly extends LitElement {
29
+ constructor() {
30
+ super(...arguments);
31
+ this.project = {};
32
+ /** 월별 metric 목록 (periodType=MONTH). KpiMetric admin 에 등록된 것 기준. */
33
+ this.monthlyMetrics = [];
34
+ /** monthRows: { workDate:'YYYY-MM', values:{[metricId]:value}, originalValues, dirty }[] */
35
+ this.monthRows = [];
36
+ this.addYear = new Date().getFullYear();
37
+ this.addMonth = new Date().getMonth() + 1;
38
+ /** kpi:input — Step4 월별 데이터 저장 권한 (cumulative 와 같은 권한) */
39
+ this.canSave = false;
40
+ }
41
+ async connectedCallback() {
42
+ super.connectedCallback();
43
+ this.canSave = await hasPrivilege({
44
+ category: 'kpi',
45
+ privilege: 'input',
46
+ domainOwnerGranted: true,
47
+ superUserGranted: true
48
+ });
49
+ }
50
+ render() {
51
+ const years = this._getYearRange();
52
+ return html `
53
+ <div class="title">
54
+ 프로젝트 수행 기간 동안의 월별 데이터를 입력합니다.<br />
55
+ 공정률, 감리자 수준 평가(1~5) 등의 항목을 월 단위로 기록하여 성과 추세 분석에 활용합니다.
56
+ </div>
57
+
58
+ <div class="toolbar">
59
+ <select
60
+ .value=${String(this.addYear)}
61
+ @change=${(e) => (this.addYear = Number(e.target.value))}
62
+ >
63
+ ${years.map(y => html `<option value=${y} ?selected=${y === this.addYear}>${y}년</option>`)}
64
+ </select>
65
+ <select
66
+ .value=${String(this.addMonth)}
67
+ @change=${(e) => (this.addMonth = Number(e.target.value))}
68
+ >
69
+ ${[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12].map(m => html `<option value=${m} ?selected=${m === this.addMonth}>${m}월</option>`)}
70
+ </select>
71
+ <div class="add-btn" @click=${this._addMonth}>+ 월 추가</div>
72
+ </div>
73
+
74
+ ${this.monthlyMetrics.length === 0
75
+ ? html `<div class="empty-msg">
76
+ 월별 metric (periodType=MONTH) 이 등록되어 있지 않습니다. KPI 관리자에서 먼저 등록해주세요.
77
+ </div>`
78
+ : this.monthRows.length === 0
79
+ ? html `<div class="empty-msg">등록된 월별 데이터가 없습니다. 위에서 월을 추가해주세요.</div>`
80
+ : html `
81
+ <div class="grid-wrapper">
82
+ <table>
83
+ <thead>
84
+ <tr>
85
+ <th>월</th>
86
+ ${this.monthlyMetrics.map(m => html `
87
+ <th class=${this._isMetricNeverEntered(m.id) ? 'pending' : ''}
88
+ title=${this._isMetricNeverEntered(m.id) ? '한 번도 입력된 적 없는 metric' : ''}>
89
+ ${m.name}${m.unit ? ` (${m.unit})` : ''}
90
+ </th>
91
+ `)}
92
+ <th>상태</th>
93
+ <th></th>
94
+ </tr>
95
+ </thead>
96
+ <tbody>
97
+ ${this.monthRows.map((row, rowIdx) => html `
98
+ <tr>
99
+ <td class="month-cell ${this._isCurrentMonth(row.workDate) ? 'current' : ''}">
100
+ ${row.workDate}
101
+ </td>
102
+ ${this.monthlyMetrics.map(m => {
103
+ var _a, _b;
104
+ const pending = this._isCellPending(row, m.id);
105
+ return isRating(m.name)
106
+ ? html `
107
+ <td class=${pending ? 'pending' : ''}>
108
+ <select
109
+ class="rating-select"
110
+ .value=${String((_a = row.values[m.id]) !== null && _a !== void 0 ? _a : '')}
111
+ @change=${(e) => this._onCellChange(rowIdx, m.id, e.target.value)}
112
+ >
113
+ <option value="">-</option>
114
+ ${[1, 2, 3, 4, 5].map(v => html `<option value=${v} ?selected=${Number(row.values[m.id]) === v}>
115
+ ${v}
116
+ </option>`)}
117
+ </select>
118
+ </td>
119
+ `
120
+ : html `
121
+ <td class=${pending ? 'pending' : ''}>
122
+ <input
123
+ type="number"
124
+ .value=${(_b = row.values[m.id]) !== null && _b !== void 0 ? _b : ''}
125
+ @input=${(e) => this._onCellChange(rowIdx, m.id, e.target.value)}
126
+ />
127
+ </td>
128
+ `;
129
+ })}
130
+ <td>
131
+ ${row.dirty
132
+ ? html `<span class="status-unsaved">수정됨</span>`
133
+ : row.isAuto
134
+ ? html `<span class="status-pending">미입력</span>`
135
+ : row.isNew
136
+ ? html `<span class="status-new">신규</span>`
137
+ : html `<span class="status-saved">저장됨</span>`}
138
+ </td>
139
+ <td>
140
+ <span class="delete-btn" title="삭제" @click=${() => this._removeMonth(rowIdx)}>✕</span>
141
+ </td>
142
+ </tr>
143
+ `)}
144
+ </tbody>
145
+ </table>
146
+ </div>
147
+ `}
148
+
149
+ <div class="button-line">
150
+ <div class="ghost-btn" @click=${this._reset}>초기화</div>
151
+ <div
152
+ class="ghost-btn secondary ${this.canSave ? '' : 'disabled'}"
153
+ title=${this.canSave ? '' : 'kpi:input 권한 필요'}
154
+ @click=${() => this.canSave && this._save()}
155
+ >
156
+ 저장
157
+ </div>
158
+ </div>
159
+ `;
160
+ }
161
+ willUpdate(changedProperties) {
162
+ var _a;
163
+ super.willUpdate(changedProperties);
164
+ if (changedProperties.has('project') && ((_a = this.project) === null || _a === void 0 ? void 0 : _a.id)) {
165
+ this._loadData();
166
+ }
167
+ }
168
+ _getYearRange() {
169
+ var _a, _b;
170
+ const startYear = ((_a = this.project) === null || _a === void 0 ? void 0 : _a.startDate)
171
+ ? new Date(this.project.startDate).getFullYear()
172
+ : new Date().getFullYear() - 2;
173
+ const endYear = ((_b = this.project) === null || _b === void 0 ? void 0 : _b.endDate)
174
+ ? new Date(this.project.endDate).getFullYear() + 1
175
+ : new Date().getFullYear() + 1;
176
+ const years = [];
177
+ for (let y = startYear; y <= endYear; y++)
178
+ years.push(y);
179
+ return years;
180
+ }
181
+ _isCurrentMonth(workDate) {
182
+ return workDate === moment().tz('Asia/Seoul').format('YYYY-MM');
183
+ }
184
+ /**
185
+ * 월별 metric 정의 + 그 프로젝트의 월별 KpiMetricValue 들을 조회해 그리드 row 구성.
186
+ *
187
+ * 1) KpiMetric where periodType=MONTH → monthlyMetrics
188
+ * 2) KpiMetricValue where org=projectId → 월별로 그룹핑하여 monthRows
189
+ */
190
+ async _loadData() {
191
+ var _a, _b, _c, _d, _e, _f;
192
+ try {
193
+ // 1) 월별 metric 목록
194
+ const metricsResp = await client.query({
195
+ query: gql `
196
+ query KpiMetrics {
197
+ kpiMetrics {
198
+ items {
199
+ id
200
+ name
201
+ unit
202
+ periodType
203
+ }
204
+ }
205
+ }
206
+ `,
207
+ context: { headers: tenantHeaders((_a = this.project) === null || _a === void 0 ? void 0 : _a.code) }
208
+ });
209
+ const all = ((_c = (_b = metricsResp.data) === null || _b === void 0 ? void 0 : _b.kpiMetrics) === null || _c === void 0 ? void 0 : _c.items) || [];
210
+ this.monthlyMetrics = all.filter((m) => m.periodType === 'MONTH');
211
+ if (this.monthlyMetrics.length === 0) {
212
+ this.monthRows = [];
213
+ return;
214
+ }
215
+ // 2) 프로젝트의 KpiMetricValue 들 (org=projectId). 월별 metric 만 client 측에서 필터.
216
+ const monthlyMetricIds = new Set(this.monthlyMetrics.map((m) => m.id));
217
+ const valuesResp = await client.query({
218
+ query: gql `
219
+ query KpiMetricValues($filters: [Filter!]) {
220
+ kpiMetricValues(filters: $filters) {
221
+ items {
222
+ id
223
+ value
224
+ unit
225
+ periodType
226
+ valueDate
227
+ metricId
228
+ }
229
+ }
230
+ }
231
+ `,
232
+ variables: { filters: [{ name: 'org', operator: 'eq', value: this.project.id }] },
233
+ context: { headers: tenantHeaders((_d = this.project) === null || _d === void 0 ? void 0 : _d.code) }
234
+ });
235
+ const allValues = ((_f = (_e = valuesResp.data) === null || _e === void 0 ? void 0 : _e.kpiMetricValues) === null || _f === void 0 ? void 0 : _f.items) || [];
236
+ // periodType='MONTH' 만 그리드에 — 비월별 row 가 valueDate prefix 로 잘못 묶이지 않도록.
237
+ const monthlyValues = allValues.filter((v) => monthlyMetricIds.has(v.metricId) && v.periodType === 'MONTH');
238
+ // 월별 그룹핑 — valueDate YYYY-MM-DD 의 앞 7자리. id 도 보존 (삭제 시 사용).
239
+ // 현재월(=this month) row 는 운영 원칙상 표시 대상 아님 → 아예 bucket 제외.
240
+ const currentYm = moment().tz('Asia/Seoul').format('YYYY-MM');
241
+ const byMonth = new Map();
242
+ for (const v of monthlyValues) {
243
+ const ym = (v.valueDate || '').slice(0, 7);
244
+ if (!ym)
245
+ continue;
246
+ if (ym === currentYm)
247
+ continue; // 현재월 record 무시 (DB 에 우연히 있더라도)
248
+ if (!byMonth.has(ym))
249
+ byMonth.set(ym, { workDate: ym, values: {}, originalValues: {}, valueIds: {}, dirty: false });
250
+ const row = byMonth.get(ym);
251
+ row.values[v.metricId] = v.value;
252
+ row.originalValues[v.metricId] = v.value;
253
+ row.valueIds[v.metricId] = v.id;
254
+ }
255
+ // project.startDate ~ 현재월 사이 누락된 월 placeholder row 자동 추가.
256
+ // 사용자가 값을 입력하지 않으면 dirty 가 안 되므로 저장 시 무시되어 spurious patch 없음.
257
+ for (const ym of this._generateExpectedMonths()) {
258
+ if (!byMonth.has(ym)) {
259
+ byMonth.set(ym, {
260
+ workDate: ym,
261
+ values: {},
262
+ originalValues: {},
263
+ valueIds: {},
264
+ dirty: false,
265
+ isAuto: true
266
+ });
267
+ }
268
+ }
269
+ this.monthRows = Array.from(byMonth.values()).sort((a, b) => b.workDate.localeCompare(a.workDate));
270
+ }
271
+ catch (e) {
272
+ console.error('Failed to load monthly data:', e);
273
+ this.monthRows = [];
274
+ }
275
+ }
276
+ /** project.startDate (YYYY-MM) ~ **전월** (YYYY-MM) 까지 매월 문자열 배열.
277
+ * 현재월은 의도적으로 제외 — 운영 원칙상 "이번달 데이터는 아직 입력 대상이 아님". */
278
+ _generateExpectedMonths() {
279
+ var _a;
280
+ const startStr = (((_a = this.project) === null || _a === void 0 ? void 0 : _a.startDate) || '').slice(0, 7);
281
+ if (!startStr || !/^\d{4}-\d{2}$/.test(startStr))
282
+ return [];
283
+ const tz = 'Asia/Seoul';
284
+ let cur = moment.tz(startStr, 'YYYY-MM', tz);
285
+ const end = moment.tz(moment().tz(tz).subtract(1, 'month').format('YYYY-MM'), 'YYYY-MM', tz);
286
+ if (!cur.isValid() || cur.isAfter(end))
287
+ return [];
288
+ const months = [];
289
+ while (cur.isSameOrBefore(end)) {
290
+ months.push(cur.format('YYYY-MM'));
291
+ cur = cur.add(1, 'month');
292
+ }
293
+ return months;
294
+ }
295
+ /** 셀 미입력 여부 — 값 없음 AND 그 월이 **전월** (직전 한 달) 인 경우만 pending.
296
+ * 과월 전체가 아니라 전월 한 달에 한해서만 강조 — 사용자 입력 흐름(이번 달에 지난달 데이터)과 일치. */
297
+ _isCellPending(row, metricId) {
298
+ var _a;
299
+ const v = (_a = row.values) === null || _a === void 0 ? void 0 : _a[metricId];
300
+ if (v !== undefined && v !== null && v !== '')
301
+ return false;
302
+ const lastMonth = moment().tz('Asia/Seoul').subtract(1, 'month').format('YYYY-MM');
303
+ return row.workDate === lastMonth;
304
+ }
305
+ /** metric 컬럼이 전 row 통틀어 한 번도 값이 없으면 헤더 강조. */
306
+ _isMetricNeverEntered(metricId) {
307
+ return !this.monthRows.some(r => {
308
+ var _a;
309
+ const v = (_a = r.values) === null || _a === void 0 ? void 0 : _a[metricId];
310
+ return v !== undefined && v !== null && v !== '';
311
+ });
312
+ }
313
+ _addMonth() {
314
+ const workDate = `${this.addYear}-${String(this.addMonth).padStart(2, '0')}`;
315
+ // 현재월 row 는 추가 금지 — 운영 원칙상 이번달 데이터는 입력 대상 아님.
316
+ const currentYm = moment().tz('Asia/Seoul').format('YYYY-MM');
317
+ if (workDate === currentYm) {
318
+ notify({ message: '현재월(이번 달) 데이터는 입력 대상이 아닙니다.' });
319
+ return;
320
+ }
321
+ // 미래월도 차단
322
+ if (workDate > currentYm) {
323
+ notify({ message: '미래월은 입력 대상이 아닙니다.' });
324
+ return;
325
+ }
326
+ if (this.monthRows.some(r => r.workDate === workDate)) {
327
+ notify({ message: `${workDate}은 이미 존재합니다.` });
328
+ return;
329
+ }
330
+ const newRow = { workDate, values: {}, originalValues: {}, valueIds: {}, dirty: true, isNew: true };
331
+ const rows = [...this.monthRows, newRow];
332
+ rows.sort((a, b) => b.workDate.localeCompare(a.workDate));
333
+ this.monthRows = rows;
334
+ }
335
+ async _removeMonth(rowIdx) {
336
+ var _a;
337
+ const row = this.monthRows[rowIdx];
338
+ // 신규 row (DB 미반영) — 메모리에서만 제거
339
+ if (row.isNew) {
340
+ this.monthRows = this.monthRows.filter((_, i) => i !== rowIdx);
341
+ return;
342
+ }
343
+ // 저장된 row — 그 월의 모든 KpiMetricValue id 들을 한 번에 삭제.
344
+ // 권한: things-factory 의 deleteKpiMetricValues 는 category="kpi", privilege="mutation"
345
+ // (superUser/도메인 owner 자동 통과, 일반 사용자는 별도 grant 필요).
346
+ const ids = Object.values(row.valueIds || {}).filter(Boolean);
347
+ if (ids.length === 0) {
348
+ this.monthRows = this.monthRows.filter((_, i) => i !== rowIdx);
349
+ return;
350
+ }
351
+ const ok = await OxPrompt.open({
352
+ title: `${row.workDate} 의 월별 데이터를 삭제하시겠습니까?`,
353
+ confirmButton: { text: '삭제' },
354
+ cancelButton: { text: '취소' }
355
+ });
356
+ if (!ok)
357
+ return;
358
+ try {
359
+ const response = await client.mutate({
360
+ mutation: gql `
361
+ mutation DeleteKpiMetricValues($ids: [String!]!) {
362
+ deleteKpiMetricValues(ids: $ids)
363
+ }
364
+ `,
365
+ variables: { ids },
366
+ context: { headers: tenantHeaders((_a = this.project) === null || _a === void 0 ? void 0 : _a.code) }
367
+ });
368
+ if (response.errors) {
369
+ throw new Error(response.errors.map((e) => e.message).join('\n'));
370
+ }
371
+ notify({ message: `${row.workDate} 월별 데이터 ${ids.length}건 삭제되었습니다.` });
372
+ await this._loadData();
373
+ }
374
+ catch (e) {
375
+ console.error('Failed to delete monthly values:', e);
376
+ notify({ message: '삭제 중 오류가 발생했습니다. 권한을 확인해주세요.' });
377
+ }
378
+ }
379
+ _onCellChange(rowIdx, metricId, rawValue) {
380
+ const value = rawValue === '' ? null : Number(rawValue);
381
+ this.monthRows = this.monthRows.map((row, i) => {
382
+ if (i !== rowIdx)
383
+ return row;
384
+ return Object.assign(Object.assign({}, row), { values: Object.assign(Object.assign({}, row.values), { [metricId]: value }), dirty: true });
385
+ });
386
+ }
387
+ /**
388
+ * 저장 — dirty row 들 안의 변경된 cell 들을 KpiMetricValuePatch 로 모아
389
+ * updateKpiMetricValuesCumulative 한 번 호출 (backend upsert 가 unique 조합 처리).
390
+ */
391
+ async _save() {
392
+ var _a;
393
+ const patches = [];
394
+ for (const row of this.monthRows) {
395
+ if (!row.dirty)
396
+ continue;
397
+ for (const m of this.monthlyMetrics) {
398
+ const value = row.values[m.id];
399
+ const original = row.originalValues[m.id];
400
+ if (value === undefined || value === null)
401
+ continue; // 빈 값은 skip (기존 유지)
402
+ if (value === original)
403
+ continue; // 변화 없으면 skip
404
+ patches.push({
405
+ metricId: m.id,
406
+ value,
407
+ unit: m.unit || '',
408
+ org: this.project.id,
409
+ periodType: 'MONTH',
410
+ valueDate: `${row.workDate}-01`
411
+ });
412
+ }
413
+ }
414
+ if (patches.length === 0) {
415
+ notify({ message: '변경된 데이터가 없습니다.' });
416
+ return;
417
+ }
418
+ try {
419
+ const response = await client.mutate({
420
+ mutation: gql `
421
+ mutation UpdateKpiMetricValuesCumulative($patches: [KpiMetricValuePatch!]!) {
422
+ updateKpiMetricValuesCumulative(patches: $patches) {
423
+ id
424
+ }
425
+ }
426
+ `,
427
+ variables: { patches },
428
+ context: { headers: tenantHeaders((_a = this.project) === null || _a === void 0 ? void 0 : _a.code) }
429
+ });
430
+ if (response.errors) {
431
+ throw new Error(response.errors.map((e) => e.message).join('\n'));
432
+ }
433
+ notify({ message: `${patches.length}건 저장되었습니다.` });
434
+ await this._loadData();
435
+ }
436
+ catch (e) {
437
+ console.error('Failed to save monthly values:', e);
438
+ notify({ message: '저장 중 오류가 발생했습니다.' });
439
+ }
440
+ }
441
+ _reset() {
442
+ this._loadData();
443
+ }
444
+ };
445
+ SvProjectCompleteTab4Monthly.styles = [
446
+ css `
447
+ :host {
448
+ display: block;
449
+ }
450
+ .title {
451
+ color: #212529;
452
+ font-size: 13px;
453
+ font-weight: 400;
454
+ line-height: 24px;
455
+ text-align: center;
456
+ margin-bottom: 8px;
457
+ }
458
+
459
+ .toolbar {
460
+ display: flex;
461
+ align-items: center;
462
+ justify-content: center;
463
+ gap: 12px;
464
+ margin-bottom: 12px;
465
+ }
466
+ .toolbar select {
467
+ padding: 5px 8px;
468
+ border: 1px solid rgba(0, 0, 0, 0.15);
469
+ border-radius: 5px;
470
+ font-size: 14px;
471
+ color: #212529;
472
+ }
473
+ .toolbar .add-btn {
474
+ display: inline-flex;
475
+ align-items: center;
476
+ gap: 4px;
477
+ padding: 5px 10px;
478
+ background: #35618e;
479
+ color: #fff;
480
+ border-radius: 5px;
481
+ cursor: pointer;
482
+ font-size: 13px;
483
+ }
484
+
485
+ .grid-wrapper {
486
+ overflow-x: auto;
487
+ padding: 0 6px;
488
+ }
489
+ table {
490
+ width: 100%;
491
+ border-collapse: collapse;
492
+ font-size: 13px;
493
+ }
494
+ thead th {
495
+ background: #f3f3fa;
496
+ border-top: 2px solid #0c4da2;
497
+ color: #212529;
498
+ text-align: center;
499
+ padding: 8px 6px;
500
+ white-space: nowrap;
501
+ font-weight: 500;
502
+ }
503
+ tbody td {
504
+ border-bottom: 1px solid rgba(0, 0, 0, 0.08);
505
+ text-align: center;
506
+ padding: 6px 4px;
507
+ vertical-align: middle;
508
+ }
509
+ tbody tr:hover {
510
+ background: #f8fafc;
511
+ }
512
+ .month-cell {
513
+ color: #35618e;
514
+ font-weight: 600;
515
+ white-space: nowrap;
516
+ }
517
+ .month-cell.current {
518
+ color: #16a085;
519
+ }
520
+
521
+ input[type='number'] {
522
+ width: 70px;
523
+ padding: 4px 6px;
524
+ border: 1px solid rgba(0, 0, 0, 0.12);
525
+ border-radius: 4px;
526
+ text-align: center;
527
+ font-size: 13px;
528
+ }
529
+ input[type='number']:focus {
530
+ outline: none;
531
+ border-color: #35618e;
532
+ }
533
+
534
+ .rating-select {
535
+ padding: 4px 6px;
536
+ border: 1px solid rgba(0, 0, 0, 0.12);
537
+ border-radius: 4px;
538
+ font-size: 13px;
539
+ text-align: center;
540
+ }
541
+
542
+ .status-saved {
543
+ color: #16a085;
544
+ font-size: 12px;
545
+ }
546
+ .status-unsaved {
547
+ color: #e67e22;
548
+ font-size: 12px;
549
+ }
550
+ .status-new {
551
+ color: #3498db;
552
+ font-size: 12px;
553
+ }
554
+ .status-pending {
555
+ color: #e74c3c;
556
+ font-size: 12px;
557
+ font-weight: 600;
558
+ }
559
+
560
+ /* 미입력 셀 — 과월/현재월 row 에서 값이 비어있을 때 강조 */
561
+ td.pending input[type='number'],
562
+ td.pending .rating-select {
563
+ border-color: #e74c3c;
564
+ background-color: #fff5f5;
565
+ }
566
+ /* 한 번도 입력된 적 없는 metric 컬럼 — 헤더 강조 */
567
+ th.pending {
568
+ background: #fdecec;
569
+ color: #c0392b;
570
+ }
571
+
572
+ .button-line {
573
+ display: flex;
574
+ justify-content: center;
575
+ gap: 10px;
576
+ margin-top: 16px;
577
+ }
578
+ .ghost-btn {
579
+ display: inline-flex;
580
+ align-items: center;
581
+ gap: 6px;
582
+ padding: 6px 10px;
583
+ background: #35618e;
584
+ color: #ffffff;
585
+ border-radius: 5px;
586
+ cursor: pointer;
587
+ }
588
+ .ghost-btn.secondary {
589
+ background: #24be7b;
590
+ }
591
+ .ghost-btn.disabled {
592
+ opacity: 0.45;
593
+ cursor: not-allowed;
594
+ }
595
+
596
+ .delete-btn {
597
+ cursor: pointer;
598
+ color: #999;
599
+ font-size: 18px;
600
+ }
601
+ .delete-btn:hover {
602
+ color: #e74c3c;
603
+ }
604
+
605
+ .empty-msg {
606
+ text-align: center;
607
+ color: #999;
608
+ padding: 40px 0;
609
+ font-size: 14px;
610
+ }
611
+ `
612
+ ];
613
+ __decorate([
614
+ property({ type: Object }),
615
+ __metadata("design:type", Object)
616
+ ], SvProjectCompleteTab4Monthly.prototype, "project", void 0);
617
+ __decorate([
618
+ state(),
619
+ __metadata("design:type", Array)
620
+ ], SvProjectCompleteTab4Monthly.prototype, "monthlyMetrics", void 0);
621
+ __decorate([
622
+ state(),
623
+ __metadata("design:type", Array)
624
+ ], SvProjectCompleteTab4Monthly.prototype, "monthRows", void 0);
625
+ __decorate([
626
+ state(),
627
+ __metadata("design:type", Number)
628
+ ], SvProjectCompleteTab4Monthly.prototype, "addYear", void 0);
629
+ __decorate([
630
+ state(),
631
+ __metadata("design:type", Number)
632
+ ], SvProjectCompleteTab4Monthly.prototype, "addMonth", void 0);
633
+ __decorate([
634
+ state(),
635
+ __metadata("design:type", Object)
636
+ ], SvProjectCompleteTab4Monthly.prototype, "canSave", void 0);
637
+ SvProjectCompleteTab4Monthly = __decorate([
638
+ customElement('sv-pc-tab4-monthly')
639
+ ], SvProjectCompleteTab4Monthly);
640
+ export { SvProjectCompleteTab4Monthly };
641
+ //# sourceMappingURL=pc-tab4-monthly.js.map