Skip to content

Conversation

imobachgs
Copy link
Contributor

@imobachgs imobachgs commented Nov 30, 2018

This PR adds support to store the data from the form so it can be exported later to be used as part of a Pillar.

Basically, a new FormData class has been added which offers an API to add, update and remove information (including collections). The data is referred using a regular path (eg. .root.person) and it is stored in a hash.

To avoid coupling the widgets with the form data, a new Form widget has been introduced. To populate the form with the initial values, the #value= method is used (values are then propagated to internal widgets). The #result method offers a way to get the final values.

In scope

  • Store the data from the forms.
  • Add and remove elements to/from a collection.

Out of scope

  • Editing existing elemens within a collection.
  • Exporting the data to a Pillar, although the test_formula client dumps the result to the standard output.

@coveralls
Copy link

coveralls commented Nov 30, 2018

Coverage Status

Coverage increased (+0.4%) to 92.182% when pulling 81d1c51 on salt-form-data into c6b769e on salt-forms-support-ng.

@imobachgs imobachgs changed the title [WIP] Salt form data Salt form data Dec 3, 2018
Copy link
Member

@mvidner mvidner left a comment

Choose a reason for hiding this comment

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

Here's a first batch of comments before I run it and try to break it

# This method propagates the values to the underlying widgets.
#
# @example Setting values for included widgets
# form.values = { "name" => "John", "surname" => "Doe" }
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
# form.values = { "name" => "John", "surname" => "Doe" }
# form.value = { "name" => "John", "surname" => "Doe" }

VBox(*children)
end

# Sets the value for the form
Copy link
Member

Choose a reason for hiding this comment

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

Hmm, this is copied from Form, I wonder if the code can be shared.

# version.
def next_handler
return false unless Yast::Popup.YesNo("Do you want to exit?")
puts data.to_h.inspect
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
puts data.to_h.inspect
require "yaml" # at the top of the file
puts data.to_h.to_yaml

@mvidner
Copy link
Member

mvidner commented Dec 4, 2018

In the current state, when I change the Name field and press Next, the data still contains the old value.

@mvidner mvidner merged commit 96fe140 into salt-forms-support-ng Dec 7, 2018
@imobachgs imobachgs deleted the salt-form-data branch December 10, 2018 18:29
@imobachgs imobachgs mentioned this pull request Jan 25, 2019
9 tasks
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