Skip to content

Commit

Permalink
CLDR-14703 fix 'empty space' above dashboard, modernize General Info (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
srl295 authored Jan 3, 2022
1 parent 7e8aabb commit 135e86f
Show file tree
Hide file tree
Showing 4 changed files with 96 additions and 62 deletions.
3 changes: 2 additions & 1 deletion tools/cldr-apps/js/src/esm/cldrEvent.js
Original file line number Diff line number Diff line change
Expand Up @@ -412,11 +412,12 @@ function unpackMenuSideBar(json) {
$(".review-link").click(function () {
$("#left-sidebar").removeClass("active");
toggleOverlay();
$("#OtherSection").hide();
const url = $(this).data("url");
if (url === "dashboard") {
cldrStatus.setCurrentSpecial("general");
cldrGui.insertDashboard();
} else {
$("#OtherSection").hide(); // Don't hide the other section when showing the dashboard.
cldrStatus.setCurrentSpecial(url);
cldrStatus.setCurrentId("");
cldrStatus.setCurrentPage("");
Expand Down
79 changes: 18 additions & 61 deletions tools/cldr-apps/js/src/esm/cldrLoad.js
Original file line number Diff line number Diff line change
Expand Up @@ -615,14 +615,24 @@ function shower(itemLoadInfo) {
isLoading = false;
window.location = cldrStatus.getSurvUrl(); // redirect home
} else {
const special = getSpecial(curSpecial);
if (special && special.load) {
cldrEvent.hideOverlayAndSidebar();
specialLoad(itemLoadInfo, curSpecial, theDiv);
}
}

function specialLoad(itemLoadInfo, curSpecial, theDiv) {
const special = getSpecial(curSpecial);
if (special && special.load) {
cldrEvent.hideOverlayAndSidebar();
if (curSpecial !== "general") {
cldrGui.hideDashboard();
special.load(curSpecial); // pass the special name to the loader
} else {
unspecialLoad(itemLoadInfo, theDiv);
}
special.load(curSpecial); // pass the special name to the loader
} else if (curSpecial !== "general") {
// Avoid recursion.
unspecialLoad(itemLoadInfo, theDiv);
} else {
// This will only be called if 'general' is a missing special.
handleMissingSpecial(curSpecial);
}
}

Expand All @@ -633,7 +643,7 @@ function unspecialLoad(itemLoadInfo, theDiv) {
const curPage = cldrStatus.getCurrentPage();
const curId = cldrStatus.getCurrentId();
if (!curPage && !curId) {
loadGeneral(itemLoadInfo);
specialLoad(itemLoadInfo, "general", theDiv); //formerly: loadGeneral(itemLoadInfo);
} else if (curId === "!") {
// TODO: clarify when and why this would happen
loadExclamationPoint();
Expand Down Expand Up @@ -702,7 +712,6 @@ function handleMissingSpecial(curSpecial) {
*
* Also these, which don't fit the fallback pattern:
* - loadExclamationPoint
* - loadGeneral
* - loadAllRows
* - localeParseHash
*
Expand Down Expand Up @@ -755,59 +764,6 @@ function isReport(str) {
return str[0] == "r" && str[1] == "_";
}

// the 'General Info' page.
function loadGeneral(itemLoadInfo) {
const curLocale = cldrStatus.getCurrentLocale();
const curLocaleName = locmap.getLocaleName(curLocale);
itemLoadInfo.appendChild(document.createTextNode(curLocaleName));
showPossibleProblems();
const message = cldrText.get("generalPageInitialGuidance");
cldrInfo.showMessage(message);
isLoading = false;
}

/**
* Show the "possible problems" section which has errors for the locale
*/
function showPossibleProblems() {
const currentLocale = cldrStatus.getCurrentLocale();
const userCov = cldrCoverage.getSurveyUserCov();
const url =
cldrStatus.getContextPath() +
"/SurveyAjax?what=possibleProblems&_=" +
currentLocale +
"&s=" +
cldrStatus.getSessionId() +
"&userCov=" +
(userCov || "auto") +
cldrSurvey.cacheKill();
myLoad(url, "possibleProblems", loadPossibleProblemsFromJson);
}

function loadPossibleProblemsFromJson(json) {
if (verifyJson(json, "possibleProblems")) {
if (json.dataLoadTime) {
cldrDom.updateIf("dynload", json.dataLoadTime);
}
const theDiv = flipper.flipToEmpty(pages.other);
insertLocaleSpecialNote(theDiv);
if (json.possibleProblems.length > 0) {
const subDiv = cldrDom.createChunk("", "div");
subDiv.className = "possibleProblems";
const h3 = cldrDom.createChunk(cldrText.get("possibleProblems"), "h3");
subDiv.appendChild(h3);
const div3 = document.createElement("div");
div3.innerHTML = cldrSurvey.testsToHtml(json.possibleProblems);
subDiv.appendChild(div3);
theDiv.appendChild(subDiv);
}
const theInfo = cldrDom.createChunk("", "p", "special_general");
theDiv.appendChild(theInfo);
theInfo.innerHTML = cldrText.get("special_general");
cldrSurvey.hideLoader();
}
}

function loadExclamationPoint() {
var frag = document.createDocumentFragment();
frag.appendChild(
Expand Down Expand Up @@ -1162,6 +1118,7 @@ export {
handleCoverageChanged,
insertLocaleSpecialNote,
linkToLocale,
localeSpecialNote,
myLoad,
parseHashAndUpdate,
reloadV,
Expand Down
2 changes: 2 additions & 0 deletions tools/cldr-apps/js/src/specialToComponentMap.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import AboutPanel from "./views/AboutPanel.vue";
import AddUser from "./views/AddUser.vue";
import AutoImport from "./views/AutoImport.vue";
import GeneralInfo from "./views/GeneralInfo.vue";
import LockAccount from "./views/LockAccount.vue";
import LookUp from "./views/LookUp.vue";
import MainMenu from "./views/MainMenu.vue";
Expand All @@ -18,6 +19,7 @@ const specialToComponentMap = {
about: AboutPanel,
add_user: AddUser,
auto_import: AutoImport,
general: GeneralInfo,
lock_account: LockAccount,
lookup: LookUp,
menu: MainMenu,
Expand Down
74 changes: 74 additions & 0 deletions tools/cldr-apps/js/src/views/GeneralInfo.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
<!--
This replaces cldrLoad.loadGeneral(itemLoadInfo);
Note that there isn't any provision for showPossibleProblems, which seems to be
entirely dead code.
-->

<template>
<div>
<div class="warnText" v-if="localeSpecialNote" v-html="localeSpecialNote" />
<div class="warnText" v-if="betaNote" v-html="betaNote" />
<p class="special_general" v-if="specialGeneral" v-html="specialGeneral" />
<button
@click="insertDashboard"
class="cldr-nav-btn btn-primary open-dash general-open-dash"
type="button"
>
Open Dashboard
</button>
</div>
</template>

<script>
import * as cldrGui from "../esm/cldrGui.js";
import * as cldrLoad from "../esm/cldrLoad.js";
import * as cldrStatus from "../esm/cldrStatus.js";
import * as cldrText from "../esm/cldrText.js";

export default {
data() {
return {
localeSpecialNote: null,
betaNote: null,
specialGeneral: null,
};
},
mounted() {
const locmap = cldrLoad.getTheLocaleMap();
const bund = locmap.getLocaleInfo(cldrStatus.getCurrentLocale());
let msg = cldrLoad.localeSpecialNote(bund, false);
if (msg) {
msg = locmap.linkify(msg);
this.localeSpecialNote = msg;
} else {
this.localeSpecialNote = null;
}

// setup beta note
if (cldrStatus.getIsPhaseBeta()) {
this.betaNote = cldrText.sub("beta_msg", {
info: bund,
locale: cldrStatus.getCurrentLocale(),
msg: msg,
});
} else {
this.betaNote = null;
}

// setup specialGeneral
this.specialGeneral = cldrText.get("special_general");
},
methods: {
insertDashboard() {
cldrGui.insertDashboard();
},
},
};
</script>

<style>
button.general-open-dash {
/* We only want THIS button to float, not all Open Dashboard buttons. */
float: right;
}
</style>

0 comments on commit 135e86f

Please sign in to comment.