-
Notifications
You must be signed in to change notification settings - Fork 385
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
CLDR-16844 Preliminary refactoring for Dashboard #3874
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,121 @@ | ||
/* | ||
* cldrDashContext: encapsulate code that determines how the Dashboard is combined with | ||
* other Survey Tool GUI components. | ||
*/ | ||
|
||
import * as cldrDrag from "./cldrDrag.mjs"; | ||
import * as cldrNotify from "./cldrNotify.mjs"; | ||
import * as cldrVue from "./cldrVue.mjs"; | ||
|
||
import DashboardWidget from "../views/DashboardWidget.vue"; | ||
|
||
// Caution: these strings also occur literally in other files (.mjs/.vue/.css) | ||
const OPEN_DASH_BUTTON_CLASS = "open-dash"; | ||
const DASH_SECTION_ID = "DashboardSection"; | ||
const NEIGHBOR_SECTION_ID = "VotingEtcSection"; | ||
|
||
/** | ||
* The application instance for the DashboardWidget component when it has been mounted | ||
*/ | ||
let wrapper = null; | ||
|
||
/** | ||
* Is the Info Panel currently displayed? | ||
*/ | ||
let visible = false; | ||
|
||
function isVisible() { | ||
return visible; // boolean | ||
} | ||
|
||
function wireUpOpenButtons() { | ||
const els = document.getElementsByClassName(OPEN_DASH_BUTTON_CLASS); | ||
for (let i = 0; i < els.length; i++) { | ||
els[i].onclick = () => insert(); | ||
} | ||
} | ||
|
||
/** | ||
* Create or reopen the DashboardWidget Vue component | ||
*/ | ||
function insert() { | ||
if (visible) { | ||
return; // already inserted and visible | ||
} | ||
try { | ||
if (wrapper) { | ||
// already created/inserted but invisible | ||
wrapper.reopen(); | ||
} else { | ||
const el = document.getElementById(DASH_SECTION_ID); | ||
wrapper = cldrVue.mountReplace(DashboardWidget, el); | ||
} | ||
show(); | ||
} catch (e) { | ||
cldrNotify.exception(e, "loading Dashboard"); | ||
console.error("Error mounting dashboard vue " + e.message + " / " + e.name); | ||
} | ||
} | ||
|
||
/** | ||
* Show the Dashboard | ||
*/ | ||
function show() { | ||
if (visible) { | ||
return; | ||
} | ||
const vote = document.getElementById(NEIGHBOR_SECTION_ID); | ||
const dash = document.getElementById(DASH_SECTION_ID); | ||
if (vote && dash) { | ||
vote.style.height = "50%"; | ||
dash.style.height = "50%"; | ||
dash.style.display = "flex"; | ||
const els = document.getElementsByClassName(OPEN_DASH_BUTTON_CLASS); | ||
for (let i = 0; i < els.length; i++) { | ||
els[i].style.display = "none"; | ||
} | ||
visible = true; | ||
cldrDrag.enable(vote, dash, true /* up/down */); | ||
} | ||
} | ||
|
||
/** | ||
* Hide the Dashboard | ||
*/ | ||
function hide() { | ||
if (!visible) { | ||
return; | ||
} | ||
const vote = document.getElementById(NEIGHBOR_SECTION_ID); | ||
const dash = document.getElementById(DASH_SECTION_ID); | ||
if (vote && dash) { | ||
vote.style.height = "100%"; | ||
dash.style.display = "none"; | ||
const els = document.getElementsByClassName(OPEN_DASH_BUTTON_CLASS); | ||
for (let i = 0; i < els.length; i++) { | ||
els[i].style.display = "inline"; | ||
} | ||
visible = false; | ||
} | ||
} | ||
|
||
function updateRow(json) { | ||
if (visible) { | ||
wrapper?.updatePath(json); | ||
} | ||
} | ||
|
||
function updateWithCoverage(newLevel) { | ||
if (visible) { | ||
wrapper?.handleCoverageChanged(newLevel); | ||
} | ||
} | ||
|
||
export { | ||
hide, | ||
insert, | ||
isVisible, | ||
updateRow, | ||
updateWithCoverage, | ||
wireUpOpenButtons, | ||
}; |
2 changes: 1 addition & 1 deletion
2
tools/cldr-apps/js/src/esm/cldrDash.mjs → tools/cldr-apps/js/src/esm/cldrDashData.mjs
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 |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
* cldrGui: encapsulate GUI functions for Survey Tool | ||
*/ | ||
import * as cldrAjax from "./cldrAjax.mjs"; | ||
import * as cldrDrag from "./cldrDrag.mjs"; | ||
import * as cldrDashContext from "./cldrDashContext.mjs"; | ||
import * as cldrEvent from "./cldrEvent.mjs"; | ||
import * as cldrForum from "./cldrForum.mjs"; | ||
import * as cldrInfo from "./cldrInfo.mjs"; | ||
|
@@ -14,17 +14,13 @@ import * as cldrStatus from "./cldrStatus.mjs"; | |
import * as cldrSurvey from "./cldrSurvey.mjs"; | ||
import * as cldrVue from "./cldrVue.mjs"; | ||
|
||
import DashboardWidget from "../views/DashboardWidget.vue"; | ||
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. ok, not new! |
||
import MainHeader from "../views/MainHeader.vue"; | ||
|
||
const GUI_DEBUG = true; | ||
|
||
const runGuiId = "st-run-gui"; | ||
|
||
let mainHeaderWrapper = null; | ||
let dashboardWidgetWrapper = null; | ||
|
||
let dashboardVisible = false; | ||
|
||
/** | ||
* Set up the DOM and start executing Survey Tool as a single page app | ||
|
@@ -162,10 +158,7 @@ function setOnClicks() { | |
if (el) { | ||
el.onclick = () => cldrForum.reload(); | ||
} | ||
let els = document.getElementsByClassName("open-dash"); | ||
for (let i = 0; i < els.length; i++) { | ||
els[i].onclick = () => insertDashboard(); | ||
} | ||
cldrDashContext.wireUpOpenButtons(); | ||
} | ||
|
||
const leftSidebar = | ||
|
@@ -411,86 +404,10 @@ function updateWithStatus() { | |
* add more widgets/components that depend on coverage level. | ||
*/ | ||
function updateWidgetsWithCoverage(newLevel) { | ||
if (dashboardVisible) { | ||
dashboardWidgetWrapper?.handleCoverageChanged(newLevel); | ||
} | ||
cldrDashContext.updateWithCoverage(newLevel); | ||
cldrProgress.updateWidgetsWithCoverage(); | ||
} | ||
|
||
/** | ||
* Create or reopen the DashboardWidget Vue component | ||
*/ | ||
function insertDashboard() { | ||
if (dashboardVisible) { | ||
return; // already inserted and visible | ||
} | ||
try { | ||
if (dashboardWidgetWrapper) { | ||
// already created/inserted but invisible | ||
dashboardWidgetWrapper.reopen(); | ||
} else { | ||
const el = document.getElementById("DashboardSection"); | ||
dashboardWidgetWrapper = cldrVue.mountReplace(DashboardWidget, el); | ||
} | ||
showDashboard(); | ||
} catch (e) { | ||
cldrNotify.exception(e, "loading Dashboard"); | ||
console.error("Error mounting dashboard vue " + e.message + " / " + e.name); | ||
} | ||
} | ||
|
||
/** | ||
* Show the dashboard | ||
*/ | ||
function showDashboard() { | ||
if (dashboardVisible) { | ||
return; | ||
} | ||
const vote = document.getElementById("VotingEtcSection"); | ||
const dash = document.getElementById("DashboardSection"); | ||
if (vote && dash) { | ||
vote.style.height = "50%"; | ||
dash.style.height = "50%"; | ||
dash.style.display = "flex"; | ||
let els = document.getElementsByClassName("open-dash"); | ||
for (let i = 0; i < els.length; i++) { | ||
els[i].style.display = "none"; | ||
} | ||
dashboardVisible = true; | ||
cldrDrag.enable(vote, dash, true /* up/down */); | ||
} | ||
} | ||
|
||
/** | ||
* Hide the dashboard | ||
*/ | ||
function hideDashboard() { | ||
if (!dashboardVisible) { | ||
return; | ||
} | ||
const vote = document.getElementById("VotingEtcSection"); | ||
const dash = document.getElementById("DashboardSection"); | ||
if (vote && dash) { | ||
vote.style.height = "100%"; | ||
dash.style.display = "none"; | ||
let els = document.getElementsByClassName("open-dash"); | ||
for (let i = 0; i < els.length; i++) { | ||
els[i].style.display = "inline"; | ||
} | ||
dashboardVisible = false; | ||
} | ||
} | ||
|
||
function dashboardIsVisible() { | ||
return dashboardVisible; // boolean | ||
} | ||
|
||
function updateDashboardRow(json) { | ||
if (dashboardVisible) { | ||
dashboardWidgetWrapper?.updatePath(json); | ||
} | ||
} | ||
|
||
function setToptitleVisibility(visible) { | ||
const topTitle = document.getElementById("toptitle"); | ||
if (topTitle) { | ||
|
@@ -513,14 +430,9 @@ function refreshCounterVetting() { | |
} | ||
|
||
export { | ||
dashboardIsVisible, | ||
hideDashboard, | ||
insertDashboard, | ||
refreshCounterVetting, | ||
run, | ||
setToptitleVisibility, | ||
showDashboard, | ||
updateDashboardRow, | ||
updateWidgetsWithCoverage, | ||
updateWithStatus, | ||
/* | ||
|
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.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is a new structure for the esm dir..