@dssp/dkpi 1.0.0-alpha.9 → 1.0.0-alpha.91

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