@projectcaluma/ember-analytics 1.0.0-beta.1

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 (84) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/addon/components/ca-field-form.hbs +82 -0
  3. package/addon/components/ca-field-form.js +100 -0
  4. package/addon/components/ca-field-select.hbs +30 -0
  5. package/addon/components/ca-field-select.js +111 -0
  6. package/addon/components/ca-field-selector-list/ca-field-alias-input.hbs +21 -0
  7. package/addon/components/ca-field-selector-list/ca-field-alias-input.js +28 -0
  8. package/addon/components/ca-field-selector-list/ca-field-function-select.hbs +8 -0
  9. package/addon/components/ca-field-selector-list/ca-field-function-select.js +49 -0
  10. package/addon/components/ca-field-selector-list.hbs +82 -0
  11. package/addon/components/ca-field-selector-list.js +54 -0
  12. package/addon/components/ca-filter-modal.hbs +77 -0
  13. package/addon/components/ca-filter-modal.js +59 -0
  14. package/addon/components/ca-report-builder.hbs +26 -0
  15. package/addon/components/ca-report-builder.js +52 -0
  16. package/addon/components/ca-report-list.hbs +27 -0
  17. package/addon/components/ca-report-preview.hbs +42 -0
  18. package/addon/components/ca-report-preview.js +61 -0
  19. package/addon/components/ca-toggle-switch.hbs +19 -0
  20. package/addon/controllers/reports/edit/index.js +17 -0
  21. package/addon/controllers/reports/edit.js +44 -0
  22. package/addon/controllers/reports/index.js +11 -0
  23. package/addon/engine.js +17 -0
  24. package/addon/gql/fragments/analytics-available-field.graphql +8 -0
  25. package/addon/gql/fragments/analytics-field.graphql +9 -0
  26. package/addon/gql/fragments/analytics-table-fields-of-field.graphql +11 -0
  27. package/addon/gql/fragments/analytics-table-result.graphql +22 -0
  28. package/addon/gql/fragments/analytics-table.graphql +23 -0
  29. package/addon/gql/mutations/remove-analytics-field.graphql +5 -0
  30. package/addon/gql/mutations/remove-analytics-table.graphql +5 -0
  31. package/addon/gql/mutations/save-analytics-field.graphql +19 -0
  32. package/addon/gql/mutations/save-analytics-table.graphql +9 -0
  33. package/addon/gql/queries/get-all-analytics-fields.graphql +12 -0
  34. package/addon/gql/queries/get-all-analytics-tables.graphql +11 -0
  35. package/addon/gql/queries/get-analytics-results.graphql +20 -0
  36. package/addon/gql/queries/get-analytics-table.graphql +7 -0
  37. package/addon/gql/queries/get-available-fields-for-field.graphql +8 -0
  38. package/addon/routes/reports/edit/index.js +7 -0
  39. package/addon/routes/reports/edit/preview.js +7 -0
  40. package/addon/routes/reports/edit.js +14 -0
  41. package/addon/routes/reports/index.js +26 -0
  42. package/addon/routes/reports/new.js +32 -0
  43. package/addon/routes.js +11 -0
  44. package/addon/tasks/get-analytics-table.js +19 -0
  45. package/addon/tasks/save-analytics-field.js +19 -0
  46. package/addon/templates/reports/edit/index.hbs +8 -0
  47. package/addon/templates/reports/edit/preview.hbs +1 -0
  48. package/addon/templates/reports/edit.hbs +51 -0
  49. package/addon/templates/reports/index.hbs +4 -0
  50. package/addon/templates/reports/new.hbs +2 -0
  51. package/addon/validations/analytics-table.js +6 -0
  52. package/addon/validations/field.js +14 -0
  53. package/app/components/ca-field-form.js +1 -0
  54. package/app/components/ca-field-select.js +1 -0
  55. package/app/components/ca-field-selector-list/ca-field-alias-input.js +1 -0
  56. package/app/components/ca-field-selector-list/ca-field-function-select.js +1 -0
  57. package/app/components/ca-field-selector-list.js +1 -0
  58. package/app/components/ca-filter-modal.js +1 -0
  59. package/app/components/ca-report-builder.js +1 -0
  60. package/app/components/ca-report-list.js +1 -0
  61. package/app/components/ca-report-preview.js +1 -0
  62. package/app/components/ca-toggle-switch.js +1 -0
  63. package/app/controllers/reports/edit/index.js +1 -0
  64. package/app/controllers/reports/edit.js +1 -0
  65. package/app/controllers/reports/index.js +1 -0
  66. package/app/routes/reports/edit/index.js +1 -0
  67. package/app/routes/reports/edit/preview.js +1 -0
  68. package/app/routes/reports/edit.js +1 -0
  69. package/app/routes/reports/index.js +1 -0
  70. package/app/routes/reports/new.js +1 -0
  71. package/app/styles/@projectcaluma/ember-analytics.scss +1 -0
  72. package/app/styles/_ca-uikit-powerselect.scss +2 -0
  73. package/app/templates/reports/edit/index.js +1 -0
  74. package/app/templates/reports/edit/preview.js +1 -0
  75. package/app/templates/reports/edit.js +1 -0
  76. package/app/templates/reports/index.js +1 -0
  77. package/app/templates/reports/new.js +1 -0
  78. package/blueprints/@projectcaluma/ember-analytics/index.js +18 -0
  79. package/config/environment.js +16 -0
  80. package/index.js +13 -0
  81. package/package.json +90 -0
  82. package/translations/de.yaml +44 -0
  83. package/translations/en.yaml +44 -0
  84. package/translations/fr.yaml +44 -0
