diff --git a/war/src/main/js/widgets/config/model/ConfigSection.js b/war/src/main/js/widgets/config/model/ConfigSection.js
index 580d0595b9d1af9bc784fd7528ded19b273730a0..c6a1fbfe94ac6ab1c13a35e10e260cb4a36f3fcd 100644
--- a/war/src/main/js/widgets/config/model/ConfigSection.js
+++ b/war/src/main/js/widgets/config/model/ConfigSection.js
@@ -9,10 +9,11 @@ module.exports = ConfigSection;
* Configuration table section.
* =======================================================================================
*/
-function ConfigSection(parentCMD, title) {
+function ConfigSection(parentCMD, headerRow) {
this.parentCMD = parentCMD;
- this.title = title;
- this.id = util.toId(title);
+ this.headerRow = headerRow;
+ this.title = headerRow.attr('title');
+ this.id = util.toId(this.title);
this.rows = [];
this.rowSets = undefined;
this.activator = undefined;
diff --git a/war/src/main/js/widgets/config/model/ConfigTableMetaData.js b/war/src/main/js/widgets/config/model/ConfigTableMetaData.js
index d55fd59754716a77226693a50554c9bde35cfd3d..15c54c9d8d0d3c9d091a18f5bcb04c4f09949c59 100644
--- a/war/src/main/js/widgets/config/model/ConfigTableMetaData.js
+++ b/war/src/main/js/widgets/config/model/ConfigTableMetaData.js
@@ -39,27 +39,33 @@ exports.fromConfigTable = function(configTable) {
sectionRow.attr('title', sectionTitle);
});
- // Go through the top level
elements (immediately inside the
)
- // and group the related s based on the "section-header-row", using a "normalized"
- // version of the section title as the section id.
var configTableMetadata = new ConfigTableMetaData(configForm, configTable);
- var curSection = new ConfigSection(configTableMetadata, 'General');
+ var topRows = configTableMetadata.getTopRows();
+ var firstRow = configTableMetadata.getFirstRow();
+ var curSection = undefined;
- configTableMetadata.sections.push(curSection);
- curSection.id = util.toId(curSection.title);
+ // The first set of rows don't have a 'section-header-row', so we manufacture one,
+ // calling it a "General" section. We do this by marking the first row in the table.
+ // See the next block of code.
+ firstRow.addClass('section-header-row');
+ firstRow.attr('title', "General");
- var topRows = configTableMetadata.getTopRows();
+ // Go through the top level
elements (immediately inside the
)
+ // and group the related s based on the "section-header-row", using a "normalized"
+ // version of the section title as the section id.
topRows.each(function () {
var tr = $(this);
if (tr.hasClass('section-header-row')) {
// a new section
- var title = tr.attr('title');
- curSection = new ConfigSection(configTableMetadata, title);
+ curSection = new ConfigSection(configTableMetadata, tr);
configTableMetadata.sections.push(curSection);
}
-
- curSection.rows.push(tr);
- tr.addClass(curSection.id);
+ if (curSection) {
+ curSection.rows.push(tr);
+ tr.addClass(curSection.id);
+ } else {
+ throw 'Unexpected error. The first row in the config table is expected to be a "section-header-row".';
+ }
});
var buttonsRow = $('#bottom-sticker', configTable).closest('tr');
@@ -91,6 +97,10 @@ ConfigTableMetaData.prototype.getTopRows = function() {
return this.configTableBody.children('tr');
};
+ConfigTableMetaData.prototype.getFirstRow = function() {
+ return this.getTopRows().first();
+};
+
ConfigTableMetaData.prototype.addWidgetsContainer = function() {
var $ = jQD.getJQuery();
this.configWidgets = $('');