@nyaruka/temba-components 0.120.4 → 0.120.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.
@@ -31,6 +31,7 @@ export interface SelectOption {
31
31
  value?: string;
32
32
  expression?: boolean;
33
33
  selected?: boolean;
34
+ arbitrary?: boolean;
34
35
  }
35
36
 
36
37
  export class Select<T extends SelectOption> extends FormElement {
@@ -798,7 +799,7 @@ export class Select<T extends SelectOption> extends FormElement {
798
799
 
799
800
  const newValues = (this.values || [])
800
801
  .map((option: T) => {
801
- return this.getValue(option);
802
+ return option.arbitrary || this.getValue(option);
802
803
  })
803
804
  .join(',');
804
805
 
@@ -105,6 +105,7 @@ export class Store extends RapidElement {
105
105
  private users: User[] = [];
106
106
  private workspace: Workspace;
107
107
  private featuredFields: ContactField[] = [];
108
+ private flowContents: FlowContents;
108
109
 
109
110
  // http promise to monitor for completeness
110
111
  public initialHttpComplete: Promise<void | WebResponse[]>;
@@ -615,4 +616,62 @@ export class Store extends RapidElement {
615
616
  return html`<temba-loading size="10" units="8"></temba-loading>`;
616
617
  }
617
618
  }
619
+
620
+ // TODO: for now we let the flow editor set this externally to avoid
621
+ // double fetches and updates
622
+ public setFlowContents(contents: FlowContents) {
623
+ this.flowContents = contents;
624
+ }
625
+
626
+ public setFlowInfo(info: FlowInfo) {
627
+ this.flowContents.info = info;
628
+ }
629
+
630
+ public async loadFlow(
631
+ flowUUID: string,
632
+ revision = 'latest'
633
+ ): Promise<FlowContents> {
634
+ const response = await getUrl(
635
+ `/flow/revisions/${flowUUID}/${revision}/?version=14.3`
636
+ );
637
+ this.flowContents = response.json;
638
+ return this.flowContents;
639
+ }
640
+
641
+ public getFlowResults(): InfoResult[] {
642
+ return this.flowContents.info.results;
643
+ }
644
+ }
645
+
646
+ export interface InfoResult {
647
+ key: string;
648
+ name: string;
649
+ categories: string[];
650
+ node_uuids: string[];
651
+ }
652
+
653
+ export interface ObjectRef {
654
+ uuid: string;
655
+ name: string;
656
+ }
657
+
658
+ export interface TypedObjectRef extends ObjectRef {
659
+ type: string;
660
+ }
661
+
662
+ export interface Language {
663
+ code: string;
664
+ name: string;
665
+ }
666
+
667
+ export interface FlowInfo {
668
+ results: InfoResult[];
669
+ dependencies: TypedObjectRef[];
670
+ counts: { nodes: number; languages: number };
671
+ locals: string[];
672
+ }
673
+
674
+ export interface FlowContents {
675
+ definition: any;
676
+ info: FlowInfo;
618
677
  }