提交 8baeec3d 编写于 作者: T tfennelly

Give the row header (tr) to the ConfigSection instance

上级 a5e005b3
......@@ -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;
......
......@@ -39,27 +39,33 @@ exports.fromConfigTable = function(configTable) {
sectionRow.attr('title', sectionTitle);
});
// Go through the top level <tr> elements (immediately inside the <tbody>)
// and group the related <tr>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 <tr> elements (immediately inside the <tbody>)
// and group the related <tr>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 = $('<div class="jenkins-config-widgets"></div>');
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册