controls.forEach(control => {
      const mapper = MapperStore.getMapper(control);
      const obsArray = mapper.getInitialObject(
        formName,
        formVersion,
        control,
        currentLayerObs,
        allObs,
        parentFormFieldPath
      );
      obsArray.forEach(data => {
        const record = new ControlRecord({
          valueMapper: ValueMapperStore.getMapper(control),
          active: !data.inactive,
          formFieldPath: data.formFieldPath,
          value: mapper.getValue(data),
          dataSource: data,
          control,
          showAddMore: true,
          children: control.controls &&
          this.getRecords(
            control.controls,
            formName,
            formVersion,
            mapper.getChildren(data),
            allObs,
            isAnyAncestorOrControlHasAddMore(control, parentFormFieldPath) ? data.formFieldPath :
            getCurrentFormFieldPathIfAddMore(formName, formVersion, control, parentFormFieldPath)
          ),
        });

        recordList = recordList.push(record);
      });
    });
Example #2
0
 it('should return tableMapper when control type is table', () => {
   control.type = 'table';
   const mapper = MapperStore.getMapper(control);
   expect(mapper instanceof TableMapper).to.eql(true);
 });
Example #3
0
 it('should return AbnormalObsGroupMapper if obsgroup is abnormal', () => {
   control.type = 'obsGroupControl';
   control.properties = { abnormal: true };
   const mapper = MapperStore.getMapper(control);
   expect(mapper instanceof AbnormalObsGroupMapper).to.eql(true);
 });
Example #4
0
 it('should return obsListMapper if multiSelect property is enabled', () => {
   control.properties = { multiSelect: true };
   const mapper = MapperStore.getMapper(control);
   expect(mapper instanceof ObsListMapper).to.eql(true);
 });
Example #5
0
 it('should return obsGroupMapper', () => {
   control.type = 'obsGroupControl';
   const mapper = MapperStore.getMapper(control);
   expect(mapper instanceof ObsGroupMapper).to.eql(true);
 });
Example #6
0
 it('should return obsMapper by default', () => {
   const mapper = MapperStore.getMapper(control);
   expect(mapper instanceof ObsMapper).to.eql(true);
 });
 const result = records.children.map((r) => {
   const mapper = MapperStore.getMapper(r.control);
   return mapper.getData(r);
 });