Changeset ca428d in indico


Ignore:
Timestamp:
11/12/09 17:56:33 (4 years ago)
Author:
Pedro Ferreira <jose.pedro.ferreira@…>
Branches:
master, burotel, hello-world-walkthrough, ipv6, new-webex, prov-dual-interface, v0.97-series, v0.98-series, v0.98.2, v0.98.3, v0.98b1, v0.98b2, v0.99, 051b2622c51afb171a1dedb46a0df4fbb0cbd02e, d9941f8582b36b24821a11ea5ba16fda6a457fb1
Children:
4314aa
Parents:
931922
git-author:
Cesar Munoz Orena <cesar.munoz.orena@…> (11/11/09 09:37:51)
git-committer:
Pedro Ferreira <jose.pedro.ferreira@…> (11/12/09 17:56:33)
Message:

[IMPROVEMENT] Changes end/startDate automatically

In the roomBooking module, when the startDate is set to a higher value than the endDate
it automatically changes it to a valid date and viceversa.
Fixes #1

Location:
indico
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • indico/MaKaC/webinterface/tpls/RoomBookingPeriodForm.tpl

    r9033fd rca428d  
    4747        var startDate = IndicoUI.Widgets.Generic.dateField_sdate(false,null,['sDay', 'sMonth', 'sYear']); 
    4848        $E('sDatePlace').set(startDate); 
    49              
     49  
    5050        var endDate = IndicoUI.Widgets.Generic.dateField_edate(false,null,['eDay', 'eMonth', 'eYear']);  
    5151        $E('eDatePlace').set(endDate); 
     52 
     53        /* In case the date changes, we need to check whether the start date is greater than the end date, 
     54        and if it's so we need to change it */ 
     55        startDate.observe(function(value) {             
     56            if ( IndicoUtil.parseDate(startDate.get()) > IndicoUtil.parseDate(endDate.get()) ) { 
     57                endDate.set(startDate.get());    
     58                endDate.dom.onchange(); 
     59                set_repeatition_comment(); 
     60            } 
     61        }); 
     62         
     63        endDate.observe(function(value) { 
     64            if ( IndicoUtil.parseDate(startDate.get()) > IndicoUtil.parseDate(endDate.get()) ) { 
     65                startDate.set(endDate.get()); 
     66                startDate.dom.onchange(); 
     67                set_repeatition_comment(); 
     68            } 
     69        }); 
    5270         
    5371       <% if startDT.day != '': %> 
     
    6583                                            <td class="blacktext"> 
    6684                                                <span id="sDatePlace"></span> 
    67                                                 <input type="hidden" value="<%= startDT.day %>" name="sDay" id="sDay" onchange="this.form.eDay.value=this.value;if ( validate_period( this.form ) ) { set_repeatition_comment() }"/> 
    68                                                 <input type="hidden" value="<%= startDT.month %>" name="sMonth" id="sMonth" onchange="this.form.eMonth.value=this.value;if ( validate_period( this.form ) ) { set_repeatition_comment() }"/> 
    69                                                 <input type="hidden" value="<%= startDT.year %>" name="sYear" id="sYear" onchange="this.form.eYear.value=this.value;if ( validate_period( this.form ) ) { set_repeatition_comment() }"/> 
     85                                                <input type="hidden" value="<%= startDT.day %>" name="sDay" id="sDay"/> 
     86                                                <input type="hidden" value="<%= startDT.month %>" name="sMonth" id="sMonth"/> 
     87                                                <input type="hidden" value="<%= startDT.year %>" name="sYear" id="sYear"/> 
    7088                                            </td> 
    7189                                          </tr>   
  • indico/MaKaC/webinterface/tpls/RoomBookingSearch4Bookings.tpl

    r9033fd rca428d  
    7777        var endDate = IndicoUI.Widgets.Generic.dateField_edate(false,null,['eDay', 'eMonth', 'eYear']);  
    7878        $E('eDatePlace').set(endDate); 
     79 
     80 
     81        /* In case the date changes, we need to check whether the start date is greater than the end date, 
     82        and if it's so we need to change it */ 
     83        startDate.observe(function(value) {             
     84            if ( IndicoUtil.parseDate(startDate.get()) > IndicoUtil.parseDate(endDate.get()) ) { 
     85                endDate.set(startDate.get());    
     86                endDate.dom.onchange(); 
     87            } 
     88        }); 
     89         
     90        endDate.observe(function(value) { 
     91            if ( IndicoUtil.parseDate(startDate.get()) > IndicoUtil.parseDate(endDate.get()) ) { 
     92                startDate.set(endDate.get()); 
     93                startDate.dom.onchange(); 
     94            } 
     95        }); 
    7996         
    8097       <% if today.day != '': %> 
  • indico/htdocs/js/indico/Legacy/Util.js

    r626e2c rca428d  
    251251        setDate(sdatetime, sdate); 
    252252        setTime(sdatetime, stime); 
     253 
     254        return sdatetime; 
     255    }, 
     256 
     257    parseDate: function(strDate) {         
     258 
     259        var sdatetime = new Date(); 
     260        var sdate = parseDate(strDate); 
     261 
     262        if ( !sdate ) { 
     263            return null; 
     264        } 
     265 
     266        setTime(sdatetime, [0,0,0,0]) 
     267        setDate(sdatetime, sdate); 
    253268 
    254269        return sdatetime; 
  • indico/htdocs/js/indico/Legacy/validation.js

    r9033fd rca428d  
    141141- allowPast : whether to allow dates in the past 
    142142- what : what to validate: 0 - both dates and times, 1 - only dates, 2 - only times 
     143 
    143144Controls must follow naming conventions: 
    144145sDay, sMonth, sYear, sTime 
     
    177178            todayDate = new Date() 
    178179            todayDate.setHours( 0, 0, 0, 0 ) 
    179             if ( sDate.valueOf() > eDate.valueOf() || 
    180                             ( !allowPast && ( sDate.valueOf() < (todayDate).valueOf()) ) ) 
     180            if ( !allowPast && ( sDate.valueOf() < (todayDate).valueOf()) ) 
    181181            { 
    182182                f1.eDay.className = f1.eMonth.className = f1.eYear.className = f1.edate.className = 'invalid' 
    183183                f1.sDay.className = f1.sMonth.className = f1.sYear.className = f1.sdate.className = 'invalid' 
    184184                isValid = false 
    185             } 
     185            }                   
    186186        } 
    187187    } 
Note: See TracChangeset for help on using the changeset viewer.