@things-factory/organization 6.1.189 → 6.1.191
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist-client/component/approval-line-templates-manager.d.ts +33 -0
- package/dist-client/component/approval-line-templates-manager.js +219 -0
- package/dist-client/component/approval-line-templates-manager.js.map +1 -0
- package/dist-client/tsconfig.tsbuildinfo +1 -1
- package/dist-server/tsconfig.tsbuildinfo +1 -1
- package/package.json +5 -5
- /package/client/component/{approval-line-templates-/bmanager.ts" → approval-line-templates-manager.ts} +0 -0
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { LitElement } from 'lit';
|
|
2
|
+
import { ApprovalLine, ApprovalLineItem } from '../types/approval-line';
|
|
3
|
+
declare const ApprovalLineTemplatesManager_base: (new (...args: any[]) => LitElement) & typeof LitElement;
|
|
4
|
+
/**
|
|
5
|
+
* 결재선 관리를 위해서
|
|
6
|
+
* 1. 결재선 리스트를 조회한다.
|
|
7
|
+
* 2. 결재선을 생성, 삭제, 수정한다.
|
|
8
|
+
*/
|
|
9
|
+
export declare class ApprovalLineTemplatesManager extends ApprovalLineTemplatesManager_base {
|
|
10
|
+
static styles: import("lit").CSSResult[];
|
|
11
|
+
gristConfig?: any;
|
|
12
|
+
approvalLine?: ApprovalLine;
|
|
13
|
+
grist?: HTMLElement & {
|
|
14
|
+
fetch: any;
|
|
15
|
+
commit: any;
|
|
16
|
+
deleteSelectedRecords: any;
|
|
17
|
+
data: any;
|
|
18
|
+
};
|
|
19
|
+
render(): import("lit-html").TemplateResult<1>;
|
|
20
|
+
firstUpdated(): Promise<void>;
|
|
21
|
+
fetchHandler({ filters, page, limit, sortings }: {
|
|
22
|
+
filters: any;
|
|
23
|
+
page: any;
|
|
24
|
+
limit: any;
|
|
25
|
+
sortings?: never[] | undefined;
|
|
26
|
+
}): Promise<{
|
|
27
|
+
total: number;
|
|
28
|
+
records: ApprovalLineItem[];
|
|
29
|
+
}>;
|
|
30
|
+
_updateDataItems(): Promise<void>;
|
|
31
|
+
_deleteDataItems(): Promise<void>;
|
|
32
|
+
}
|
|
33
|
+
export {};
|
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
import { __decorate, __metadata } from "tslib";
|
|
2
|
+
import gql from 'graphql-tag';
|
|
3
|
+
import { css, html, LitElement } from 'lit';
|
|
4
|
+
import { customElement, property, query } from 'lit/decorators.js';
|
|
5
|
+
import { client } from '@operato/graphql';
|
|
6
|
+
import { i18next, localize } from '@operato/i18n';
|
|
7
|
+
import { getEditor, getRenderer } from '@operato/data-grist';
|
|
8
|
+
import { isMobileDevice } from '@operato/utils';
|
|
9
|
+
import { ButtonContainerStyles } from '@operato/styles';
|
|
10
|
+
import { ApprovalLine } from '../types/approval-line';
|
|
11
|
+
/**
|
|
12
|
+
* 결재선 관리를 위해서
|
|
13
|
+
* 1. 결재선 리스트를 조회한다.
|
|
14
|
+
* 2. 결재선을 생성, 삭제, 수정한다.
|
|
15
|
+
*/
|
|
16
|
+
let ApprovalLineTemplatesManager = class ApprovalLineTemplatesManager extends localize(i18next)(LitElement) {
|
|
17
|
+
render() {
|
|
18
|
+
return html `
|
|
19
|
+
<ox-grist
|
|
20
|
+
.mode=${isMobileDevice() ? 'CARD' : 'GRID'}
|
|
21
|
+
.config=${this.gristConfig}
|
|
22
|
+
.fetchHandler=${this.fetchHandler.bind(this)}
|
|
23
|
+
></ox-grist>
|
|
24
|
+
<div class="button-container">
|
|
25
|
+
<mwc-button raised danger @click=${this._deleteDataItems.bind(this)}>${i18next.t('button.delete')}</mwc-button>
|
|
26
|
+
<mwc-button raised @click=${this._updateDataItems.bind(this)}>${i18next.t('button.save')}</mwc-button>
|
|
27
|
+
</div>
|
|
28
|
+
`;
|
|
29
|
+
}
|
|
30
|
+
async firstUpdated() {
|
|
31
|
+
this.gristConfig = {
|
|
32
|
+
list: {
|
|
33
|
+
fields: ['name', 'description', 'active']
|
|
34
|
+
},
|
|
35
|
+
columns: [
|
|
36
|
+
{ type: 'gutter', gutterName: 'row-selector', multiple: true },
|
|
37
|
+
{ type: 'gutter', gutterName: 'sequence' },
|
|
38
|
+
{
|
|
39
|
+
type: 'gutter',
|
|
40
|
+
gutterName: 'button',
|
|
41
|
+
icon: 'arrow_upward',
|
|
42
|
+
handlers: {
|
|
43
|
+
click: 'move-up'
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
type: 'gutter',
|
|
48
|
+
gutterName: 'button',
|
|
49
|
+
icon: 'arrow_downward',
|
|
50
|
+
handlers: {
|
|
51
|
+
click: 'move-down'
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
type: 'select',
|
|
56
|
+
name: 'type',
|
|
57
|
+
header: i18next.t('field.type'),
|
|
58
|
+
record: {
|
|
59
|
+
editable: true,
|
|
60
|
+
options: ['', 'Employee', 'Department', 'Role']
|
|
61
|
+
},
|
|
62
|
+
width: 140
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
type: 'resource-object',
|
|
66
|
+
name: 'approver',
|
|
67
|
+
header: i18next.t('field.approver'),
|
|
68
|
+
record: {
|
|
69
|
+
editable: true,
|
|
70
|
+
editor: function (value, column, record, rowIndex, field) {
|
|
71
|
+
var options = {};
|
|
72
|
+
switch (record.type) {
|
|
73
|
+
case 'Employee':
|
|
74
|
+
options = {
|
|
75
|
+
title: i18next.t('title.employee list'),
|
|
76
|
+
queryName: 'employees',
|
|
77
|
+
columns: [
|
|
78
|
+
{ name: 'id', hidden: true },
|
|
79
|
+
{
|
|
80
|
+
name: 'controlNo',
|
|
81
|
+
header: { renderer: () => i18next.t('field.control-no') },
|
|
82
|
+
filter: 'search'
|
|
83
|
+
},
|
|
84
|
+
{ name: 'name', header: { renderer: () => i18next.t('field.name') }, filter: 'search' }
|
|
85
|
+
],
|
|
86
|
+
list: { fields: ['name', 'control-no'] },
|
|
87
|
+
valueField: 'id',
|
|
88
|
+
nameField: 'name',
|
|
89
|
+
descriptionField: 'controlNo'
|
|
90
|
+
};
|
|
91
|
+
break;
|
|
92
|
+
case 'Department':
|
|
93
|
+
options = {
|
|
94
|
+
title: i18next.t('title.department list'),
|
|
95
|
+
queryName: 'departments'
|
|
96
|
+
};
|
|
97
|
+
break;
|
|
98
|
+
case 'Role':
|
|
99
|
+
options = {
|
|
100
|
+
title: i18next.t('title.lookup role'),
|
|
101
|
+
queryName: 'roles'
|
|
102
|
+
};
|
|
103
|
+
break;
|
|
104
|
+
default:
|
|
105
|
+
options = {};
|
|
106
|
+
}
|
|
107
|
+
var dynamicRecord = Object.assign(Object.assign({}, column.record), { options });
|
|
108
|
+
return getEditor(column.type)(value, Object.assign(Object.assign({}, column), { record: dynamicRecord }), record, rowIndex, field);
|
|
109
|
+
},
|
|
110
|
+
renderer: function (value, column, record, rowIndex, field) {
|
|
111
|
+
var options = {};
|
|
112
|
+
switch (record.type) {
|
|
113
|
+
case 'Employee':
|
|
114
|
+
options = {
|
|
115
|
+
valueField: 'id',
|
|
116
|
+
nameField: 'name',
|
|
117
|
+
descriptionField: 'controlNo'
|
|
118
|
+
};
|
|
119
|
+
break;
|
|
120
|
+
case 'Department':
|
|
121
|
+
case 'Role':
|
|
122
|
+
default:
|
|
123
|
+
break;
|
|
124
|
+
}
|
|
125
|
+
var dynamicRecord = Object.assign(Object.assign({}, column.record), { options });
|
|
126
|
+
return getRenderer(column.type)(value, Object.assign(Object.assign({}, column), { record: dynamicRecord }), record, rowIndex, field);
|
|
127
|
+
}
|
|
128
|
+
},
|
|
129
|
+
width: 180
|
|
130
|
+
}
|
|
131
|
+
],
|
|
132
|
+
rows: {
|
|
133
|
+
selectable: {
|
|
134
|
+
multiple: true
|
|
135
|
+
}
|
|
136
|
+
},
|
|
137
|
+
pagination: {
|
|
138
|
+
infinite: true
|
|
139
|
+
},
|
|
140
|
+
sorters: []
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
async fetchHandler({ filters, page, limit, sortings = [] }) {
|
|
144
|
+
var _a;
|
|
145
|
+
const model = ((_a = this.approvalLine) === null || _a === void 0 ? void 0 : _a.model) || [];
|
|
146
|
+
return {
|
|
147
|
+
total: model.length,
|
|
148
|
+
records: model
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
async _updateDataItems() {
|
|
152
|
+
var _a, _b;
|
|
153
|
+
(_a = this.grist) === null || _a === void 0 ? void 0 : _a.commit();
|
|
154
|
+
const response = await client.mutate({
|
|
155
|
+
mutation: gql `
|
|
156
|
+
mutation ($id: String!, $patch: ApprovalLinePatch!) {
|
|
157
|
+
updateApprovalLine(id: $id, patch: $patch) {
|
|
158
|
+
name
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
`,
|
|
162
|
+
variables: {
|
|
163
|
+
id: this.approvalLine.id,
|
|
164
|
+
patch: {
|
|
165
|
+
model: (_b = this.grist) === null || _b === void 0 ? void 0 : _b.data.records,
|
|
166
|
+
cuFlag: 'M'
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
});
|
|
170
|
+
if (!response.errors) {
|
|
171
|
+
await document.dispatchEvent(new CustomEvent('notify', {
|
|
172
|
+
detail: {
|
|
173
|
+
message: i18next.t('text.info_x_successfully', {
|
|
174
|
+
x: i18next.t('button.save')
|
|
175
|
+
})
|
|
176
|
+
}
|
|
177
|
+
}));
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
async _deleteDataItems() {
|
|
181
|
+
var _a;
|
|
182
|
+
if (!confirm(i18next.t('text.sure_to_x', { x: i18next.t('text.delete') }))) {
|
|
183
|
+
return;
|
|
184
|
+
}
|
|
185
|
+
(_a = this.grist) === null || _a === void 0 ? void 0 : _a.deleteSelectedRecords(false);
|
|
186
|
+
}
|
|
187
|
+
};
|
|
188
|
+
ApprovalLineTemplatesManager.styles = [
|
|
189
|
+
ButtonContainerStyles,
|
|
190
|
+
css `
|
|
191
|
+
:host {
|
|
192
|
+
display: flex;
|
|
193
|
+
flex-direction: column;
|
|
194
|
+
|
|
195
|
+
background-color: #fff;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
ox-grist {
|
|
199
|
+
flex: 1;
|
|
200
|
+
}
|
|
201
|
+
`
|
|
202
|
+
];
|
|
203
|
+
__decorate([
|
|
204
|
+
property({ type: Object }),
|
|
205
|
+
__metadata("design:type", Object)
|
|
206
|
+
], ApprovalLineTemplatesManager.prototype, "gristConfig", void 0);
|
|
207
|
+
__decorate([
|
|
208
|
+
property({ type: Object }),
|
|
209
|
+
__metadata("design:type", ApprovalLine)
|
|
210
|
+
], ApprovalLineTemplatesManager.prototype, "approvalLine", void 0);
|
|
211
|
+
__decorate([
|
|
212
|
+
query('ox-grist'),
|
|
213
|
+
__metadata("design:type", Object)
|
|
214
|
+
], ApprovalLineTemplatesManager.prototype, "grist", void 0);
|
|
215
|
+
ApprovalLineTemplatesManager = __decorate([
|
|
216
|
+
customElement('approval-line-templates-manager')
|
|
217
|
+
], ApprovalLineTemplatesManager);
|
|
218
|
+
export { ApprovalLineTemplatesManager };
|
|
219
|
+
//# sourceMappingURL=approval-line-templates-manager.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"approval-line-templates-manager.js","sourceRoot":"","sources":["../../client/component/approval-line-templates-manager.ts"],"names":[],"mappings":";AAAA,OAAO,GAAG,MAAM,aAAa,CAAA;AAC7B,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,KAAK,CAAA;AAC3C,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AAElE,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAA;AACzC,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AACjD,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAA;AAC5D,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAC/C,OAAO,EAAE,qBAAqB,EAAE,MAAM,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,CAAC,CAAC,CAAC,aAAa,CAAC,EAAE,CAAC,CAAC,EAAE;YAC1E,OAAM;SACP;QAED,MAAA,IAAI,CAAC,KAAK,0CAAE,qBAAqB,CAAC,KAAK,CAAC,CAAA;IAC1C,CAAC;;AAzMM,mCAAM,GAAG;IACd,qBAAqB;IACrB,GAAG,CAAA;;;;;;;;;;;KAWF;CACF,CAAA;AAED;IAAC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;iEAAkB;AAC7C;IAAC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;8BAAgB,YAAY;kEAAA;AAEvD;IAAC,KAAK,CAAC,UAAU,CAAC;;2DAAyF;AApBhG,4BAA4B;IADxC,aAAa,CAAC,iCAAiC,CAAC;GACpC,4BAA4B,CA2MxC;SA3MY,4BAA4B","sourcesContent":["import gql from 'graphql-tag'\nimport { css, html, LitElement } from 'lit'\nimport { customElement, property, query } from 'lit/decorators.js'\n\nimport { client } from '@operato/graphql'\nimport { i18next, localize } from '@operato/i18n'\nimport { getEditor, getRenderer } from '@operato/data-grist'\nimport { isMobileDevice } from '@operato/utils'\nimport { ButtonContainerStyles } from '@operato/styles'\n\nimport { ApprovalLine, ApprovalLineItem } from '../types/approval-line'\n\n/**\n * 결재선 관리를 위해서\n * 1. 결재선 리스트를 조회한다.\n * 2. 결재선을 생성, 삭제, 수정한다.\n */\n@customElement('approval-line-templates-manager')\nexport class ApprovalLineTemplatesManager extends localize(i18next)(LitElement) {\n static styles = [\n ButtonContainerStyles,\n css`\n :host {\n display: flex;\n flex-direction: column;\n\n background-color: #fff;\n }\n\n ox-grist {\n flex: 1;\n }\n `\n ]\n\n @property({ type: Object }) gristConfig?: any\n @property({ type: Object }) approvalLine?: ApprovalLine\n\n @query('ox-grist') grist?: HTMLElement & { fetch: any; commit: any; deleteSelectedRecords: any; data: any }\n\n render() {\n return html`\n <ox-grist\n .mode=${isMobileDevice() ? 'CARD' : 'GRID'}\n .config=${this.gristConfig}\n .fetchHandler=${this.fetchHandler.bind(this)}\n ></ox-grist>\n <div class=\"button-container\">\n <mwc-button raised danger @click=${this._deleteDataItems.bind(this)}>${i18next.t('button.delete')}</mwc-button>\n <mwc-button raised @click=${this._updateDataItems.bind(this)}>${i18next.t('button.save')}</mwc-button>\n </div>\n `\n }\n\n async firstUpdated() {\n this.gristConfig = {\n list: {\n fields: ['name', 'description', 'active']\n },\n columns: [\n { type: 'gutter', gutterName: 'row-selector', multiple: true },\n { type: 'gutter', gutterName: 'sequence' },\n {\n type: 'gutter',\n gutterName: 'button',\n icon: 'arrow_upward',\n handlers: {\n click: 'move-up'\n }\n },\n {\n type: 'gutter',\n gutterName: 'button',\n icon: 'arrow_downward',\n handlers: {\n click: 'move-down'\n }\n },\n {\n type: 'select',\n name: 'type',\n header: i18next.t('field.type'),\n record: {\n editable: true,\n options: ['', 'Employee', 'Department', 'Role']\n },\n width: 140\n },\n {\n type: 'resource-object',\n name: 'approver',\n header: i18next.t('field.approver'),\n record: {\n editable: true,\n editor: function (value, column, record, rowIndex, field) {\n var options = {}\n switch (record.type) {\n case 'Employee':\n options = {\n title: i18next.t('title.employee list'),\n queryName: 'employees',\n columns: [\n { name: 'id', hidden: true },\n {\n name: 'controlNo',\n header: { renderer: () => i18next.t('field.control-no') },\n filter: 'search'\n },\n { name: 'name', header: { renderer: () => i18next.t('field.name') }, filter: 'search' }\n ],\n list: { fields: ['name', 'control-no'] },\n valueField: 'id',\n nameField: 'name',\n descriptionField: 'controlNo'\n }\n break\n case 'Department':\n options = {\n title: i18next.t('title.department list'),\n queryName: 'departments'\n }\n break\n case 'Role':\n options = {\n title: i18next.t('title.lookup role'),\n queryName: 'roles'\n }\n break\n default:\n options = {}\n }\n\n var dynamicRecord = { ...column.record, options }\n\n return getEditor(column.type)(value, { ...column, record: dynamicRecord }, record, rowIndex, field)\n },\n renderer: function (value, column, record, rowIndex, field) {\n var options = {}\n switch (record.type) {\n case 'Employee':\n options = {\n valueField: 'id',\n nameField: 'name',\n descriptionField: 'controlNo'\n }\n break\n case 'Department':\n case 'Role':\n default:\n break\n }\n\n var dynamicRecord = { ...column.record, options }\n\n return getRenderer(column.type)(value, { ...column, record: dynamicRecord }, record, rowIndex, field)\n }\n },\n width: 180\n }\n ],\n rows: {\n selectable: {\n multiple: true\n }\n },\n pagination: {\n infinite: true\n },\n sorters: []\n }\n }\n\n async fetchHandler({ filters, page, limit, sortings = [] }) {\n const model = this.approvalLine?.model || []\n\n return {\n total: model.length,\n records: model\n }\n }\n\n async _updateDataItems() {\n this.grist?.commit()\n\n const response = await client.mutate({\n mutation: gql`\n mutation ($id: String!, $patch: ApprovalLinePatch!) {\n updateApprovalLine(id: $id, patch: $patch) {\n name\n }\n }\n `,\n variables: {\n id: this.approvalLine!.id,\n patch: {\n model: this.grist?.data.records,\n cuFlag: 'M'\n }\n }\n })\n\n if (!response.errors) {\n await document.dispatchEvent(\n new CustomEvent('notify', {\n detail: {\n message: i18next.t('text.info_x_successfully', {\n x: i18next.t('button.save')\n })\n }\n })\n )\n }\n }\n\n async _deleteDataItems() {\n if (!confirm(i18next.t('text.sure_to_x', { x: i18next.t('text.delete') }))) {\n return\n }\n\n this.grist?.deleteSelectedRecords(false)\n }\n}\n"]}
|