@dssp/project 0.0.2 → 0.0.6

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 (196) hide show
  1. package/client/pages/checklist/checklist-importer.ts +6 -8
  2. package/client/pages/checklist/checklist-list-page.ts +10 -25
  3. package/client/pages/project/popup/popup-plan-upload.ts +138 -0
  4. package/client/pages/project/{project-create-popup.ts → popup/popup-project-create.ts} +2 -3
  5. package/client/pages/project/project-detail.ts +11 -11
  6. package/client/pages/project/project-list.ts +17 -10
  7. package/client/pages/project/project-plan-management.ts +117 -39
  8. package/client/pages/project/project-schedule-list.ts +2 -0
  9. package/client/pages/project/project-schedule.ts +296 -7
  10. package/client/pages/project/project-setting-list.ts +10 -6
  11. package/client/pages/project/project-update.ts +5 -2
  12. package/client/pages/resource/construction-type-management.ts +211 -0
  13. package/client/pages/resource/manager-management.ts +202 -0
  14. package/client/pages/resource/worker-type-management.ts +226 -0
  15. package/client/pages/task/task-importer.ts +6 -8
  16. package/client/pages/task/task-list-page.ts +10 -25
  17. package/client/route.ts +8 -4
  18. package/dist-client/pages/checklist/checklist-importer.d.ts +1 -0
  19. package/dist-client/pages/checklist/checklist-importer.js +3 -2
  20. package/dist-client/pages/checklist/checklist-importer.js.map +1 -1
  21. package/dist-client/pages/checklist/checklist-list-page.d.ts +1 -0
  22. package/dist-client/pages/checklist/checklist-list-page.js +8 -16
  23. package/dist-client/pages/checklist/checklist-list-page.js.map +1 -1
  24. package/dist-client/pages/project/popup/popup-plan-upload.d.ts +10 -0
  25. package/dist-client/pages/project/popup/popup-plan-upload.js +139 -0
  26. package/dist-client/pages/project/popup/popup-plan-upload.js.map +1 -0
  27. package/dist-client/pages/project/{project-create-popup.d.ts → popup/popup-project-create.d.ts} +1 -3
  28. package/dist-client/pages/project/{project-create-popup.js → popup/popup-project-create.js} +9 -10
  29. package/dist-client/pages/project/popup/popup-project-create.js.map +1 -0
  30. package/dist-client/pages/project/project-detail.d.ts +5 -4
  31. package/dist-client/pages/project/project-detail.js +9 -10
  32. package/dist-client/pages/project/project-detail.js.map +1 -1
  33. package/dist-client/pages/project/project-list.d.ts +12 -2
  34. package/dist-client/pages/project/project-list.js +11 -14
  35. package/dist-client/pages/project/project-list.js.map +1 -1
  36. package/dist-client/pages/project/project-plan-management.d.ts +9 -4
  37. package/dist-client/pages/project/project-plan-management.js +105 -35
  38. package/dist-client/pages/project/project-plan-management.js.map +1 -1
  39. package/dist-client/pages/project/project-schedule-list.d.ts +1 -0
  40. package/dist-client/pages/project/project-schedule-list.js +1 -0
  41. package/dist-client/pages/project/project-schedule-list.js.map +1 -1
  42. package/dist-client/pages/project/project-schedule.d.ts +10 -3
  43. package/dist-client/pages/project/project-schedule.js +294 -7
  44. package/dist-client/pages/project/project-schedule.js.map +1 -1
  45. package/dist-client/pages/project/project-setting-list.d.ts +3 -2
  46. package/dist-client/pages/project/project-setting-list.js +9 -6
  47. package/dist-client/pages/project/project-setting-list.js.map +1 -1
  48. package/dist-client/pages/project/project-update.d.ts +3 -2
  49. package/dist-client/pages/project/project-update.js +4 -2
  50. package/dist-client/pages/project/project-update.js.map +1 -1
  51. package/dist-client/pages/resource/construction-type-management.d.ts +22 -0
  52. package/dist-client/pages/resource/construction-type-management.js +208 -0
  53. package/dist-client/pages/resource/construction-type-management.js.map +1 -0
  54. package/dist-client/pages/resource/manager-management.d.ts +31 -0
  55. package/dist-client/pages/resource/manager-management.js +196 -0
  56. package/dist-client/pages/resource/manager-management.js.map +1 -0
  57. package/dist-client/pages/resource/worker-type-management.d.ts +28 -0
  58. package/dist-client/pages/resource/worker-type-management.js +222 -0
  59. package/dist-client/pages/resource/worker-type-management.js.map +1 -0
  60. package/dist-client/pages/task/task-importer.d.ts +1 -0
  61. package/dist-client/pages/task/task-importer.js +3 -2
  62. package/dist-client/pages/task/task-importer.js.map +1 -1
  63. package/dist-client/pages/task/task-list-page.d.ts +1 -0
  64. package/dist-client/pages/task/task-list-page.js +8 -16
  65. package/dist-client/pages/task/task-list-page.js.map +1 -1
  66. package/dist-client/route.d.ts +1 -1
  67. package/dist-client/route.js +7 -4
  68. package/dist-client/route.js.map +1 -1
  69. package/dist-client/tsconfig.tsbuildinfo +1 -1
  70. package/dist-server/controllers/index.d.ts +0 -0
  71. package/dist-server/controllers/project-to-excel.d.ts +7 -0
  72. package/dist-server/index.d.ts +2 -0
  73. package/dist-server/middlewares/index.d.ts +1 -0
  74. package/dist-server/routes.d.ts +1 -0
  75. package/dist-server/service/check-item/check-item-mutation.d.ts +10 -0
  76. package/dist-server/service/check-item/check-item-query.d.ts +11 -0
  77. package/dist-server/service/check-item/check-item-type.d.ts +18 -0
  78. package/dist-server/service/check-item/check-item.d.ts +18 -0
  79. package/dist-server/service/check-item/index.d.ts +5 -0
  80. package/dist-server/service/checklist/checklist-mutation.d.ts +10 -0
  81. package/dist-server/service/checklist/checklist-query.d.ts +11 -0
  82. package/dist-server/service/checklist/checklist-type.d.ts +18 -0
  83. package/dist-server/service/checklist/checklist.d.ts +26 -0
  84. package/dist-server/service/checklist/index.d.ts +5 -0
  85. package/dist-server/service/construction-type/construction-type-mutation.d.ts +6 -0
  86. package/dist-server/service/construction-type/construction-type-mutation.js +64 -0
  87. package/dist-server/service/construction-type/construction-type-mutation.js.map +1 -0
  88. package/dist-server/service/construction-type/construction-type-query.d.ts +11 -0
  89. package/dist-server/service/construction-type/construction-type-query.js +78 -0
  90. package/dist-server/service/construction-type/construction-type-query.js.map +1 -0
  91. package/dist-server/service/construction-type/construction-type-type.d.ts +11 -0
  92. package/dist-server/service/construction-type/construction-type-type.js +43 -0
  93. package/dist-server/service/construction-type/construction-type-type.js.map +1 -0
  94. package/dist-server/service/construction-type/construction-type.d.ts +16 -0
  95. package/dist-server/service/construction-type/construction-type.js +77 -0
  96. package/dist-server/service/construction-type/construction-type.js.map +1 -0
  97. package/dist-server/service/construction-type/index.d.ts +5 -0
  98. package/dist-server/service/construction-type/index.js +9 -0
  99. package/dist-server/service/construction-type/index.js.map +1 -0
  100. package/dist-server/service/index.d.ts +12 -0
  101. package/dist-server/service/index.js +12 -4
  102. package/dist-server/service/index.js.map +1 -1
  103. package/dist-server/service/manager/index.d.ts +5 -0
  104. package/dist-server/service/manager/index.js +9 -0
  105. package/dist-server/service/manager/index.js.map +1 -0
  106. package/dist-server/service/manager/manager-mutation.d.ts +5 -0
  107. package/dist-server/service/manager/manager-mutation.js +39 -0
  108. package/dist-server/service/manager/manager-mutation.js.map +1 -0
  109. package/dist-server/service/manager/manager-query.d.ts +4 -0
  110. package/dist-server/service/manager/manager-query.js +39 -0
  111. package/dist-server/service/manager/manager-query.js.map +1 -0
  112. package/dist-server/service/manager/manager-type.d.ts +15 -0
  113. package/dist-server/service/manager/manager-type.js +62 -0
  114. package/dist-server/service/manager/manager-type.js.map +1 -0
  115. package/dist-server/service/manager/manager.d.ts +8 -0
  116. package/dist-server/service/manager/manager.js +41 -0
  117. package/dist-server/service/manager/manager.js.map +1 -0
  118. package/dist-server/service/project/index.d.ts +7 -0
  119. package/dist-server/service/project/project-mutation.d.ts +9 -0
  120. package/dist-server/service/project/project-mutation.js +61 -55
  121. package/dist-server/service/project/project-mutation.js.map +1 -1
  122. package/dist-server/service/project/project-query.d.ts +16 -0
  123. package/dist-server/service/project/project-query.js +3 -3
  124. package/dist-server/service/project/project-query.js.map +1 -1
  125. package/dist-server/service/project/project-type.d.ts +29 -0
  126. package/dist-server/service/project/project-type.js +1 -2
  127. package/dist-server/service/project/project-type.js.map +1 -1
  128. package/dist-server/service/project/project.d.ts +35 -0
  129. package/dist-server/service/project/project.js +1 -2
  130. package/dist-server/service/project/project.js.map +1 -1
  131. package/dist-server/service/task/index.d.ts +5 -0
  132. package/dist-server/service/task/task-mutation.d.ts +10 -0
  133. package/dist-server/service/task/task-query.d.ts +11 -0
  134. package/dist-server/service/task/task-type.d.ts +18 -0
  135. package/dist-server/service/task/task.d.ts +25 -0
  136. package/dist-server/service/worker-type/index.d.ts +5 -0
  137. package/dist-server/service/worker-type/index.js +9 -0
  138. package/dist-server/service/worker-type/index.js.map +1 -0
  139. package/dist-server/service/worker-type/worker-type-mutation.d.ts +6 -0
  140. package/dist-server/service/worker-type/worker-type-mutation.js +64 -0
  141. package/dist-server/service/worker-type/worker-type-mutation.js.map +1 -0
  142. package/dist-server/service/worker-type/worker-type-query.d.ts +11 -0
  143. package/dist-server/service/{resource/resource-query.js → worker-type/worker-type-query.js} +31 -39
  144. package/dist-server/service/worker-type/worker-type-query.js.map +1 -0
  145. package/dist-server/service/worker-type/worker-type-type.d.ts +11 -0
  146. package/dist-server/service/worker-type/worker-type-type.js +43 -0
  147. package/dist-server/service/worker-type/worker-type-type.js.map +1 -0
  148. package/dist-server/service/worker-type/worker-type.d.ts +16 -0
  149. package/dist-server/service/{resource/resource.js → worker-type/worker-type.js} +35 -20
  150. package/dist-server/service/worker-type/worker-type.js.map +1 -0
  151. package/dist-server/tsconfig.tsbuildinfo +1 -1
  152. package/package.json +3 -3
  153. package/server/service/construction-type/construction-type-mutation.ts +66 -0
  154. package/server/service/construction-type/construction-type-query.ts +47 -0
  155. package/server/service/construction-type/construction-type-type.ts +26 -0
  156. package/server/service/{resource/resource.ts → construction-type/construction-type.ts} +18 -6
  157. package/server/service/construction-type/index.ts +6 -0
  158. package/server/service/index.ts +12 -4
  159. package/server/service/manager/index.ts +6 -0
  160. package/server/service/manager/manager-mutation.ts +42 -0
  161. package/server/service/manager/manager-query.ts +28 -0
  162. package/server/service/manager/manager-type.ts +40 -0
  163. package/server/service/manager/manager.ts +29 -0
  164. package/server/service/project/project-mutation.ts +101 -79
  165. package/server/service/project/project-query.ts +5 -8
  166. package/server/service/worker-type/index.ts +6 -0
  167. package/server/service/worker-type/worker-type-mutation.ts +66 -0
  168. package/server/service/worker-type/worker-type-query.ts +47 -0
  169. package/server/service/worker-type/worker-type-type.ts +26 -0
  170. package/server/service/worker-type/worker-type.ts +68 -0
  171. package/things-factory.config.js +3 -0
  172. package/client/pages/project/ox-progress-circle.ts +0 -133
  173. package/client/pages/resource/resource-importer.ts +0 -96
  174. package/client/pages/resource/resource-list-page.ts +0 -355
  175. package/dist-client/pages/project/ox-progress-circle.d.ts +0 -41
  176. package/dist-client/pages/project/ox-progress-circle.js +0 -182
  177. package/dist-client/pages/project/ox-progress-circle.js.map +0 -1
  178. package/dist-client/pages/project/project-create-popup.js.map +0 -1
  179. package/dist-client/pages/resource/resource-importer.d.ts +0 -9
  180. package/dist-client/pages/resource/resource-importer.js +0 -100
  181. package/dist-client/pages/resource/resource-importer.js.map +0 -1
  182. package/dist-client/pages/resource/resource-list-page.d.ts +0 -62
  183. package/dist-client/pages/resource/resource-list-page.js +0 -331
  184. package/dist-client/pages/resource/resource-list-page.js.map +0 -1
  185. package/dist-server/service/resource/index.js +0 -9
  186. package/dist-server/service/resource/index.js.map +0 -1
  187. package/dist-server/service/resource/resource-mutation.js +0 -129
  188. package/dist-server/service/resource/resource-mutation.js.map +0 -1
  189. package/dist-server/service/resource/resource-query.js.map +0 -1
  190. package/dist-server/service/resource/resource-type.js +0 -69
  191. package/dist-server/service/resource/resource-type.js.map +0 -1
  192. package/dist-server/service/resource/resource.js.map +0 -1
  193. package/server/service/resource/index.ts +0 -6
  194. package/server/service/resource/resource-mutation.ts +0 -139
  195. package/server/service/resource/resource-query.ts +0 -56
  196. package/server/service/resource/resource-type.ts +0 -49
