@things-factory/meta-ui 7.0.1-alpha.86 → 7.0.1-alpha.87

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.
@@ -1,11 +1,15 @@
1
1
  import '@material/web/icon/icon.js'
2
2
  import '@things-factory/form-ui'
3
3
 
4
+ import gql from 'graphql-tag'
4
5
  import { html } from 'lit'
6
+ import { customElement, property, state, query } from 'lit/decorators.js'
5
7
 
6
8
  import { PageView } from '@operato/shell'
9
+ import { client } from '@operato/graphql'
7
10
  import { i18next, localize } from '@operato/i18n'
8
11
  import { p13n } from '@operato/p13n'
12
+ import { OxFiltersFormBase } from '@operato/form'
9
13
 
10
14
  import { TermsUtil } from './../../utils/terms-util'
11
15
  import { MetaApi } from '../../utils/meta-api'
@@ -14,22 +18,22 @@ import './dynamic-menu-template.js'
14
18
  import './export-menu-popup.js'
15
19
  import { ValueUtil } from '../../utils/value-util'
16
20
  import { UiUtil } from '../../utils/ui-util'
21
+ import { DataGrist, FetchOption } from '@operato/data-grist'
17
22
 
18
- class DynamicMenu extends p13n(localize(i18next)(PageView)) {
19
- static get properties() {
20
- return {
21
- searchFields: Array,
22
- groupConfig: Object,
23
- detailConfig: Object,
24
- menuGroupId: String
25
- }
26
- }
23
+ @customElement('dynamic-menu')
24
+ export class DynamicMenu extends p13n(localize(i18next)(PageView)) {
25
+ static styles = [...MetaApi.getBasicMasterDetailGristStyle('top-down')]
27
26
 
28
- static get styles() {
29
- return MetaApi.getBasicMasterDetailGristStyle('top-down')
30
- }
27
+ @state() searchFields?: string[]
28
+ @state() groupConfig: any
29
+ @state() detailConfig: any
30
+
31
+ @query('ox-filters-form-base') searchForm!: OxFiltersFormBase
32
+ @query('#master-grist') groupGrist!: DataGrist
33
+ @query('#detail-grist') detailGrist!: DataGrist
34
+
35
+ private menuGroupId?: string
31
36
 
32
- // 화면
33
37
  render() {
34
38
  return html`
35
39
  <div slot="headroom" class="header">
@@ -52,9 +56,8 @@ class DynamicMenu extends p13n(localize(i18next)(PageView)) {
52
56
  id="master-grist"
53
57
  .config=${this.groupConfig}
54
58
  .mode=${MetaApi.isMobileEnv() ? 'LIST' : 'GRID'}
55
- .personalConfigProvider=${this.getPagePreferenceProvider('master-grist')}
59
+ .personalConfigProvider=${this.getPagePreferenceProvider('master-grist')!}
56
60
  .fetchHandler=${this.fetchGroupHandler.bind(this)}
57
- auto-fetch
58
61
  >
59
62
  <ox-grist-personalizer slot="setting"></ox-grist-personalizer>
60
63
  </ox-grist>
@@ -72,7 +75,7 @@ class DynamicMenu extends p13n(localize(i18next)(PageView)) {
72
75
  .config=${this.detailConfig}
73
76
  .mode=${MetaApi.isMobileEnv() ? 'LIST' : 'GRID'}
74
77
  .fetchHandler=${this.fetchDetailHandler.bind(this)}
75
- .personalConfigProvider=${this.getPagePreferenceProvider('detail-grist')}
78
+ .personalConfigProvider=${this.getPagePreferenceProvider('detail-grist')!}
76
79
  explcit-fetch
77
80
  >
78
81
  <ox-grist-personalizer slot="setting"></ox-grist-personalizer>
@@ -95,24 +98,6 @@ class DynamicMenu extends p13n(localize(i18next)(PageView)) {
95
98
  }
96
99
  }
97
100
 
98
- get searchForm() {
99
- return this.shadowRoot.querySelector('ox-filters-form-base')
100
- }
101
-
102
- /**
103
- * 메뉴 그룹 그리드
104
- */
105
- get groupGrist() {
106
- return this.shadowRoot.querySelector('#master-grist')
107
- }
108
-
109
- /**
110
- * 메뉴 그룹에 포함 된 메뉴 그리드
111
- */
112
- get detailGrist() {
113
- return this.shadowRoot.querySelector('#detail-grist')
114
- }
115
-
116
101
  /*******************************************/
117
102
  /* 조회 */
118
103
  /*******************************************/
@@ -122,7 +107,7 @@ class DynamicMenu extends p13n(localize(i18next)(PageView)) {
122
107
  *********************************
123
108
  * @param {Object} param0
124
109
  */
125
- async fetchDetailHandler({ page, limit = 999999, sorters = [{ name: 'rank' }, { name: 'name' }] }) {
110
+ async fetchDetailHandler({ page, limit = 999999, sorters = [{ name: 'rank' }, { name: 'name' }] }: FetchOption) {
126
111
  if (this.menuGroupId) {
127
112
  let filters = [
128
113
  {
@@ -177,12 +162,12 @@ class DynamicMenu extends p13n(localize(i18next)(PageView)) {
177
162
  * @param {Object} param0
178
163
  * @returns
179
164
  */
180
- async fetchGroupHandler({ page, limit = 999999, sorters = [{ name: 'rank' }, { name: 'name' }] }) {
165
+ async fetchGroupHandler({ page, limit = 999999, sorters = [{ name: 'rank' }, { name: 'name' }] }: FetchOption) {
181
166
  // 선택된 부모 메뉴 ID 초기화
182
- this.menuGroupId = null
167
+ this.menuGroupId = ''
183
168
 
184
169
  if (this.detailGrist && this.detailGrist.data) {
185
- this.detailGrist.data = {}
170
+ this.detailGrist.data = { records: [] }
186
171
  }
187
172
 
188
173
  let filters = [...(await this.searchForm.getQueryFilters()), { name: 'parentId', operator: 'is_null', value: '' }]
@@ -288,10 +273,10 @@ class DynamicMenu extends p13n(localize(i18next)(PageView)) {
288
273
  patch.parent = { id: this.menuGroupId }
289
274
  } else {
290
275
  patch.parent = { id: patch.parentId }
291
-
292
- delete patch.parentId
293
276
  }
294
277
 
278
+ delete patch.parentId
279
+
295
280
  if (patch.hiddenFlag === undefined || patch.hiddenFlag == null) {
296
281
  patch.hiddenFlag = false
297
282
  }
@@ -301,18 +286,36 @@ class DynamicMenu extends p13n(localize(i18next)(PageView)) {
301
286
  return patch
302
287
  })
303
288
 
304
- let result = await MetaApi.updateMultiple('updateMultipleMenu', patches)
305
- if (result) {
306
- this.detailGrist.fetch()
289
+ const response = await client.mutate({
290
+ mutation: gql`
291
+ mutation UpdateMultipleMenu($patches: [MenuPatch!]!) {
292
+ updateMultipleMenu(patches: $patches) {
293
+ id
294
+ }
295
+ }
296
+ `,
297
+ variables: {
298
+ patches
299
+ }
300
+ })
301
+
302
+ if (!response.errors) {
303
+ const result = response.data.updateMultipleMenu
304
+
305
+ if (result) {
306
+ this.detailGrist.fetch()
307
+ }
307
308
  }
308
309
  }
309
310
  }
310
311
 
311
312
  async exportMenu(record) {
312
313
  let exportMenuElement = MetaApi.createCustomElement('export-menu-popup', 'export-menu-popup')
314
+
313
315
  exportMenuElement.title = TermsUtil.tLabel('export')
314
- exportMenuElement.recordId = record.id
315
- exportMenuElement.recordName = record.name
316
+ ;(exportMenuElement as any).recordId = record.id
317
+ ;(exportMenuElement as any).recordName = record.name
318
+
316
319
  await MetaApi.openPopupByElement(record.name, 'large', exportMenuElement, true)
317
320
  }
318
321
 
@@ -376,8 +379,10 @@ class DynamicMenu extends p13n(localize(i18next)(PageView)) {
376
379
  */
377
380
  async openMenuTemplatePopup(record) {
378
381
  let menuTemplateElement = MetaApi.createCustomElement('dynamic-menu-template', 'dynamic-menu-template')
382
+
379
383
  menuTemplateElement.title = TermsUtil.tLabel('template')
380
- menuTemplateElement.recordId = record.id
384
+ ;(menuTemplateElement as any).recordId = record.id
385
+
381
386
  await MetaApi.openPopupByElement(record.name, 'large', menuTemplateElement, true)
382
387
  }
383
388
 
@@ -733,5 +738,3 @@ class DynamicMenu extends p13n(localize(i18next)(PageView)) {
733
738
  }
734
739
  }
735
740
  }
736
-
737
- customElements.define('dynamic-menu', DynamicMenu)
@@ -94,7 +94,7 @@ export class MetaApi {
94
94
  *************************************************
95
95
  * @param {String} popupTitle 팝업 타이틀
96
96
  * @param {String} popupSize 팝업 사이즈 ex) 'large', 'medium', 'small'
97
- * @param {String} element 팝업에 표시할 엘리먼트 HTML 문자열
97
+ * @param {HTMLElement} element 팝업에 표시할 엘리먼트 HTMLElement
98
98
  * @param {Boolean} backdrop 백드롭 여부
99
99
  * @returns {Object} 팝업 객체
100
100
  */
@@ -139,7 +139,7 @@ export class MetaApi {
139
139
  * @description 페이지 이동
140
140
  **************************************
141
141
  * @param {String} url 페이지 URL (route 값)
142
- * @param {Object} params 페이지 파라미터, null 가능
142
+ * @param {Object} [params] 페이지 파라미터, null 가능
143
143
  */
144
144
  static pageNavigate(url, params) {
145
145
  UiUtil.pageNavigate(url, params)
@@ -270,7 +270,7 @@ export class MetaApi {
270
270
  * @param {String} queryFunc 쿼리 함수
271
271
  * @param {Array} filters 조회 조건
272
272
  * @param {Array} sortings 소팅 조건
273
- * @param {Number} page 현재 페이지
273
+ * @param {Number|undefined} page 현재 페이지
274
274
  * @param {Number} limit 페이지 당 표시할 레코드 건수
275
275
  * @param {String} selectFields 조회할 필드 리스트
276
276
  * @returns {FetchResult} 조회 결과 { records : [{,...}], total : 100 }
@@ -611,7 +611,7 @@ export class MetaApi {
611
611
  * @param {String} type 검색 편집기 유형
612
612
  * @param {String} label 검색 필드 라벨명
613
613
  * @param {String} operator 검색 연산자
614
- * @param {Array} optionValues 옵션 값
614
+ * @param {Array} [optionValues] 옵션 값
615
615
  * @returns {Object} 그리스트 검색 편집기 설정
616
616
  */
617
617
  static getGristSearchColumnConfig(name, type, label, operator, optionValues) {
@@ -523,12 +523,12 @@ export class ServiceUtil {
523
523
  * @param {String} queryFunc 쿼리 함수
524
524
  * @param {Array} filters 조회 조건
525
525
  * @param {Array} sortings 소팅 조건
526
- * @param {Number} page 현재 페이지
526
+ * @param {Number|undefined} page 현재 페이지
527
527
  * @param {Number} limit 페이지 당 표시할 레코드 건수
528
528
  * @param {String} selectFields 조회할 필드 리스트
529
529
  * @returns {Array} 조회 결과 { records : [{...}], total : 100 }
530
530
  */
531
- static async searchByPagination(queryFunc, filters, sortings, page, limit, selectFields) {
531
+ static async searchByPagination(queryFunc, filters, sortings, page = 1, limit, selectFields) {
532
532
  try {
533
533
  const response = await client.query({
534
534
  query: gql`
@@ -73,7 +73,7 @@ export class UiUtil {
73
73
  *************************************************
74
74
  * @param {String} popupTitle 팝업 타이틀
75
75
  * @param {String} popupSize 팝업 사이즈 ex) 'large', 'medium', 'small'
76
- * @param {String} element 팝업에 표시할 엘리먼트
76
+ * @param {HTMLElement} element 팝업에 표시할 엘리먼트
77
77
  * @param {Boolean} backdrop 백드롭 여부
78
78
  * @returns {Object} popup
79
79
  */
@@ -101,7 +101,9 @@ export class UiUtil {
101
101
  */
102
102
  static async openDynamicPopup(title, popupConfig, paramData, popupCloseCallback) {
103
103
  // 부모 필드
104
- let parentValue = ValueUtil.isNotEmpty(popupConfig.parent_field) ? ValueUtil.getParams(paramData, ...popupConfig.parent_field.split('.')) : undefined
104
+ let parentValue = ValueUtil.isNotEmpty(popupConfig.parent_field)
105
+ ? ValueUtil.getParams(paramData, ...popupConfig.parent_field.split('.'))
106
+ : undefined
105
107
 
106
108
  // 팝업 엘리먼트 생성
107
109
  let htmlText = `<${popupConfig.tagname} route_name='${popupConfig.menu}' parent_id='${parentValue}' is_popup=true></${popupConfig.tagname}>`
@@ -222,7 +224,7 @@ export class UiUtil {
222
224
  * @param {String} textCode Alert 텍스트 표시를 위한 용어 이름 예) text.are_you_sure
223
225
  * @param {String} type Alert 창 유형 - info, error, warning ...
224
226
  * @param {String} confirmButtonCode 확인 버튼 표시를 위한 용어 이름 예) confirm
225
- * @param {String} cancelButtonCode 취소 버튼 표시를 위한 용어 이름 예) cancel
227
+ * @param {String} [cancelButtonCode] 취소 버튼 표시를 위한 용어 이름 예) cancel
226
228
  * @returns {Object} Alert 팝업
227
229
  */
228
230
  static async showAlertPopup(titleCode, textCode, type, confirmButtonCode, cancelButtonCode) {
@@ -1 +1,84 @@
1
+ import '@material/web/icon/icon.js';
2
+ import '@things-factory/form-ui';
3
+ import { PageView } from '@operato/shell';
4
+ import { OxFiltersFormBase } from '@operato/form';
5
+ import './dynamic-menu-template.js';
6
+ import './export-menu-popup.js';
7
+ import { DataGrist, FetchOption } from '@operato/data-grist';
8
+ declare const DynamicMenu_base: (new (...args: any[]) => {
9
+ getPagePreferenceProvider(element: string): {
10
+ load: () => Promise<any>;
11
+ save: (preference: any) => Promise<any>;
12
+ reset: () => Promise<void>;
13
+ } | undefined;
14
+ }) & (new (...args: any[]) => import("lit").LitElement) & typeof PageView;
15
+ export declare class DynamicMenu extends DynamicMenu_base {
16
+ static styles: any[];
17
+ searchFields?: string[];
18
+ groupConfig: any;
19
+ detailConfig: any;
20
+ searchForm: OxFiltersFormBase;
21
+ groupGrist: DataGrist;
22
+ detailGrist: DataGrist;
23
+ private menuGroupId?;
24
+ render(): import("lit").TemplateResult<1>;
25
+ get context(): {
26
+ title: string;
27
+ };
28
+ /*******************************************/
29
+ /*******************************************/
30
+ /**
31
+ * @description 부모 메뉴 (메뉴 그룹) 선택시 하위 메뉴 리스트 조회
32
+ *********************************
33
+ * @param {Object} param0
34
+ */
35
+ fetchDetailHandler({ page, limit, sorters }: FetchOption): Promise<any>;
36
+ /**
37
+ * @description 부모 메뉴 (메뉴 그룹) 조회
38
+ ****************************************
39
+ * @param {Object} param0
40
+ * @returns
41
+ */
42
+ fetchGroupHandler({ page, limit, sorters }: FetchOption): Promise<FetchResult>;
43
+ /*******************************************/
44
+ /*******************************************/
45
+ /**
46
+ * 메뉴 그룹 Create / Update
47
+ */
48
+ saveGroup(): Promise<void>;
49
+ /**
50
+ * 메뉴 그룹 Delete
51
+ * @returns
52
+ */
53
+ deleteGroup(): Promise<void>;
54
+ /**
55
+ * 메뉴 Create / Update
56
+ */
57
+ saveMenu(): Promise<void>;
58
+ exportMenu(record: any): Promise<void>;
59
+ /**
60
+ * 메뉴 Delete
61
+ * @returns
62
+ */
63
+ deleteMenu(): Promise<void>;
64
+ /**
65
+ * 메뉴 복사
66
+ */
67
+ copyMenu(): Promise<void>;
68
+ groupMenuQuery(record: any): void;
69
+ /**
70
+ * 메뉴 템플릿을 편집 할 수 있는 팝업을 오픈한다.
71
+ * @param {Object} record
72
+ */
73
+ openMenuTemplatePopup(record: any): Promise<void>;
74
+ /**
75
+ * 메뉴 템플릿을 생성 할 수 있는 화면으로 이동한다.
76
+ * @param {Object} record
77
+ */
78
+ navigateMetaGenerator(record: any): void;
79
+ /**
80
+ * LifeCycle - 화면 레더링 설정
81
+ */
82
+ pageInitialized(lifecycle: any): Promise<void>;
83
+ }
1
84
  export {};
@@ -1,29 +1,22 @@
1
- import { __rest } from "tslib";
1
+ import { __decorate, __metadata, __rest } from "tslib";
2
2
  import '@material/web/icon/icon.js';
3
3
  import '@things-factory/form-ui';
4
+ import gql from 'graphql-tag';
4
5
  import { html } from 'lit';
6
+ import { customElement, state, query } from 'lit/decorators.js';
5
7
  import { PageView } from '@operato/shell';
8
+ import { client } from '@operato/graphql';
6
9
  import { i18next, localize } from '@operato/i18n';
7
10
  import { p13n } from '@operato/p13n';
11
+ import { OxFiltersFormBase } from '@operato/form';
8
12
  import { TermsUtil } from './../../utils/terms-util';
9
13
  import { MetaApi } from '../../utils/meta-api';
10
14
  import './dynamic-menu-template.js';
11
15
  import './export-menu-popup.js';
12
16
  import { ValueUtil } from '../../utils/value-util';
13
17
  import { UiUtil } from '../../utils/ui-util';
14
- class DynamicMenu extends p13n(localize(i18next)(PageView)) {
15
- static get properties() {
16
- return {
17
- searchFields: Array,
18
- groupConfig: Object,
19
- detailConfig: Object,
20
- menuGroupId: String
21
- };
22
- }
23
- static get styles() {
24
- return MetaApi.getBasicMasterDetailGristStyle('top-down');
25
- }
26
- // 화면
18
+ import { DataGrist } from '@operato/data-grist';
19
+ let DynamicMenu = class DynamicMenu extends p13n(localize(i18next)(PageView)) {
27
20
  render() {
28
21
  return html `
29
22
  <div slot="headroom" class="header">
@@ -49,7 +42,6 @@ class DynamicMenu extends p13n(localize(i18next)(PageView)) {
49
42
  .mode=${MetaApi.isMobileEnv() ? 'LIST' : 'GRID'}
50
43
  .personalConfigProvider=${this.getPagePreferenceProvider('master-grist')}
51
44
  .fetchHandler=${this.fetchGroupHandler.bind(this)}
52
- auto-fetch
53
45
  >
54
46
  <ox-grist-personalizer slot="setting"></ox-grist-personalizer>
55
47
  </ox-grist>
@@ -88,21 +80,6 @@ class DynamicMenu extends p13n(localize(i18next)(PageView)) {
88
80
  title: TermsUtil.tTitle('dynamic_menu')
89
81
  };
90
82
  }
91
- get searchForm() {
92
- return this.shadowRoot.querySelector('ox-filters-form-base');
93
- }
94
- /**
95
- * 메뉴 그룹 그리드
96
- */
97
- get groupGrist() {
98
- return this.shadowRoot.querySelector('#master-grist');
99
- }
100
- /**
101
- * 메뉴 그룹에 포함 된 메뉴 그리드
102
- */
103
- get detailGrist() {
104
- return this.shadowRoot.querySelector('#detail-grist');
105
- }
106
83
  /*******************************************/
107
84
  /* 조회 */
108
85
  /*******************************************/
@@ -163,9 +140,9 @@ class DynamicMenu extends p13n(localize(i18next)(PageView)) {
163
140
  */
164
141
  async fetchGroupHandler({ page, limit = 999999, sorters = [{ name: 'rank' }, { name: 'name' }] }) {
165
142
  // 선택된 부모 메뉴 ID 초기화
166
- this.menuGroupId = null;
143
+ this.menuGroupId = '';
167
144
  if (this.detailGrist && this.detailGrist.data) {
168
- this.detailGrist.data = {};
145
+ this.detailGrist.data = { records: [] };
169
146
  }
170
147
  let filters = [...(await this.searchForm.getQueryFilters()), { name: 'parentId', operator: 'is_null', value: '' }];
171
148
  let selectFields = `
@@ -235,17 +212,31 @@ class DynamicMenu extends p13n(localize(i18next)(PageView)) {
235
212
  }
236
213
  else {
237
214
  patch.parent = { id: patch.parentId };
238
- delete patch.parentId;
239
215
  }
216
+ delete patch.parentId;
240
217
  if (patch.hiddenFlag === undefined || patch.hiddenFlag == null) {
241
218
  patch.hiddenFlag = false;
242
219
  }
243
220
  patch.cuFlag = __dirty__;
244
221
  return patch;
245
222
  });
246
- let result = await MetaApi.updateMultiple('updateMultipleMenu', patches);
247
- if (result) {
248
- this.detailGrist.fetch();
223
+ const response = await client.mutate({
224
+ mutation: gql `
225
+ mutation UpdateMultipleMenu($patches: [MenuPatch!]!) {
226
+ updateMultipleMenu(patches: $patches) {
227
+ id
228
+ }
229
+ }
230
+ `,
231
+ variables: {
232
+ patches
233
+ }
234
+ });
235
+ if (!response.errors) {
236
+ const result = response.data.updateMultipleMenu;
237
+ if (result) {
238
+ this.detailGrist.fetch();
239
+ }
249
240
  }
250
241
  }
251
242
  }
@@ -635,6 +626,34 @@ class DynamicMenu extends p13n(localize(i18next)(PageView)) {
635
626
  ]
636
627
  };
637
628
  }
638
- }
639
- customElements.define('dynamic-menu', DynamicMenu);
629
+ };
630
+ DynamicMenu.styles = [...MetaApi.getBasicMasterDetailGristStyle('top-down')];
631
+ __decorate([
632
+ state(),
633
+ __metadata("design:type", Array)
634
+ ], DynamicMenu.prototype, "searchFields", void 0);
635
+ __decorate([
636
+ state(),
637
+ __metadata("design:type", Object)
638
+ ], DynamicMenu.prototype, "groupConfig", void 0);
639
+ __decorate([
640
+ state(),
641
+ __metadata("design:type", Object)
642
+ ], DynamicMenu.prototype, "detailConfig", void 0);
643
+ __decorate([
644
+ query('ox-filters-form-base'),
645
+ __metadata("design:type", OxFiltersFormBase)
646
+ ], DynamicMenu.prototype, "searchForm", void 0);
647
+ __decorate([
648
+ query('#master-grist'),
649
+ __metadata("design:type", DataGrist)
650
+ ], DynamicMenu.prototype, "groupGrist", void 0);
651
+ __decorate([
652
+ query('#detail-grist'),
653
+ __metadata("design:type", DataGrist)
654
+ ], DynamicMenu.prototype, "detailGrist", void 0);
655
+ DynamicMenu = __decorate([
656
+ customElement('dynamic-menu')
657
+ ], DynamicMenu);
658
+ export { DynamicMenu };
640
659
  //# sourceMappingURL=dynamic-menu.js.map