@things-factory/meta-ui 8.0.0-beta.8 → 8.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (115) hide show
  1. package/client/bootstrap.ts +170 -0
  2. package/client/component/filter/filter-form-meta-code-select.ts +102 -0
  3. package/client/component/filter/filter-form-meta-object-select.ts +107 -0
  4. package/client/component/filter/filter-grist-meta-code-select.ts +97 -0
  5. package/client/component/filter/filter-grist-meta-object-select.ts +102 -0
  6. package/client/component/grist/editor/grist-editor-code-input.js +96 -0
  7. package/client/component/grist/editor/grist-editor-meta-code-selector.js +157 -0
  8. package/client/component/grist/editor/grist-editor-meta-object-selector.js +122 -0
  9. package/client/component/grist/renderer/grist-renderer-code-input.js +20 -0
  10. package/client/component/grist/renderer/grist-renderer-meta-code-selector.js +28 -0
  11. package/client/component/grist/renderer/grist-renderer-meta-object-selector.js +25 -0
  12. package/client/component/popup/code-input-editor-popup.js +111 -0
  13. package/client/component/popup/file-upload-popup.js +129 -0
  14. package/client/component/popup/meta-object-selector-popup.ts +356 -0
  15. package/client/component/popup/record-based-code-editor-popup.ts +141 -0
  16. package/client/dynamic-menus.ts +38 -0
  17. package/client/index.ts +18 -0
  18. package/client/load-components.ts +17 -0
  19. package/client/mixin/meta-base-mixin.js +323 -0
  20. package/client/mixin/meta-basic-grist-mixin.js +283 -0
  21. package/client/mixin/meta-button-mixin.js +116 -0
  22. package/client/mixin/meta-form-mixin.js +435 -0
  23. package/client/mixin/meta-grist-tab-mixin.js +335 -0
  24. package/client/mixin/meta-main-tab-mixin.js +267 -0
  25. package/client/mixin/meta-master-detail-mixin.js +395 -0
  26. package/client/mixin/meta-service-mixin.js +306 -0
  27. package/client/mixin/meta-tab-detail-mixin.js +283 -0
  28. package/client/mixin/meta-tab-mixin.js +190 -0
  29. package/client/pages/activity/meta-activity-define-page.js +422 -0
  30. package/client/pages/activity/meta-activity-list-page.js +262 -0
  31. package/client/pages/activity/meta-activity-viewer-element.js +35 -0
  32. package/client/pages/activity/meta-activity-writer-element.js +48 -0
  33. package/client/pages/activity/meta-activiy-mixin.js +79 -0
  34. package/client/pages/button-role/button-role-detail.js +50 -0
  35. package/client/pages/button-role/button-role-page.js +25 -0
  36. package/client/pages/doc-number/doc-number-page.js +24 -0
  37. package/client/pages/doc-number/next-doc-number-popup.js +25 -0
  38. package/client/pages/entity/config-entity.js +955 -0
  39. package/client/pages/entity/main-menu-selector.js +245 -0
  40. package/client/pages/history/history-copy-list-popup.js +145 -0
  41. package/client/pages/history/history-json-list-popup.js +159 -0
  42. package/client/pages/menu/dynamic-menu-template.js +92 -0
  43. package/client/pages/menu/dynamic-menu.ts +744 -0
  44. package/client/pages/menu/export-menu-popup.js +468 -0
  45. package/client/pages/meta-form-element.js +9 -0
  46. package/client/pages/meta-grist-element.js +12 -0
  47. package/client/pages/meta-grist-page.js +16 -0
  48. package/client/pages/meta-grist-tab-element.js +16 -0
  49. package/client/pages/meta-grist-tab-page.js +16 -0
  50. package/client/pages/meta-main-tab-element.js +12 -0
  51. package/client/pages/meta-main-tab-page.js +16 -0
  52. package/client/pages/meta-master-detail-element.js +12 -0
  53. package/client/pages/meta-master-detail-page.js +16 -0
  54. package/client/pages/meta-tab-detail-element.js +12 -0
  55. package/client/pages/meta-tab-detail-page.js +16 -0
  56. package/client/pages/meta-tab-element.js +15 -0
  57. package/client/pages/printer-device/printer-device-page.js +24 -0
  58. package/client/pages/template/doc-template-page.js +24 -0
  59. package/client/pages/template/template-file-page.js +24 -0
  60. package/client/pages/terms/config-terminology.js +214 -0
  61. package/client/pages/work-code/work-code-detail-popup.js +16 -0
  62. package/client/pages/work-code/work-code-page.js +23 -0
  63. package/client/route.ts +36 -0
  64. package/client/tsconfig.json +13 -0
  65. package/client/utils/grist-default-value.js +36 -0
  66. package/client/utils/meta-api.js +811 -0
  67. package/client/utils/meta-crypto.js +52 -0
  68. package/client/utils/meta-ui-util.js +3304 -0
  69. package/client/utils/rest-service-util.js +328 -0
  70. package/client/utils/service-util.js +1327 -0
  71. package/client/utils/terms-util.ts +119 -0
  72. package/client/utils/ui-util.js +338 -0
  73. package/client/utils/value-util.js +234 -0
  74. package/dist-client/tsconfig.tsbuildinfo +1 -1
  75. package/dist-client/utils/service-util.d.ts +2 -2
  76. package/dist-client/utils/service-util.js +4 -4
  77. package/dist-client/utils/service-util.js.map +1 -1
  78. package/dist-server/tsconfig.tsbuildinfo +1 -1
  79. package/package.json +24 -24
  80. package/server/activity/CommonActivity.ts +68 -0
  81. package/server/index.ts +3 -0
  82. package/server/routes.ts +61 -0
  83. package/server/service/button-role/button-role-mutation.ts +105 -0
  84. package/server/service/button-role/button-role-query.ts +53 -0
  85. package/server/service/button-role/button-role-type.ts +39 -0
  86. package/server/service/button-role/button-role.ts +61 -0
  87. package/server/service/button-role/index.ts +7 -0
  88. package/server/service/dynamic-menu/dynamic-menu-query.ts +270 -0
  89. package/server/service/dynamic-menu/dynamic-menu-type.ts +74 -0
  90. package/server/service/dynamic-menu/index.ts +3 -0
  91. package/server/service/entity-event-subscriber/entity-event-subscriber.ts +80 -0
  92. package/server/service/entity-event-subscriber/index.ts +3 -0
  93. package/server/service/index.ts +41 -0
  94. package/server/service/menu-button-auth/index.ts +7 -0
  95. package/server/service/menu-button-auth/menu-button-auth-mutation.ts +133 -0
  96. package/server/service/menu-button-auth/menu-button-auth-query.ts +138 -0
  97. package/server/service/menu-button-auth/menu-button-auth-type.ts +63 -0
  98. package/server/service/menu-button-auth/menu-button-auth.ts +92 -0
  99. package/server/service/meta-activity/index.ts +5 -0
  100. package/server/service/meta-activity/meta-activity-mutation.ts +191 -0
  101. package/server/service/meta-activity/meta-activity-query.ts +43 -0
  102. package/server/service/meta-activity/meta-activity-type.ts +56 -0
  103. package/server/service/set-translations/index.ts +3 -0
  104. package/server/service/set-translations/set-translation-resolver.ts +63 -0
  105. package/server/service/work-code/index.ts +6 -0
  106. package/server/service/work-code/work-code-mutation.ts +147 -0
  107. package/server/service/work-code/work-code-query.ts +67 -0
  108. package/server/service/work-code/work-code-type.ts +60 -0
  109. package/server/service/work-code/work-code.ts +83 -0
  110. package/server/service/work-code-detail/index.ts +6 -0
  111. package/server/service/work-code-detail/work-code-detail-mutation.ts +149 -0
  112. package/server/service/work-code-detail/work-code-detail-query.ts +59 -0
  113. package/server/service/work-code-detail/work-code-detail-type.ts +50 -0
  114. package/server/service/work-code-detail/work-code-detail.ts +82 -0
  115. package/server/tsconfig.json +9 -0
@@ -0,0 +1,328 @@
1
+ import { decreaseActiveRequestCounter, increaseActiveRequestCounter } from '@operato/graphql'
2
+
3
+ import { TermsUtil } from './terms-util'
4
+ import { UiUtil } from './ui-util'
5
+
6
+ /**
7
+ * @license
8
+ * Copyright © HatioLab Inc. All rights reserved.
9
+ * @author Shortstop <shortstop@hatiolab.com>
10
+ * @description REST 서비스 핸들링 유틸리티 함수 정의
11
+ */
12
+ export class RestServiceUtil {
13
+ /**
14
+ * @description REST 서비스 응답이 에러인 경우 Error 메시지 표시
15
+ ****************************************************
16
+ * @param {Object} response 응답
17
+ */
18
+ static async showRestErrorResponse(response) {
19
+ if (response.status && response.status >= 400) {
20
+ try {
21
+ let errData = await response.json()
22
+ let errMsg =
23
+ errData.code && errData.msg ? `${errData.code} - ${errData.msg}` : TermsUtil.tText('unexpected_server_error')
24
+ UiUtil.showAlertPopup('title.error', errMsg, 'error', 'confirm')
25
+ return errData
26
+ } catch (err) {
27
+ UiUtil.showAlertPopup('title.error', err, 'error', 'confirm')
28
+ return false
29
+ }
30
+ }
31
+ }
32
+
33
+ /**
34
+ * @description REST 서비스 실행 시 발생한 예외 표시
35
+ *************************************************
36
+ * @param {Object} exception 에러 Object
37
+ */
38
+ static async showRestException(exception) {
39
+ if (exception) {
40
+ await UiUtil.showAlertPopup('REST Service Error', exception.message, 'error', 'confirm')
41
+ }
42
+ }
43
+
44
+ /**
45
+ * @description 레코드의 id를 이용해 데이터 한 건 조회
46
+ *********************************************
47
+ * @param {String} url 조회할 서비스 URL
48
+ * @param {Object} params 파라미터
49
+ * @return {Object} 조회한 레코드
50
+ */
51
+ static async restGet(url, params) {
52
+ let res = await RestServiceUtil.callRestGet(url, params, false)
53
+ if (res && res.status && res.status < 400) {
54
+ return await res.json()
55
+ }
56
+
57
+ return null
58
+ }
59
+
60
+ /**
61
+ * @description 메소드 PUT인 REST 서비스 호출
62
+ *********************************************
63
+ * @param {String} url 서비스 URL
64
+ * @param {Object} params 파라미터
65
+ * @param {String} confirmTitleKey 확인 타이틀 용어 키
66
+ * @param {String} confirmMsgKey 확인 메시지 용어 키
67
+ * @param {Function} successCallback 성공 콜백
68
+ * @param {Function} failureCallback 실패 콜백
69
+ * @return {Object}
70
+ */
71
+ static async restPut(url, params, confirmTitleKey, confirmMsgKey, successCallback, failureCallback) {
72
+ return await RestServiceUtil.callRest(
73
+ 'PUT',
74
+ url,
75
+ params,
76
+ confirmTitleKey,
77
+ confirmMsgKey,
78
+ successCallback,
79
+ failureCallback
80
+ )
81
+ }
82
+
83
+ /**
84
+ * @description 메소드 POST인 REST 서비스 호출
85
+ *********************************************
86
+ * @param {String} url 서비스 URL
87
+ * @param {Object} params 파라미터
88
+ * @param {String} confirmTitleKey 확인 타이틀 용어 키
89
+ * @param {String} confirmMsgKey 확인 메시지 용어 키
90
+ * @param {Function} successCallback 성공 콜백
91
+ * @param {Function} failureCallback 실패 콜백
92
+ * @return {Object}
93
+ */
94
+ static async restPost(url, params, confirmTitleKey, confirmMsgKey, successCallback, failureCallback) {
95
+ return await RestServiceUtil.callRest(
96
+ 'POST',
97
+ url,
98
+ params,
99
+ confirmTitleKey,
100
+ confirmMsgKey,
101
+ successCallback,
102
+ failureCallback
103
+ )
104
+ }
105
+
106
+ /**
107
+ * @description 메소드 DELETE인 REST 서비스 호출
108
+ *********************************************
109
+ * @param {String} url 서비스 URL
110
+ * @param {Object} params 파라미터
111
+ * @param {String} confirmTitleKey 확인 타이틀 용어 키
112
+ * @param {String} confirmMsgKey 확인 메시지 용어 키
113
+ * @param {Function} successCallback 성공 콜백
114
+ * @param {Function} failureCallback 실패 콜백
115
+ * @return {Object}
116
+ */
117
+ static async restDelete(url, params, confirmTitleKey, confirmMsgKey, successCallback, failureCallback) {
118
+ return await RestServiceUtil.callRest(
119
+ 'DELETE',
120
+ url,
121
+ params,
122
+ confirmTitleKey,
123
+ confirmMsgKey,
124
+ successCallback,
125
+ failureCallback
126
+ )
127
+ }
128
+
129
+ /**
130
+ * @description REST 서비스 호출
131
+ *********************************************
132
+ * @param {String} method 메소드
133
+ * @param {String} url 서비스 URL
134
+ * @param {Object} params 파라미터
135
+ * @param {String} confirmTitleKey 확인 타이틀 용어 키
136
+ * @param {String} confirmMsgKey 확인 메시지 용어 키
137
+ * @param {Function} successCallback 성공 콜백
138
+ * @param {Function} failureCallback 실패 콜백
139
+ * @return {Object}
140
+ */
141
+ static async callRest(method, url, params, confirmTitleKey, confirmMsgKey, successCallback, failureCallback) {
142
+ let confirm = confirmMsgKey
143
+ ? await UiUtil.showAlertPopup(confirmTitleKey, confirmMsgKey, 'question', 'confirm', 'cancel')
144
+ : true
145
+
146
+ if (confirm) {
147
+ // 서비스 호출 결과
148
+ let res = null
149
+
150
+ if (method == 'POST') {
151
+ res = await restCallPost(url, params, false)
152
+ } else if (method == 'PUT') {
153
+ res = await restCallPut(url, params, false)
154
+ } else if (method == 'DELETE') {
155
+ res = await restCallDelete(url, params, false)
156
+ }
157
+
158
+ if (res && res.status && res.status < 400) {
159
+ UiUtil.showToast('info', TermsUtil.tText('Success to Process'))
160
+ if (successCallback) successCallback()
161
+ return res.json ? await res.json() : res
162
+ } else {
163
+ if (failureCallback) failureCallback()
164
+ }
165
+ }
166
+
167
+ return null
168
+ }
169
+
170
+ /**
171
+ * @description REST 서버에 GET 방식 호출, response 리턴
172
+ *******************************************************
173
+ * @param {String} url
174
+ * @param {*} params
175
+ * @param {Boolean} responseJson
176
+ * @returns response 리턴
177
+ */
178
+ static async callRestGet(url, params, responseJson) {
179
+ try {
180
+ increaseActiveRequestCounter()
181
+
182
+ if (params == null || typeof params == undefined) {
183
+ } else if (typeof params == 'string') {
184
+ url = `${url}?${params}`
185
+ } else if (Array.isArray(params)) {
186
+ url += '?'
187
+ params.forEach((item, index, array) => {
188
+ url += `${item['name']}=${item['value']}&`
189
+ })
190
+ } else if (Object.keys(params).length > 0) {
191
+ url += '?'
192
+ for (let param in params) {
193
+ url += `${param}=${params[param]}&`
194
+ }
195
+ }
196
+ const res = await fetch(url, {
197
+ method: 'GET',
198
+ headers: {
199
+ 'Content-type': 'application/json',
200
+ Accept: 'application/json',
201
+ 'x-locale': currentLocale()
202
+ }
203
+ })
204
+
205
+ const resJson = responseJson ? responseJson : false
206
+ return await checkResponse(res, resJson)
207
+ } finally {
208
+ decreaseActiveRequestCounter()
209
+ }
210
+ }
211
+
212
+ /**
213
+ * @description REST 서버에 POST 방식 호출, 서버 response 자체를 리턴
214
+ *****************************************************************
215
+ * @param {*} url
216
+ * @param {*} bodyObj
217
+ * @param {Boolean} responseJson 응답 JSON을 받을 지 여부
218
+ * @returns response 리턴
219
+ */
220
+ static async callRestPost(url, bodyObj, responseJson) {
221
+ const bodyStr = typeof bodyObj === 'string' ? bodyObj : JSON.stringify(bodyObj)
222
+
223
+ try {
224
+ increaseActiveRequestCounter()
225
+
226
+ const res = await fetch(url, {
227
+ method: 'POST',
228
+ headers: {
229
+ 'Content-type': 'application/json',
230
+ Accept: 'application/json',
231
+ 'x-locale': currentLocale()
232
+ },
233
+ body: bodyStr
234
+ })
235
+
236
+ const resJson = responseJson ? responseJson : false
237
+ return await checkResponse(res, resJson)
238
+ } finally {
239
+ decreaseActiveRequestCounter()
240
+ }
241
+ }
242
+
243
+ /**
244
+ * @description REST 서버에 PUT 방식 호출, 서버 Response 자체를 리턴
245
+ ****************************************************************
246
+ * @param {String} url
247
+ * @param {Object} bodyObj
248
+ * @param {Boolean} responseJson 응답 JSON을 받을 지 여부
249
+ * @returns 서버 response 리턴
250
+ */
251
+ static async callRestPut(url, bodyObj, responseJson) {
252
+ try {
253
+ increaseActiveRequestCounter()
254
+
255
+ const bodyStr = typeof bodyObj === 'string' ? bodyObj : JSON.stringify(bodyObj)
256
+ const res = await fetch(url, {
257
+ method: 'PUT',
258
+ credentials: 'include',
259
+ headers: {
260
+ 'Content-type': 'application/json',
261
+ Accept: 'application/json',
262
+ 'x-locale': currentLocale()
263
+ },
264
+ body: bodyStr
265
+ })
266
+
267
+ const resJson = responseJson ? responseJson : false
268
+ return await checkResponse(res, resJson)
269
+ } finally {
270
+ decreaseActiveRequestCounter()
271
+ }
272
+ }
273
+
274
+ /**
275
+ * @description REST 서버에 DELETE 방식 호출 후 서버 response를 리턴
276
+ ****************************************************************
277
+ * @param {String} url
278
+ * @param {Object} bodyObj
279
+ * @param {Boolean} responseJson 응답 JSON을 받을 지 여부
280
+ * @returns response 리턴
281
+ */
282
+ static async restCallDelete(url, bodyObj, responseJson) {
283
+ try {
284
+ increaseActiveRequestCounter()
285
+
286
+ const bodyStr = typeof bodyObj === 'string' ? bodyObj : JSON.stringify(bodyObj)
287
+ const res = await fetch(url, {
288
+ method: 'DELETE',
289
+ headers: {
290
+ 'Content-type': 'application/json',
291
+ Accept: 'application/json',
292
+ 'x-locale': currentLocale()
293
+ },
294
+ body: bodyStr
295
+ })
296
+
297
+ const resJson = responseJson ? responseJson : false
298
+ return await checkResponse(res, resJson)
299
+ } finally {
300
+ decreaseActiveRequestCounter()
301
+ }
302
+ }
303
+
304
+ /**
305
+ * @description response 상태 체크 후 에러이면 에러 메시지 표시
306
+ *******************************************************
307
+ * @param {Object} res
308
+ * @param {Boolean} responseJson
309
+ */
310
+ static async checkResponse(res, responseJson) {
311
+ if (res && res.status && res.status >= 400) {
312
+ try {
313
+ let isJson = await res.json ? true : false;
314
+ let errData = isJson ? await res.json() : await res.text();
315
+ let errMsg = (typeof errData == 'string') ?
316
+ errData :
317
+ (errData.code && errData.msg ? `${errData.code} - ${errData.msg}` : TermsUtil.tText('unexpected_server_error'))
318
+
319
+ await UiUtil.showAlertPopup('title.error', errMsg, 'error', 'confirm')
320
+ return errData;
321
+ } catch (err) {
322
+ console.log(err)
323
+ }
324
+ } else {
325
+ return responseJson === true && res.json ? await res.json() : res
326
+ }
327
+ }
328
+ }