@@ -1,100 +0,0 @@
1
- import { __decorate, __metadata } from "tslib";
2
- import '@operato/data-grist';
3
- import gql from 'graphql-tag';
4
- import { css, html, LitElement } from 'lit';
5
- import { state } from 'lit/decorators.js';
6
- import { client } from '@operato/graphql';
7
- import { i18next } from '@operato/i18n';
8
- import { isMobileDevice } from '@operato/utils';
9
- export class ResourceImporter extends LitElement {
10
- constructor() {
11
- super(...arguments);
12
- this.resources = [];
13
- this.columns = {
14
- list: { fields: ['name', 'description'] },
15
- pagination: { infinite: true },
16
- columns: [
17
- {
18
- type: 'string',
19
- name: 'name',
20
- header: i18next.t('field.name'),
21
- width: 150
22
- },
23
- {
24
- type: 'string',
25
- name: 'description',
26
- header: i18next.t('field.description'),
27
- width: 200
28
- },
29
- {
30
- type: 'checkbox',
31
- name: 'active',
32
- header: i18next.t('field.active'),
33
- width: 60
34
- }
35
- ]
36
- };
37
- }
38
- render() {
39
- return html `
40
- <ox-grist
41
- .mode=${isMobileDevice() ? 'LIST' : 'GRID'}
42
- .config=${this.columns}
43
- .data=${{
44
- records: this.resources
45
- }}
46
- ></ox-grist>
47
-
48
- <div class="button-container">
49
- <mwc-button raised @click="${this.save.bind(this)}">${i18next.t('button.save')}</mwc-button>
50
- </div>
51
- `;
52
- }
53
- async save() {
54
- var _a;
55
- const response = await client.mutate({
56
- mutation: gql `
57
- mutation importResources($resources: [ResourcePatch!]!) {
58
- importResources(resources: $resources)
59
- }
60
- `,
61
- variables: { resources: this.resources }
62
- });
63
- if ((_a = response.errors) === null || _a === void 0 ? void 0 : _a.length)
64
- return;
65
- this.dispatchEvent(new CustomEvent('imported'));
66
- }
67
- }
68
- ResourceImporter.styles = [
69
- css `
70
- :host {
71
- display: flex;
72
- flex-direction: column;
73
-
74
- background-color: #fff;
75
- }
76
-
77
- ox-grist {
78
- flex: 1;
79
- }
80
-
81
- .button-container {
82
- display: flex;
83
- margin-left: auto;
84
- padding: var(--padding-default);
85
- }
86
-
87
- mwc-button {
88
- margin-left: var(--margin-default);
89
- }
90
- `
91
- ];
92
- __decorate([
93
- state(),
94
- __metadata("design:type", Array)
95
- ], ResourceImporter.prototype, "resources", void 0);
96
- __decorate([
97
- state(),
98
- __metadata("design:type", Object)
99
- ], ResourceImporter.prototype, "columns", void 0);
100
- //# sourceMappingURL=resource-importer.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"resource-importer.js","sourceRoot":"","sources":["../../../client/pages/resource/resource-importer.ts"],"names":[],"mappings":";AAAA,OAAO,qBAAqB,CAAA;AAE5B,OAAO,GAAG,MAAM,aAAa,CAAA;AAC7B,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,UAAU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AC;IAEO,KAAK,CAAC,IAAI;;QAChB,MAAM,QAAQ,GAAG,MAAM,MAAM,CAAC,MAAM,CAAC;YACnC,QAAQ,EAAE,GAAG,CAAA;;;;OAIZ;YACD,SAAS,EAAE,EAAE,SAAS,EAAE,IAAI,CAAC,SAAS,EAAE;SACzC,CAAC,CAAA;QAEF,IAAI,MAAA,QAAQ,CAAC,MAAM,0CAAE,MAAM;YAAE,OAAM;QAEnC,IAAI,CAAC,aAAa,CAAC,IAAI,WAAW,CAAC,UAAU,CAAC,CAAC,CAAA;IACjD,CAAC;;AAlFM,uBAAM,GAAG;IACd,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;KAqBF;CACF,CAAA;AAED;IAAC,KAAK,EAAE;;mDAA8B;AACtC;IAAC,KAAK,EAAE;;iDAuBP","sourcesContent":["import '@operato/data-grist'\n\nimport gql from 'graphql-tag'\nimport { css, html, LitElement } from 'lit'\nimport { property, state } from 'lit/decorators.js'\n\nimport { client } from '@operato/graphql'\nimport { i18next } from '@operato/i18n'\nimport { isMobileDevice } from '@operato/utils'\n\nexport class ResourceImporter extends LitElement {\n static styles = [\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 .button-container {\n display: flex;\n margin-left: auto;\n padding: var(--padding-default);\n }\n\n mwc-button {\n margin-left: var(--margin-default);\n }\n `\n ]\n\n @state() private resources: any[] = []\n @state() private columns = {\n list: { fields: ['name', 'description'] },\n pagination: { infinite: true },\n columns: [\n {\n type: 'string',\n name: 'name',\n header: i18next.t('field.name'),\n width: 150\n },\n {\n type: 'string',\n name: 'description',\n header: i18next.t('field.description'),\n width: 200\n },\n {\n type: 'checkbox',\n name: 'active',\n header: i18next.t('field.active'),\n width: 60\n }\n ]\n }\n\n render() {\n return html`\n <ox-grist\n .mode=${isMobileDevice() ? 'LIST' : 'GRID'}\n .config=${this.columns}\n .data=${\n { \n records: this.resources \n }\n }\n ></ox-grist>\n\n <div class=\"button-container\">\n <mwc-button raised @click=\"${this.save.bind(this)}\">${i18next.t('button.save')}</mwc-button>\n </div>\n `\n }\n\n private async save() {\n const response = await client.mutate({\n mutation: gql`\n mutation importResources($resources: [ResourcePatch!]!) {\n importResources(resources: $resources)\n }\n `,\n variables: { resources: this.resources }\n })\n\n if (response.errors?.length) return\n\n this.dispatchEvent(new CustomEvent('imported'))\n }\n}\n\n"]}
@@ -1,62 +0,0 @@
1
- import '@operato/data-grist';
2
- import { PageView } from '@operato/shell';
3
- import { FetchOption } from '@operato/data-grist';
4
- import { ResourceImporter } from './resource-importer';
5
- declare const ResourceListPage_base: (new (...args: any[]) => {
6
- _storeUnsubscribe: import("redux").Unsubscribe;
7
- connectedCallback(): void;
8
- disconnectedCallback(): void;
9
- stateChanged(_state: unknown): void;
10
- readonly isConnected: boolean;
11
- }) & (new (...args: any[]) => import("lit").LitElement) & typeof PageView & import("@open-wc/dedupe-mixin").Constructor<import("@open-wc/scoped-elements/types/src/types").ScopedElementsHost>;
12
- export declare class ResourceListPage extends ResourceListPage_base {
13
- static styles: import("lit").CSSResult[];
14
- static get scopedElements(): {
15
- 'resource-importer': typeof ResourceImporter;
16
- };
17
- private gristConfig;
18
- private mode;
19
- private grist;
20
- private sortersControl;
21
- get context(): {
22
- title: string;
23
- search: {
24
- handler: (search: string) => void;
25
- value: string;
26
- };
27
- filter: {
28
- handler: () => void;
29
- };
30
- help: string;
31
- actions: {
32
- icon: string;
33
- emphasis: {
34
- raised: boolean;
35
- outlined: boolean;
36
- dense: boolean;
37
- danger: boolean;
38
- };
39
- title: string;
40
- action: () => Promise<void>;
41
- }[];
42
- exportable: {
43
- name: string;
44
- data: () => Promise<{}[]>;
45
- };
46
- importable: {
47
- handler: (records: any) => Promise<void>;
48
- };
49
- };
50
- render(): import("lit-html").TemplateResult<1>;
51
- pageInitialized(lifecycle: any): Promise<void>;
52
- pageUpdated(changes: any, lifecycle: any): Promise<void>;
53
- fetchHandler({ page, limit, sortings, filters }: FetchOption): Promise<{
54
- total: any;
55
- records: any;
56
- }>;
57
- private deleteResource;
58
- private updateResource;
59
- private exportHandler;
60
- private importHandler;
61
- }
62
- export {};
@@ -1,331 +0,0 @@
1
- import { __decorate, __metadata } from "tslib";
2
- import '@operato/data-grist';
3
- import { CommonButtonStyles, CommonGristStyles, ScrollbarStyles } from '@operato/styles';
4
- import { PageView, store } from '@operato/shell';
5
- import { css, html } from 'lit';
6
- import { customElement, query, state } from 'lit/decorators.js';
7
- import { ScopedElementsMixin } from '@open-wc/scoped-elements';
8
- import { DataGrist } from '@operato/data-grist';
9
- import { client } from '@operato/graphql';
10
- import { i18next, localize } from '@operato/i18n';
11
- import { notify, openPopup } from '@operato/layout';
12
- import { OxPopup, OxPrompt } from '@operato/popup';
13
- import { isMobileDevice } from '@operato/utils';
14
- import { connect } from 'pwa-helpers/connect-mixin';
15
- import gql from 'graphql-tag';
16
- import { ResourceImporter } from './resource-importer';
17
- let ResourceListPage = class ResourceListPage extends connect(store)(localize(i18next)(ScopedElementsMixin(PageView))) {
18
- constructor() {
19
- super(...arguments);
20
- this.mode = isMobileDevice() ? 'CARD' : 'GRID';
21
- }
22
- static get scopedElements() {
23
- return {
24
- 'resource-importer': ResourceImporter
25
- };
26
- }
27
- get context() {
28
- return {
29
- title: i18next.t('title.resource list'),
30
- search: {
31
- handler: (search) => {
32
- this.grist.searchText = search;
33
- },
34
- value: this.grist.searchText
35
- },
36
- filter: {
37
- handler: () => {
38
- this.grist.toggleHeadroom();
39
- }
40
- },
41
- help: 'project/resource',
42
- actions: [
43
- Object.assign({ title: i18next.t('button.save'), action: this.updateResource.bind(this) }, CommonButtonStyles.save),
44
- Object.assign({ title: i18next.t('button.delete'), action: this.deleteResource.bind(this) }, CommonButtonStyles.delete)
45
- ],
46
- exportable: {
47
- name: i18next.t('title.resource list'),
48
- data: this.exportHandler.bind(this)
49
- },
50
- importable: {
51
- handler: this.importHandler.bind(this)
52
- }
53
- };
54
- }
55
- render() {
56
- const mode = this.mode || (isMobileDevice() ? 'CARD' : 'GRID');
57
- return html `
58
- <ox-grist
59
- .mode=${mode}
60
- .config=${this.gristConfig}
61
- .fetchHandler=${this.fetchHandler.bind(this)}
62
- >
63
- <div slot="headroom">
64
- <div id="filters">
65
- <ox-filters-form autofocus></ox-filters-form>
66
- </div>
67
-
68
- <div id="sorters">
69
- Sort
70
- <mwc-icon
71
- @click=${e => {
72
- const target = e.currentTarget;
73
- this.sortersControl.open({
74
- right: 0,
75
- top: target.offsetTop + target.offsetHeight
76
- });
77
- }}
78
- >expand_more</mwc-icon
79
- >
80
- <ox-popup id="sorter-control">
81
- <ox-sorters-control> </ox-sorters-control>
82
- </ox-popup>
83
- </div>
84
-
85
- <div id="modes">
86
- <mwc-icon @click=${() => (this.mode = 'GRID')} ?active=${mode == 'GRID'}>grid_on</mwc-icon>
87
- <mwc-icon @click=${() => (this.mode = 'LIST')} ?active=${mode == 'LIST'}>format_list_bulleted</mwc-icon>
88
- <mwc-icon @click=${() => (this.mode = 'CARD')} ?active=${mode == 'CARD'}>apps</mwc-icon>
89
- </div>
90
- </div>
91
- </ox-grist>
92
- `;
93
- }
94
- async pageInitialized(lifecycle) {
95
- this.gristConfig = {
96
- list: {
97
- fields: ['name', 'description'],
98
- details: ['active', 'updatedAt']
99
- },
100
- columns: [
101
- { type: 'gutter', gutterName: 'sequence' },
102
- { type: 'gutter', gutterName: 'row-selector', multiple: true },
103
- {
104
- type: 'string',
105
- name: 'name',
106
- header: i18next.t('field.name'),
107
- record: {
108
- editable: true
109
- },
110
- filter: 'search',
111
- sortable: true,
112
- width: 150
113
- },
114
- {
115
- type: 'string',
116
- name: 'description',
117
- header: i18next.t('field.description'),
118
- record: {
119
- editable: true
120
- },
121
- filter: 'search',
122
- width: 200
123
- },
124
- {
125
- type: 'checkbox',
126
- name: 'active',
127
- label: true,
128
- header: i18next.t('field.active'),
129
- record: {
130
- editable: true
131
- },
132
- filter: true,
133
- sortable: true,
134
- width: 60
135
- },
136
- {
137
- type: 'resource-object',
138
- name: 'updater',
139
- header: i18next.t('field.updater'),
140
- record: {
141
- editable: false
142
- },
143
- sortable: true,
144
- width: 120
145
- },
146
- {
147
- type: 'datetime',
148
- name: 'updatedAt',
149
- header: i18next.t('field.updated_at'),
150
- record: {
151
- editable: false
152
- },
153
- sortable: true,
154
- width: 180
155
- }
156
- ],
157
- rows: {
158
- selectable: {
159
- multiple: true
160
- }
161
- },
162
- sorters: [
163
- {
164
- name: 'name'
165
- }
166
- ]
167
- };
168
- }
169
- async pageUpdated(changes, lifecycle) {
170
- if (this.active) {
171
- // do something here when this page just became as active
172
- }
173
- }
174
- async fetchHandler({ page = 1, limit = 100, sortings = [], filters = [] }) {
175
- const response = await client.query({
176
- query: gql `
177
- query ($filters: [Filter!], $pagination: Pagination, $sortings: [Sorting!]) {
178
- responses: resources(filters: $filters, pagination: $pagination, sortings: $sortings) {
179
- items {
180
- id
181
- name
182
- description
183
- active
184
- updater {
185
- id
186
- name
187
- }
188
- updatedAt
189
- }
190
- total
191
- }
192
- }
193
- `,
194
- variables: {
195
- filters,
196
- pagination: { page, limit },
197
- sortings
198
- }
199
- });
200
- return {
201
- total: response.data.responses.total || 0,
202
- records: response.data.responses.items || []
203
- };
204
- }
205
- async deleteResource() {
206
- if (await OxPrompt.open({
207
- title: i18next.t('text.are_you_sure'),
208
- text: i18next.t('text.sure_to_x', { x: i18next.t('text.delete') }),
209
- confirmButton: { text: i18next.t('button.confirm') },
210
- cancelButton: { text: i18next.t('button.cancel') }
211
- })) {
212
- const ids = this.grist.selected.map(record => record.id);
213
- if (ids && ids.length > 0) {
214
- const response = await client.mutate({
215
- mutation: gql `
216
- mutation ($ids: [String!]!) {
217
- deleteResources(ids: $ids)
218
- }
219
- `,
220
- variables: {
221
- ids
222
- }
223
- });
224
- if (!response.errors) {
225
- this.grist.fetch();
226
- notify({
227
- message: i18next.t('text.info_x_successfully', { x: i18next.t('text.delete') })
228
- });
229
- }
230
- }
231
- }
232
- }
233
- async updateResource() {
234
- let patches = this.grist.dirtyRecords;
235
- if (patches && patches.length) {
236
- patches = patches.map(patch => {
237
- let patchField = patch.id ? { id: patch.id } : {};
238
- const dirtyFields = patch.__dirtyfields__;
239
- for (let key in dirtyFields) {
240
- patchField[key] = dirtyFields[key].after;
241
- }
242
- patchField.cuFlag = patch.__dirty__;
243
- return patchField;
244
- });
245
- const response = await client.mutate({
246
- mutation: gql `
247
- mutation ($patches: [ResourcePatch!]!) {
248
- updateMultipleResource(patches: $patches) {
249
- name
250
- }
251
- }
252
- `,
253
- variables: {
254
- patches
255
- }
256
- });
257
- if (!response.errors) {
258
- this.grist.fetch();
259
- }
260
- }
261
- }
262
- async exportHandler() {
263
- const exportTargets = this.grist.selected.length ? this.grist.selected : this.grist.dirtyData.records;
264
- const targetFieldSet = new Set([
265
- 'id',
266
- 'name',
267
- 'description',
268
- 'active'
269
- ]);
270
- return exportTargets.map(resource => {
271
- let tempObj = {};
272
- for (const field of targetFieldSet) {
273
- tempObj[field] = resource[field];
274
- }
275
- return tempObj;
276
- });
277
- }
278
- async importHandler(records) {
279
- const popup = openPopup(html `
280
- <resource-importer
281
- .resources=${records}
282
- @imported=${() => {
283
- history.back();
284
- this.grist.fetch();
285
- }}
286
- ></resource-importer>
287
- `, {
288
- backdrop: true,
289
- size: 'large',
290
- title: i18next.t('title.import resource')
291
- });
292
- popup.onclosed = () => {
293
- this.grist.fetch();
294
- };
295
- }
296
- };
297
- ResourceListPage.styles = [
298
- ScrollbarStyles,
299
- CommonGristStyles,
300
- css `
301
- :host {
302
- display: flex;
303
-
304
- width: 100%;
305
-
306
- --grid-record-emphasized-background-color: red;
307
- --grid-record-emphasized-color: yellow;
308
- }
309
- `
310
- ];
311
- __decorate([
312
- state(),
313
- __metadata("design:type", Object)
314
- ], ResourceListPage.prototype, "gristConfig", void 0);
315
- __decorate([
316
- state(),
317
- __metadata("design:type", String)
318
- ], ResourceListPage.prototype, "mode", void 0);
319
- __decorate([
320
- query('ox-grist'),
321
- __metadata("design:type", DataGrist)
322
- ], ResourceListPage.prototype, "grist", void 0);
323
- __decorate([
324
- query('#sorter-control'),
325
- __metadata("design:type", OxPopup)
326
- ], ResourceListPage.prototype, "sortersControl", void 0);
327
- ResourceListPage = __decorate([
328
- customElement('resource-list-page')
329
- ], ResourceListPage);
330
- export { ResourceListPage };
331
- //# sourceMappingURL=resource-list-page.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"resource-list-page.js","sourceRoot":"","sources":["../../../client/pages/resource/resource-list-page.ts"],"names":[],"mappings":";AAAA,OAAO,qBAAqB,CAAA;AAE5B,OAAO,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AACxF,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAA;AAChD,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,KAAK,CAAA;AAC/B,OAAO,EAAE,aAAa,EAAY,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AACzE,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAA;AAC9D,OAAO,EAEL,SAAS,EAGV,MAAM,qBAAqB,CAAA;AAC5B,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAA;AACzC,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AACjD,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AACnD,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AAClD,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAE/C,OAAO,EAAE,OAAO,EAAE,MAAM,2BAA2B,CAAA;AACnD,OAAO,GAAG,MAAM,aAAa,CAAA;AAE7B,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAA;AAG/C,IAAM,gBAAgB,GAAtB,MAAM,gBAAiB,SAAQ,OAAO,CAAC,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;IACH,CAAC;;AArUM,uBAAM,GAAG;IACd,eAAe;IACf,iBAAiB;IACjB,GAAG,CAAA;;;;;;;;;KASF;CACF,CAAA;AAQD;IAAC,KAAK,EAAE;;qDAAyB;AACjC;IAAC,KAAK,EAAE;;8CAA4E;AAEpF;IAAC,KAAK,CAAC,UAAU,CAAC;8BAAiB,SAAS;+CAAA;AAC5C;IAAC,KAAK,CAAC,iBAAiB,CAAC;8BAA0B,OAAO;wDAAA;AA3B/C,gBAAgB;IAD5B,aAAa,CAAC,oBAAoB,CAAC;GACvB,gBAAgB,CAwU5B;SAxUY,gBAAgB","sourcesContent":["import '@operato/data-grist'\n\nimport { CommonButtonStyles, CommonGristStyles, ScrollbarStyles } from '@operato/styles'\nimport { 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 {\n ColumnConfig,\n DataGrist,\n FetchOption,\n SortersControl\n} from '@operato/data-grist'\nimport { client } from '@operato/graphql'\nimport { i18next, localize } from '@operato/i18n'\nimport { notify, openPopup } from '@operato/layout'\nimport { OxPopup, OxPrompt } from '@operato/popup'\nimport { isMobileDevice } from '@operato/utils'\n\nimport { connect } from 'pwa-helpers/connect-mixin'\nimport gql from 'graphql-tag'\n\nimport { ResourceImporter } from './resource-importer'\n\n@customElement('resource-list-page')\nexport class ResourceListPage extends connect(store)(localize(i18next)(ScopedElementsMixin(PageView))) {\n\n static styles = [\n ScrollbarStyles,\n CommonGristStyles,\n css`\n :host {\n display: flex;\n\n width: 100%;\n\n --grid-record-emphasized-background-color: red;\n --grid-record-emphasized-color: yellow;\n }\n `\n ]\n\n static get scopedElements() {\n return {\n 'resource-importer': ResourceImporter\n }\n }\n\n @state() private gristConfig: any\n @state() private mode: 'CARD' | 'GRID' | 'LIST' = isMobileDevice() ? 'CARD' : 'GRID'\n\n @query('ox-grist') private grist!: DataGrist\n @query('#sorter-control') private sortersControl!: OxPopup\n\n get context() {\n return {\n title: i18next.t('title.resource list'),\n search: {\n handler: (search: string) => {\n this.grist.searchText = search\n },\n value: this.grist.searchText\n },\n filter: {\n handler: () => {\n this.grist.toggleHeadroom()\n }\n },\n help: 'project/resource',\n actions: [\n {\n title: i18next.t('button.save'),\n action: this.updateResource.bind(this),\n ...CommonButtonStyles.save\n },\n {\n title: i18next.t('button.delete'),\n action: this.deleteResource.bind(this),\n ...CommonButtonStyles.delete\n }\n ],\n exportable: {\n name: i18next.t('title.resource list'),\n data: this.exportHandler.bind(this)\n },\n importable: {\n handler: this.importHandler.bind(this)\n }\n }\n }\n\n render() {\n const mode = this.mode || (isMobileDevice() ? 'CARD' : 'GRID')\n\n return html`\n <ox-grist\n .mode=${mode}\n .config=${this.gristConfig}\n .fetchHandler=${this.fetchHandler.bind(this)}\n >\n <div slot=\"headroom\">\n <div id=\"filters\">\n <ox-filters-form autofocus></ox-filters-form>\n </div>\n\n <div id=\"sorters\">\n Sort\n <mwc-icon\n @click=${e => {\n const target = e.currentTarget\n this.sortersControl.open({\n right: 0,\n top: target.offsetTop + target.offsetHeight\n })\n }}\n >expand_more</mwc-icon\n >\n <ox-popup id=\"sorter-control\">\n <ox-sorters-control> </ox-sorters-control>\n </ox-popup>\n </div>\n\n <div id=\"modes\">\n <mwc-icon @click=${() => (this.mode = 'GRID')} ?active=${mode == 'GRID'}>grid_on</mwc-icon>\n <mwc-icon @click=${() => (this.mode = 'LIST')} ?active=${mode == 'LIST'}>format_list_bulleted</mwc-icon>\n <mwc-icon @click=${() => (this.mode = 'CARD')} ?active=${mode == 'CARD'}>apps</mwc-icon>\n </div>\n </div>\n </ox-grist>\n `\n }\n\n async pageInitialized(lifecycle: any) {\n this.gristConfig = {\n list: {\n fields: ['name', 'description'],\n details: ['active', 'updatedAt']\n },\n columns: [\n { type: 'gutter', gutterName: 'sequence' },\n { type: 'gutter', gutterName: 'row-selector', multiple: true },\n {\n type: 'string',\n name: 'name',\n header: i18next.t('field.name'),\n record: {\n editable: true\n },\n filter: 'search',\n sortable: true,\n width: 150\n },\n {\n type: 'string',\n name: 'description',\n header: i18next.t('field.description'),\n record: {\n editable: true\n },\n filter: 'search',\n width: 200\n },\n {\n type: 'checkbox',\n name: 'active',\n label: true,\n header: i18next.t('field.active'),\n record: {\n editable: true\n },\n filter: true,\n sortable: true,\n width: 60\n },\n {\n type: 'resource-object',\n name: 'updater',\n header: i18next.t('field.updater'),\n record: {\n editable: false\n },\n sortable: true,\n width: 120\n },\n {\n type: 'datetime',\n name: 'updatedAt',\n header: i18next.t('field.updated_at'),\n record: {\n editable: false\n },\n sortable: true,\n width: 180\n }\n ],\n rows: {\n selectable: {\n multiple: true\n }\n },\n sorters: [\n {\n name: 'name'\n }\n ]\n }\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 fetchHandler({ page = 1, limit = 100, sortings = [], filters = [] }: FetchOption) {\n const response = await client.query({\n query: gql`\n query ($filters: [Filter!], $pagination: Pagination, $sortings: [Sorting!]) {\n responses: resources(filters: $filters, pagination: $pagination, sortings: $sortings) {\n items {\n id\n name\n description\n active\n updater {\n id\n name\n }\n updatedAt\n }\n total\n }\n }\n `,\n variables: {\n filters,\n pagination: { page, limit },\n sortings\n }\n })\n\n return {\n total: response.data.responses.total || 0,\n records: response.data.responses.items || []\n }\n }\n\n private async deleteResource() {\n if (\n await OxPrompt.open({\n title: i18next.t('text.are_you_sure'),\n text: i18next.t('text.sure_to_x', { x: i18next.t('text.delete') }),\n confirmButton: { text: i18next.t('button.confirm') },\n cancelButton: { text: i18next.t('button.cancel') }\n })\n ) {\n const ids = this.grist.selected.map(record => record.id)\n if (ids && ids.length > 0) {\n const response = await client.mutate({\n mutation: gql`\n mutation ($ids: [String!]!) {\n deleteResources(ids: $ids)\n }\n `,\n variables: {\n ids\n }\n })\n\n if (!response.errors) {\n this.grist.fetch()\n notify({\n message: i18next.t('text.info_x_successfully', { x: i18next.t('text.delete') })\n })\n }\n }\n }\n }\n\n private async updateResource() {\n let patches = this.grist.dirtyRecords\n if (patches && patches.length) {\n patches = patches.map(patch => {\n let patchField: any = patch.id ? { id: patch.id } : {}\n const dirtyFields = patch.__dirtyfields__\n for (let key in dirtyFields) {\n patchField[key] = dirtyFields[key].after\n }\n patchField.cuFlag = patch.__dirty__\n\n return patchField\n })\n\n const response = await client.mutate({\n mutation: gql`\n mutation ($patches: [ResourcePatch!]!) {\n updateMultipleResource(patches: $patches) {\n name\n }\n }\n `,\n variables: {\n patches\n }\n })\n\n if (!response.errors) {\n this.grist.fetch()\n }\n }\n }\n\n private async exportHandler() {\n const exportTargets = this.grist.selected.length ? this.grist.selected : this.grist.dirtyData.records\n const targetFieldSet = new Set([\n 'id',\n 'name',\n 'description',\n 'active'\n ])\n\n return exportTargets.map(resource => {\n let tempObj = {}\n for (const field of targetFieldSet) {\n tempObj[field] = resource[field]\n }\n\n return tempObj\n })\n }\n\n private async importHandler(records) {\n const popup = openPopup(\n html`\n <resource-importer\n .resources=${records}\n @imported=${() => {\n history.back()\n this.grist.fetch()\n }}\n ></resource-importer>\n `,\n {\n backdrop: true,\n size: 'large',\n title: i18next.t('title.import resource')\n }\n )\n \n popup.onclosed = () => {\n this.grist.fetch()\n }\n }\n}\n\n"]}
@@ -1,9 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.resolvers = exports.entities = void 0;
4
- const resource_1 = require("./resource");
5
- const resource_query_1 = require("./resource-query");
6
- const resource_mutation_1 = require("./resource-mutation");
7
- exports.entities = [resource_1.Resource];
8
- exports.resolvers = [resource_query_1.ResourceQuery, resource_mutation_1.ResourceMutation];
9
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../server/service/resource/index.ts"],"names":[],"mappings":";;;AAAA,yCAAqC;AACrC,qDAAgD;AAChD,2DAAsD;AAEzC,QAAA,QAAQ,GAAG,CAAC,mBAAQ,CAAC,CAAA;AACrB,QAAA,SAAS,GAAG,CAAC,8BAAa,EAAE,oCAAgB,CAAC,CAAA","sourcesContent":["import { Resource } from './resource'\nimport { ResourceQuery } from './resource-query'\nimport { ResourceMutation } from './resource-mutation'\n\nexport const entities = [Resource]\nexport const resolvers = [ResourceQuery, ResourceMutation]\n"]}