-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Add drag and drop for selected reports #23913
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 22 commits
be396ae
480a0c0
769888e
8bfd644
79ea46f
e1b618b
61f21e4
dc8bb90
d7b23f5
eb75431
3558046
dfc04ec
7db4ccc
313926a
5d33065
14d7d38
c5b6ea1
51bc2ee
2b46ebc
1025e6e
5a1ca07
08acd09
5860435
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -171,6 +171,7 @@ public function testAddReportGetReports() | |
| 'emailMe' => true, | ||
| 'additionalEmails' => array('[email protected]', '[email protected]'), | ||
| 'evolutionGraph' => true, | ||
| 'enforceOrder' => true, | ||
| ), | ||
| ); | ||
|
|
||
|
|
@@ -208,6 +209,18 @@ public function testAddReportGetReports() | |
| $this->assertReportsEqual($report, $data); | ||
| } | ||
|
|
||
| public function testAddReportDefaultsEnforceOrderToFalse() | ||
| { | ||
| $data = self::getDailyPDFReportData($this->idSite); | ||
| $idReport = self::addReport($data); | ||
|
|
||
| $reports = APIScheduledReports::getInstance()->getReports($this->idSite, $data['period'], $idReport); | ||
| $report = reset($reports); | ||
|
|
||
| $this->assertArrayHasKey('enforceOrder', $report['parameters']); | ||
| $this->assertFalse($report['parameters']['enforceOrder']); | ||
| } | ||
|
|
||
| /** | ||
| * @group Plugins | ||
| */ | ||
|
|
@@ -1004,6 +1017,7 @@ private static function getMonthlyEmailReportData($idSite) | |
| 'emailMe' => false, | ||
| 'additionalEmails' => array('[email protected]'), | ||
| 'evolutionGraph' => false, | ||
| 'enforceOrder' => true, | ||
| ), | ||
| ); | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -40,4 +40,102 @@ describe("ScheduledReports", function () { | |
|
|
||
| expect(await page.screenshot({ fullPage: true })).to.matchImage('invalid_token'); | ||
| }); | ||
|
|
||
| describe('ManageScheduledReports', function () { | ||
| const manageReportsUrl = "?module=ScheduledReports&action=index&idSite=1&period=day&date=2013-01-23"; | ||
| const createdReportName = "for testing"; | ||
|
|
||
| // Helper function to open the report we will use for testing | ||
| async function openReportForTesting() { | ||
| await page.evaluate((description) => { | ||
| const rows = Array.from(document.querySelectorAll('#entityEditContainer tbody tr')); | ||
|
|
||
| for (const row of rows) { | ||
| if (!row.textContent || row.textContent.indexOf(description) === -1) { | ||
| continue; | ||
| } | ||
| const editButton = row.querySelector('button[title="Edit"]'); | ||
| editButton.click(); | ||
| } | ||
| }, createdReportName); | ||
|
|
||
| await page.waitForSelector('#addEditReport', { visible: true }); | ||
| await page.waitForSelector('.selectedReportsList li', { visible: true }); | ||
| } | ||
|
|
||
| it("should show selected reports when creating a new report", async function () { | ||
| await page.goto(manageReportsUrl); | ||
| await page.waitForNetworkIdle(); | ||
|
|
||
| await page.waitForSelector('#add-report'); | ||
| await page.click('#add-report'); | ||
| await page.waitForSelector('#addEditReport', { visible: true }); | ||
|
|
||
| const reportCheckboxes = await page.$$( | ||
| 'div[name="reportsList"]:not([style*="display: none"]) .listReports input[type="checkbox"]', | ||
| ); | ||
|
|
||
| const selectedReportIds = []; | ||
| // Click the first 4 checkboxes | ||
| for (const checkbox of reportCheckboxes.slice(0, 4)) { | ||
| await checkbox.click(); | ||
| const uniqueId = await checkbox.evaluate((input) => input.id ); | ||
| if (uniqueId) { | ||
| selectedReportIds.push(uniqueId); | ||
| } | ||
| } | ||
| const selectedReportsWrapper = await page.$('.selectedReportsWrapper'); | ||
| expect(await selectedReportsWrapper.screenshot()).to.matchImage('selected_reports'); | ||
| }); | ||
|
|
||
| it("should persist manually reordered selected reports when saving a report", async function () { | ||
| await openReportForTesting(); | ||
|
|
||
| const initialOrder = await page.$$eval( | ||
| '.selectedReportsList li', | ||
| (items) => items.map((item) => item.getAttribute('data-unique-id')), | ||
| ); | ||
|
|
||
| const reorderSelectedReports = async (order) => { | ||
|
|
||
| }; | ||
|
|
||
| const expectedOrder = initialOrder.slice().reverse(); | ||
|
|
||
| // Reorder the selected reports via DOM manipulation | ||
| await page.evaluate((newOrder) => { | ||
| const list = document.querySelector('.selectedReportsList'); | ||
| newOrder.forEach((uniqueId) => { | ||
| const item = list.querySelector(`li[data-unique-id="${uniqueId}"]`); | ||
| if (item) { | ||
| list.appendChild(item); | ||
| } | ||
| }); | ||
|
|
||
| const jq = window.jQuery || window.$; | ||
| const $list = jq('.selectedReportsList'); | ||
| // Get sortable instance and call stop handler manually, | ||
| // so that we simulate the emitted reorder event | ||
| const stopHandler = $list.sortable('option', 'stop'); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should avoid using jQuery UI where possible. The short / mid term plan is to fully remove it, not to add more usage of it. See #16033
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for the info on this @sgiehl.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Interesting info. |
||
| if (typeof stopHandler === 'function') { | ||
| stopHandler(); | ||
| } | ||
| }, expectedOrder); | ||
|
|
||
| await page.click('.matomo-save-button .btn'); | ||
| await page.waitForNetworkIdle(); | ||
| await page.waitForTimeout(500); | ||
|
|
||
| await openReportForTesting(); | ||
| const persistedOrder = await page.$$eval( | ||
| '.selectedReportsList li', | ||
| (items) => items.map((item) => item.getAttribute('data-unique-id')), | ||
| ); | ||
|
|
||
| expect(persistedOrder).to.deep.equal(expectedOrder); | ||
|
|
||
| const selectedReportsWrapper = await page.$('.selectedReportsWrapper'); | ||
| expect(await selectedReportsWrapper.screenshot()).to.matchImage('reorder_persisted'); | ||
| }); | ||
| }); | ||
| }); | ||
Uh oh!
There was an error while loading. Please reload this page.