@things-factory/organization 7.0.63 → 7.0.65

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,13 +1,13 @@
1
1
  import '@operato/data-tree'
2
2
  import '@operato/context/ox-context-page-toolbar.js'
3
3
 
4
- import { CommonHeaderStyles, ScrollbarStyles } from '@operato/styles'
5
- import { CustomAlert, PageView, store } from '@operato/shell'
6
- import { css, html } from 'lit'
4
+ import { css, html, PropertyValues } from 'lit'
7
5
  import { customElement, property, query, state } from 'lit/decorators.js'
8
6
  import { ScopedElementsMixin } from '@open-wc/scoped-elements'
9
7
  import { client } from '@operato/graphql'
10
8
  import { i18next, localize } from '@operato/i18n'
9
+ import { CommonHeaderStyles, ScrollbarStyles } from '@operato/styles'
10
+ import { CustomAlert, PageView, store } from '@operato/shell'
11
11
 
12
12
  import { connect } from 'pwa-helpers/connect-mixin'
13
13
  import gql from 'graphql-tag'
@@ -63,7 +63,7 @@ export class DepartmentTreePage extends connect(store)(localize(i18next)(ScopedE
63
63
  }
64
64
 
65
65
  div[editor] {
66
- width: 260px;
66
+ width: 300px;
67
67
  display: flex;
68
68
  flex-direction: column;
69
69
  }
@@ -79,6 +79,11 @@ export class DepartmentTreePage extends connect(store)(localize(i18next)(ScopedE
79
79
  background-color: var(--md-sys-color-surface-variant);
80
80
  overflow: auto;
81
81
  }
82
+
83
+ .footer button[disabled] {
84
+ color: var(--md-sys-color-surface-dim);
85
+ background-color: transparent;
86
+ }
82
87
  `
83
88
  ]
84
89
 
@@ -90,6 +95,9 @@ export class DepartmentTreePage extends connect(store)(localize(i18next)(ScopedE
90
95
 
91
96
  @state() root?: Department
92
97
  @state() selected?: Department
98
+ @state() department?: Department
99
+ @state() modified: boolean = false
100
+ @state() appendable: boolean = false
93
101
 
94
102
  @query('department-view') departmentView!: DepartmentView
95
103
 
@@ -121,8 +129,6 @@ export class DepartmentTreePage extends connect(store)(localize(i18next)(ScopedE
121
129
  render() {
122
130
  return html`
123
131
  <div class="header">
124
- <div class="title">${i18next.t('title.department list')}</div>
125
-
126
132
  <ox-context-page-toolbar class="actions" .context=${this.context}></ox-context-page-toolbar>
127
133
  </div>
128
134
 
@@ -137,12 +143,22 @@ export class DepartmentTreePage extends connect(store)(localize(i18next)(ScopedE
137
143
  ></ox-tree-vertical>
138
144
 
139
145
  <div editor>
140
- <department-view .department=${this.selected}></department-view>
146
+ <department-view
147
+ .department=${this.department}
148
+ @property-change=${(e: CustomEvent) => {
149
+ const { controlNo, name } = e.detail || {}
150
+
151
+ this.modified = true
152
+ this.appendable = controlNo && controlNo !== this.selected?.controlNo && name !== this.selected?.name
153
+ }}
154
+ ></department-view>
141
155
  <div class="footer">
142
- <div filler></div>
143
156
  <button @click=${this.reset.bind(this)}><md-icon>restart_alt</md-icon>${i18next.t('button.reset')}</button>
144
- <button @click=${this.create.bind(this)}><md-icon>add</md-icon>${i18next.t('button.add')}</button>
145
- <button @click=${this.save.bind(this)} ?disabled=${!!this.selected} done>
157
+ <div filler></div>
158
+ <button @click=${this.create.bind(this)} ?disabled=${!this.appendable}>
159
+ <md-icon>add</md-icon>${i18next.t('button.add')}
160
+ </button>
161
+ <button @click=${this.save.bind(this)} ?disabled=${!this.modified} done>
146
162
  <md-icon>save</md-icon>${i18next.t('button.save')}
147
163
  </button>
148
164
  </div>
@@ -151,6 +167,13 @@ export class DepartmentTreePage extends connect(store)(localize(i18next)(ScopedE
151
167
  `
152
168
  }
153
169
 
170
+ updated(changes: PropertyValues<this>) {
171
+ if (changes.has('selected')) {
172
+ this.modified = false
173
+ this.department = { ...this.selected }
174
+ }
175
+ }
176
+
154
177
  onSelect(e: CustomEvent) {
155
178
  this.selected = e.detail as Department
156
179
  this.updateContext()
@@ -161,8 +184,8 @@ export class DepartmentTreePage extends connect(store)(localize(i18next)(ScopedE
161
184
  }
162
185
 
163
186
  async create() {
164
- const { id: parentId } = this.selected || {}
165
- const { controlNo, name, description, picture, active, manager } = this.departmentView.department
187
+ const { id: parentId } = this.department || {}
188
+ const { controlNo, name, description, picture, active, manager } = this.department || {}
166
189
 
167
190
  var department = {
168
191
  controlNo,
@@ -172,7 +195,7 @@ export class DepartmentTreePage extends connect(store)(localize(i18next)(ScopedE
172
195
  active
173
196
  } as any
174
197
 
175
- if (picture instanceof File) {
198
+ if ((picture as any) instanceof File) {
176
199
  department.picture = picture
177
200
  }
178
201
 
@@ -205,7 +228,7 @@ export class DepartmentTreePage extends connect(store)(localize(i18next)(ScopedE
205
228
  }
206
229
 
207
230
  async save() {
208
- const { id, controlNo, name, description, picture, active, manager } = this.departmentView.department
231
+ const { id, controlNo, name, description, picture, active, manager } = this.department || {}
209
232
 
210
233
  if (!id) {
211
234
  await CustomAlert({
@@ -226,7 +249,7 @@ export class DepartmentTreePage extends connect(store)(localize(i18next)(ScopedE
226
249
  manager
227
250
  } as any
228
251
 
229
- if (picture instanceof File) {
252
+ if ((picture as any) instanceof File) {
230
253
  patch.picture = picture
231
254
  }
232
255
 
@@ -1,6 +1,6 @@
1
1
  import '@operato/data-grist'
2
2
  import '@operato/context/ox-context-page-toolbar.js'
3
- import '@things-factory/contact'
3
+ import '@things-factory/contact/dist-client'
4
4
 
5
5
  import gql from 'graphql-tag'
6
6
  import { css, html } from 'lit'
@@ -19,7 +19,6 @@ import { isMobileDevice } from '@operato/utils'
19
19
  import { p13n } from '@operato/p13n'
20
20
 
21
21
  import { EmployeeImporter } from './employee-importer'
22
- import { ApprovalLineTemplatesManager } from 'component/approval-line-templates-manager'
23
22
 
24
23
  @customElement('employee-list-page')
25
24
  export class EmployeeListPage extends connect(store)(p13n(localize(i18next)(ScopedElementsMixin(PageView)))) {
@@ -134,25 +133,6 @@ export class EmployeeListPage extends connect(store)(p13n(localize(i18next)(Scop
134
133
  columns: [
135
134
  { type: 'gutter', gutterName: 'sequence', fixed: true },
136
135
  { type: 'gutter', gutterName: 'row-selector', multiple: true, fixed: true },
137
- // {
138
- // type: 'gutter',
139
- // gutterName: 'button',
140
- // fixed: true,
141
- // forList: true,
142
- // icon: 'contact_page',
143
- // iconOnly: false,
144
- // title: i18next.t('button.edit-contact'),
145
- // width: 110,
146
- // handlers: {
147
- // click: async (columns, data, column, record, rowIndex) => {
148
- // if (record && record.contact) {
149
- // this.openContactPopup(record)
150
- // } else {
151
- // this.openContactSelector(record)
152
- // }
153
- // }
154
- // }
155
- // },
156
136
  {
157
137
  type: 'image',
158
138
  name: 'profile',
@@ -212,7 +192,7 @@ export class EmployeeListPage extends connect(store)(p13n(localize(i18next)(Scop
212
192
  editable: true
213
193
  },
214
194
  filter: 'search',
215
- sortable: true,
195
+ sortable: false,
216
196
  width: 110
217
197
  },
218
198
  {
@@ -234,8 +214,8 @@ export class EmployeeListPage extends connect(store)(p13n(localize(i18next)(Scop
234
214
  list: { fields: ['name', 'email'] }
235
215
  }
236
216
  },
237
- sortable: true,
238
- filter: false,
217
+ sortable: false,
218
+ filter: 'search',
239
219
  width: 100
240
220
  },
241
221
  {
@@ -243,8 +223,8 @@ export class EmployeeListPage extends connect(store)(p13n(localize(i18next)(Scop
243
223
  name: 'type',
244
224
  header: i18next.t('field.type'),
245
225
  width: 115,
246
- sortable: false,
247
- filter: false,
226
+ sortable: true,
227
+ filter: true,
248
228
  record: {
249
229
  editable: true,
250
230
  codeName: 'EMPLOYEE_TYPE',
@@ -258,8 +238,8 @@ export class EmployeeListPage extends connect(store)(p13n(localize(i18next)(Scop
258
238
  record: {
259
239
  editable: true
260
240
  },
261
- sortable: true,
262
- filter: false,
241
+ sortable: false,
242
+ filter: true,
263
243
  width: 130
264
244
  },
265
245
  {
@@ -350,7 +330,7 @@ export class EmployeeListPage extends connect(store)(p13n(localize(i18next)(Scop
350
330
  descriptionField: 'controlNo'
351
331
  }
352
332
  },
353
- sortable: true,
333
+ sortable: false,
354
334
  width: 120
355
335
  },
356
336
  {
@@ -364,7 +344,7 @@ export class EmployeeListPage extends connect(store)(p13n(localize(i18next)(Scop
364
344
  return record.contact ? record.contact.email : ''
365
345
  }
366
346
  },
367
- sortable: true
347
+ sortable: false
368
348
  },
369
349
  {
370
350
  type: 'string',
@@ -377,7 +357,7 @@ export class EmployeeListPage extends connect(store)(p13n(localize(i18next)(Scop
377
357
  return record.contact ? record.contact.phone : ''
378
358
  }
379
359
  },
380
- sortable: true
360
+ sortable: false
381
361
  },
382
362
  {
383
363
  type: 'code',
@@ -388,7 +368,8 @@ export class EmployeeListPage extends connect(store)(p13n(localize(i18next)(Scop
388
368
  editable: true,
389
369
  codeName: 'JOB_RESPONSIBILITY',
390
370
  selectDispOpt: 'name'
391
- }
371
+ },
372
+ filter: true
392
373
  },
393
374
  {
394
375
  type: 'code',
@@ -399,7 +380,8 @@ export class EmployeeListPage extends connect(store)(p13n(localize(i18next)(Scop
399
380
  editable: true,
400
381
  codeName: 'JOB_POSITION',
401
382
  selectDispOpt: 'name'
402
- }
383
+ },
384
+ filter: true
403
385
  },
404
386
  {
405
387
  type: 'date',
@@ -431,7 +413,7 @@ export class EmployeeListPage extends connect(store)(p13n(localize(i18next)(Scop
431
413
  editable: true
432
414
  },
433
415
  filter: true,
434
- sortable: true
416
+ sortable: false
435
417
  },
436
418
  {
437
419
  type: 'string',
@@ -18,6 +18,8 @@ export class Department {
18
18
  extension?: string
19
19
  picture?: string
20
20
 
21
+ active?: boolean
22
+
21
23
  createdAt?: Date
22
24
  updatedAt?: Date
23
25
  deletedAt?: Date
@@ -1,5 +1,6 @@
1
1
  import '@operato/data-tree';
2
2
  import '@operato/context/ox-context-page-toolbar.js';
3
+ import { PropertyValues } from 'lit';
3
4
  import { PageView } from '@operato/shell';
4
5
  import { DepartmentImporter } from './department-importer';
5
6
  import { Department } from '../../types/department';
@@ -18,6 +19,9 @@ export declare class DepartmentTreePage extends DepartmentTreePage_base {
18
19
  };
19
20
  root?: Department;
20
21
  selected?: Department;
22
+ department?: Department;
23
+ modified: boolean;
24
+ appendable: boolean;
21
25
  departmentView: DepartmentView;
22
26
  get context(): {
23
27
  title: string;
@@ -40,6 +44,7 @@ export declare class DepartmentTreePage extends DepartmentTreePage_base {
40
44
  toolbar: boolean;
41
45
  };
42
46
  render(): import("lit-html").TemplateResult<1>;
47
+ updated(changes: PropertyValues<this>): void;
43
48
  onSelect(e: CustomEvent): void;
44
49
  reset(): void;
45
50
  create(): Promise<void>;
@@ -1,13 +1,13 @@
1
1
  import { __decorate, __metadata } from "tslib";
2
2
  import '@operato/data-tree';
3
3
  import '@operato/context/ox-context-page-toolbar.js';
4
- import { CommonHeaderStyles, ScrollbarStyles } from '@operato/styles';
5
- import { CustomAlert, PageView, store } from '@operato/shell';
6
4
  import { css, html } from 'lit';
7
5
  import { customElement, query, state } from 'lit/decorators.js';
8
6
  import { ScopedElementsMixin } from '@open-wc/scoped-elements';
9
7
  import { client } from '@operato/graphql';
10
8
  import { i18next, localize } from '@operato/i18n';
9
+ import { CommonHeaderStyles, ScrollbarStyles } from '@operato/styles';
10
+ import { CustomAlert, PageView, store } from '@operato/shell';
11
11
  import { connect } from 'pwa-helpers/connect-mixin';
12
12
  import gql from 'graphql-tag';
13
13
  import { DepartmentImporter } from './department-importer';
@@ -38,6 +38,11 @@ const SubDepartmentFragment = gql `
38
38
  }
39
39
  `;
40
40
  let DepartmentTreePage = class DepartmentTreePage extends connect(store)(localize(i18next)(ScopedElementsMixin(PageView))) {
41
+ constructor() {
42
+ super(...arguments);
43
+ this.modified = false;
44
+ this.appendable = false;
45
+ }
41
46
  static get scopedElements() {
42
47
  return {
43
48
  'department-importer': DepartmentImporter
@@ -70,8 +75,6 @@ let DepartmentTreePage = class DepartmentTreePage extends connect(store)(localiz
70
75
  render() {
71
76
  return html `
72
77
  <div class="header">
73
- <div class="title">${i18next.t('title.department list')}</div>
74
-
75
78
  <ox-context-page-toolbar class="actions" .context=${this.context}></ox-context-page-toolbar>
76
79
  </div>
77
80
 
@@ -86,12 +89,22 @@ let DepartmentTreePage = class DepartmentTreePage extends connect(store)(localiz
86
89
  ></ox-tree-vertical>
87
90
 
88
91
  <div editor>
89
- <department-view .department=${this.selected}></department-view>
92
+ <department-view
93
+ .department=${this.department}
94
+ @property-change=${(e) => {
95
+ var _a, _b;
96
+ const { controlNo, name } = e.detail || {};
97
+ this.modified = true;
98
+ this.appendable = controlNo && controlNo !== ((_a = this.selected) === null || _a === void 0 ? void 0 : _a.controlNo) && name !== ((_b = this.selected) === null || _b === void 0 ? void 0 : _b.name);
99
+ }}
100
+ ></department-view>
90
101
  <div class="footer">
91
- <div filler></div>
92
102
  <button @click=${this.reset.bind(this)}><md-icon>restart_alt</md-icon>${i18next.t('button.reset')}</button>
93
- <button @click=${this.create.bind(this)}><md-icon>add</md-icon>${i18next.t('button.add')}</button>
94
- <button @click=${this.save.bind(this)} ?disabled=${!!this.selected} done>
103
+ <div filler></div>
104
+ <button @click=${this.create.bind(this)} ?disabled=${!this.appendable}>
105
+ <md-icon>add</md-icon>${i18next.t('button.add')}
106
+ </button>
107
+ <button @click=${this.save.bind(this)} ?disabled=${!this.modified} done>
95
108
  <md-icon>save</md-icon>${i18next.t('button.save')}
96
109
  </button>
97
110
  </div>
@@ -99,6 +112,12 @@ let DepartmentTreePage = class DepartmentTreePage extends connect(store)(localiz
99
112
  </content>
100
113
  `;
101
114
  }
115
+ updated(changes) {
116
+ if (changes.has('selected')) {
117
+ this.modified = false;
118
+ this.department = Object.assign({}, this.selected);
119
+ }
120
+ }
102
121
  onSelect(e) {
103
122
  this.selected = e.detail;
104
123
  this.updateContext();
@@ -107,8 +126,8 @@ let DepartmentTreePage = class DepartmentTreePage extends connect(store)(localiz
107
126
  this.departmentView.department = {};
108
127
  }
109
128
  async create() {
110
- const { id: parentId } = this.selected || {};
111
- const { controlNo, name, description, picture, active, manager } = this.departmentView.department;
129
+ const { id: parentId } = this.department || {};
130
+ const { controlNo, name, description, picture, active, manager } = this.department || {};
112
131
  var department = {
113
132
  controlNo,
114
133
  name,
@@ -144,7 +163,7 @@ let DepartmentTreePage = class DepartmentTreePage extends connect(store)(localiz
144
163
  await this.fetch();
145
164
  }
146
165
  async save() {
147
- const { id, controlNo, name, description, picture, active, manager } = this.departmentView.department;
166
+ const { id, controlNo, name, description, picture, active, manager } = this.department || {};
148
167
  if (!id) {
149
168
  await CustomAlert({
150
169
  type: 'warning',
@@ -292,7 +311,7 @@ DepartmentTreePage.styles = [
292
311
  }
293
312
 
294
313
  div[editor] {
295
- width: 260px;
314
+ width: 300px;
296
315
  display: flex;
297
316
  flex-direction: column;
298
317
  }
@@ -308,6 +327,11 @@ DepartmentTreePage.styles = [
308
327
  background-color: var(--md-sys-color-surface-variant);
309
328
  overflow: auto;
310
329
  }
330
+
331
+ .footer button[disabled] {
332
+ color: var(--md-sys-color-surface-dim);
333
+ background-color: transparent;
334
+ }
311
335
  `
312
336
  ];
313
337
  __decorate([
@@ -318,6 +342,18 @@ __decorate([
318
342
  state(),
319
343
  __metadata("design:type", Department)
320
344
  ], DepartmentTreePage.prototype, "selected", void 0);
345
+ __decorate([
346
+ state(),
347
+ __metadata("design:type", Department)
348
+ ], DepartmentTreePage.prototype, "department", void 0);
349
+ __decorate([
350
+ state(),
351
+ __metadata("design:type", Boolean)
352
+ ], DepartmentTreePage.prototype, "modified", void 0);
353
+ __decorate([
354
+ state(),
355
+ __metadata("design:type", Boolean)
356
+ ], DepartmentTreePage.prototype, "appendable", void 0);
321
357
  __decorate([
322
358
  query('department-view'),
323
359
  __metadata("design:type", DepartmentView)
@@ -1 +1 @@
1
- {"version":3,"file":"department-tree-page.js","sourceRoot":"","sources":["../../../client/pages/department/department-tree-page.ts"],"names":[],"mappings":";AAAA,OAAO,oBAAoB,CAAA;AAC3B,OAAO,6CAA6C,CAAA;AAEpD,OAAO,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AACrE,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAA;AAC7D,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,KAAK,CAAA;AAC/B,OAAO,EAAE,aAAa,E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AY,UAAU;oDAAA;AAEJ;IAAzB,KAAK,CAAC,iBAAiB,CAAC;8BAAkB,cAAc;0DAAA;AAhD9C,kBAAkB;IAD9B,aAAa,CAAC,sBAAsB,CAAC;GACzB,kBAAkB,CAsT9B","sourcesContent":["import '@operato/data-tree'\nimport '@operato/context/ox-context-page-toolbar.js'\n\nimport { CommonHeaderStyles, ScrollbarStyles } from '@operato/styles'\nimport { CustomAlert, PageView, store } from '@operato/shell'\nimport { css, html } from 'lit'\nimport { customElement, property, query, state } from 'lit/decorators.js'\nimport { ScopedElementsMixin } from '@open-wc/scoped-elements'\nimport { client } from '@operato/graphql'\nimport { i18next, localize } from '@operato/i18n'\n\nimport { connect } from 'pwa-helpers/connect-mixin'\nimport gql from 'graphql-tag'\n\nimport { DepartmentImporter } from './department-importer'\nimport { Department } from '../../types/department'\n\nimport { DepartmentView } from '../../component/department-view'\n\nconst SubDepartmentFragment = gql`\n fragment SubDepartmentFragment on Department {\n id\n controlNo\n name\n description\n\n manager {\n id\n name\n controlNo\n photo\n email\n }\n active\n picture\n\n updater {\n id\n name\n }\n updatedAt\n }\n`\n\n@customElement('department-tree-page')\nexport class DepartmentTreePage extends connect(store)(localize(i18next)(ScopedElementsMixin(PageView))) {\n static styles = [\n CommonHeaderStyles,\n ScrollbarStyles,\n css`\n :host {\n display: flex;\n flex-direction: column;\n\n width: 100%;\n overflow: auto;\n }\n\n content {\n flex: 1;\n display: flex;\n flex-direction: row;\n }\n\n div[editor] {\n width: 260px;\n display: flex;\n flex-direction: column;\n }\n\n ox-tree-vertical {\n flex: 1;\n overflow: auto;\n }\n\n department-view {\n flex: 1;\n padding: var(--spacing-medium);\n background-color: var(--md-sys-color-surface-variant);\n overflow: auto;\n }\n `\n ]\n\n static get scopedElements() {\n return {\n 'department-importer': DepartmentImporter\n }\n }\n\n @state() root?: Department\n @state() selected?: Department\n\n @query('department-view') departmentView!: DepartmentView\n\n get context() {\n return {\n title: i18next.t('title.department list'),\n help: 'organization/department',\n actions: [\n {\n icon: 'delete',\n title: i18next.t('button.delete'),\n action: this.delete.bind(this),\n emphasis: {\n danger: true\n }\n }\n ].filter(Boolean),\n exportable: {\n name: i18next.t('title.department list'),\n data: this.exportHandler.bind(this)\n },\n importable: {\n handler: this.importHandler.bind(this)\n },\n toolbar: false\n }\n }\n\n render() {\n return html`\n <div class=\"header\">\n <div class=\"title\">${i18next.t('title.department list')}</div>\n\n <ox-context-page-toolbar class=\"actions\" .context=${this.context}></ox-context-page-toolbar>\n </div>\n\n <content>\n <ox-tree-vertical\n .data=${this.root}\n .selected=${this.selected}\n @select=${this.onSelect.bind(this)}\n id-property=\"controlNo\"\n label-property=\"name\"\n description-property=\"description\"\n ></ox-tree-vertical>\n\n <div editor>\n <department-view .department=${this.selected}></department-view>\n <div class=\"footer\">\n <div filler></div>\n <button @click=${this.reset.bind(this)}><md-icon>restart_alt</md-icon>${i18next.t('button.reset')}</button>\n <button @click=${this.create.bind(this)}><md-icon>add</md-icon>${i18next.t('button.add')}</button>\n <button @click=${this.save.bind(this)} ?disabled=${!!this.selected} done>\n <md-icon>save</md-icon>${i18next.t('button.save')}\n </button>\n </div>\n </div>\n </content>\n `\n }\n\n onSelect(e: CustomEvent) {\n this.selected = e.detail as Department\n this.updateContext()\n }\n\n reset() {\n this.departmentView.department = {}\n }\n\n async create() {\n const { id: parentId } = this.selected || {}\n const { controlNo, name, description, picture, active, manager } = this.departmentView.department\n\n var department = {\n controlNo,\n name,\n description,\n manager,\n active\n } as any\n\n if (picture instanceof File) {\n department.picture = picture\n }\n\n if (parentId) {\n department.parent = { id: parentId }\n }\n\n const response = await client.mutate({\n mutation: gql`\n mutation ($department: NewDepartment!) {\n createDepartment(department: $department) {\n ...SubDepartmentFragment\n }\n }\n\n ${SubDepartmentFragment}\n `,\n variables: {\n department\n },\n context: {\n hasUpload: true\n }\n })\n\n this.selected = response.data.createDepartment\n this.updateContext()\n\n await this.fetch()\n }\n\n async save() {\n const { id, controlNo, name, description, picture, active, manager } = this.departmentView.department\n\n if (!id) {\n await CustomAlert({\n type: 'warning',\n title: 'department not selected',\n text: 'Please select department first.',\n confirmButton: { text: i18next.t('button.confirm') }\n })\n\n return\n }\n\n var patch = {\n controlNo,\n name,\n description,\n active,\n manager\n } as any\n\n if (picture instanceof File) {\n patch.picture = picture\n }\n\n const response = await client.mutate({\n mutation: gql`\n mutation ($id: String!, $patch: DepartmentPatch!) {\n updateDepartment(id: $id, patch: $patch) {\n ...SubDepartmentFragment\n }\n }\n\n ${SubDepartmentFragment}\n `,\n variables: {\n id,\n patch\n },\n context: {\n hasUpload: true\n }\n })\n\n this.selected = response.data.updateDepartment\n\n this.fetch()\n }\n\n async delete() {\n if (!this.selected) {\n await CustomAlert({\n type: 'warning',\n title: 'department not selected',\n text: 'Please select department first.',\n confirmButton: { text: i18next.t('button.confirm') }\n })\n\n return\n }\n\n const children = this.selected?.children\n if (children && children.length > 0) {\n await CustomAlert({\n type: 'warning',\n title: 'Departments with subordinates cannot be deleted.',\n text: 'Department having children cannot be deleted.',\n confirmButton: { text: i18next.t('button.confirm') }\n })\n\n return\n }\n\n if (confirm(i18next.t('text.sure_to_x', { x: i18next.t('text.delete') }))) {\n const { id } = this.selected || {}\n\n const response = await client.mutate({\n mutation: gql`\n mutation ($id: String!) {\n deleteDepartment(id: $id)\n }\n `,\n variables: {\n id\n }\n })\n\n this.selected = {}\n this.updateContext()\n\n await this.fetch()\n }\n }\n\n async pageInitialized(lifecycle: any) {\n this.fetch()\n }\n\n async pageUpdated(changes: any, lifecycle: any) {\n if (this.active) {\n // do something here when this page just became as active\n }\n }\n\n async fetch() {\n const response = await client.query({\n query: gql`\n query {\n responses: departmentRoots {\n total\n items {\n ...SubDepartmentFragment\n children {\n ...SubDepartmentFragment\n children {\n ...SubDepartmentFragment\n children {\n ...SubDepartmentFragment\n children {\n ...SubDepartmentFragment\n children {\n ...SubDepartmentFragment\n children {\n ...SubDepartmentFragment\n children {\n ...SubDepartmentFragment\n }\n }\n }\n }\n }\n }\n }\n }\n }\n }\n\n ${SubDepartmentFragment}\n `\n })\n const { items: records, total } = response.data.responses\n\n this.root = records[0]\n }\n\n async exportHandler() {}\n\n async importHandler(records) {}\n}\n"]}
1
+ {"version":3,"file":"department-tree-page.js","sourceRoot":"","sources":["../../../client/pages/department/department-tree-page.ts"],"names":[],"mappings":";AAAA,OAAO,oBAAoB,CAAA;AAC3B,OAAO,6CAA6C,CAAA;AAEpD,OAAO,EAAE,GAAG,EAAE,IAAI,EAAkB,MAAM,KAAK,CAAA;AAC/C,OAAO,EAAE,aAAa,EAAY,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AACzE,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAA;AAC9D,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAA;AACzC,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AACjD,OAAO,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AACrE,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAA;AAE7D,OAAO,EAAE,OAAO,EAAE,MAAM,2BAA2B,CAAA;AACnD,OAAO,GAAG,MAAM,aAAa,CAAA;AAE7B,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAA;AAC1D,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAA;AAEnD,OAAO,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAA;AAEhE,MAAM,qBAAqB,GAAG,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;CAuBhC,CAAA;AAGM,IAAM,kBAAkB,GAAxB,MAAM,kBAAmB,SAAQ,OAAO,CAAC,KAAK,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,mBAAmB,CAAC,QAAQ,CAAC,CAAC,CAAC;IAAjG;;QAqDI,aAAQ,GAAY,KAAK,CAAA;QACzB,eAAU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AE;;sDAA4B;AAEV;IAAzB,KAAK,CAAC,iBAAiB,CAAC;8BAAkB,cAAc;0DAAA;AAxD9C,kBAAkB;IAD9B,aAAa,CAAC,sBAAsB,CAAC;GACzB,kBAAkB,CA6U9B","sourcesContent":["import '@operato/data-tree'\nimport '@operato/context/ox-context-page-toolbar.js'\n\nimport { css, html, PropertyValues } from 'lit'\nimport { customElement, property, query, state } from 'lit/decorators.js'\nimport { ScopedElementsMixin } from '@open-wc/scoped-elements'\nimport { client } from '@operato/graphql'\nimport { i18next, localize } from '@operato/i18n'\nimport { CommonHeaderStyles, ScrollbarStyles } from '@operato/styles'\nimport { CustomAlert, PageView, store } from '@operato/shell'\n\nimport { connect } from 'pwa-helpers/connect-mixin'\nimport gql from 'graphql-tag'\n\nimport { DepartmentImporter } from './department-importer'\nimport { Department } from '../../types/department'\n\nimport { DepartmentView } from '../../component/department-view'\n\nconst SubDepartmentFragment = gql`\n fragment SubDepartmentFragment on Department {\n id\n controlNo\n name\n description\n\n manager {\n id\n name\n controlNo\n photo\n email\n }\n active\n picture\n\n updater {\n id\n name\n }\n updatedAt\n }\n`\n\n@customElement('department-tree-page')\nexport class DepartmentTreePage extends connect(store)(localize(i18next)(ScopedElementsMixin(PageView))) {\n static styles = [\n CommonHeaderStyles,\n ScrollbarStyles,\n css`\n :host {\n display: flex;\n flex-direction: column;\n\n width: 100%;\n overflow: auto;\n }\n\n content {\n flex: 1;\n display: flex;\n flex-direction: row;\n }\n\n div[editor] {\n width: 300px;\n display: flex;\n flex-direction: column;\n }\n\n ox-tree-vertical {\n flex: 1;\n overflow: auto;\n }\n\n department-view {\n flex: 1;\n padding: var(--spacing-medium);\n background-color: var(--md-sys-color-surface-variant);\n overflow: auto;\n }\n\n .footer button[disabled] {\n color: var(--md-sys-color-surface-dim);\n background-color: transparent;\n }\n `\n ]\n\n static get scopedElements() {\n return {\n 'department-importer': DepartmentImporter\n }\n }\n\n @state() root?: Department\n @state() selected?: Department\n @state() department?: Department\n @state() modified: boolean = false\n @state() appendable: boolean = false\n\n @query('department-view') departmentView!: DepartmentView\n\n get context() {\n return {\n title: i18next.t('title.department list'),\n help: 'organization/department',\n actions: [\n {\n icon: 'delete',\n title: i18next.t('button.delete'),\n action: this.delete.bind(this),\n emphasis: {\n danger: true\n }\n }\n ].filter(Boolean),\n exportable: {\n name: i18next.t('title.department list'),\n data: this.exportHandler.bind(this)\n },\n importable: {\n handler: this.importHandler.bind(this)\n },\n toolbar: false\n }\n }\n\n render() {\n return html`\n <div class=\"header\">\n <ox-context-page-toolbar class=\"actions\" .context=${this.context}></ox-context-page-toolbar>\n </div>\n\n <content>\n <ox-tree-vertical\n .data=${this.root}\n .selected=${this.selected}\n @select=${this.onSelect.bind(this)}\n id-property=\"controlNo\"\n label-property=\"name\"\n description-property=\"description\"\n ></ox-tree-vertical>\n\n <div editor>\n <department-view\n .department=${this.department}\n @property-change=${(e: CustomEvent) => {\n const { controlNo, name } = e.detail || {}\n\n this.modified = true\n this.appendable = controlNo && controlNo !== this.selected?.controlNo && name !== this.selected?.name\n }}\n ></department-view>\n <div class=\"footer\">\n <button @click=${this.reset.bind(this)}><md-icon>restart_alt</md-icon>${i18next.t('button.reset')}</button>\n <div filler></div>\n <button @click=${this.create.bind(this)} ?disabled=${!this.appendable}>\n <md-icon>add</md-icon>${i18next.t('button.add')}\n </button>\n <button @click=${this.save.bind(this)} ?disabled=${!this.modified} done>\n <md-icon>save</md-icon>${i18next.t('button.save')}\n </button>\n </div>\n </div>\n </content>\n `\n }\n\n updated(changes: PropertyValues<this>) {\n if (changes.has('selected')) {\n this.modified = false\n this.department = { ...this.selected }\n }\n }\n\n onSelect(e: CustomEvent) {\n this.selected = e.detail as Department\n this.updateContext()\n }\n\n reset() {\n this.departmentView.department = {}\n }\n\n async create() {\n const { id: parentId } = this.department || {}\n const { controlNo, name, description, picture, active, manager } = this.department || {}\n\n var department = {\n controlNo,\n name,\n description,\n manager,\n active\n } as any\n\n if ((picture as any) instanceof File) {\n department.picture = picture\n }\n\n if (parentId) {\n department.parent = { id: parentId }\n }\n\n const response = await client.mutate({\n mutation: gql`\n mutation ($department: NewDepartment!) {\n createDepartment(department: $department) {\n ...SubDepartmentFragment\n }\n }\n\n ${SubDepartmentFragment}\n `,\n variables: {\n department\n },\n context: {\n hasUpload: true\n }\n })\n\n this.selected = response.data.createDepartment\n this.updateContext()\n\n await this.fetch()\n }\n\n async save() {\n const { id, controlNo, name, description, picture, active, manager } = this.department || {}\n\n if (!id) {\n await CustomAlert({\n type: 'warning',\n title: 'department not selected',\n text: 'Please select department first.',\n confirmButton: { text: i18next.t('button.confirm') }\n })\n\n return\n }\n\n var patch = {\n controlNo,\n name,\n description,\n active,\n manager\n } as any\n\n if ((picture as any) instanceof File) {\n patch.picture = picture\n }\n\n const response = await client.mutate({\n mutation: gql`\n mutation ($id: String!, $patch: DepartmentPatch!) {\n updateDepartment(id: $id, patch: $patch) {\n ...SubDepartmentFragment\n }\n }\n\n ${SubDepartmentFragment}\n `,\n variables: {\n id,\n patch\n },\n context: {\n hasUpload: true\n }\n })\n\n this.selected = response.data.updateDepartment\n\n this.fetch()\n }\n\n async delete() {\n if (!this.selected) {\n await CustomAlert({\n type: 'warning',\n title: 'department not selected',\n text: 'Please select department first.',\n confirmButton: { text: i18next.t('button.confirm') }\n })\n\n return\n }\n\n const children = this.selected?.children\n if (children && children.length > 0) {\n await CustomAlert({\n type: 'warning',\n title: 'Departments with subordinates cannot be deleted.',\n text: 'Department having children cannot be deleted.',\n confirmButton: { text: i18next.t('button.confirm') }\n })\n\n return\n }\n\n if (confirm(i18next.t('text.sure_to_x', { x: i18next.t('text.delete') }))) {\n const { id } = this.selected || {}\n\n const response = await client.mutate({\n mutation: gql`\n mutation ($id: String!) {\n deleteDepartment(id: $id)\n }\n `,\n variables: {\n id\n }\n })\n\n this.selected = {}\n this.updateContext()\n\n await this.fetch()\n }\n }\n\n async pageInitialized(lifecycle: any) {\n this.fetch()\n }\n\n async pageUpdated(changes: any, lifecycle: any) {\n if (this.active) {\n // do something here when this page just became as active\n }\n }\n\n async fetch() {\n const response = await client.query({\n query: gql`\n query {\n responses: departmentRoots {\n total\n items {\n ...SubDepartmentFragment\n children {\n ...SubDepartmentFragment\n children {\n ...SubDepartmentFragment\n children {\n ...SubDepartmentFragment\n children {\n ...SubDepartmentFragment\n children {\n ...SubDepartmentFragment\n children {\n ...SubDepartmentFragment\n children {\n ...SubDepartmentFragment\n }\n }\n }\n }\n }\n }\n }\n }\n }\n }\n\n ${SubDepartmentFragment}\n `\n })\n const { items: records, total } = response.data.responses\n\n this.root = records[0]\n }\n\n async exportHandler() {}\n\n async importHandler(records) {}\n}\n"]}
@@ -1,6 +1,6 @@
1
1
  import '@operato/data-grist';
2
2
  import '@operato/context/ox-context-page-toolbar.js';
3
- import '@things-factory/contact';
3
+ import '@things-factory/contact/dist-client';
4
4
  import { Contact } from '@operato/contact/ox-contact.js';
5
5
  import { FetchOption, GristRecord } from '@operato/data-grist';
6
6
  import { PageView } from '@operato/shell';
@@ -1,7 +1,7 @@
1
1
  import { __decorate, __metadata } from "tslib";
2
2
  import '@operato/data-grist';
3
3
  import '@operato/context/ox-context-page-toolbar.js';
4
- import '@things-factory/contact';
4
+ import '@things-factory/contact/dist-client';
5
5
  import gql from 'graphql-tag';
6
6
  import { css, html } from 'lit';
7
7
  import { customElement, property, query } from 'lit/decorators.js';
@@ -99,25 +99,6 @@ let EmployeeListPage = class EmployeeListPage extends connect(store)(p13n(locali
99
99
  columns: [
100
100
  { type: 'gutter', gutterName: 'sequence', fixed: true },
101
101
  { type: 'gutter', gutterName: 'row-selector', multiple: true, fixed: true },
102
- // {
103
- // type: 'gutter',
104
- // gutterName: 'button',
105
- // fixed: true,
106
- // forList: true,
107
- // icon: 'contact_page',
108
- // iconOnly: false,
109
- // title: i18next.t('button.edit-contact'),
110
- // width: 110,
111
- // handlers: {
112
- // click: async (columns, data, column, record, rowIndex) => {
113
- // if (record && record.contact) {
114
- // this.openContactPopup(record)
115
- // } else {
116
- // this.openContactSelector(record)
117
- // }
118
- // }
119
- // }
120
- // },
121
102
  {
122
103
  type: 'image',
123
104
  name: 'profile',
@@ -178,7 +159,7 @@ let EmployeeListPage = class EmployeeListPage extends connect(store)(p13n(locali
178
159
  editable: true
179
160
  },
180
161
  filter: 'search',
181
- sortable: true,
162
+ sortable: false,
182
163
  width: 110
183
164
  },
184
165
  {
@@ -200,8 +181,8 @@ let EmployeeListPage = class EmployeeListPage extends connect(store)(p13n(locali
200
181
  list: { fields: ['name', 'email'] }
201
182
  }
202
183
  },
203
- sortable: true,
204
- filter: false,
184
+ sortable: false,
185
+ filter: 'search',
205
186
  width: 100
206
187
  },
207
188
  {
@@ -209,8 +190,8 @@ let EmployeeListPage = class EmployeeListPage extends connect(store)(p13n(locali
209
190
  name: 'type',
210
191
  header: i18next.t('field.type'),
211
192
  width: 115,
212
- sortable: false,
213
- filter: false,
193
+ sortable: true,
194
+ filter: true,
214
195
  record: {
215
196
  editable: true,
216
197
  codeName: 'EMPLOYEE_TYPE',
@@ -224,8 +205,8 @@ let EmployeeListPage = class EmployeeListPage extends connect(store)(p13n(locali
224
205
  record: {
225
206
  editable: true
226
207
  },
227
- sortable: true,
228
- filter: false,
208
+ sortable: false,
209
+ filter: true,
229
210
  width: 130
230
211
  },
231
212
  {
@@ -316,7 +297,7 @@ let EmployeeListPage = class EmployeeListPage extends connect(store)(p13n(locali
316
297
  descriptionField: 'controlNo'
317
298
  }
318
299
  },
319
- sortable: true,
300
+ sortable: false,
320
301
  width: 120
321
302
  },
322
303
  {
@@ -330,7 +311,7 @@ let EmployeeListPage = class EmployeeListPage extends connect(store)(p13n(locali
330
311
  return record.contact ? record.contact.email : '';
331
312
  }
332
313
  },
333
- sortable: true
314
+ sortable: false
334
315
  },
335
316
  {
336
317
  type: 'string',
@@ -343,7 +324,7 @@ let EmployeeListPage = class EmployeeListPage extends connect(store)(p13n(locali
343
324
  return record.contact ? record.contact.phone : '';
344
325
  }
345
326
  },
346
- sortable: true
327
+ sortable: false
347
328
  },
348
329
  {
349
330
  type: 'code',
@@ -354,7 +335,8 @@ let EmployeeListPage = class EmployeeListPage extends connect(store)(p13n(locali
354
335
  editable: true,
355
336
  codeName: 'JOB_RESPONSIBILITY',
356
337
  selectDispOpt: 'name'
357
- }
338
+ },
339
+ filter: true
358
340
  },
359
341
  {
360
342
  type: 'code',
@@ -365,7 +347,8 @@ let EmployeeListPage = class EmployeeListPage extends connect(store)(p13n(locali
365
347
  editable: true,
366
348
  codeName: 'JOB_POSITION',
367
349
  selectDispOpt: 'name'
368
- }
350
+ },
351
+ filter: true
369
352
  },
370
353
  {
371
354
  type: 'date',
@@ -397,7 +380,7 @@ let EmployeeListPage = class EmployeeListPage extends connect(store)(p13n(locali
397
380
  editable: true
398
381
  },
399
382
  filter: true,
400
- sortable: true
383
+ sortable: false
401
384
  },
402
385
  {
403
386
  type: 'string',