-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#1235 - fixed reordering logic using drag and drop. refactoring.
- Loading branch information
1 parent
ca1455e
commit 0eb8d07
Showing
17 changed files
with
2,876 additions
and
228 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import WebDashboardSection from "./WebDashboardSection"; | ||
import WebDashboardSectionCardMapping from "./WebDashboardSectionCardMapping"; | ||
import WebReportCardFactory from "./WebReportCardFactory"; | ||
import { assert } from "chai"; | ||
|
||
it("should reorder cards down to up", function() { | ||
const section = { | ||
dashboardSectionCardMappings: [ | ||
WebDashboardSectionCardMapping.newCard(WebReportCardFactory.create({ id: 2 }), 1), | ||
WebDashboardSectionCardMapping.newCard(WebReportCardFactory.create({ id: 3 }), 2), | ||
WebDashboardSectionCardMapping.newCard(WebReportCardFactory.create({ id: 1 }), 3), | ||
WebDashboardSectionCardMapping.newCard(WebReportCardFactory.create({ id: 4 }), 4) | ||
] | ||
}; | ||
|
||
const reOrderedSection = WebDashboardSection.reorderCards(section, 2, 1); | ||
assert.equal(WebDashboardSection.getReportCardMapping(reOrderedSection, 2).displayOrder, 1); | ||
assert.equal(WebDashboardSection.getReportCardMapping(reOrderedSection, 1).displayOrder, 2); | ||
assert.equal(WebDashboardSection.getReportCardMapping(reOrderedSection, 3).displayOrder, 3); | ||
assert.equal(WebDashboardSection.getReportCardMapping(reOrderedSection, 4).displayOrder, 4); | ||
}); | ||
|
||
it("should reorder cards up to down", function() { | ||
const section = { | ||
dashboardSectionCardMappings: [ | ||
WebDashboardSectionCardMapping.newCard(WebReportCardFactory.create({ id: 2 }), 1), | ||
WebDashboardSectionCardMapping.newCard(WebReportCardFactory.create({ id: 3 }), 2), | ||
WebDashboardSectionCardMapping.newCard(WebReportCardFactory.create({ id: 1 }), 3), | ||
WebDashboardSectionCardMapping.newCard(WebReportCardFactory.create({ id: 4 }), 4) | ||
] | ||
}; | ||
|
||
const reOrderedSection = WebDashboardSection.reorderCards(section, 1, 2); | ||
assert.equal(WebDashboardSection.getReportCardMapping(reOrderedSection, 2).displayOrder, 1); | ||
assert.equal(WebDashboardSection.getReportCardMapping(reOrderedSection, 1).displayOrder, 2); | ||
assert.equal(WebDashboardSection.getReportCardMapping(reOrderedSection, 3).displayOrder, 3); | ||
assert.equal(WebDashboardSection.getReportCardMapping(reOrderedSection, 4).displayOrder, 4); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import WebReportCard from "../WebReportCard"; | ||
|
||
class WebReportCardFactory { | ||
static create({ id, uuid, name }) { | ||
const webReportCard = new WebReportCard(); | ||
webReportCard.id = id; | ||
webReportCard.uuid = uuid; | ||
webReportCard.name = name; | ||
return webReportCard; | ||
} | ||
} | ||
|
||
export default WebReportCardFactory; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.