From be9500b1190298bd39b9fa1bb522d9efd5fe7d39 Mon Sep 17 00:00:00 2001 From: erickson Date: Wed, 24 May 2006 18:37:53 +0000 Subject: [PATCH] added required survey support, left disabled for now git-svn-id: svn://svn.open-ils.org/ILS/trunk@4378 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- Open-ILS/xul/staff_client/server/patron/ue.js | 27 +++++++++++++++++++ .../xul/staff_client/server/patron/ue.xhtml | 1 + .../xul/staff_client/server/patron/ue_ui.js | 26 ++++++++++++++++-- 3 files changed, 52 insertions(+), 2 deletions(-) diff --git a/Open-ILS/xul/staff_client/server/patron/ue.js b/Open-ILS/xul/staff_client/server/patron/ue.js index 6185eee00d..6430344196 100644 --- a/Open-ILS/xul/staff_client/server/patron/ue.js +++ b/Open-ILS/xul/staff_client/server/patron/ue.js @@ -348,6 +348,33 @@ function uEditGetErrorStrings() { } ); + + /* munge up something for all of the required surveys + (which are not registered with the fields) */ + + /* AWAITS POLICY DECISION */ + + /* + var rows = $('ue_survey_table').getElementsByTagName('tr'); + for( var r in rows ) { + + var row = rows[r]; + var sel = $n(row, 'ue_survey_answer'); + if(!sel) continue; + var qstn = row.getAttribute('question'); + + if(qstn) { + qstn = surveyQuestionsCache[qstn]; + survey = surveysCache[qstn.survey()]; + var val = getSelectorVal(sel); + if(!val && survey.required() && survey.required() != 'f') + errors.push($('ue_bad_survey').innerHTML); + } + } + */ + + /* ------------------------------------------------------------ */ + if(errors[0]) return errors; return null; } diff --git a/Open-ILS/xul/staff_client/server/patron/ue.xhtml b/Open-ILS/xul/staff_client/server/patron/ue.xhtml index 76942d57a8..3feac0c606 100644 --- a/Open-ILS/xul/staff_client/server/patron/ue.xhtml +++ b/Open-ILS/xul/staff_client/server/patron/ue.xhtml @@ -935,6 +935,7 @@ Address state is invalid Address country is invalid Address zip is invalid + Required survey is unanswered This will remove this address from the user. Are you sure you wish to continue? diff --git a/Open-ILS/xul/staff_client/server/patron/ue_ui.js b/Open-ILS/xul/staff_client/server/patron/ue_ui.js index 8045562828..df2c1fcc1b 100644 --- a/Open-ILS/xul/staff_client/server/patron/ue_ui.js +++ b/Open-ILS/xul/staff_client/server/patron/ue_ui.js @@ -193,10 +193,11 @@ function uEditInsertCat( row, cat, idx ) { /* draw the surveys */ function uEditDrawSurveys(surveys) { + var div = $('uedit_surveys'); var table = div.removeChild($('ue_survey_table')); - if( surveys.length == 0 ) - unHideMe($('uedit_no_surveys')); + if( surveys.length == 0 ) unHideMe($('uedit_no_surveys')); + for( var s in surveys ) { var survey = surveys[s]; surveysCache[survey.id()] = survey; @@ -208,8 +209,10 @@ function uEditDrawSurveys(surveys) { /* insert the servey then insert each of that surveys questions */ function uEditInsertSurvey( div, table, survey, sidx ) { + $n(table, 'ue_survey_name').appendChild(text(survey.name())); $n(table, 'ue_survey_desc').appendChild(text(survey.description())); + var tbody = $n(table, 'ue_survey_tbody'); var templ = tbody.removeChild($n(table, 'ue_survey_row')); @@ -222,9 +225,11 @@ function uEditInsertSurvey( div, table, survey, sidx ) { } function uEditInsertSurveyQuestion( row, survey, question ) { + var selector = $n(row, 'ue_survey_answer'); row.setAttribute('question', question.id()); $n(row, 'ue_survey_question').appendChild(text(question.question())); + for( var a in question.answers() ) { var answer = question.answers()[a]; surveyAnswersCache[answer.id()] = answer; @@ -233,6 +238,12 @@ function uEditInsertSurveyQuestion( row, survey, question ) { surveyQuestionsCache[question.id()] = question; + /* XXX + if( survey.required() && survey.required() != 'f' ) { + addCSSClass(selector, 'invalid_value'); + } + */ + selector.onchange = function() { /* remove any existing responses for this survey */ @@ -244,10 +255,21 @@ function uEditInsertSurveyQuestion( row, survey, question ) { ) ); + if(!patron.survey_responses()) patron.survey_responses([]); var val = getSelectorVal(selector); + + /* XXX + if( survey.required() && survey.required() != 'f' ) { + if(val) + removeCSSClass(selector, 'invalid_value'); + else + addCSSClass(selector, 'invalid_value'); + } + */ + if(!val) return; var resp = new asvr(); -- 2.43.2