Bug 1041989

Summary: [RFE][horizon]: DataTable with support for Django Formset
Product: Red Hat OpenStack Reporter: RHOS Integration <rhos-integ>
Component: python-django-horizonAssignee: RHOS Maint <rhos-maint>
Status: CLOSED ERRATA QA Contact: Ido Ovadia <iovadia>
Severity: medium Docs Contact:
Priority: medium    
Version: unspecifiedCC: aberezin, aortega, dnavale, jpichon, markmc, mrunge, yeylon
Target Milestone: Upstream M2Keywords: FutureFeature, Triaged
Target Release: 5.0 (RHEL 7)   
Hardware: Unspecified   
OS: Unspecified   
URL: https://blueprints.launchpad.net/horizon/+spec/formset-data-table
Whiteboard: upstream_milestone_icehouse-2 upstream_status_implemented upstream_definition_pending-approval
Fixed In Version: Doc Type: Enhancement
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2014-07-08 15:43:24 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:

Description RHOS Integration 2013-12-12 20:27:39 UTC
Cloned from launchpad blueprint https://blueprints.launchpad.net/horizon/+spec/formset-data-table.

Description:

DataTable is an excellent way to display tabular data, and Django Formsets are an excellent way to input tabular data -- but there seems to be no easy way to use them together. There should be a way to associate a DataTable with a Formset, so that they are both fed with the same initial data and displayed consistently.

This solves a somewhat different (but related) problem to that solved by https://blueprints.launchpad.net/horizon/+spec/inline-table-editing and https://blueprints.launchpad.net/horizon/+spec/inline-table-add-remove-rows which allow you to edit an existing data table. With a Formset-enabled data table you can do more:

* Input completely new data that is not kept anywhere yet until the form is submitted. An example of use case where we actually use that in Tuskar is the Resource Class creation dialog, where the user has to specify the Flavors for the new Resource Class -- since the Resource Class being created doesn't exist yet, you can't really do AJAX-based editing of data.
* Extend existing data with additional information -- for example, again in Resource Class creation dialog in Tuskar, we display a list of available Racks, with an additional column with checkboxes for selecting which Racks should be included in the newly created Resource Class.

The basic idea is that we use a mixin to DataTable, which allows us to specify the Formset class to use. The formset is created together with the DataTable instance, and populated with the data taken from the column data (the fields to be populated have to be named the same as the columns) and the POST data. Then, when the DataTable is rendered, the columns that correspond to fields from the formset have the corresponding widgets rendered instead of the plain data in them. Any validation errors are also displayed. Then you can get the Formset instance for the DataTable instance, validate it and get all the data from it.

There is also some additional (optional) JavaScript for making it easier to add and delete rows of the table.

I'm sure that this would be useful in many places in Horizon in general, not just in Tuskar, so I would like to include it.

Specification URL (additional information):

None

Comment 2 Stephen Gordon 2014-01-23 20:51:10 UTC
Moving to POST based on upstream status (Implemented).

Comment 3 Ido Ovadia 2014-03-23 15:10:48 UTC
Does it need QE verificaton?
If yes, please provide any steps

Comment 4 Matthias Runge 2014-03-25 14:15:43 UTC
This implements infrastructure for development. IMHO, no QE verification required.

Comment 6 Ido Ovadia 2014-04-13 13:04:33 UTC
Regression passed

Comment 8 errata-xmlrpc 2014-07-08 15:43:24 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

http://rhn.redhat.com/errata/RHEA-2014-0855.html