Skip to content

Conversation

teclator
Copy link
Contributor

@teclator teclator commented Jan 25, 2019

  • It adds an specific widget for dictionaries with primitive values like:

Formula:

user_passwords:
    $type: edit-group
    $minItems: 1
    $prototype:
        $key:
            $type: text
        $type: text
    $default:
        alice: secret-password
        bob: you-shall-not-pass

Pillar:

user_passwords:
    alice:
        secret-password
    bob:
        you-shall-not-pass

By now we are only supporting "text" ones

Pending: Reading and writing the pillar data

@coveralls
Copy link

coveralls commented Jan 25, 2019

Coverage Status

Coverage decreased (-6.4%) to 88.377% when pulling 005a3e3 on key_value_widget into 87280a5 on salt-forms-support-ng.

@teclator teclator changed the title Scalar collections fixes [WIP] Scalar collections fixes Jan 25, 2019
@imobachgs imobachgs changed the title [WIP] Scalar collections fixes Scalar collections fixes Jan 25, 2019
#
# It will be converted to:
#
# [{ "$key" => "vers", "$value" => "4" }, { "$key" => "timeout", "$value" => "0" }]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So in the pillar, I see 4 possibilities along 2 axes:

Outside, the collection is one of

  • Hash
  • Array

Inside, its elements are one of

  • scalar
  • group (hash)

How do we represent that in FormData?

For the "outside" axis, we always use an array, and represent a hash by embedding "$key" inside.

For the "inside", we either put plain scalars (for an array of scalars), or if we have a hash on the outside, then we use a hash which always has a "$key" element and then either the other elements, or a "$value" element if it is a hash of scalars.

Is that right?

It seems to me that we could simplify this by always having a hash at the inside, with an array of scalars being represented as [{ "$value" => "one" }, { "$value" => "two" }, ...]

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, you are right. I will try that approach.

@imobachgs imobachgs mentioned this pull request Jan 25, 2019
9 tasks
@imobachgs imobachgs merged commit 3afac9b into salt-forms-support-ng Jan 25, 2019
@imobachgs imobachgs deleted the key_value_widget branch January 25, 2019 15:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants