/
checker-module-output.model.ts
executable file
·85 lines (65 loc) · 2.76 KB
/
checker-module-output.model.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
import { CheckerModuleBaseModel, CheckerModuleIOTypeOptions, CheckerModuleOutput, CheckerOutput, CheckerModuleType, CheckerModuleTypeOptions, CheckerModuleIOType, CheckerModuleIOTypeValue } from './checker-internals';
import { ThreeSiteModel } from '../site.model';
import { model, type, validate, Model, GetAllOptions } from 'aurelia-deco';
@model('/three/checker/flow')
export class CheckerModuleOutputModel extends CheckerModuleBaseModel implements CheckerModuleOutput {
@type.id
public id: string;
public flowId: string;
@type.model({model: ThreeSiteModel})
@validate.required
public siteId: string;
@type.select({options: CheckerModuleIOTypeOptions, multiple: true})
public allowedInputTypes: Array<CheckerModuleIOType> = ['number', 'numbers', 'string', 'strings', 'boolean', 'booleans'];
@type.select({options: CheckerModuleTypeOptions})
@validate.required
public moduleType: CheckerModuleType = 'output';
@type.string
public name: string = '';
@type.string
@validate.required
public inputVarName?: string;
@type.string
@validate.required
public outputVarName: string;
@type.select({options: CheckerModuleTypeOptions, multiple: false})
public outputType: CheckerModuleIOType = 'json';
public outputValue: CheckerModuleIOTypeValue;
@type.string
public outputSummary: string;
@type.array({type: 'object', options: {
keys: {
prefix: {type: 'string'},
varName: {type: 'string'},
suffix: {type: 'string'},
display: {type: 'select', options: ['paragraph', 'blocks']}
}
}})
public outputs: CheckerOutput[] = [];
static getAll<T extends typeof Model>(this: T, suffix: string = '', options: GetAllOptions & {flowId?: string} = {} ): Promise<Array<InstanceType <T>>> {
if (!options.route && options.flowId) {
options.route = this.baseroute.replace('/flow/', `/flow/${options.flowId}/module`);
}
return super.getAll(suffix, options).then((elements) => {
for (let element of elements) {
if (options.flowId) element.set('flowId', options.flowId);
}
return elements as Array<InstanceType <T>>;
});
}
getRoute(): string {
return this.deco.baseroute.replace('/flow', `/flow/${this.flowId}/module`) + '/';
}
// getOneRoute(elementId: string): string {
// return this.deco.baseroute.replace('/flow', `/flow/${this.flowId}/module`) + `/${elementId}`;
// }
postRoute(): string {
return this.deco.baseroute.replace('/flow', `/flow/${this.flowId}/module`) + '/';
}
putRoute(elementId: string): string {
return this.deco.baseroute.replace('/flow', `/flow/${this.flowId}/module`) + `/${elementId}`;
}
deleteRoute(elementId: string): string {
return this.deco.baseroute.replace('/flow', `/flow/${this.flowId}/module`) + `/${elementId}`;
}
}