Under Review
over 1 year ago

Confusion and bugs in Array Settings

When I try the array Settings example from: https://developer.garmin.com/connect-iq/core-topics/properties-and-app-settings/ I get all kinds of errors, but essentially it's because the examples in the doc are either wrong or at least missing some parts. Does anyone have a working example?

Garmin, what's confusing is:
- "To create a variable list, the property referenced must be of type array." but the example doesn't have it, so it's not clear what should be the array. I assumed the following:

<properties>
  <property id="s" type="array"></property><!--Sensor-->
</properties>

- When I try to build my settings based on the example in the doc I get:

<settings>
  <setting propertyKey="@Properties.s" title="@Strings.settingsSensorTitle" maxLength="3">
    <setting title="@Strings.settingsExt1AntId" prompt="@Strings.settingsExtXAntIdPrompt">
      <settingConfig id="i" type="number" min="0" max="99999"/>
    </setting>
    <setting title="@Strings.settingsExt1Name">
      <settingConfig id="n" type="string" maxLength="8"/>
    </setting>
    <defaults>
      <entry>
        <default id="i">0</default>
        <default id="n"></default>
      </entry>
    </defaults>
  </setting>
</settings>

- But this fails to compile: Attribute 'type' must appear on element 'setting'. However the documentation doesn't list "type" as an attribute of setting.

- When I try to add type on the outer setting ("s"): Attribute 'type' is not allowed to appear in element 'setting'.

- When I try to add type on the inner settings ("i", "n") it starts to work, but still, it's not clear what the type value should be: string or alphaNumeric. With some try & error I got to the decision that it should be one of the types that in the doc is an attribute of the properyt... So I get:

<properties>
  <property id="s" type="array"></property><!--Sensor-->
</properties>

<settings>
  <setting propertyKey="@Properties.s" title="@Strings.settingsSensorTitle" maxLength="3">
    <setting title="@Strings.settingsExt1AntId" prompt="@Strings.settingsExtXAntIdPrompt" type="number">
      <settingConfig id="i" type="numeric" min="0" max="99999"/>
    </setting>
    <setting title="@Strings.settingsExt1Name" type="string">
      <settingConfig id="n" type="alphaNumeric" maxLength="8"/>
    </setting>
    <defaults>
      <entry>
        <default id="i">0</default>
        <default id="n"></default>
      </entry>
    </defaults>
  </setting>
</settings>

- But then the compiler still fails: ERROR: Property not found for the property key 'Properties.s'. So I tried:

<properties>
  <property id="s" type="array"></property><!--Sensor-->
</properties>

<settings>
  <setting propertyKey="s" title="@Strings.settingsSensorTitle" maxLength="3">
    <setting title="@Strings.settingsExt1AntId" prompt="@Strings.settingsExtXAntIdPrompt" type="number">
      <settingConfig id="i" type="numeric" min="0" max="99999"/>
    </setting>
    <setting title="@Strings.settingsExt1Name" type="string">
      <settingConfig id="n" type="alphaNumeric" maxLength="8"/>
    </setting>
    <defaults>
      <entry>
        <default id="i">0</default>
        <default id="n"></default>
      </entry>
    </defaults>
  </setting>
</settings>

Which finally compiles.

- But then I also added users:

<properties>
  <property id="u" type="array"></property><!--User-->
</properties>

</settings>
  <setting propertyKey="u" title="@Strings.settingsUsersTitle" maxLength="3">
    <setting title="@Strings.settingsExt1Name" type="string">
      <settingConfig id="n" type="alphaNumeric" maxLength="8"/>
    </setting>
    <setting title="@Strings.settingsZone1Min" type="number">
      <settingConfig id="z0" type="numeric" min="0" max="300"/>
    </setting>
    <setting title="@Strings.settingsZone1Max" type="number">
      <settingConfig id="z1" type="numeric" min="0" max="300"/>
    </setting>
    <setting title="@Strings.settingsZone2Max" type="number">
      <settingConfig id="z2" type="numeric" min="0" max="300"/>
    </setting>
    <setting title="@Strings.settingsZone3Max" type="number">
      <settingConfig id="z3" type="numeric" min="0" max="300"/>
    </setting>
    <setting title="@Strings.settingsZone4Max" type="number">
      <settingConfig id="z4" type="numeric" min="0" max="300"/>
    </setting>
    <setting title="@Strings.settingsZone5Max" type="number">
      <settingConfig id="z5" type="numeric" min="0" max="300"/>
    </setting>
    <setting title="@Strings.settingsMaxHr" type="number">
      <settingConfig id="m" type="numeric" min="0" max="300"/>
    </setting>
    <defaults>
      <entry>
        <default id="n"></default>
        <default id="z0">0</default>
        <default id="z1">0</default>
        <default id="z2">0</default>
        <default id="z3">0</default>
        <default id="z4">0</default>
        <default id="z5">0</default>
        <default id="m">0</default>
      </entry>
    </defaults>
  </setting>
</settings>

Note that in <setting propertyKey="u" title="@Strings.settingsUsersTitle" maxLength="3"> the maxLength is supposed to tell that I can add mas 3 users. But then I try to compile and get:
- ERROR: Setting for 'u' has 8 entries, but should have no more than 3.

So in order to compile this I have to change the maxLength to 8, but then I can add up to 8 users, when I only want to allow 3.

Please fix the documentation:

- add the missing parts to the example, so we have a full, working example.

- add the missing explanation to where type need to go and what the values should be (very confusing, even if you add this people will be confused...)

- make sure the example compiles and works

Please fix the compiler:

- maxLength on a setting of an array property should mean the max number of items that can be added to the array and not to be confused by the number of dictionary keys inside the array's elements...