@@ -0,0 +1,59 @@
1
+ import { action } from "@ember/object";
2
+ import { inject as service } from "@ember/service";
3
+ import Component from "@glimmer/component";
4
+ import { tracked } from "@glimmer/tracking";
5
+ import { queryManager } from "ember-apollo-client";
6
+ import { enqueueTask } from "ember-concurrency";
7
+
8
+ import saveAnalyticsField from "@projectcaluma/ember-analytics/tasks/save-analytics-field";
9
+
10
+ export default class CaFilterModalComponent extends Component {
11
+ @queryManager apollo;
12
+ @service notification;
13
+ @service intl;
14
+
15
+ @tracked visible = false;
16
+ @tracked newFilter;
17
+ @tracked filters;
18
+
19
+ @enqueueTask saveField = saveAnalyticsField;
20
+
21
+ constructor(...args) {
22
+ super(...args);
23
+ this.filters = this.args.field?.filters ?? [];
24
+ }
25
+
26
+ get graphqlInput() {
27
+ return {
28
+ id: this.args.field.id,
29
+ alias: this.args.field.alias,
30
+ dataSource: this.args.field.dataSource,
31
+ function: this.args.field.function,
32
+ table: this.args.table,
33
+ filters: this.filters,
34
+ };
35
+ }
36
+
37
+ @action
38
+ updateNewFilter({ target: { value } }) {
39
+ this.newFilter = value;
40
+ }
41
+
42
+ @action
43
+ removeFilter(filter) {
44
+ this.filters = this.filters.filter((value) => value !== filter);
45
+ }
46
+
47
+ @action
48
+ addFilter() {
49
+ const filter = this.newFilter.trim();
50
+ if (this.filters.includes(filter)) {
51
+ this.notification.warning(
52
+ this.intl.t("caluma.analytics.notification.filter-exists")
53
+ );
54
+ } else {
55
+ this.filters = [filter, ...this.filters];
56
+ }
57
+ this.newFilter = null;
58
+ }
59
+ }
@@ -0,0 +1,26 @@
1
+ <div data-test-analytics-table ...attributes>
2
+ <ValidatedForm
3
+ @model={{@analyticsTable}}
4
+ @on-submit={{perform this.createTable}}
5
+ as |f|
6
+ >
7
+ <f.input
8
+ @name="name"
9
+ @label={{t "caluma.analytics.report.title"}}
10
+ @required={{true}}
11
+ />
12
+ <f.input
13
+ @type="select"
14
+ @name="startingObject"
15
+ @label={{t "caluma.analytics.report.starting-object"}}
16
+ @options={{this.startingObjects}}
17
+ @optionTargetPath="value"
18
+ @optionValuePath="label"
19
+ @required={{true}}
20
+ />
21
+ <f.submit
22
+ class="uk-margin-small"
23
+ @label={{t "caluma.analytics.report.new"}}
24
+ />
25
+ </ValidatedForm>
26
+ </div>
@@ -0,0 +1,52 @@
1
+ import { inject as service } from "@ember/service";
2
+ import Component from "@glimmer/component";
3
+ import { queryManager } from "ember-apollo-client";
4
+ import { dropTask } from "ember-concurrency";
5
+
6
+ import saveAnalyticsTableMutation from "@projectcaluma/ember-analytics/gql/mutations/save-analytics-table.graphql";
7
+
8
+ export default class CaReportBuilderComponent extends Component {
9
+ @queryManager apollo;
10
+ @service notification;
11
+ @service intl;
12
+ @service router;
13
+
14
+ get startingObjects() {
15
+ // TODO: Replace with dynamic list
16
+ // return this.args.startingObjects;
17
+ return [{ label: "Cases", value: "CASES" }];
18
+ }
19
+
20
+ @dropTask
21
+ *createTable() {
22
+ try {
23
+ this.args.analyticsTable.execute();
24
+ const data = this.args.analyticsTable.data;
25
+ const input = {
26
+ slug: data.slug,
27
+ name: data.name,
28
+ startingObject: data.startingObject,
29
+ };
30
+ yield this.apollo.mutate(
31
+ {
32
+ mutation: saveAnalyticsTableMutation,
33
+ fetchPolicy: "network-only",
34
+ variables: {
35
+ input,
36
+ },
37
+ },
38
+ "saveAnalyticsTable.analyticsTable"
39
+ );
40
+ yield this.args.onAdd?.(
41
+ this.args.analyticsTable.slug,
42
+ this.args.analyticsTable.startingObject
43
+ );
44
+ this.router.transitionTo("reports.edit", data.slug);
45
+ } catch (error) {
46
+ console.error(error);
47
+ this.notification.danger(
48
+ this.intl.t(`caluma.analytics.notification.create-error`)
49
+ );
50
+ }
51
+ }
52
+ }
@@ -0,0 +1,27 @@
1
+ <div ...attributes>
2
+ <table class="uk-table uk-table-divider uk-table-striped uk-table-hover">
3
+ <caption>{{t "caluma.analytics.list.list-title"}}</caption>
4
+ <thead>
5
+ <tr>
6
+ <th>{{t "caluma.analytics.report.title"}}</th>
7
+ <th>{{t "caluma.analytics.report.starting-object"}}</th>
8
+ </tr>
9
+ </thead>
10
+ <tbody>
11
+ {{#each @reports as |report|}}
12
+ <tr>
13
+ <td>
14
+ <LinkTo
15
+ data-test-report-list-item
16
+ @route="reports.edit.index"
17
+ @model={{report.slug}}
18
+ >
19
+ {{report.name}}
20
+ </LinkTo>
21
+ </td>
22
+ <td>{{report.startingObject}}</td>
23
+ </tr>
24
+ {{/each}}
25
+ </tbody>
26
+ </table>
27
+ </div>
@@ -0,0 +1,42 @@
1
+ <div class="uk-overflow-auto">
2
+ {{#if this.data.isRunning}}
3
+ <div class="uk-text-center">
4
+ <UkSpinner @ratio={{1}} />
5
+ </div>
6
+ {{else}}
7
+ <table class="uk-table uk-table-divider uk-table-striped">
8
+ <thead>
9
+ <tr>
10
+ {{#each this.data.value.headings as |header|}}
11
+ <th>
12
+ {{header.alias}}
13
+ {{#if (not-eq header.function "VALUE")}}
14
+ ({{header.function}})
15
+ {{/if}}
16
+ </th>
17
+ {{/each}}
18
+ </tr>
19
+ </thead>
20
+ <tbody>
21
+ {{#each this.data.value.fields as |row|}}
22
+ <tr>
23
+ {{#each row as |entry|}}
24
+ <td>
25
+ {{entry.value}}
26
+ </td>
27
+ {{/each}}
28
+ </tr>
29
+ {{/each}}
30
+ {{#if this.data.value.summary}}
31
+ <tr class="uk-text-bold">
32
+ {{#each this.data.value.summary as |summary|}}
33
+ <td>
34
+ {{summary.value}}
35
+ </td>
36
+ {{/each}}
37
+ </tr>
38
+ {{/if}}
39
+ </tbody>
40
+ </table>
41
+ {{/if}}
42
+ </div>
@@ -0,0 +1,61 @@
1
+ import { inject as service } from "@ember/service";
2
+ import Component from "@glimmer/component";
3
+ import { tracked } from "@glimmer/tracking";
4
+ import { queryManager } from "ember-apollo-client";
5
+ import { task } from "ember-concurrency";
6
+ import { trackedTask } from "ember-resources/util/ember-concurrency";
7
+
8
+ import getAnalyticsResultsQuery from "@projectcaluma/ember-analytics/gql/queries/get-analytics-results.graphql";
9
+
10
+ export default class CaReportPreviewComponent extends Component {
11
+ @queryManager apollo;
12
+ @service notification;
13
+ @service intl;
14
+
15
+ @tracked data = trackedTask(this, this.fetchData, () => [this.args.slug]);
16
+
17
+ @task
18
+ *fetchData() {
19
+ if (this.args.slug) {
20
+ try {
21
+ const result = yield this.apollo.watchQuery(
22
+ {
23
+ query: getAnalyticsResultsQuery,
24
+ fetchPolicy: "no-cache",
25
+ variables: {
26
+ slug: this.args.slug,
27
+ },
28
+ },
29
+ "analyticsTable"
30
+ );
31
+ const headings = result.fields.edges
32
+ .filter(({ node: { showOutput } }) => showOutput)
33
+ .map(({ node }) => node);
34
+ return {
35
+ fields: result.resultData.records.edges.map(({ node }) =>
36
+ headings.map(({ alias }) =>
37
+ node.edges
38
+ .map(({ node }) => node)
39
+ .find((node) => node.alias === alias)
40
+ )
41
+ ),
42
+ summary: result.resultData.summary.edges.length
43
+ ? headings.map(({ alias: headingAlias }) =>
44
+ result.resultData.summary.edges
45
+ .map(({ node }) => node)
46
+ .find(({ alias }) => alias === headingAlias)
47
+ )
48
+ : null,
49
+
50
+ headings,
51
+ };
52
+ } catch (error) {
53
+ console.error(error);
54
+ this.notification.danger(
55
+ this.intl.t("caluma.analytics.notification.fetch-error")
56
+ );
57
+ }
58
+ }
59
+ return null;
60
+ }
61
+ }
@@ -0,0 +1,19 @@
1
+ <div class="uk-flex uk-flex-middle">
2
+ <@labelComponent />
3
+
4
+ <div
5
+ class="uk-form-controls uk-flex uk-flex-middle uk-margin-left"
6
+ ...attributes
7
+ >
8
+ <UkToggleSwitch
9
+ @value={{@value}}
10
+ @size={{@size}}
11
+ @name={{@name}}
12
+ @disabled={{@disabled}}
13
+ @onToggle={{@update}}
14
+ />
15
+ </div>
16
+
17
+ <@hintComponent />
18
+ <@errorComponent />
19
+ </div>
@@ -0,0 +1,17 @@
1
+ import Controller from "@ember/controller";
2
+ import { inject as service } from "@ember/service";
3
+ import { tracked } from "@glimmer/tracking";
4
+ import { queryManager } from "ember-apollo-client";
5
+ import { task } from "ember-concurrency";
6
+ import { trackedTask } from "ember-resources/util/ember-concurrency";
7
+
8
+ import getAnalyticsTable from "@projectcaluma/ember-analytics/tasks/get-analytics-table";
9
+
10
+ export default class ReportsEditIndexController extends Controller {
11
+ @service intl;
12
+ @service notification;
13
+ @queryManager apollo;
14
+
15
+ @task getTable = getAnalyticsTable;
16
+ @tracked data = trackedTask(this, this.getTable, () => [this.model]);
17
+ }
@@ -0,0 +1,44 @@
1
+ import Controller from "@ember/controller";
2
+ import { inject as service } from "@ember/service";
3
+ import { tracked } from "@glimmer/tracking";
4
+ import { queryManager } from "ember-apollo-client";
5
+ import { dropTask, task } from "ember-concurrency";
6
+ import { trackedTask } from "ember-resources/util/ember-concurrency";
7
+
8
+ import removeAnalyticsTableMutation from "@projectcaluma/ember-analytics/gql/mutations/remove-analytics-table.graphql";
9
+ import getAnalyticsTable from "@projectcaluma/ember-analytics/tasks/get-analytics-table";
10
+
11
+ export default class ReportsEditController extends Controller {
12
+ @service intl;
13
+ @service notification;
14
+ @service router;
15
+ @queryManager apollo;
16
+
17
+ @task getTable = getAnalyticsTable;
18
+ @tracked data = trackedTask(this, this.getTable, () => [this.model]);
19
+
20
+ get currentRoute() {
21
+ return this.router.currentRouteName.split(".").pop();
22
+ }
23
+
24
+ @dropTask
25
+ *deleteTable() {
26
+ try {
27
+ yield this.apollo.mutate({
28
+ mutation: removeAnalyticsTableMutation,
29
+ fetchPolicy: "network-only",
30
+ variables: {
31
+ input: {
32
+ slug: this.data.value.slug,
33
+ },
34
+ },
35
+ });
36
+ this.router.transitionTo("reports");
37
+ } catch (error) {
38
+ console.error(error);
39
+ this.notification.danger(
40
+ this.intl.t(`caluma.analytics.notification.delete-error`)
41
+ );
42
+ }
43
+ }
44
+ }
@@ -0,0 +1,11 @@
1
+ import Controller from "@ember/controller";
2
+ import { action } from "@ember/object";
3
+ import { inject as service } from "@ember/service";
4
+ export default class ReportsIndexController extends Controller {
5
+ @service router;
6
+
7
+ @action
8
+ createTable() {
9
+ this.router.transitionTo("reports.new");
10
+ }
11
+ }
@@ -0,0 +1,17 @@
1
+ import Engine from "@ember/engine";
2
+ import loadInitializers from "ember-load-initializers";
3
+ import Resolver from "ember-resolver";
4
+
5
+ import config from "./config/environment";
6
+
7
+ const { modulePrefix } = config;
8
+
9
+ export default class YourEngine extends Engine {
10
+ modulePrefix = modulePrefix;
11
+ Resolver = Resolver;
12
+ dependencies = {
13
+ services: ["apollo", "notification", "intl"],
14
+ };
15
+ }
16
+
17
+ loadInitializers(YourEngine, modulePrefix);
@@ -0,0 +1,8 @@
1
+ fragment AvailableField on AvailableField {
2
+ id
3
+ label
4
+ isLeaf
5
+ isValue
6
+ sourcePath
7
+ supportedFunctions
8
+ }
@@ -0,0 +1,9 @@
1
+ fragment AnalyticsField on AnalyticsField {
2
+ id
3
+ alias
4
+ meta
5
+ dataSource
6
+ function
7
+ showOutput
8
+ filters
9
+ }
@@ -0,0 +1,11 @@
1
+ # import * from '@projectcaluma/ember-analytics/gql/fragments/analytics-available-field.graphql'
2
+
3
+ fragment AnalyticsTableFieldsOfField on AnalyticsTable {
4
+ availableFields(prefix: $prefix, depth: $depth) {
5
+ edges {
6
+ node {
7
+ ...AvailableField
8
+ }
9
+ }
10
+ }
11
+ }
@@ -0,0 +1,22 @@
1
+ fragment ResultData on AnalyticsOutput {
2
+ records {
3
+ edges {
4
+ node {
5
+ edges {
6
+ node {
7
+ alias
8
+ value
9
+ }
10
+ }
11
+ }
12
+ }
13
+ }
14
+ summary {
15
+ edges {
16
+ node {
17
+ alias
18
+ value
19
+ }
20
+ }
21
+ }
22
+ }
@@ -0,0 +1,23 @@
1
+ # import * from '@projectcaluma/ember-analytics/gql/fragments/analytics-field.graphql'
2
+ # import * from '@projectcaluma/ember-analytics/gql/fragments/analytics-available-field.graphql'
3
+
4
+ fragment AnalyticsTable on AnalyticsTable {
5
+ id
6
+ slug
7
+ name
8
+ fields {
9
+ edges {
10
+ node {
11
+ ...AnalyticsField
12
+ }
13
+ }
14
+ }
15
+ availableFields {
16
+ edges {
17
+ node {
18
+ ...AvailableField
19
+ }
20
+ }
21
+ }
22
+ startingObject
23
+ }
@@ -0,0 +1,5 @@
1
+ mutation RemoveAnalyticsField($input: RemoveAnalyticsFieldInput!) {
2
+ removeAnalyticsField(input: $input) {
3
+ clientMutationId
4
+ }
5
+ }
@@ -0,0 +1,5 @@
1
+ mutation RemoveAnalyticsTable($input: RemoveAnalyticsTableInput!) {
2
+ removeAnalyticsTable(input: $input) {
3
+ clientMutationId
4
+ }
5
+ }
@@ -0,0 +1,19 @@
1
+ # import * from '@projectcaluma/ember-analytics/gql/fragments/analytics-field.graphql'
2
+
3
+ mutation SaveAnalyticsField($input: SaveAnalyticsFieldInput!) {
4
+ saveAnalyticsField(input: $input) {
5
+ analyticsField {
6
+ ...AnalyticsField
7
+ table {
8
+ id
9
+ fields {
10
+ edges {
11
+ node {
12
+ id
13
+ }
14
+ }
15
+ }
16
+ }
17
+ }
18
+ }
19
+ }
@@ -0,0 +1,9 @@
1
+ # import * from '@projectcaluma/ember-analytics/gql/fragments/analytics-table.graphql'
2
+
3
+ mutation SaveAnalyticsTable($input: SaveAnalyticsTableInput!) {
4
+ saveAnalyticsTable(input: $input) {
5
+ analyticsTable {
6
+ ...AnalyticsTable
7
+ }
8
+ }
9
+ }
@@ -0,0 +1,12 @@
1
+ # import * from '@projectcaluma/ember-analytics/gql/fragments/analytics-field.graphql'
2
+
3
+ query AllAnalyticsFields {
4
+ allAnalyticsFields {
5
+ totalCount
6
+ edges {
7
+ node {
8
+ ...AnalyticsField
9
+ }
10
+ }
11
+ }
12
+ }
@@ -0,0 +1,11 @@
1
+ # import * from '@projectcaluma/ember-analytics/gql/fragments/analytics-table.graphql'
2
+
3
+ query AllAnalyticsTables {
4
+ allAnalyticsTables {
5
+ edges {
6
+ node {
7
+ ...AnalyticsTable
8
+ }
9
+ }
10
+ }
11
+ }
@@ -0,0 +1,20 @@
1
+ # import * from '@projectcaluma/ember-analytics/gql/fragments/analytics-table-result.graphql'
2
+
3
+ query AnalyticsResults($slug: String!) {
4
+ analyticsTable(slug: $slug) {
5
+ id
6
+ resultData {
7
+ ...ResultData
8
+ }
9
+ fields {
10
+ edges {
11
+ node {
12
+ id
13
+ alias
14
+ function
15
+ showOutput
16
+ }
17
+ }
18
+ }
19
+ }
20
+ }
@@ -0,0 +1,7 @@
1
+ # import * from '@projectcaluma/ember-analytics/gql/fragments/analytics-table.graphql'
2
+
3
+ query AnalyticsTable($slug: String!) {
4
+ analyticsTable(slug: $slug) {
5
+ ...AnalyticsTable
6
+ }
7
+ }
@@ -0,0 +1,8 @@
1
+ # import * from '@projectcaluma/ember-analytics/gql/fragments/analytics-table-fields-of-field.graphql'
2
+
3
+ query AllAnalyticsFields($slug: String!, $prefix: String!, $depth: Int = 1) {
4
+ analyticsTable(slug: $slug) {
5
+ id
6
+ ...AnalyticsTableFieldsOfField
7
+ }
8
+ }
@@ -0,0 +1,7 @@
1
+ import Route from "@ember/routing/route";
2
+
3
+ export default class ReportsEditIndexRoute extends Route {
4
+ model() {
5
+ return this.modelFor("reports.edit");
6
+ }
7
+ }
@@ -0,0 +1,7 @@
1
+ import Route from "@ember/routing/route";
2
+
3
+ export default class ReportsEditPreviewRoute extends Route {
4
+ model() {
5
+ return this.modelFor("reports.edit");
6
+ }
7
+ }
@@ -0,0 +1,14 @@
1
+ import Route from "@ember/routing/route";
2
+ import { t } from "ember-intl";
3
+
4
+ import { navigationTitle } from "@projectcaluma/ember-form-builder/decorators";
5
+
6
+ export default class ReportsEditRoute extends Route {
7
+ @navigationTitle
8
+ @t("caluma.analytics.list.edit")
9
+ title;
10
+
11
+ async model({ report_id: reportId }) {
12
+ return reportId;
13
+ }
14
+ }
@@ -0,0 +1,26 @@
1
+ import Route from "@ember/routing/route";
2
+ import { queryManager } from "ember-apollo-client";
3
+ import { t } from "ember-intl";
4
+
5
+ import getAllAnalyticsTableQuery from "@projectcaluma/ember-analytics/gql/queries/get-all-analytics-tables.graphql";
6
+ import { navigationTitle } from "@projectcaluma/ember-form-builder/decorators";
7
+
8
+ export default class ReportsIndexRoute extends Route {
9
+ @queryManager apollo;
10
+
11
+ @navigationTitle
12
+ @t("caluma.analytics.report.new")
13
+ title;
14
+
15
+ async model() {
16
+ const tables = await this.apollo.query(
17
+ {
18
+ fetchPolicy: "network-only",
19
+ query: getAllAnalyticsTableQuery,
20
+ },
21
+ "allAnalyticsTables"
22
+ );
23
+
24
+ return tables.edges.map((edge) => edge.node);
25
+ }
26
+ }
@@ -0,0 +1,32 @@
1
+ import Route from "@ember/routing/route";
2
+ import { tracked } from "@glimmer/tracking";
3
+ import { Changeset } from "ember-changeset";
4
+ import lookupValidator from "ember-changeset-validations";
5
+
6
+ import AnalyticsTableValidations from "@projectcaluma/ember-analytics/validations/analytics-table";
7
+ import slugify from "@projectcaluma/ember-core/utils/slugify";
8
+
9
+ class AnalyticsTable {
10
+ constructor({ name, startingObject } = {}) {
11
+ this.name = name;
12
+ this.startingObject = startingObject;
13
+ }
14
+
15
+ get slug() {
16
+ return slugify(this.name ?? "");
17
+ }
18
+ @tracked name;
19
+ @tracked startingObject;
20
+ }
21
+
22
+ export default class ReportsNewRoute extends Route {
23
+ model() {
24
+ return new Changeset(
25
+ new AnalyticsTable({
26
+ startingObject: "CASES",
27
+ }),
28
+ lookupValidator(AnalyticsTableValidations),
29
+ AnalyticsTableValidations
30
+ );
31
+ }
32
+ }