Changeset 214


Ignore:
Timestamp:
Dec 4, 2009, 1:13:08 AM (15 years ago)
Author:
gav
Message:

Clicking on a searchCalendar day allows user to create a task with that day preset as targetStartDate.

Location:
trunk/grails-app
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/grails-app/controllers/TaskDetailedController.groovy

    r209 r214  
    1010    def filterService
    1111    def exportService
     12    def dateUtilService
    1213
    1314    // these actions only accept POST requests
     
    409410    def create = {
    410411        def taskInstance = new Task()
     412
     413        // Set the targetStartDate if specified, used by searchCalendar view.
     414        if(params.year && params.month && params.day)
     415            taskInstance.targetStartDate = dateUtilService.makeDate(params.year, params.month, params.day)
     416
    411417        // Default leadPerson to current user, unless supplied in params.
    412418        taskInstance.leadPerson = personService.currentUser()
  • trunk/grails-app/services/DateUtilService.groovy

    r210 r214  
    7676    }
    7777
     78    /**
     79    * Make a date object from supplied year, month, day values.
     80    * The Calendar.getInstance() or Calendar.instance factory returns a new calendar instance, usually
     81    * a Gregorian calendar but using Calendar we don't have to worry about those details.
     82    * The time fields are set to zero and cal.getTime() or cal.time returns a java.util.Date object.
     83    * @param year The year as a string or integer.
     84    * @param month The month as a string or integer.
     85    * @param day The day as a string or integer.
     86    * @returns A Date object having the given date and all time fields set to 0, so the very start of the given day.
     87    */
     88    public static Date makeDate(year, month, day) {
     89        Calendar cal = Calendar.instance
     90        cal.clear()
     91        // Stupid month is 0-based, grumble.
     92        cal.set(year.toInteger(), month.toInteger()-1, day.toInteger())
     93        cal.time
     94    }
     95
    7896}
  • trunk/grails-app/views/taskDetailed/create.gsp

    r196 r214  
    5151                                </td>
    5252                                <td valign="top" class="value ${hasErrors(bean:taskInstance,field:'targetStartDate','errors')}">
    53                                     <richui:dateChooser name="targetStartDate" format="dd-MM-yyyy" value="${new Date()}" />
     53                                    <richui:dateChooser name="targetStartDate" format="dd-MM-yyyy" value="${taskInstance.targetStartDate}" />
    5454                                    <g:helpBalloon class="helpballoon" code="task.targetStartDate" />
    5555                                </td>
     
    6161                                </td>
    6262                                <td valign="top" class="value ${hasErrors(bean:taskInstance,field:'targetCompletionDate','errors')}">
    63                                     <richui:dateChooser name="targetCompletionDate" format="dd-MM-yyyy" value="${new Date()}" />
     63                                    <richui:dateChooser name="targetCompletionDate" format="dd-MM-yyyy" value="${taskInstance.targetCompletionDate}" />
    6464                                    <g:helpBalloon class="helpballoon" code="task.targetCompletionDate" />
    6565                                </td>
  • trunk/grails-app/views/taskDetailed/searchCalendar.gsp

    r181 r214  
    3838                <filterpane:filterButton text="Advanced" appliedText="Advanced" />
    3939            </div>
    40             <richui:calendarMonthView items="${taskInstanceList}" createLink="true" constraintDateFields="['targetStartDate']" month="${new Date()}" controller="taskDetailed" action="show" />
     40            <richui:calendarMonthView items="${taskInstanceList}"
     41                                                                    createLink="true"
     42                                                                    constraintDateFields="['targetStartDate']"
     43                                                                    month="${new Date()}"
     44                                                                    controller="taskDetailed"
     45                                                                    action="show"
     46                                                                    dayAction="create"/>
    4147            <filterpane:filterPane domainBean="Task"
    4248                                    title="Advanced Search"
Note: See TracChangeset for help on using the changeset viewer.