diff options
author | Matthieu Aubry <matt@piwik.org> | 2015-06-08 06:01:56 +0300 |
---|---|---|
committer | Matthieu Aubry <matt@piwik.org> | 2015-06-08 06:01:56 +0300 |
commit | 043b4707fbe58fd869c575ad0ce2c2b1e6f79804 (patch) | |
tree | fa50cd078df7bc3cc2ba2320f24c4586436da659 | |
parent | 254ec097b228721cb646badd71e3c54ac4b429c8 (diff) | |
parent | c8255e1ef6428f0987cae493197f78d359c6e768 (diff) |
Merge pull request #8018 from piwik/7891
Expand Outlinks / Downloads if only one domain given
-rw-r--r-- | plugins/Actions/javascripts/actionsDataTable.js | 34 | ||||
-rw-r--r-- | tests/UI/specs/ActionsDataTable_spec.js | 10 |
2 files changed, 42 insertions, 2 deletions
diff --git a/plugins/Actions/javascripts/actionsDataTable.js b/plugins/Actions/javascripts/actionsDataTable.js index acc81b8709..29d56fd312 100644 --- a/plugins/Actions/javascripts/actionsDataTable.js +++ b/plugins/Actions/javascripts/actionsDataTable.js @@ -91,6 +91,36 @@ self.handleExpandFooter(domElem); self.setFixWidthToMakeEllipsisWork(domElem); self.handleSummaryRow(domElem); + self.openSubtableFromLevel0IfOnlyOneSubtableGiven(domElem); + }, + + openSubtableFromLevel0IfOnlyOneSubtableGiven: function (domElem) { + var $subtables = domElem.find('.subDataTable'); + var hasOnlyOneSubtable = $subtables.length === 1; + + if (hasOnlyOneSubtable) { + var hasOnlyOneRow = domElem.find('tbody tr.level0').length === 1; + + if (hasOnlyOneRow) { + var $labels = $subtables.find('.label'); + if ($labels.length) { + $labels.first().click(); + } + } + } + }, + + openSubtableFromSubtableIfOnlyOneSubtableGiven: function (domElem) { + var hasOnlyOneRow = domElem.length === 1 + var hasOnlyOneSubtable = domElem.hasClass('subDataTable'); + + if (hasOnlyOneRow && hasOnlyOneSubtable) { + // when subtable is loaded + var $labels = domElem.find('.label'); + if ($labels.length) { + $labels.first().click(); + } + } }, //see dataTable::applyCosmetics @@ -323,7 +353,9 @@ function () { self.onClickActionSubDataTable(this) }); + + self.openSubtableFromSubtableIfOnlyOneSubtableGiven(response); } }); -})(jQuery, require);
\ No newline at end of file +})(jQuery, require); diff --git a/tests/UI/specs/ActionsDataTable_spec.js b/tests/UI/specs/ActionsDataTable_spec.js index 7f4874b37e..b4a4deecb1 100644 --- a/tests/UI/specs/ActionsDataTable_spec.js +++ b/tests/UI/specs/ActionsDataTable_spec.js @@ -91,4 +91,12 @@ describe("ActionsDataTable", function () { page.click('.dataTableSearchPattern>input[type=submit]'); }, done); }); -});
\ No newline at end of file + + it("should automatically expand subtables if it contains only one folder", function (done) { + expect.screenshot('auto_expand').to.be.capture(function (page) { + page.load(url + '&viewDataTable=table'); + page.click('tr .value:contains("blog")'); + page.click('tr .value:contains("2012")'); + }, done); + }); +}); |