Commit 13ff9bdd authored by Romain Loth's avatar Romain Loth

make field pointer able to open containing panel (TODO transform cC.COLS in a dict to optimize)

parent 94d7b3ae
......@@ -33,33 +33,33 @@ var cmxClt = (function() {
cC.strokeDeepGrey = "3px 3px 4px #333,-3px 3px 4px #333,-3px -3px 4px #333,3px -3px 4px #333"
// the target columns in DB: tuple (name, mandatoryBool, group, type)
cC.COLS = [ ["doors_uid", true, "auto" , "t"],
["last_modified_date", true, "auto" , "d"],
["email", true, "plsfill", "t"],
["country", true, "plsfill", "t"],
["first_name", true, "plsfill", "t"],
["middle_name", false, "pref", "t"],
["last_name", true, "plsfill", "t"],
["initials", true, "plsfill", "t"],
["position", true, "plsfill", "t"],
["hon_title", false, "plsfill", "t"],
["interests_text", false, "plsfill", "t"],
["community_hashtags", false, "plsfill", "at"],
["gender", false, "plsfill", "m"],
["job_looking_date", false, "pref" , "d"],
["home_url", false, "plsfill", "t"],
["pic_url", false, "pref" , "t"],
["pic_file", false, "pref" , "f"],
// the target columns in DB: tuple (name, mandatory, group, type, section)
cC.COLS = [ ["doors_uid", true, "auto" , "t", null],
["last_modified_date", true, "auto" , "d", null],
["email", true, "plsfill", "t", "basic_infos"],
["country", true, "plsfill", "t", "basic_infos"],
["first_name", true, "plsfill", "t", "basic_infos"],
["middle_name", false, "pref", "t", "basic_infos"],
["last_name", true, "plsfill", "t", "basic_infos"],
["initials", true, "plsfill", "t", null],
["position", true, "plsfill", "t", "map_infos"],
["hon_title", false, "plsfill", "t", "basic_infos"],
["interests_text", false, "plsfill", "t", "other_infos"],
["community_hashtags", false, "plsfill", "at", "map_infos"],
["gender", false, "plsfill", "m", "other_infos"],
["job_looking_date", false, "pref" , "d", "map_infos"],
["home_url", false, "plsfill", "t", "other_infos"],
["pic_url", false, "pref" , "t", "other_infos"],
["pic_file", false, "pref" , "f", "other_infos"],
// ==> *scholars* table
["keywords", true, "plsfill", "at"],
["keywords", true, "plsfill", "at", "map_infos"],
// ==> *keywords* table
["org", true, "plsfill", "t"],
["org_type", true, "plsfill", "m"],
["team_lab", false, "pref" , "t"],
["org_city", false, "pref" , "t"]]
["org", true, "plsfill", "t", "org_infos"],
["org_type", true, "plsfill", "m", "org_infos"],
["team_lab", false, "pref" , "t", "map_infos"],
["org_city", false, "pref" , "t", "org_infos"]]
// ==> *affiliations* table
// group "auto" === filled by controllers
......@@ -90,8 +90,13 @@ var cmxClt = (function() {
var fname = cplArray[i][0]
var flabel = cplArray[i][1]
// to open any collapsible containing the label and input
var openFun = 'return cC.uform.openPanelForField(\''+fname+'\')'
console.log("openFun", openFun)
// link works if anchorLabels was run
resultHtml += '<li class="minilabel"><a href="#'+fname+'_lbl'+'">'+flabel+'</a></li>'
resultHtml += '<li class="minilabel"><a onclick="'+openFun+'" href="#'+fname+'_lbl'+'">'+flabel+'</a></li>'
}
resultHtml += '</ul>'
return resultHtml
......@@ -109,12 +114,19 @@ var cmxClt = (function() {
// insert after
// cf. stackoverflow.com/questions/4793604
function insertAfter(referenceNode, newNode) {
cC.insertAfter = function(referenceNode, newNode) {
referenceNode.parentNode.insertBefore(
newNode, referenceNode.nextSibling
)
}
// find ancestor
// cf. stackoverflow.com/questions/22119673
cC.findAncestor = function(elt, cls) {
while ((elt = elt.parentElement) && !elt.classList.contains(cls));
return elt
}
// ============================================
// cmxClt.uform: common vars to all user forms
// ============================================
......@@ -133,6 +145,7 @@ var cmxClt = (function() {
cC.uform.stampTime
cC.uform.anchorLabels
cC.uform.multiTextinput
cC.uform.openPanelForField
// dates up to 2049/12/31
cC.uform.validDate = new RegExp( /^20[0-4][0-9]\/(?:0?[1-9]|1[0-2])\/(?:0?[1-9]|[1-2][0-9]|3[0-1])$/)
......@@ -180,6 +193,36 @@ var cmxClt = (function() {
}
// openPanelForField
cC.uform.openPanelForField = function (fName) {
console.log('fName', fName)
var labelElt = document.getElementById(fName+'_lbl')
var ourPanel = cC.findAncestor(labelElt, "panel-collapse")
console.log('ourPanel.classList.contains("in")', ourPanel.classList.contains('in'))
// if panel is not open
if (! ourPanel.classList.contains('in')) {
// POSS use cols with key/value structure to use cols[fName] instead of looking for i
var theCol = -1
for (var i in cC.COLS) {
if (fName == cC.COLS[i][0]) {
theCol = i
break
}
}
var ccSection = cC.COLS[i][4]
console.log('ccSection', ccSection)
if (ccSection) {
// click the corresponding toggler
document.getElementById('ccsection_toggle_'+ccSection).click()
}
}
}
// initialize
// -----------
cC.uform.initialize = function(aFormId, aValidationFun) {
......
......@@ -39,7 +39,8 @@
data-parent="#profile_box"
data-toggle="collapse"
href="#overview"
aria-controls="overview">
aria-controls="overview"
id="ccsection_toggle_overview">
<div class="panel-heading ccsection-heading" role="tab">
<h2 class="ccsection">
......@@ -51,8 +52,8 @@
</a>
<div id="overview"
class="panel-body panel-collapse collapse out"
role="tabpanel" aria-expanded="false">
class="panel-body panel-collapse collapse in"
role="tabpanel" aria-expanded="true">
<!-- CARTE DE VISITE -->
<h3 class="formcatfirst"> Carte de visite </h3>
......@@ -94,7 +95,7 @@
value="{{ current_user.info.email }}">
</div>
</div>
<div class="panel-footer ccsection-footer">&nbsp</div>
<div class="panel-footer ccsection-footer">&nbsp;</div>
</div>
......@@ -119,7 +120,8 @@
data-parent="#profile_uform"
data-toggle="collapse"
href="#basic_infos_usection"
aria-controls="basic_infos_usection">
aria-controls="basic_infos_usection"
id="ccsection_toggle_basic_infos">
<div class="panel-heading ccsection-heading" role="tab">
<h2 class="ccsection"
......@@ -204,7 +206,7 @@
</div> <!-- /panel-body -->
<div class="panel-footer ccsection-footer">&nbsp</div>
<div class="panel-footer ccsection-footer">&nbsp;</div>
</div>
......@@ -222,7 +224,8 @@
data-parent="#profile_uform"
data-toggle="collapse"
href="#map_infos_usection"
aria-controls="map_infos_usection">
aria-controls="map_infos_usection"
id="ccsection_toggle_map_infos">
<div class="panel-heading ccsection-heading" role="tab">
<h2 class="ccsection"
......@@ -320,7 +323,7 @@
</div> <!-- /panel-body -->
<div class="panel-footer ccsection-footer">&nbsp</div>
<div class="panel-footer ccsection-footer">&nbsp;</div>
</div>
......@@ -338,7 +341,8 @@
data-parent="#profile_uform"
data-toggle="collapse"
href="#org_infos_usection"
aria-controls="org_infos_usection">
aria-controls="org_infos_usection"
id="ccsection_toggle_org_infos">
<div class="panel-heading ccsection-heading" role="tab">
<h2 class="ccsection"
......@@ -372,7 +376,8 @@
<select id="org_type" name="org_type"
class="custom-select form-control"
onchange="if(this.value=='other'){otherInstDivStyle.display = 'block'} else {otherInstDivStyle.display='none'}">
<option selected value="university">University</option>
<option selected disabled value="">Please select</option>
<option value="university">University</option>
<option value="public R&amp;D org">Public sector R&amp;D organization</option>
<option value="public other org">Other public sector organization</option>
<option value="private org">Private sector organization</option>
......@@ -395,7 +400,7 @@
</div> <!-- /panel-body -->
<div class="panel-footer ccsection-footer">&nbsp</div>
<div class="panel-footer ccsection-footer">&nbsp;</div>
</div>
......@@ -409,7 +414,8 @@
data-parent="#profile_uform"
data-toggle="collapse"
href="#other_infos_usection"
aria-controls="other_infos_usection">
aria-controls="other_infos_usection"
id="ccsection_toggle_other_infos">
<div class="panel-heading ccsection-heading" role="tab">
<h2 class="ccsection"
......@@ -508,7 +514,7 @@
</div>
</div> <!-- /panel-body -->
<div class="panel-footer ccsection-footer">&nbsp</div>
<div class="panel-footer ccsection-footer">&nbsp;</div>
</div>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment