@genesislcap/pbc-reporting-ui 14.392.0 → 14.393.0

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 (23) hide show
  1. package/dist/dts/new/main/edit-config/base-config/base-config.d.ts +7 -3
  2. package/dist/dts/new/main/edit-config/base-config/base-config.d.ts.map +1 -1
  3. package/dist/dts/new/main/edit-config/base-config/base-config.template.d.ts.map +1 -1
  4. package/dist/dts/new/main/edit-config/config-journey-orchestrator.d.ts.map +1 -1
  5. package/dist/dts/new/main/edit-config/datasource-config/datasources-config-container.helpers.d.ts.map +1 -1
  6. package/dist/dts/new/main/edit-config/datasource-config/datasources-config-container.template.d.ts.map +1 -1
  7. package/dist/dts/new/utils/tooltip.d.ts +2 -2
  8. package/dist/dts/new/utils/tooltip.d.ts.map +1 -1
  9. package/dist/esm/new/main/edit-config/base-config/base-config.js +20 -7
  10. package/dist/esm/new/main/edit-config/base-config/base-config.template.js +28 -32
  11. package/dist/esm/new/main/edit-config/config-journey-orchestrator.js +12 -4
  12. package/dist/esm/new/main/edit-config/datasource-config/datasources-config-container.helpers.js +4 -2
  13. package/dist/esm/new/main/edit-config/datasource-config/datasources-config-container.helpers.test.js +39 -3
  14. package/dist/esm/new/main/edit-config/datasource-config/datasources-config-container.template.js +6 -5
  15. package/dist/esm/new/utils/tooltip.js +3 -3
  16. package/package.json +22 -22
  17. package/src/new/main/edit-config/base-config/base-config.template.ts +37 -45
  18. package/src/new/main/edit-config/base-config/base-config.ts +17 -6
  19. package/src/new/main/edit-config/config-journey-orchestrator.ts +19 -4
  20. package/src/new/main/edit-config/datasource-config/datasources-config-container.helpers.test.ts +51 -3
  21. package/src/new/main/edit-config/datasource-config/datasources-config-container.helpers.ts +4 -2
  22. package/src/new/main/edit-config/datasource-config/datasources-config-container.template.ts +6 -5
  23. package/src/new/utils/tooltip.ts +3 -3
@@ -1,11 +1,15 @@
1
1
  import { Connect } from '@genesislcap/foundation-comms';
2
- import { GenesisElement } from '@genesislcap/web-core';
2
+ import { ExecutionContext, GenesisElement } from '@genesislcap/web-core';
3
3
  import { Genesis } from '../../../types';
