Changeset 1665

Show
Ignore:
Timestamp:
12/10/07 16:42:10
Author:
johnsa
Message:

event submit: added validation, more changes to admin to accomodate

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/deployment/webadmin/webapp/resources/default/default/default.xsl

    r1663 r1665  
    6666       dynamically in the xslt). --> 
    6767 
    68   <xsl:variable name="submissionsRoot" select="/bedework/submissionsRoot"/> 
     68  <xsl:variable name="submissionsRootEncoded" select="/bedework/submissionsRoot/encoded"/> 
     69  <xsl:variable name="submissionsRootUnencoded" select="/bedework/submissionsRoot/unencoded"/> 
    6970 
    7071  <!-- primary navigation, menu tabs --> 
     
    523524            <xsl:attribute name="class">selected</xsl:attribute> 
    524525          </xsl:if> 
    525           <a href="{$initPendingTab}&amp;ignoreCreator=yes&amp;calPath={$submissionsRoot}">Pending Events</a> 
     526          <a href="{$initPendingTab}&amp;ignoreCreator=yes&amp;calPath={$submissionsRootEncoded}">Pending Events</a> 
    526527        </li> 
    527528        <xsl:if test="/bedework/currentCalSuite/currentAccess/current-user-privilege-set/privilege/write or /bedework/userInfo/superUser='true'"> 
     
    21662167      <tr> 
    21672168        <xsl:choose> 
    2168           <xsl:when test="starts-with(form/calendar/all/select/option[@selected],$submissionsRoot)"> 
     2169          <xsl:when test="starts-with(form/calendar/all/select/option[@selected],$submissionsRootUnencoded)"> 
    21692170            <td> 
    21702171              <input type="submit" name="updateSubmitEvent" value="Update Event"/> 
  • trunk/deployment/websubmit/webapp/resources/demoskins/default/default/default.css

    r1660 r1665  
    248248  font-size: 0.9em; 
    249249} 
    250 #bedework #instructions .navButtons { 
     250#bedework .navButtons { 
    251251  float: right; 
    252252  text-align: right; 
    253253} 
    254 #bedework #instructions .navButtons img { 
     254#bedework .navButtons img { 
    255255  vertical-align: middle; 
     256} 
     257#bedework .navBox { 
     258  padding: 4px; 
     259  background-color: #ffe; 
     260  border: 1px solid #ccc; 
    256261} 
    257262#bedework #bwBottomNav { 
     
    729734  font-style: italic; 
    730735} 
     736#bedework .highlight { 
     737  color: black; 
     738  background-color: #fee; 
     739  border: 1px solid #333; 
     740} 
     741#bedework .notice { 
     742  font-weight: bold; 
     743  font-style: italic; 
     744} 
  • trunk/deployment/websubmit/webapp/resources/demoskins/default/default/default.xsl

    r1660 r1665  
    154154        document.getElementById(id).focus(); 
    155155      } 
    156       function validate(form) { 
    157         alert ("check"); 
    158         if (form.summary.value == "") { 
    159           alert("Please enter a summary."); 
    160           form.summary.focus(); 
    161           return false; 
    162         } 
    163       } 
    164156      ]]> 
    165157      </xsl:comment> 
     
    235227  <!--==== HOME ====--> 
    236228  <xsl:template name="home"> 
     229    <div class="navButtons navBox"> 
     230      <a href="{$initEvent}">start 
     231        <img alt="previous" 
     232          src="{$resourcesRoot}/resources/arrowRight.gif" 
     233          width="13" 
     234          height="13" 
     235          border="0"/> 
     236      </a> 
     237    </div> 
    237238    <h1>Entering Events</h1> 
    238239    <ol id="introduction"> 
     
    266267  <!--==== ADD EVENT ====--> 
    267268  <xsl:template match="formElements" mode="addEvent"> 
    268     <form name="eventForm" method="post" action="{$addEvent}" id="standardForm" onsubmit="return validate(); setEventFields(this);"> 
     269    <form name="eventForm" method="post" action="{$addEvent}" id="standardForm" onsubmit="setEventFields(this);"> 
    269270      <xsl:apply-templates select="." mode="eventForm"/> 
    270271    </form> 
     
    273274  <!--==== EDIT EVENT ====--> 
    274275  <xsl:template match="formElements" mode="editEvent"> 
    275     <form name="eventForm" method="post" action="{$updateEvent}" id="standardForm" onsubmit="return validate(); setEventFields(this);"> 
     276    <form name="eventForm" method="post" action="{$updateEvent}" id="standardForm" onsubmit="setEventFields(this);"> 
    276277      <xsl:apply-templates select="." mode="eventForm"/> 
    277278    </form> 
     
    287288    <xsl:variable name="recurrenceId" select="recurrenceId"/> 
    288289    <input type="hidden" name="endType" value="date"/> 
     290    <!-- for now, the comment field will hold the user's suggestions; 
     291         this should be replaced with a different field to avoid 
     292         overloading the RFC property.  --> 
     293    <input type="hidden" name="comment" id="bwEventComment"/> 
    289294 
    290295      <!-- event info for edit event --> 
     
    375380      <div id="bwHelp-Details"> 
    376381        <div class="navButtons"> 
    377           <a href="javascript:show('bwEventTab-Location','bwHelp-Location','bwBottomNav-Location'); hide('bwEventTab-Details','bwHelp-Details','bwBottomNav-Details');"> 
     382          <a href="javascript:show('bwEventTab-Location','bwHelp-Location','bwBottomNav-Location');hide('bwEventTab-Details','bwHelp-Details','bwBottomNav-Details');" 
     383             onclick="return validateStep1();"> 
    378384            next 
    379385            <img alt="previous" 
     
    395401              border="0"/> 
    396402          previous</a> | 
    397           <a href="javascript:show('bwEventTab-Contact','bwHelp-Contact','bwBottomNav-Contact'); hide('bwEventTab-Location','bwHelp-Location','bwBottomNav-Location');"> 
     403          <a href="javascript:show('bwEventTab-Contact','bwHelp-Contact','bwBottomNav-Contact'); hide('bwEventTab-Location','bwHelp-Location','bwBottomNav-Location');" 
     404             onclick="return validateStep2();"> 
    398405            next 
    399406            <img alt="previous" 
     
    415422              border="0"/> 
    416423          previous</a> | 
    417           <a href="javascript:show('bwEventTab-Categories','bwHelp-Categories','bwBottomNav-Categories'); hide('bwHelp-Contact','bwEventTab-Contact','bwBottomNav-Contact');"> 
     424          <a href="javascript:show('bwEventTab-Categories','bwHelp-Categories','bwBottomNav-Categories'); hide('bwHelp-Contact','bwEventTab-Contact','bwBottomNav-Contact');" 
     425             onclick="return validateStep3();"> 
    418426            next 
    419427            <img alt="previous" 
     
    458466      <div id="bwEventTab-Details"> 
    459467        <table cellspacing="0" class="common"> 
     468          <!-- Calendar --> 
     469          <!-- ======== --> 
     470          <!--  the string "user/" should not be hard coded; fix this --> 
     471          <xsl:variable name="userPath">user/<xsl:value-of select="/bedework/userid"/></xsl:variable> 
     472          <xsl:variable name="writableCalendars"> 
     473            <xsl:value-of select=" 
     474              count(/bedework/myCalendars//calendar[calType = '1' and 
     475                     currentAccess/current-user-privilege-set/privilege/write-content]) + 
     476              count(/bedework/mySubscriptions//calendar[calType = '1' and 
     477                     currentAccess/current-user-privilege-set/privilege/write-content and 
     478                     (not(contains(path,$userPath)))])"/> 
     479          </xsl:variable> 
    460480          <tr> 
     481            <xsl:if test="$writableCalendars = 1"> 
     482              <xsl:attribute name="class">invisible</xsl:attribute> 
     483              <!-- hide this row altogether if there is only one calendar; if you want the calendar 
     484                   path displayed, comment out this xsl:if. --> 
     485            </xsl:if> 
    461486            <td class="fieldname"> 
    462487              Calendar: 
    463488            </td> 
    464489            <td class="fieldval"> 
    465               <!--  the string "user/" should not be hard coded; fix this --> 
    466               <xsl:variable name="userPath">user/<xsl:value-of select="/bedework/userid"/></xsl:variable> 
    467               <xsl:variable name="writableCalendars"> 
    468                 <xsl:value-of select=" 
    469                   count(/bedework/myCalendars//calendar[calType = '1' and 
    470                          currentAccess/current-user-privilege-set/privilege/write-content]) + 
    471                   count(/bedework/mySubscriptions//calendar[calType = '1' and 
    472                          currentAccess/current-user-privilege-set/privilege/write-content and 
    473                          (not(contains(path,$userPath)))])"/> 
    474               </xsl:variable> 
    475490              <xsl:choose> 
    476491                <xsl:when test="$writableCalendars = 1"> 
     
    520535          </tr> 
    521536          <!--  Summary (title) of event  --> 
     537          <!--  ========================= --> 
    522538          <tr> 
    523539            <td class="fieldname"> 
     
    525541            </td> 
    526542            <td class="fieldval"> 
     543              <div id="bwEventTitleNotice" class="invisible">You must include a title.</div> <!-- a holder for validation notes --> 
    527544              <xsl:variable name="title" select="form/title/input/@value"/> 
    528545              <input type="text" name="summary" size="80" value="{$title}" id="bwEventTitle"/> 
     
    837854            <td class="fieldname">Description:</td> 
    838855            <td class="fieldval"> 
     856              <div id="bwEventDescNotice" class="invisible">You must include a description.</div> <!-- a holder for validation notes --> 
    839857              <xsl:choose> 
    840858                <xsl:when test="normalize-space(form/desc/textarea) = ''"> 
    841                   <textarea name="description" cols="60" rows="4"
     859                  <textarea name="description" cols="60" rows="4" id="bwEventDesc"
    842860                    <xsl:text> </xsl:text> 
    843861                  </textarea> 
     
    846864                </xsl:when> 
    847865                <xsl:otherwise> 
    848                   <textarea name="description" cols="60" rows="4"
     866                  <textarea name="description" cols="60" rows="4" id="bwEventDescription"
    849867                    <xsl:value-of select="form/desc/textarea"/> 
    850868                  </textarea> 
     
    888906      <!-- ============== --> 
    889907      <div id="bwEventTab-Location" class="invisible"> 
     908        <div id="bwLocationUidNotice" class="invisible">You must either select a location or suggest one below.</div> 
    890909        <div class="mainForm"> 
    891910          <span id="eventFormLocationList"> 
    892             <select name="locationUid" class="bigSelect"
     911            <select name="locationUid" class="bigSelect" id="bwLocationUid"
    893912              <option value="">select an existing location...</option> 
    894913              <xsl:copy-of select="form/location/locationmenu/select/*"/> 
     
    902921          <p> 
    903922            <label for="commentLocationAddress">Address: </label> 
    904             <input type="text" name="commentLocationAddress"/> 
     923            <input type="text" name="commentLocationAddress" id="bwCommentLocationAddress"/> 
    905924          </p> 
    906925          <p> 
     
    918937      <!-- ============== --> 
    919938      <div id="bwEventTab-Contact" class="invisible"> 
     939        <div id="bwContactUidNotice" class="invisible">You must either select a contact or suggest one below.</div> 
    920940        <div class="mainForm"> 
    921           <select name="allContactId" id="eventFormPrefContactList" class="bigSelect"> 
     941          <select name="contactUid" id="bwContactUid" class="bigSelect"> 
    922942            <option value=""> 
    923943              select an existing contact... 
     
    932952          <p> 
    933953            <label for="commentContactName">Organization Name: </label> 
    934             <input type="text" name="commentContactName" size="40"/> 
     954            <input type="text" name="commentContactName" id="bwCommentContactName" size="40"/> 
    935955            <span class="note"> Please limit contacts to organizations, not individuals.</span> 
    936956          </p> 
  • trunk/deployment/websubmit/webapp/resources/demoskins/resources/bedework.js

    r1580 r1665  
    218218  } 
    219219} 
     220// trim function 
     221function trim(str) { 
     222  var trimmedStr = str.replace(/^\s+|\s+$/g, ''); 
     223  return trimmedStr.replace(/^(\&nbsp\;)+|(\&nbsp\;)+$/g, ''); 
     224} 
     225 
  • trunk/deployment/websubmit/webapp/resources/demoskins/resources/bedeworkEventForm.js

    r1580 r1665  
    237237 
    238238// ======================================================================== 
     239// Form Manipulation Functions 
    239240// ======================================================================== 
    240241 
    241242function setEventFields(formObj) { 
    242243  setDates(formObj); 
     244  setComment(formObj); 
    243245  setRecurrence(formObj); 
    244246  setAccessHow(formObj,1); 
     
    257259  formObj["eventEndDate.month"].value = endDate.getMonth() + 1; 
    258260  formObj["eventEndDate.day"].value = endDate.getDate(); 
     261} 
     262function setComment(formObj) { 
     263  // set the submission comments (location, contact, and category suggestions) 
     264  // in xml format for easier post processing. 
     265  // add and remove values as the application grows. 
     266  var comment = "<location>" 
     267  if (formObj["commentLocationAddress"].value != "") { 
     268    comment += "<address>" + formObj["commentLocationAddress"].value + "</address>"; 
     269  } 
     270  if (formObj["commentLocationSubaddress"].value != "") { 
     271    comment += "<subaddress>" + formObj["commentLocationSubaddress"].value + "</subaddress>"; 
     272  } 
     273  if (formObj["commentLocationURL"].value != "") { 
     274    comment += "<url>" + formObj["commentLocationURL"].value + "</url>"; 
     275  } 
     276  if (formObj["commentLocationSubaddress"].value != "") { 
     277    comment += "<subaddress>" + formObj["commentLocationSubaddress"].value + "</subaddress>"; 
     278  } 
     279  comment += "</location>"; 
     280  comment += "<contact>"; 
     281  if (formObj["commentContactName"].value != "") { 
     282    comment += "<name>" + formObj["commentContactName"].value + "</name>"; 
     283  } 
     284  if (formObj["commentContactPhone"].value != "") { 
     285    comment += "<phone>" + formObj["commentContactPhone"].value + "</phone>"; 
     286  } 
     287  if (formObj["commentContactURL"].value != "") { 
     288    comment += "<url>" + formObj["commentContactURL"].value + "</url>"; 
     289  } 
     290  if (formObj["commentContactEmail"].value != "") { 
     291    comment += "<email>" + formObj["commentContactEmail"].value + "</email>"; 
     292  } 
     293  comment += "</contact>"; 
     294  if (formObj["commentCategory"].value != "") { 
     295    comment += "<category>" + formObj["commentCategory"].value + "</category>"; 
     296  } 
     297  formObj["comment"].value = comment; 
    259298} 
    260299function swapAllDayEvent(obj) { 
     
    584623} 
    585624 
     625// ======================================================= 
     626// Event submit validation by page 
     627// ======================================================= 
     628function validateStep1() { 
     629  var validity = true; 
     630  if (trim(document.getElementById("bwEventTitle").value) == '') { 
     631    changeClass("bwEventTitle","highlight"); 
     632    changeClass("bwEventTitleNotice","notice"); 
     633    validity = false; 
     634  } else { 
     635    changeClass("bwEventTitle","none"); 
     636    changeClass("bwEventTitleNotice","invisible"); 
     637  } 
     638  if (trim(document.getElementById("bwEventDesc").value) == '') { 
     639    changeClass("bwEventDesc","highlight"); 
     640    changeClass("bwEventDescNotice","notice"); 
     641    validity = false; 
     642  } else { 
     643    changeClass("bwEventDesc","none"); 
     644    changeClass("bwEventDescNotice","invisible"); 
     645  } 
     646  document.getElementById("bwEventComment").value = "<comment>test</comment>"; 
     647  return validity; 
     648} 
     649 
     650function validateStep2() { 
     651  var validity = true; 
     652  if (document.getElementById("bwLocationUid").value == '' && 
     653      document.getElementById("bwCommentLocationAddress").value == '') { 
     654    changeClass("bwLocationUid","highlight bigSelect"); 
     655    changeClass("bwCommentLocationAddress","highlight"); 
     656    changeClass("bwLocationUidNotice","notice"); 
     657    validity = false; 
     658  } else { 
     659    changeClass("bwLocationUid","bigSelect"); 
     660    changeClass("bwCommentLocationAddress","none"); 
     661    changeClass("bwLocationUidNotice","invisible"); 
     662  } 
     663  return validity; 
     664} 
     665function validateStep3() { 
     666  var validity = true; 
     667  if (document.getElementById("bwContactUid").value == '' && 
     668      document.getElementById("bwCommentContactName").value == '') { 
     669    changeClass("bwContactUid","highlight bigSelect"); 
     670    changeClass("bwCommentContactName","highlight"); 
     671    changeClass("bwContactUidNotice","notice"); 
     672    validity = false; 
     673  } else { 
     674    changeClass("bwContactUid","bigSelect"); 
     675    changeClass("bwCommentContactName","none"); 
     676    changeClass("bwContactUidNotice","invisible"); 
     677  } 
     678  return validity; 
     679} 
     680 
     681// ======================================================= 
     682// Dojo initialization 
     683// ======================================================= 
     684 
    586685function init() { 
    587686  var untilHolder = dojo.byId("untilHolder");