@crowdin/app-project-module 0.20.3 → 0.20.5

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/README.md CHANGED
@@ -217,6 +217,22 @@ configuration.projectIntegration.loginForm = {
217
217
  helpText: 'Api Key for http requests',
218
218
  key: 'apiKey',
219
219
  label: 'Api Key'
220
+ },
221
+ {
222
+ key: 'server',
223
+ label: 'Data center',
224
+ type: 'select',
225
+ defaultValue: '1',
226
+ options: [
227
+ {
228
+ value: '1',
229
+ label: 'USA'
230
+ },
231
+ {
232
+ value: '2',
233
+ label: 'EU'
234
+ }
235
+ ]
220
236
  }
221
237
  ]
222
238
  };
@@ -337,7 +337,19 @@ export interface FormField {
337
337
  helpText?: string;
338
338
  helpTextHtml?: string;
339
339
  label: string;
340
- type?: 'text' | 'password' | 'checkbox';
340
+ type?: 'text' | 'password' | 'checkbox' | 'select';
341
+ defaultValue?: any;
342
+ /**
343
+ * only for select
344
+ */
345
+ isMulti?: boolean;
346
+ /**
347
+ * only for select
348
+ */
349
+ options?: {
350
+ label: string;
351
+ value: string;
352
+ }[];
341
353
  }
342
354
  export declare type TreeItem = File | Folder;
343
355
  export interface File {
@@ -30,6 +30,8 @@ class PostgreStorage {
30
30
  return res;
31
31
  }
32
32
  catch (e) {
33
+ console.error('executeQuery error occurred!');
34
+ console.error(e);
33
35
  yield client.end();
34
36
  throw e;
35
37
  }
@@ -24,24 +24,48 @@
24
24
  {{#if helpTextHtml}}
25
25
  help-text-html="{{helpTextHtml}}"
26
26
  {{/if}}
27
+ {{#ifeq defaultValue true}}
28
+ checked="{{defaultValue}}"
29
+ {{/ifeq}}
27
30
  >
28
31
  </crowdin-checkbox>
29
32
  {{else}}
30
- <crowdin-input
31
- id="{{key}}"
32
- label="{{label}}"
33
- {{#if helpText}}
34
- help-text="{{helpText}}"
35
- {{/if}}
36
- {{#if helpTextHtml}}
37
- help-text-html="{{helpTextHtml}}"
38
- {{/if}}
39
- {{#if type}}
40
- type="{{type}}"
41
- {{/if}}
42
- value="">
43
- </crowdin-input>
44
- {{/ifeq}}
33
+ {{#ifeq type "select"}}
34
+ <crowdin-select
35
+ {{#if isMulti}}
36
+ is-multi
37
+ close-on-select="false"
38
+ {{/if}}
39
+ id="{{key}}"
40
+ label="{{label}}"
41
+ {{#if helpText}}
42
+ help-text="{{helpText}}"
43
+ {{/if}}
44
+ {{#if helpTextHtml}}
45
+ help-text-html="{{helpTextHtml}}"
46
+ {{/if}}
47
+ >
48
+ {{#each options}}
49
+ <option {{#ifeq ../defaultValue value}} selected {{/ifeq}} value="{{value}}">{{label}}</option>
50
+ {{/each}}
51
+ </crowdin-select>
52
+ {{else}}
53
+ <crowdin-input
54
+ id="{{key}}"
55
+ label="{{label}}"
56
+ {{#if helpText}}
57
+ help-text="{{helpText}}"
58
+ {{/if}}
59
+ {{#if helpTextHtml}}
60
+ help-text-html="{{helpTextHtml}}"
61
+ {{/if}}
62
+ {{#if type}}
63
+ type="{{type}}"
64
+ {{/if}}
65
+ value="{{#if defaultValue}}{{defaultValue}}{{/if}}">
66
+ </crowdin-input>
67
+ {{/ifeq}}
68
+ {{/ifeq}}
45
69
  {{/each}}
46
70
  </div>
47
71
  {{/if}}
@@ -133,7 +133,7 @@
133
133
  <script type="text/javascript">
134
134
  document.body.addEventListener('refreshFilesList', (e) => {
135
135
  if (e.detail.refreshIntegration) {
136
- getIntegrationData();
136
+ getIntegrationData(true);
137
137
  } else if (e.detail.refreshCrowdin) {
138
138
  getCrowdinData();
139
139
  }
@@ -144,7 +144,7 @@
144
144
  }
145
145
  {{#if integrationOneLevelFetching}}
146
146
  if (event.detail.componentId === 'integration-files' && event.detail.isOpen) {
147
- getIntegrationData(event.detail.id);
147
+ getIntegrationData(false, event.detail.id);
148
148
  }
149
149
  {{/if}}
150
150
  });
@@ -152,7 +152,7 @@
152
152
  document.body.addEventListener('uploadFilesToIntegration', uploadFilesToIntegration);
153
153
  {{#if integrationSearchListener}}
154
154
  document.body.addEventListener("integrationFilterChange", (event) => {
155
- getIntegrationData(0, event.detail);
155
+ getIntegrationData(false, 0, event.detail);
156
156
  })
157
157
  {{/if}}
158
158
  const appComponent = document.querySelector('crowdin-simple-integration');
@@ -212,7 +212,7 @@
212
212
  .finally(() => (appComponent.setAttribute('is-crowdin-loading', false)));
213
213
  }
214
214
 
215
- function getIntegrationData(parentId = null, search = '') {
215
+ function getIntegrationData(hardReload = false, parentId = '', search = '',) {
216
216
  appComponent.setAttribute('is-integration-loading', true);
217
217
  checkOrigin()
218
218
  .then(restParams => fetch(`api/integration/data${restParams}&parent_id=${parentId}&search=${search}`))
@@ -232,7 +232,11 @@
232
232
  }
233
233
  return item;
234
234
  });
235
- appComponent.pushIntegrationFilesData(tree);
235
+ if (hardReload) {
236
+ appComponent.setIntegrationFilesData(tree);
237
+ } else {
238
+ appComponent.pushIntegrationFilesData(tree);
239
+ }
236
240
  if (search) {
237
241
  const openIds = res.filter(e => !e.type).map(e => e.id);
238
242
  appComponent.setIntegrationOpenedFolders(openIds);
@@ -382,7 +386,7 @@
382
386
  settingsSaveBtn.removeAttribute('disabled');
383
387
  settingsModal.close();
384
388
  {{#if reloadOnConfigSave}}
385
- getIntegrationData();
389
+ getIntegrationData(true);
386
390
  getCrowdinData();
387
391
  {{/if}}
388
392
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@crowdin/app-project-module",
3
- "version": "0.20.3",
3
+ "version": "0.20.5",
4
4
  "description": "Module that generates for you all common endpoints for serving standalone Crowdin App",
5
5
  "main": "out/index.js",
6
6
  "types": "out/index.d.ts",