4
4
  export declare class BaseConfig extends GenesisElement {
5
5
  connect: Connect;
6
+ /** All templates available in the document server */
6
7
  fileTemplates: Array<Genesis.FileStorageDataRow>;
7
- get allowedTemplates(): Array<Genesis.FileStorageDataRow>;
8
- connectedCallback(): void;
8
+ /** All available templates accounting for currently selected output type */
9
+ allowedTemplates: Array<Genesis.FileStorageDataRow>;
10
+ connectedCallback(): Promise<void>;
11
+ getAllowedTemplates(): Array<Genesis.FileStorageDataRow>;
12
+ handleOutputFormatChanged(ctx: ExecutionContext<any, any>): void;
9
13
  handleOutputFormatChange(event: Event): Promise<void>;
10
14
  handleTemplateSelectChange(selectInput: HTMLSelectElement): void;
11
15
  getFileTemplates(): Promise<void>;
@@ -1 +1 @@
1
- {"version":3,"file":"base-config.d.ts","sourceRoot":"","sources":["../../../../../../src/new/main/edit-config/base-config/base-config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAU,MAAM,+BAA+B,CAAC;AAEhE,OAAO,EAAiB,cAAc,EAAwB,MAAM,uBAAuB,CAAC;AAE5F,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAMzC,qBAKa,UAAW,SAAQ,cAAc;IACnC,OAAO,EAAG,OAAO,CAAC;IAEf,aAAa,EAAE,KAAK,CAAC,OAAO,CAAC,kBAAkB,CAAC,CAAC;IAE7D,IACI,gBAAgB,IAAI,KAAK,CAAC,OAAO,CAAC,kBAAkB,CAAC,CAWxD;IAED,iBAAiB;IAKX,wBAAwB,CAAC,KAAK,EAAE,KAAK;IAiC3C,0BAA0B,CAAC,WAAW,EAAE,iBAAiB;IAYnD,gBAAgB,IAAI,OAAO,CAAC,IAAI,CAAC;CAkBxC"}
1
+ {"version":3,"file":"base-config.d.ts","sourceRoot":"","sources":["../../../../../../src/new/main/edit-config/base-config/base-config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAU,MAAM,+BAA+B,CAAC;AAEhE,OAAO,EAAiB,gBAAgB,EAAE,cAAc,EAAc,MAAM,uBAAuB,CAAC;AAEpG,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAMzC,qBAKa,UAAW,SAAQ,cAAc;IACnC,OAAO,EAAG,OAAO,CAAC;IAE3B,qDAAqD;IACzC,aAAa,EAAE,KAAK,CAAC,OAAO,CAAC,kBAAkB,CAAC,CAAC;IAC7D,4EAA4E;IAChE,gBAAgB,EAAE,KAAK,CAAC,OAAO,CAAC,kBAAkB,CAAC,CAAC;IAE1D,iBAAiB;IAMvB,mBAAmB,IAAI,KAAK,CAAC,OAAO,CAAC,kBAAkB,CAAC;IAaxD,yBAAyB,CAAC,GAAG,EAAE,gBAAgB,CAAC,GAAG,EAAE,GAAG,CAAC;IAQnD,wBAAwB,CAAC,KAAK,EAAE,KAAK;IAiC3C,0BAA0B,CAAC,WAAW,EAAE,iBAAiB;IAYnD,gBAAgB,IAAI,OAAO,CAAC,IAAI,CAAC;CAkBxC"}
@@ -1 +1 @@
1
- {"version":3,"file":"base-config.template.d.ts","sourceRoot":"","sources":["../../../../../../src/new/main/edit-config/base-config/base-config.template.ts"],"names":[],"mappings":"AACA,OAAO,EAAgC,iBAAiB,EAAa,MAAM,gBAAgB,CAAC;AAG5F,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAEhD,eAAO,MAAM,aAAa,sBAAsB,CAAC;AAEjD,eAAO,MAAM,wBAAwB,EAAE,MAAM,CAAC,iBAAiB,EAAE,MAAM,EAAE,CAIxE,CAAC;AA+CF,eAAO,MAAM,QAAQ,iEAsEpB,CAAC"}
1
+ {"version":3,"file":"base-config.template.d.ts","sourceRoot":"","sources":["../../../../../../src/new/main/edit-config/base-config/base-config.template.ts"],"names":[],"mappings":"AACA,OAAO,EAAgC,iBAAiB,EAAa,MAAM,gBAAgB,CAAC;AAG5F,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAEhD,eAAO,MAAM,aAAa,sBAAsB,CAAC;AAEjD,eAAO,MAAM,wBAAwB,EAAE,MAAM,CAAC,iBAAiB,EAAE,MAAM,EAAE,CAIxE,CAAC;AA6CF,eAAO,MAAM,QAAQ,iEAgEpB,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"config-journey-orchestrator.d.ts","sourceRoot":"","sources":["../../../../../src/new/main/edit-config/config-journey-orchestrator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,+BAA+B,CAAC;AAExD,OAAO,EAAE,IAAI,EAAE,MAAM,8BAA8B,CAAC;AASpD,OAAO,EAAE,uBAAuB,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIjF,qBAKa,yBAA0B,SAAQ,8BAE9C;IACU,OAAO,EAAG,OAAO,CAAC;IACrB,IAAI,EAAG,IAAI,CAAC;IAElB,OAAO,CAAC,cAAc,CAAyC;IAE/D,mBAAmB;IAInB,oBAAoB;IASpB,kBAAkB;IAUZ,iBAAiB;IAyBvB,OAAO,CAAC,YAAY;CASrB"}
1
+ {"version":3,"file":"config-journey-orchestrator.d.ts","sourceRoot":"","sources":["../../../../../src/new/main/edit-config/config-journey-orchestrator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,+BAA+B,CAAC;AAExD,OAAO,EAAE,IAAI,EAAE,MAAM,8BAA8B,CAAC;AASpD,OAAO,EAAE,uBAAuB,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIjF,qBAKa,yBAA0B,SAAQ,8BAE9C;IACU,OAAO,EAAG,OAAO,CAAC;IACrB,IAAI,EAAG,IAAI,CAAC;IAElB,OAAO,CAAC,cAAc,CAAyC;IAE/D,mBAAmB;IAInB,oBAAoB;IASpB,kBAAkB;IAyBZ,iBAAiB;IAyBvB,OAAO,CAAC,YAAY;CASrB"}
@@ -1 +1 @@
1
- {"version":3,"file":"datasources-config-container.helpers.d.ts","sourceRoot":"","sources":["../../../../../../src/new/main/edit-config/datasource-config/datasources-config-container.helpers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAU,MAAM,+BAA+B,CAAC;AAEhE,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAGzC,OAAO,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAE3C,MAAM,MAAM,gBAAgB,GAAG,CAAC,QAAQ,EAAE,MAAM,KAAK,OAAO,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;AAElF,eAAO,MAAM,yBAAyB,GACnC,WAAW,gBAAgB,MACrB,SAAS,gBAAgB,EAAE,KAAG,OAAO,CAAC,IAAI,CAkChD,CAAC;AAEJ,eAAO,MAAM,wBAAwB,GAClC,WAAW,gBAAgB,MAAY,kBAAkB,gBAAgB,EAAE;;;;EAc3E,CAAC;AAGJ,eAAO,MAAM,cAAc,GAAU,SAAS,OAAO,KAAG,OAAO,CAAC,gBAAgB,EAAE,CAsBjF,CAAC"}
1
+ {"version":3,"file":"datasources-config-container.helpers.d.ts","sourceRoot":"","sources":["../../../../../../src/new/main/edit-config/datasource-config/datasources-config-container.helpers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAU,MAAM,+BAA+B,CAAC;AAEhE,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAGzC,OAAO,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAE3C,MAAM,MAAM,gBAAgB,GAAG,CAAC,QAAQ,EAAE,MAAM,KAAK,OAAO,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;AAElF,eAAO,MAAM,yBAAyB,GACnC,WAAW,gBAAgB,MACrB,SAAS,gBAAgB,EAAE,KAAG,OAAO,CAAC,IAAI,CAoChD,CAAC;AAEJ,eAAO,MAAM,wBAAwB,GAClC,WAAW,gBAAgB,MAAY,kBAAkB,gBAAgB,EAAE;;;;EAc3E,CAAC;AAGJ,eAAO,MAAM,cAAc,GAAU,SAAS,OAAO,KAAG,OAAO,CAAC,gBAAgB,EAAE,CAsBjF,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"datasources-config-container.template.d.ts","sourceRoot":"","sources":["../../../../../../src/new/main/edit-config/datasource-config/datasources-config-container.template.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,gCAAgC,CAAC;AA+CjF,eAAO,MAAM,QAAQ,iFAUpB,CAAC"}
1
+ {"version":3,"file":"datasources-config-container.template.d.ts","sourceRoot":"","sources":["../../../../../../src/new/main/edit-config/datasource-config/datasources-config-container.template.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,gCAAgC,CAAC;AAgDjF,eAAO,MAAM,QAAQ,iFAUpB,CAAC"}
@@ -5,8 +5,8 @@ export declare namespace TOOLTIP {
5
5
  const SETUP_FILENAME = "\n <h3>File name</h3>\n <p>Configure the file name to apply to generated reports.</p>\n <p>The file extension type will automatically be added to this file name.</p>\n";
6
6
  const SETUP_DIRECTORY = "\n <h3>Output directory</h3>\n <p>Configure the directory that generated reports will be stored under within the Document Manager</p>\n";
7
7
  const SETUP_DESCRIPTION = "\n <h3>Description</h3>\n <p>Here you may optionally include a more detailed description describing this report configuration.</p>\n";
8
- const SETUP_FILE_TYPE = "\n <h3>File type</h3>\n <p>Select the type of file to use when generating the report. You can choose between CSV, XLSX, and PDF</p>\n <ul>\n <li><strong>CSV</strong>: Generates a simple csv report. No template is required</li>\n <li><strong>XLSX</strong>: Generates an Excel workbook. Selecting a template is optional</li>\n <li><strong>PDF</strong>: Generates a PDF file. Selecting a template is mandatory</li>\n </ul>\n <p>Note: If you currently have more than one datasource selected in the \"Add Datasources\" step, then you cannot select CSV output here, please delete all but one datasource where changing the file type</p>\n";
9
- const SETUP_FILE_TEMPLATE = "\n <h3>File template</h3>\n <p>The template file to use when generating the report. This will only display relevant template files that are available in the Document Manager for the file type configured.</p>\n <ul>\n <li>Where File type is set to <strong>XLXS</strong> you may optionally select a <code>.xls</code> or <code>.xlxs</code> template. Where no template file is selected, you the workbook will be generated with a tab for each of the data sources configured in the \"Add Datasources\" step.</li>\n <li>Where File type is set to <strong>PDF</strong> you must select a <code>.html</code> or <code>.xhtml</code> template that you've uploaded to the document manager PBC</li>\n </ul>\n ";
8
+ const SETUP_FILE_TYPE = "\n <h3>File type</h3>\n <p>Select the type of file to use when generating the report. You can choose between CSV, XLSX, and PDF</p>\n <ul>\n <li><strong>CSV</strong>: Generates a CSV report. Selecting a template is optional</li>\n <li><strong>XLSX</strong>: Generates an Excel workbook. Selecting a template is optional</li>\n <li><strong>PDF</strong>: Generates a PDF file. Selecting a template is mandatory</li>\n </ul>\n";
9
+ const SETUP_FILE_TEMPLATE = "\n <h3>File template</h3>\n <p>The template file to use when generating the report. This will only display relevant template files that are available in the Document Manager for the file type configured.</p>\n <ul>\n <li>Where File type is set to <strong>CSV</strong> you may optionally select a <code>.csv</code> or <code>.txt</code> template. To use multiple datasources with <strong>CSV</strong> you must select a template.</li>\n <li>Where File type is set to <strong>XLSX</strong> you may optionally select a <code>.xls</code> or <code>.xlsx</code> template. Where no template file is selected, the workbook will be generated with a tab for each of the data sources configured in the \"Add Datasources\" step.</li>\n <li>Where File type is set to <strong>PDF</strong> you must select a <code>.html</code> or <code>.xhtml</code> template that you've uploaded to the document manager PBC</li>\n </ul>\n ";
10
10
  const DATASOURCES_NAME = "\n <h3>Datasource name</h3>\n <p>Allows you to set a name for the datasource which must correspond with your template data references where the report is configured to use a template file.</p>\n <p>Where File Type is XLSX and no template is selected, this will be the name of the tab containing this data source's data in the resulting workbook.</p>\n";
11
11
  const DATASOURCES_TYPE = "\n <h3>Datasource type</h3>\n <p>Configures the method by which the server constructs the report configuration. Currently only TABLE is supported, which means the entire datasource is loaded into memory when generating the report using this report configuration.</p>\n";
12
12
  const DELIVERY_TIMEZONE = "\n <h3>Timezone</h3>\n <p>Select the timezone to be used for this schedule.</p>\n";
@@ -1 +1 @@
1
- {"version":3,"file":"tooltip.d.ts","sourceRoot":"","sources":["../../../../src/new/utils/tooltip.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,OAAO,GAAI,MAAM,MAAM,EAAE,OAAO,MAAM,6DAElD,CAAC;AAMF,eAAO,MAAM,eAAe,0DAA0C,CAAC;AAEvE,yBAAiB,OAAO,CAAC;IAChB,MAAM,UAAU,uJAGxB,CAAC;IAEO,MAAM,cAAc,+KAI5B,CAAC;IAEO,MAAM,eAAe,8IAG7B,CAAC;IAEO,MAAM,iBAAiB,2IAG/B,CAAC;IAEO,MAAM,eAAe,0oBAS7B,CAAC;IAEO,MAAM,mBAAmB,qsBAO/B,CAAC;IAEK,MAAM,gBAAgB,uWAI9B,CAAC;IAEO,MAAM,gBAAgB,mRAG9B,CAAC;IAEO,MAAM,iBAAiB,wFAG/B,CAAC;IAEO,MAAM,gBAAgB,qGAG9B,CAAC;CACD"}
1
+ {"version":3,"file":"tooltip.d.ts","sourceRoot":"","sources":["../../../../src/new/utils/tooltip.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,OAAO,GAAI,MAAM,MAAM,EAAE,OAAO,MAAM,6DAElD,CAAC;AAMF,eAAO,MAAM,eAAe,0DAA0C,CAAC;AAEvE,yBAAiB,OAAO,CAAC;IAChB,MAAM,UAAU,uJAGxB,CAAC;IAEO,MAAM,cAAc,+KAI5B,CAAC;IAEO,MAAM,eAAe,8IAG7B,CAAC;IAEO,MAAM,iBAAiB,2IAG/B,CAAC;IAEO,MAAM,eAAe,ybAQ7B,CAAC;IAEO,MAAM,mBAAmB,65BAQ/B,CAAC;IAEK,MAAM,gBAAgB,uWAI9B,CAAC;IAEO,MAAM,gBAAgB,mRAG9B,CAAC;IAEO,MAAM,iBAAiB,wFAG/B,CAAC;IAEO,MAAM,gBAAgB,qGAG9B,CAAC;CACD"}
@@ -1,7 +1,7 @@
1
1
  import { __awaiter, __decorate } from "tslib";
2
2
  import { Connect, logger } from '@genesislcap/foundation-comms';
3
3
  import { showNotificationToast } from '@genesislcap/foundation-notifications';
4
- import { customElement, GenesisElement, observable, volatile } from '@genesislcap/web-core';
4
+ import { customElement, GenesisElement, observable } from '@genesislcap/web-core';
5
5
  import { actions, selectors } from '../../../store';
6
6
  import { Genesis } from '../../../types';
7
7
  import { getDatasourceSchema } from '../../../utils';
@@ -9,7 +9,17 @@ import { setDefaultFormatsForDatasource } from '../data-transforms-derived-field
9
9
  import { styles } from './base-config.styles';
10
10
  import { allowedTemplateFiletypes, NULL_TEMPLATE, template } from './base-config.template';
11
11
  let BaseConfig = class BaseConfig extends GenesisElement {
12
- get allowedTemplates() {
12
+ connectedCallback() {
13
+ const _super = Object.create(null, {
14
+ connectedCallback: { get: () => super.connectedCallback }
15
+ });
16
+ return __awaiter(this, void 0, void 0, function* () {
17
+ _super.connectedCallback.call(this);
18
+ yield this.getFileTemplates();
19
+ this.allowedTemplates = this.getAllowedTemplates();
20
+ });
21
+ }
22
+ getAllowedTemplates() {
13
23
  var _a, _b;
14
24
  const allowedFiletypes = allowedTemplateFiletypes[(_a = selectors.baseConfig.getConfig().OUTPUT_FORMAT) !== null && _a !== void 0 ? _a : 'CSV'];
15
25
  return ((_b = this.fileTemplates) !== null && _b !== void 0 ? _b : [])
@@ -21,9 +31,12 @@ let BaseConfig = class BaseConfig extends GenesisElement {
21
31
  .filter(({ fileExtension }) => allowedFiletypes.includes(fileExtension))
22
32
  .map(({ file }) => file);
23
33
  }
24
- connectedCallback() {
25
- super.connectedCallback();
26
- this.getFileTemplates();
34
+ handleOutputFormatChanged(ctx) {
35
+ actions.baseConfig.deleteTemplate();
36
+ actions.baseConfig.setOutputFormat({
37
+ format: ctx.event.target.value,
38
+ });
39
+ this.allowedTemplates = this.getAllowedTemplates();
27
40
  }
28
41
  handleOutputFormatChange(event) {
29
42
  return __awaiter(this, void 0, void 0, function* () {
@@ -94,8 +107,8 @@ __decorate([
94
107
  observable
95
108
  ], BaseConfig.prototype, "fileTemplates", void 0);
96
109
  __decorate([
97
- volatile
98
- ], BaseConfig.prototype, "allowedTemplates", null);
110
+ observable
111
+ ], BaseConfig.prototype, "allowedTemplates", void 0);
99
112
  BaseConfig = __decorate([
100
113
  customElement({
101
114
  name: 'base-config',
@@ -1,41 +1,42 @@
1
- import { html, repeat, when, whenElse } from '@genesislcap/web-core';
1
+ import { html, repeat, when } from '@genesislcap/web-core';
2
2
  import { actions, reportOutputFormats, selectors } from '../../../store';
3
3
  import { Genesis } from '../../../types';
4
4
  import { requiredTooltip, TOOLTIP, tooltip } from '../../../utils';
5
5
  export const NULL_TEMPLATE = 'Select a template';
6
6
  export const allowedTemplateFiletypes = {
7
- CSV: [],
7
+ CSV: ['csv', 'txt'],
8
8
  PDF: ['html', 'xhtml'],
9
9
  XLSX: ['xls', 'xlsx'],
10
10
  };
11
11
  const fileTemplatePicker = html `
12
- ${when((_) => selectors.baseConfig.getConfig().OUTPUT_FORMAT !== 'CSV', html `
13
- <label class="label">File template${tooltip(TOOLTIP.SETUP_FILE_TEMPLATE)}</label>
14
- ${whenElse((x) => { var _a; return ((_a = x.allowedTemplates) === null || _a === void 0 ? void 0 : _a.length) > 0; }, html `
15
- <rapid-select
16
- data-test-id="config-document-template"
17
- value=${() => selectors.baseConfig.getConfig().DOCUMENT_TEMPLATE_ID || NULL_TEMPLATE}
18
- @change=${(x, ctx) => x.handleTemplateSelectChange(ctx.event.target)}
19
- >
12
+ <label class="label">File template${tooltip(TOOLTIP.SETUP_FILE_TEMPLATE)}</label>
13
+ ${repeat(
14
+ // Wrap in a repeat directive with recycle false forces FAST to to rebuild the DOM
15
+ // structure when `x.allowedTemplates` changes. This fixes issue with stale options
16
+ // in the select input
17
+ (x) => { var _a; return (((_a = x.allowedTemplates) === null || _a === void 0 ? void 0 : _a.length) > 0 ? [x] : []); }, html `
18
+ <rapid-select
19
+ data-test-id="config-document-template"
20
+ value=${() => selectors.baseConfig.getConfig().DOCUMENT_TEMPLATE_ID || NULL_TEMPLATE}
21
+ @change=${(x, ctx) => x.handleTemplateSelectChange(ctx.event.target)}
22
+ >
23
+ <rapid-option ?selected=${(_) => !selectors.baseConfig.getConfig().DOCUMENT_TEMPLATE_ID}>
24
+ ${NULL_TEMPLATE}
25
+ </rapid-option>
26
+ ${repeat((x) => x.allowedTemplates, html `
20
27
  <rapid-option
21
- ?selected=${(_) => !selectors.baseConfig.getConfig().DOCUMENT_TEMPLATE_ID}
28
+ value="${(x) => x[Genesis.FileStorageFields.FILE_STORAGE_ID]}"
29
+ ?selected=${(x) => x[Genesis.FileStorageFields.FILE_STORAGE_ID] ===
30
+ selectors.baseConfig.getConfig().DOCUMENT_TEMPLATE_ID}
22
31
  >
23
- ${NULL_TEMPLATE}
32
+ ${(x) => x[Genesis.FileStorageFields.FILE_NAME]}
24
33
  </rapid-option>
25
- ${repeat((x) => x.allowedTemplates, html `
26
- <rapid-option
27
- value="${(x) => x[Genesis.FileStorageFields.FILE_STORAGE_ID]}"
28
- ?selected=${(x) => x[Genesis.FileStorageFields.FILE_STORAGE_ID] ===
29
- selectors.baseConfig.getConfig().DOCUMENT_TEMPLATE_ID}
30
- >
31
- ${(x) => x[Genesis.FileStorageFields.FILE_NAME]}
32
- </rapid-option>
33
- `, { recycle: false })}
34
- </rapid-select>
35
- `, html `
36
- No valid templates defined on file server for selected output format
37
- (${(_) => allowedTemplateFiletypes[selectors.baseConfig.getConfig().OUTPUT_FORMAT].join(', ')}).
38
- `)}
34
+ `)}
35
+ </rapid-select>
36
+ `, { recycle: false })}
37
+ ${when((x) => !x.allowedTemplates || x.allowedTemplates.length === 0, html `
38
+ No valid templates defined on file server for selected output format
39
+ (${(_) => allowedTemplateFiletypes[selectors.baseConfig.getConfig().OUTPUT_FORMAT].join(', ')}).
39
40
  `)}
40
41
  `;
41
42
  export const template = html `
@@ -61,12 +62,7 @@ export const template = html `
61
62
  @change=${(x, ctx) => x.handleOutputFormatChange(ctx.event)}
62
63
  >
63
64
  ${repeat(() => reportOutputFormats, html `
64
- <rapid-option
65
- value="${(x) => x}"
66
- ?disabled=${(x) => x === 'CSV' && Object.keys(selectors.datasourceConfig.getAllConfigSet()).length > 1}
67
- >
68
- ${(x) => '.' + x.toLowerCase()}
69
- </rapid-option>
65
+ <rapid-option value="${(x) => x}">${(x) => '.' + x.toLowerCase()}</rapid-option>
70
66
  `)}
71
67
  </rapid-select>
72
68
  <label class="label">File name${requiredTooltip}${tooltip(TOOLTIP.SETUP_FILENAME)}</label>
@@ -25,13 +25,21 @@ let ConfigJourneyOrchestrator = class ConfigJourneyOrchestrator extends EventEmi
25
25
  return true;
26
26
  }
27
27
  validateDatasource() {
28
- // This should only fail if there is a serious issue and no datasources are being returned
28
+ // Basic check against a serious issue and no datasources are being returned
29
29
  // to the front end
30
- const isValid = Object.keys(selectors.datasourceConfig.getAllConfigSet()).length > 0;
31
- if (!isValid) {
30
+ if (!(Object.keys(selectors.datasourceConfig.getAllConfigSet()).length > 0)) {
32
31
  this.displayError(new Error('At least one datasource needs to be configured'), true);
32
+ return false;
33
+ }
34
+ // Check the user hasn't selected multiple datasources with csv but no template
35
+ if (selectors.baseConfig.getConfig().OUTPUT_FORMAT === 'CSV' &&
36
+ !selectors.baseConfig.getConfig().DOCUMENT_TEMPLATE_ID &&
37
+ Object.keys(selectors.datasourceConfig.getAllConfigSet()).length > 1) {
38
+ this.displayError(new Error('You cannot select more than one datasource if you are using csv output format, unless you select a template.' +
39
+ '\nSelect a template or change output type on the previous step, or remove all but one datasource.'), true);
40
+ return false;
33
41
  }
34
- return isValid;
42
+ return true;
35
43
  }
36
44
  saveConfigHandler() {
37
45
  return __awaiter(this, void 0, void 0, function* () {
@@ -11,9 +11,11 @@ export const createNewDatasourceConfig = (getSchema) => (choices) => __awaiter(v
11
11
  logger.error('No datasources available to create new config from');
12
12
  return;
13
13
  }
14
+ const baseConfig = selectors.baseConfig.getConfig();
14
15
  if (Object.keys(selectors.datasourceConfig.getAllConfigSet()).length > 0 &&
15
- selectors.baseConfig.getConfig().OUTPUT_FORMAT === 'CSV') {
16
- logger.error('Cannot add multiple datasources when using csv file');
16
+ baseConfig.OUTPUT_FORMAT === 'CSV' &&
17
+ !baseConfig.DOCUMENT_TEMPLATE_ID) {
18
+ logger.error('Cannot add multiple datasources when using csv file without a template');
17
19
  return;
18
20
  }
19
21
  const { KEY, INPUT_TYPE, schema } = yield findFirstValidDatasource(getSchema)(validDatasources);
@@ -190,10 +190,46 @@ CreateNewDatasourceConfig('should exit when trying to add multiple datasources w
190
190
  const loggerStub = sinon.stub(logger, 'error');
191
191
  const getSchemaStub = sinon.stub().resolves({});
192
192
  yield createNewDatasourceConfig(getSchemaStub)(mockChoices);
193
+ assert.equal(getAllConfigSetStub.callCount, 2, 'getAllConfigSetStub should be called twice');
194
+ assert.equal(getConfigStub.callCount, 1, 'getConfigStub should be called once');
195
+ // assert.ok(loggerStub.calledWith('Cannot add multiple datasources when using csv file without a template'));
196
+ if (loggerStub.args.length > 0) {
197
+ assert.equal(loggerStub.args[0][0], 'Cannot add multiple datasources when using csv file without a template');
198
+ }
199
+ else {
200
+ assert.unreachable('Logger was not called');
201
+ }
202
+ assert.equal(getSchemaStub.callCount, 0, 'getSchemaStub should not be called');
203
+ }));
204
+ CreateNewDatasourceConfig('should allow adding multiple datasources with CSV format IF template is selected', () => __awaiter(void 0, void 0, void 0, function* () {
205
+ const mockChoices = [{ name: 'test', inputType: 'REQ_REP' }];
206
+ const getAllConfigSetStub = sinon.stub(selectors.datasourceConfig, 'getAllConfigSet').returns({
207
+ REQ_REP_existing: {
208
+ KEY: 'REQ_REP_existing',
209
+ NAME: 'Existing Datasource',
210
+ INPUT_TYPE: 'REQ_REP',
211
+ OUTPUT_TYPE: 'TABLE',
212
+ TRANSFORMER_CONFIGURATION: { INCLUDE_COLUMNS: [] },
213
+ },
214
+ });
215
+ sinon.stub(selectors.baseConfig, 'getConfig').returns({
216
+ DESTINATION_IDS: [],
217
+ OUTPUT_DIRECTORY: '/reports',
218
+ OUTPUT_FORMAT: 'CSV',
219
+ DOCUMENT_TEMPLATE_ID: 'some-template-id',
220
+ });
221
+ const mockSchema = {
222
+ properties: {
223
+ field1: {},
224
+ field2: {},
225
+ },
226
+ };
227
+ const getSchemaStub = sinon.stub().resolves(mockSchema);
228
+ const initConfigStub = sinon.stub(actions.datasourceConfig, 'initDatasourceConfiguration');
229
+ yield createNewDatasourceConfig(getSchemaStub)(mockChoices);
193
230
  assert.ok(getAllConfigSetStub.calledTwice);
194
- assert.ok(getConfigStub.calledOnce);
195
- assert.ok(loggerStub.calledWith('Cannot add multiple datasources when using csv file'));
196
- assert.ok(!getSchemaStub.called);
231
+ assert.ok(getSchemaStub.calledOnce);
232
+ assert.ok(initConfigStub.called);
197
233
  }));
198
234
  CreateNewDatasourceConfig('should successfully create new datasource configuration', () => __awaiter(void 0, void 0, void 0, function* () {
199
235
  const mockChoices = [{ name: 'test', inputType: 'REQ_REP' }];
@@ -11,14 +11,15 @@ const container = html `
11
11
  <div class="container">
12
12
  <h1>Datasources</h1>
13
13
  ${when((_) => selectors.baseConfig.getConfig().OUTPUT_FORMAT &&
14
- selectors.baseConfig.getConfig().OUTPUT_FORMAT !== 'CSV', addDatasourceControl)}
14
+ (selectors.baseConfig.getConfig().OUTPUT_FORMAT !== 'CSV' ||
15
+ !!selectors.baseConfig.getConfig().DOCUMENT_TEMPLATE_ID), addDatasourceControl)}
15
16
  </div>
16
17
  <p>Here you can select the datasource(s) you want to use in the generated report.</p>
17
18
  <p>
18
- CSV reports may only have a single data source. XLSX or PDF reports may contain one or more
19
- datasources to include in the report and will allow you to configure the "Name" of each, which
20
- must correspond with your template data references if the report is configured to use a template
21
- file. Use the + button in the top right to add any additional data sources.
19
+ CSV reports may only have a single data source unless a template is selected. XLSX and PDF
20
+ reports may contain one or more datasources. If a template file is used, you must configure the
21
+ "Name" of each datasource to correspond with your template data references. Use the + button in
22
+ the top right to add any additional data sources.
22
23
  </p>
23
24
  <p>
24
25
  Changing the data source will remove any datasource related configurations previously set up for
@@ -30,17 +30,17 @@ export var TOOLTIP;
30
30
  <h3>File type</h3>
31
31
  <p>Select the type of file to use when generating the report. You can choose between CSV, XLSX, and PDF</p>
32
32
  <ul>
33
- <li><strong>CSV</strong>: Generates a simple csv report. No template is required</li>
33
+ <li><strong>CSV</strong>: Generates a CSV report. Selecting a template is optional</li>
34
34
  <li><strong>XLSX</strong>: Generates an Excel workbook. Selecting a template is optional</li>
35
35
  <li><strong>PDF</strong>: Generates a PDF file. Selecting a template is mandatory</li>
36
36
  </ul>
37
- <p>Note: If you currently have more than one datasource selected in the "Add Datasources" step, then you cannot select CSV output here, please delete all but one datasource where changing the file type</p>
38
37
  `;
39
38
  TOOLTIP.SETUP_FILE_TEMPLATE = `
40
39
  <h3>File template</h3>
41
40
  <p>The template file to use when generating the report. This will only display relevant template files that are available in the Document Manager for the file type configured.</p>
42
41
  <ul>
43
- <li>Where File type is set to <strong>XLXS</strong> you may optionally select a <code>.xls</code> or <code>.xlxs</code> template. Where no template file is selected, you the workbook will be generated with a tab for each of the data sources configured in the "Add Datasources" step.</li>
42
+ <li>Where File type is set to <strong>CSV</strong> you may optionally select a <code>.csv</code> or <code>.txt</code> template. To use multiple datasources with <strong>CSV</strong> you must select a template.</li>
43
+ <li>Where File type is set to <strong>XLSX</strong> you may optionally select a <code>.xls</code> or <code>.xlsx</code> template. Where no template file is selected, the workbook will be generated with a tab for each of the data sources configured in the "Add Datasources" step.</li>
44
44
  <li>Where File type is set to <strong>PDF</strong> you must select a <code>.html</code> or <code>.xhtml</code> template that you've uploaded to the document manager PBC</li>
45
45
  </ul>
46
46
  `;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@genesislcap/pbc-reporting-ui",
3
3
  "description": "Genesis PBC Reporting UI",
4
- "version": "14.392.0",
4
+ "version": "14.393.0",
5
5
  "license": "SEE LICENSE IN license.txt",
6
6
  "main": "dist/esm/index.js",
7
7
  "types": "dist/dts/index.d.ts",
@@ -104,21 +104,21 @@
104
104
  "@ag-grid-community/core": "29.2.0"
105
105
  },
106
106
  "dependencies": {
107
- "@genesislcap/foundation-comms": "14.392.0",
108
- "@genesislcap/foundation-entity-management": "14.392.0",
109
- "@genesislcap/foundation-events": "14.392.0",
110
- "@genesislcap/foundation-forms": "14.392.0",
111
- "@genesislcap/foundation-logger": "14.392.0",
112
- "@genesislcap/foundation-notifications": "14.392.0",
113
- "@genesislcap/foundation-ui": "14.392.0",
114
- "@genesislcap/foundation-user": "14.392.0",
115
- "@genesislcap/foundation-utils": "14.392.0",
116
- "@genesislcap/foundation-zero": "14.392.0",
117
- "@genesislcap/foundation-zero-grid-pro": "14.392.0",
118
- "@genesislcap/grid-pro": "14.392.0",
119
- "@genesislcap/rapid-design-system": "14.392.0",
120
- "@genesislcap/rapid-grid-pro": "14.392.0",
121
- "@genesislcap/web-core": "14.392.0",
107
+ "@genesislcap/foundation-comms": "14.393.0",
108
+ "@genesislcap/foundation-entity-management": "14.393.0",
109
+ "@genesislcap/foundation-events": "14.393.0",
110
+ "@genesislcap/foundation-forms": "14.393.0",
111
+ "@genesislcap/foundation-logger": "14.393.0",
112
+ "@genesislcap/foundation-notifications": "14.393.0",
113
+ "@genesislcap/foundation-ui": "14.393.0",
114
+ "@genesislcap/foundation-user": "14.393.0",
115
+ "@genesislcap/foundation-utils": "14.393.0",
116
+ "@genesislcap/foundation-zero": "14.393.0",
117
+ "@genesislcap/foundation-zero-grid-pro": "14.393.0",
118
+ "@genesislcap/grid-pro": "14.393.0",
119
+ "@genesislcap/rapid-design-system": "14.393.0",
120
+ "@genesislcap/rapid-grid-pro": "14.393.0",
121
+ "@genesislcap/web-core": "14.393.0",
122
122
  "@reduxjs/toolkit": "^2.2.5",
123
123
  "@types/node": "^22.10.2",
124
124
  "change-case": "^5.4.3",
@@ -127,11 +127,11 @@
127
127
  "devDependencies": {
128
128
  "@genesiscommunitysuccess/cep-fast-plugin": "^5.0.3",
129
129
  "@genesiscommunitysuccess/custom-elements-lsp": "^5.0.3",
130
- "@genesislcap/eslint-config": "14.392.0",
131
- "@genesislcap/foundation-testing": "14.392.0",
132
- "@genesislcap/genx": "14.392.0",
133
- "@genesislcap/prettier-config": "14.392.0",
134
- "@genesislcap/stylelint-config": "14.392.0",
130
+ "@genesislcap/eslint-config": "14.393.0",
131
+ "@genesislcap/foundation-testing": "14.393.0",
132
+ "@genesislcap/genx": "14.393.0",
133
+ "@genesislcap/prettier-config": "14.393.0",
134
+ "@genesislcap/stylelint-config": "14.393.0",
135
135
  "@types/json-schema": "^7.0.11",
136
136
  "playwright-lighthouse": "^4.0.0",
137
137
  "rimraf": "^5.0.0"
@@ -140,5 +140,5 @@
140
140
  "access": "public"
141
141
  },
142
142
  "customElements": "dist/custom-elements.json",
143
- "gitHead": "3737d3ce26db3413e4473aa3487eaa1955ea27b5"
143
+ "gitHead": "25378dcb43ef1a8a78dbcbcd39720c3cd3c61f78"
144
144
  }
@@ -1,4 +1,4 @@
1
- import { html, repeat, when, whenElse } from '@genesislcap/web-core';
1
+ import { html, repeat, when } from '@genesislcap/web-core';
2
2
  import { actions, reportOutputFormats, ReportOutputTypes, selectors } from '../../../store';
3
3
  import { Genesis } from '../../../types';
4
4
  import { requiredTooltip, TOOLTIP, tooltip } from '../../../utils';
@@ -7,52 +7,50 @@ import type { BaseConfig } from './base-config';
7
7
  export const NULL_TEMPLATE = 'Select a template';
8
8
 
9
9
  export const allowedTemplateFiletypes: Record<ReportOutputTypes, string[]> = {
10
- CSV: [],
10
+ CSV: ['csv', 'txt'],
11
11
  PDF: ['html', 'xhtml'],
12
12
  XLSX: ['xls', 'xlsx'],
13
13
  };
14
14
 
15
15
  const fileTemplatePicker = html<BaseConfig>`
16
- ${when(
17
- (_) => selectors.baseConfig.getConfig().OUTPUT_FORMAT !== 'CSV',
16
+ <label class="label">File template${tooltip(TOOLTIP.SETUP_FILE_TEMPLATE)}</label>
17
+ ${repeat(
18
+ // Wrap in a repeat directive with recycle false forces FAST to to rebuild the DOM
19
+ // structure when `x.allowedTemplates` changes. This fixes issue with stale options
20
+ // in the select input
21
+ (x) => (x.allowedTemplates?.length > 0 ? [x] : []),
18
22
  html<BaseConfig>`
19
- <label class="label">File template${tooltip(TOOLTIP.SETUP_FILE_TEMPLATE)}</label>
20
- ${whenElse(
21
- (x) => x.allowedTemplates?.length > 0,
22
- html<BaseConfig>`
23
- <rapid-select
24
- data-test-id="config-document-template"
25
- value=${() => selectors.baseConfig.getConfig().DOCUMENT_TEMPLATE_ID || NULL_TEMPLATE}
26
- @change=${(x, ctx) =>
27
- x.handleTemplateSelectChange(ctx.event.target as HTMLSelectElement)}
28
- >
23
+ <rapid-select
24
+ data-test-id="config-document-template"
25
+ value=${() => selectors.baseConfig.getConfig().DOCUMENT_TEMPLATE_ID || NULL_TEMPLATE}
26
+ @change=${(x, ctx) => x.handleTemplateSelectChange(ctx.event.target as HTMLSelectElement)}
27
+ >
28
+ <rapid-option ?selected=${(_) => !selectors.baseConfig.getConfig().DOCUMENT_TEMPLATE_ID}>
29
+ ${NULL_TEMPLATE}
30
+ </rapid-option>
31
+ ${repeat(
32
+ (x) => x.allowedTemplates,
33
+ html<Genesis.FileStorageDataRow>`
29
34
  <rapid-option
30
- ?selected=${(_) => !selectors.baseConfig.getConfig().DOCUMENT_TEMPLATE_ID}
35
+ value="${(x) => x[Genesis.FileStorageFields.FILE_STORAGE_ID]}"
36
+ ?selected=${(x) =>
37
+ x[Genesis.FileStorageFields.FILE_STORAGE_ID] ===
38
+ selectors.baseConfig.getConfig().DOCUMENT_TEMPLATE_ID}
31
39
  >
32
- ${NULL_TEMPLATE}
40
+ ${(x) => x[Genesis.FileStorageFields.FILE_NAME]}
33
41
  </rapid-option>
34
- ${repeat(
35
- (x) => x.allowedTemplates,
36
- html<Genesis.FileStorageDataRow>`
37
- <rapid-option
38
- value="${(x) => x[Genesis.FileStorageFields.FILE_STORAGE_ID]}"
39
- ?selected=${(x) =>
40
- x[Genesis.FileStorageFields.FILE_STORAGE_ID] ===
41
- selectors.baseConfig.getConfig().DOCUMENT_TEMPLATE_ID}
42
- >
43
- ${(x) => x[Genesis.FileStorageFields.FILE_NAME]}
44
- </rapid-option>
45
- `,
46
- { recycle: false },
47
- )}
48
- </rapid-select>
49
- `,
50
- html`
51
- No valid templates defined on file server for selected output format
52
- (${(_) =>
53
- allowedTemplateFiletypes[selectors.baseConfig.getConfig().OUTPUT_FORMAT].join(', ')}).
54
- `,
55
- )}
42
+ `,
43
+ )}
44
+ </rapid-select>
45
+ `,
46
+ { recycle: false },
47
+ )}
48
+ ${when(
49
+ (x) => !x.allowedTemplates || x.allowedTemplates.length === 0,
50
+ html`
51
+ No valid templates defined on file server for selected output format
52
+ (${(_) =>
53
+ allowedTemplateFiletypes[selectors.baseConfig.getConfig().OUTPUT_FORMAT].join(', ')}).
56
54
  `,
57
55
  )}
58
56
  `;
@@ -83,13 +81,7 @@ export const template = html<BaseConfig>`
83
81
  ${repeat(
84
82
  () => reportOutputFormats,
85
83
  html<ReportOutputTypes>`
86
- <rapid-option
87
- value="${(x) => x}"
88
- ?disabled=${(x) =>
89
- x === 'CSV' && Object.keys(selectors.datasourceConfig.getAllConfigSet()).length > 1}
90
- >
91
- ${(x) => '.' + x.toLowerCase()}
92
- </rapid-option>
84
+ <rapid-option value="${(x) => x}">${(x) => '.' + x.toLowerCase()}</rapid-option>
93
85
  `,
94
86
  )}
95
87
  </rapid-select>
@@ -1,6 +1,6 @@
1
1
  import { Connect, logger } from '@genesislcap/foundation-comms';
2
2
  import { showNotificationToast } from '@genesislcap/foundation-notifications';
3
- import { customElement, GenesisElement, observable, volatile } from '@genesislcap/web-core';
3
+ import { customElement, ExecutionContext, GenesisElement, observable } from '@genesislcap/web-core';
4
4
  import { actions, DatasourceName, ReportOutputTypes, selectors } from '../../../store';
5
5
  import { Genesis } from '../../../types';
6
6
  import { getDatasourceSchema } from '../../../utils';
@@ -16,10 +16,18 @@ import { allowedTemplateFiletypes, NULL_TEMPLATE, template } from './base-config
16
16
  export class BaseConfig extends GenesisElement {
17
17
  @Connect connect!: Connect;
18
18
 
19
+ /** All templates available in the document server */
19
20
  @observable fileTemplates: Array<Genesis.FileStorageDataRow>;
21
+ /** All available templates accounting for currently selected output type */
22
+ @observable allowedTemplates: Array<Genesis.FileStorageDataRow>;
20
23
 
21
- @volatile
22
- get allowedTemplates(): Array<Genesis.FileStorageDataRow> {
24
+ async connectedCallback() {
25
+ super.connectedCallback();
26
+ await this.getFileTemplates();
27
+ this.allowedTemplates = this.getAllowedTemplates();
28
+ }
29
+
30
+ getAllowedTemplates(): Array<Genesis.FileStorageDataRow> {
23
31
  const allowedFiletypes =
24
32
  allowedTemplateFiletypes[selectors.baseConfig.getConfig().OUTPUT_FORMAT ?? 'CSV'];
25
33
  return (this.fileTemplates ?? [])
@@ -32,9 +40,12 @@ export class BaseConfig extends GenesisElement {
32
40
  .map(({ file }) => file);
33
41
  }
34
42
 
35
- connectedCallback() {
36
- super.connectedCallback();
37
- this.getFileTemplates();
43
+ handleOutputFormatChanged(ctx: ExecutionContext<any, any>) {
44
+ actions.baseConfig.deleteTemplate();
45
+ actions.baseConfig.setOutputFormat({
46
+ format: (<HTMLSelectElement>ctx.event.target).value as ReportOutputTypes,
47
+ });
48
+ this.allowedTemplates = this.getAllowedTemplates();
38
49
  }
39
50
 
40
51
  async handleOutputFormatChange(event: Event) {
@@ -40,13 +40,28 @@ export class ConfigJourneyOrchestrator extends EventEmitter<ReportingEventDetail
40
40
  }
41
41
 
42
42
  validateDatasource() {
43
- // This should only fail if there is a serious issue and no datasources are being returned
43
+ // Basic check against a serious issue and no datasources are being returned
44
44
  // to the front end
45
- const isValid = Object.keys(selectors.datasourceConfig.getAllConfigSet()).length > 0;
46
- if (!isValid) {
45
+ if (!(Object.keys(selectors.datasourceConfig.getAllConfigSet()).length > 0)) {
47
46
  this.displayError(new Error('At least one datasource needs to be configured'), true);
47
+ return false;
48
+ }
49
+ // Check the user hasn't selected multiple datasources with csv but no template
50
+ if (
51
+ selectors.baseConfig.getConfig().OUTPUT_FORMAT === 'CSV' &&
52
+ !selectors.baseConfig.getConfig().DOCUMENT_TEMPLATE_ID &&
53
+ Object.keys(selectors.datasourceConfig.getAllConfigSet()).length > 1
54
+ ) {
55
+ this.displayError(
56
+ new Error(
57
+ 'You cannot select more than one datasource if you are using csv output format, unless you select a template.' +
58
+ '\nSelect a template or change output type on the previous step, or remove all but one datasource.',
59
+ ),
60
+ true,
61
+ );
62
+ return false;
48
63
  }
49
- return isValid;
64
+ return true;
50
65
  }
51
66
 
52
67
  async saveConfigHandler() {
@@ -238,10 +238,58 @@ CreateNewDatasourceConfig(
238
238
 
239
239
  await createNewDatasourceConfig(getSchemaStub)(mockChoices);
240
240
 
241
+ assert.equal(getAllConfigSetStub.callCount, 2, 'getAllConfigSetStub should be called twice');
242
+ assert.equal(getConfigStub.callCount, 1, 'getConfigStub should be called once');
243
+ // assert.ok(loggerStub.calledWith('Cannot add multiple datasources when using csv file without a template'));
244
+ if (loggerStub.args.length > 0) {
245
+ assert.equal(
246
+ loggerStub.args[0][0],
247
+ 'Cannot add multiple datasources when using csv file without a template',
248
+ );
249
+ } else {
250
+ assert.unreachable('Logger was not called');
251
+ }
252
+ assert.equal(getSchemaStub.callCount, 0, 'getSchemaStub should not be called');
253
+ },
254
+ );
255
+
256
+ CreateNewDatasourceConfig(
257
+ 'should allow adding multiple datasources with CSV format IF template is selected',
258
+ async () => {
259
+ const mockChoices = [{ name: 'test', inputType: 'REQ_REP' as DatasourceInputTypes }];
260
+
261
+ const getAllConfigSetStub = sinon.stub(selectors.datasourceConfig, 'getAllConfigSet').returns({
262
+ REQ_REP_existing: {
263
+ KEY: 'REQ_REP_existing',
264
+ NAME: 'Existing Datasource',
265
+ INPUT_TYPE: 'REQ_REP' as const,
266
+ OUTPUT_TYPE: 'TABLE' as const,
267
+ TRANSFORMER_CONFIGURATION: { INCLUDE_COLUMNS: [] },
268
+ },
269
+ });
270
+
271
+ sinon.stub(selectors.baseConfig, 'getConfig').returns({
272
+ DESTINATION_IDS: [],
273
+ OUTPUT_DIRECTORY: '/reports',
274
+ OUTPUT_FORMAT: 'CSV',
275
+ DOCUMENT_TEMPLATE_ID: 'some-template-id',
276
+ });
277
+
278
+ const mockSchema = {
279
+ properties: {
280
+ field1: {},
281
+ field2: {},
282
+ },
283
+ };
284
+
285
+ const getSchemaStub = sinon.stub().resolves(mockSchema);
286
+ const initConfigStub = sinon.stub(actions.datasourceConfig, 'initDatasourceConfiguration');
287
+
288
+ await createNewDatasourceConfig(getSchemaStub)(mockChoices);
289
+
241
290
  assert.ok(getAllConfigSetStub.calledTwice);
242
- assert.ok(getConfigStub.calledOnce);
243
- assert.ok(loggerStub.calledWith('Cannot add multiple datasources when using csv file'));
244
- assert.ok(!getSchemaStub.called);
291
+ assert.ok(getSchemaStub.calledOnce);
292
+ assert.ok(initConfigStub.called);
245
293
  },
246
294
  );
247
295
 
@@ -22,11 +22,13 @@ export const createNewDatasourceConfig =
22
22
  logger.error('No datasources available to create new config from');
23
23
  return;
24
24
  }
25
+ const baseConfig = selectors.baseConfig.getConfig();
25
26
  if (
26
27
  Object.keys(selectors.datasourceConfig.getAllConfigSet()).length > 0 &&
27
- selectors.baseConfig.getConfig().OUTPUT_FORMAT === 'CSV'
28
+ baseConfig.OUTPUT_FORMAT === 'CSV' &&
29
+ !baseConfig.DOCUMENT_TEMPLATE_ID
28
30
  ) {
29
- logger.error('Cannot add multiple datasources when using csv file');
31
+ logger.error('Cannot add multiple datasources when using csv file without a template');
30
32
  return;
31
33
  }
32
34
 
@@ -17,16 +17,17 @@ const container = html<DatasourcesConfigContainer>`
17
17
  ${when(
18
18
  (_) =>
19
19
  selectors.baseConfig.getConfig().OUTPUT_FORMAT &&
20
- selectors.baseConfig.getConfig().OUTPUT_FORMAT !== 'CSV',
20
+ (selectors.baseConfig.getConfig().OUTPUT_FORMAT !== 'CSV' ||
21
+ !!selectors.baseConfig.getConfig().DOCUMENT_TEMPLATE_ID),
21
22
  addDatasourceControl,
22
23
  )}
23
24
  </div>
24
25
  <p>Here you can select the datasource(s) you want to use in the generated report.</p>
25
26
  <p>
26
- CSV reports may only have a single data source. XLSX or PDF reports may contain one or more
27
- datasources to include in the report and will allow you to configure the "Name" of each, which
28
- must correspond with your template data references if the report is configured to use a template
29
- file. Use the + button in the top right to add any additional data sources.
27
+ CSV reports may only have a single data source unless a template is selected. XLSX and PDF
28
+ reports may contain one or more datasources. If a template file is used, you must configure the
29
+ "Name" of each datasource to correspond with your template data references. Use the + button in
30
+ the top right to add any additional data sources.
30
31
  </p>
31
32
  <p>
32
33
  Changing the data source will remove any datasource related configurations previously set up for
@@ -36,18 +36,18 @@ export namespace TOOLTIP {
36
36
  <h3>File type</h3>
37
37
  <p>Select the type of file to use when generating the report. You can choose between CSV, XLSX, and PDF</p>
38
38
  <ul>
39
- <li><strong>CSV</strong>: Generates a simple csv report. No template is required</li>
39
+ <li><strong>CSV</strong>: Generates a CSV report. Selecting a template is optional</li>
40
40
  <li><strong>XLSX</strong>: Generates an Excel workbook. Selecting a template is optional</li>
41
41
  <li><strong>PDF</strong>: Generates a PDF file. Selecting a template is mandatory</li>
42
42
  </ul>
43
- <p>Note: If you currently have more than one datasource selected in the "Add Datasources" step, then you cannot select CSV output here, please delete all but one datasource where changing the file type</p>
44
43
  `;
45
44
 
46
45
  export const SETUP_FILE_TEMPLATE = `
47
46
  <h3>File template</h3>
48
47
  <p>The template file to use when generating the report. This will only display relevant template files that are available in the Document Manager for the file type configured.</p>
49
48
  <ul>
50
- <li>Where File type is set to <strong>XLXS</strong> you may optionally select a <code>.xls</code> or <code>.xlxs</code> template. Where no template file is selected, you the workbook will be generated with a tab for each of the data sources configured in the "Add Datasources" step.</li>
49
+ <li>Where File type is set to <strong>CSV</strong> you may optionally select a <code>.csv</code> or <code>.txt</code> template. To use multiple datasources with <strong>CSV</strong> you must select a template.</li>
50
+ <li>Where File type is set to <strong>XLSX</strong> you may optionally select a <code>.xls</code> or <code>.xlsx</code> template. Where no template file is selected, the workbook will be generated with a tab for each of the data sources configured in the "Add Datasources" step.</li>
51
51
  <li>Where File type is set to <strong>PDF</strong> you must select a <code>.html</code> or <code>.xhtml</code> template that you've uploaded to the document manager PBC</li>
52
52
  </ul>
53
53
  `;