Changeset 162


Ignore:
Timestamp:
Oct 22, 2009, 8:26:09 PM (14 years ago)
Author:
gav
Message:

Add Department domain class, controller, views and demo data.
Add costCode and department attributes to SystemSection? and regen non-detailed controller and views, adjust detailed views to suite.

Location:
trunk/grails-app
Files:
7 added
11 edited

Legend:

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

    r118 r162  
    2727        if(systemSectionInstance) {
    2828            try {
    29                 systemSectionInstance.delete()
     29                systemSectionInstance.delete(flush:true)
    3030                flash.message = "SystemSection ${params.id} deleted"
    3131                redirect(action:list)
     
    7777        else {
    7878            flash.message = "SystemSection not found with id ${params.id}"
    79             redirect(action:edit,id:params.id)
     79            redirect(action:list)
    8080        }
    8181    }
  • trunk/grails-app/controllers/SystemSectionDetailedController.groovy

    r124 r162  
    2727        if(systemSectionInstance) {
    2828            try {
    29                 systemSectionInstance.delete()
     29                systemSectionInstance.delete(flush:true)
    3030                flash.message = "SystemSection ${params.id} deleted"
    3131                redirect(action:list)
     
    7777        else {
    7878            flash.message = "SystemSection not found with id ${params.id}"
    79             redirect(action:edit,id:params.id)
     79            redirect(action:list)
    8080        }
    8181    }
  • trunk/grails-app/domain/SystemSection.groovy

    r121 r162  
    11class SystemSection {
    2    
     2
    33    Site site
     4    Department department
    45
    56    String name
    67    String description = ""
     8    String costCode = ""
    79    boolean isActive = true
    810
  • trunk/grails-app/services/CreateDataService.groovy

    r149 r162  
    5959        createDemoPersons()
    6060        createDemoSites()
     61        createDemoDepartments()
    6162        // Tasks
    6263        createDemoTaskGroups() /// @todo: Perhaps this should be BaseData?
     
    240241        siteInstance = new Site(name: "Jasper Street Depot")
    241242        saveAndTest(siteInstance)
     243
     244        siteInstance = new Site(name: "River Press")
     245        saveAndTest(siteInstance)
     246    }
     247
     248    def createDemoDepartments() {
     249
     250        //Department
     251        def departmentInstance
     252
     253        //Department #1
     254        departmentInstance = new Department(name: "Print Centre",
     255                                                                                    site: Site.get(1))
     256        saveAndTest(departmentInstance)
     257
     258        //Department #2
     259        departmentInstance = new Department(name: "Pulp Mill 2",
     260                                                                                    site: Site.get(2))
     261        saveAndTest(departmentInstance)
    242262    }
    243263
     
    784804        //SystemSection #1
    785805        systemSectionInstance = new SystemSection(name: "Press Section",
    786                                                                                     site: Site.get(1))
     806                                                                                    site: Site.get(1),
     807                                                                                    department: Department.get(1))
    787808        saveAndTest(systemSectionInstance)
    788809
    789810        //SystemSection #2
    790811        systemSectionInstance = new SystemSection(name: "RO System",
    791                                                                                     site: Site.get(2))
     812                                                                                    site: Site.get(2),
     813                                                                                    department: Department.get(2))
    792814        saveAndTest(systemSectionInstance)
    793815
    794816        //SystemSection #3
    795817        systemSectionInstance = new SystemSection(name: "Auxilliray Section",
    796                                                                                     site: Site.get(1))
     818                                                                                    site: Site.get(1),
     819                                                                                    department: Department.get(1))
    797820        saveAndTest(systemSectionInstance)
    798821    }
  • trunk/grails-app/views/systemSection/create.gsp

    r151 r162  
    2626                    <table>
    2727                        <tbody>
     28                       
     29                            <tr class="prop">
     30                                <td valign="top" class="name">
     31                                    <label for="costCode">Cost Code:</label>
     32                                </td>
     33                                <td valign="top" class="value ${hasErrors(bean:systemSectionInstance,field:'costCode','errors')}">
     34                                    <input type="text" id="costCode" name="costCode" value="${fieldValue(bean:systemSectionInstance,field:'costCode')}"/>
     35                                </td>
     36                            </tr>
     37                       
     38                            <tr class="prop">
     39                                <td valign="top" class="name">
     40                                    <label for="department">Department:</label>
     41                                </td>
     42                                <td valign="top" class="value ${hasErrors(bean:systemSectionInstance,field:'department','errors')}">
     43                                    <g:select optionKey="id" from="${Department.list()}" name="department.id" value="${systemSectionInstance?.department?.id}" ></g:select>
     44                                </td>
     45                            </tr>
    2846                       
    2947                            <tr class="prop">
  • trunk/grails-app/views/systemSection/edit.gsp

    r151 r162  
    4343<g:link controller="asset" params="['systemSection.id':systemSectionInstance?.id]" action="create">Add Asset</g:link>
    4444
     45                                </td>
     46                            </tr>
     47                       
     48                            <tr class="prop">
     49                                <td valign="top" class="name">
     50                                    <label for="costCode">Cost Code:</label>
     51                                </td>
     52                                <td valign="top" class="value ${hasErrors(bean:systemSectionInstance,field:'costCode','errors')}">
     53                                    <input type="text" id="costCode" name="costCode" value="${fieldValue(bean:systemSectionInstance,field:'costCode')}"/>
     54                                </td>
     55                            </tr>
     56                       
     57                            <tr class="prop">
     58                                <td valign="top" class="name">
     59                                    <label for="department">Department:</label>
     60                                </td>
     61                                <td valign="top" class="value ${hasErrors(bean:systemSectionInstance,field:'department','errors')}">
     62                                    <g:select optionKey="id" from="${Department.list()}" name="department.id" value="${systemSectionInstance?.department?.id}" ></g:select>
    4563                                </td>
    4664                            </tr>
  • trunk/grails-app/views/systemSection/list.gsp

    r151 r162  
    2424                                <g:sortableColumn property="id" title="Id" />
    2525                       
     26                                <g:sortableColumn property="costCode" title="Cost Code" />
     27                       
     28                                <th>Department</th>
     29                           
    2630                                <g:sortableColumn property="description" title="Description" />
    2731                       
     
    3034                                <g:sortableColumn property="name" title="Name" />
    3135                       
    32                                 <th>Site</th>
    33                            
    3436                        </tr>
    3537                    </thead>
     
    4042                            <td><g:link action="show" id="${systemSectionInstance.id}">${fieldValue(bean:systemSectionInstance, field:'id')}</g:link></td>
    4143                       
     44                            <td>${fieldValue(bean:systemSectionInstance, field:'costCode')}</td>
     45                       
     46                            <td>${fieldValue(bean:systemSectionInstance, field:'department')}</td>
     47                       
    4248                            <td>${fieldValue(bean:systemSectionInstance, field:'description')}</td>
    4349                       
     
    4551                       
    4652                            <td>${fieldValue(bean:systemSectionInstance, field:'name')}</td>
    47                        
    48                             <td>${fieldValue(bean:systemSectionInstance, field:'site')}</td>
    4953                       
    5054                        </tr>
  • trunk/grails-app/views/systemSection/show.gsp

    r151 r162  
    4040                                </ul>
    4141                            </td>
     42                           
     43                        </tr>
     44                   
     45                        <tr class="prop">
     46                            <td valign="top" class="name">Cost Code:</td>
     47                           
     48                            <td valign="top" class="value">${fieldValue(bean:systemSectionInstance, field:'costCode')}</td>
     49                           
     50                        </tr>
     51                   
     52                        <tr class="prop">
     53                            <td valign="top" class="name">Department:</td>
     54                           
     55                            <td valign="top" class="value"><g:link controller="department" action="show" id="${systemSectionInstance?.department?.id}">${systemSectionInstance?.department?.encodeAsHTML()}</g:link></td>
    4256                           
    4357                        </tr>
  • trunk/grails-app/views/systemSectionDetailed/create.gsp

    r151 r162  
    2929                            <tr class="prop">
    3030                                <td valign="top" class="name">
     31                                    <label for="name">Name:</label>
     32                                </td>
     33                                <td valign="top" class="value ${hasErrors(bean:systemSectionInstance,field:'name','errors')}">
     34                                    <input type="text" id="name" name="name" value="${fieldValue(bean:systemSectionInstance,field:'name')}"/>
     35                                </td>
     36                            </tr>
     37                       
     38                            <tr class="prop">
     39                                <td valign="top" class="name">
    3140                                    <label for="description">Description:</label>
    3241                                </td>
     
    3443                                    <input type="text" id="description" name="description" value="${fieldValue(bean:systemSectionInstance,field:'description')}"/>
    3544                                </td>
    36                             </tr> 
     45                            </tr>
    3746                       
    3847                            <tr class="prop">
    3948                                <td valign="top" class="name">
    40                                     <label for="isActive">Is Active:</label>
     49                                    <label for="costCode">Cost Code:</label>
    4150                                </td>
    42                                 <td valign="top" class="value ${hasErrors(bean:systemSectionInstance,field:'isActive','errors')}">
    43                                     <g:checkBox name="isActive" value="${systemSectionInstance?.isActive}" ></g:checkBox>
     51                                <td valign="top" class="value ${hasErrors(bean:systemSectionInstance,field:'costCode','errors')}">
     52                                    <input type="text" id="costCode" name="costCode" value="${fieldValue(bean:systemSectionInstance,field:'costCode')}"/>
    4453                                </td>
    4554                            </tr>
     
    4756                            <tr class="prop">
    4857                                <td valign="top" class="name">
    49                                     <label for="name">Name:</label>
     58                                    <label for="department">Department:</label>
    5059                                </td>
    51                                 <td valign="top" class="value ${hasErrors(bean:systemSectionInstance,field:'name','errors')}">
    52                                     <input type="text" id="name" name="name" value="${fieldValue(bean:systemSectionInstance,field:'name')}"/>
     60                                <td valign="top" class="value ${hasErrors(bean:systemSectionInstance,field:'department','errors')}">
     61                                    <g:select optionKey="id" from="${Department.list()}" name="department.id" value="${systemSectionInstance?.department?.id}" ></g:select>
    5362                                </td>
    5463                            </tr>
     
    6372                            </tr>
    6473                       
     74                            <tr class="prop">
     75                                <td valign="top" class="name">
     76                                    <label for="isActive">Is Active:</label>
     77                                </td>
     78                                <td valign="top" class="value ${hasErrors(bean:systemSectionInstance,field:'isActive','errors')}">
     79                                    <g:checkBox name="isActive" value="${systemSectionInstance?.isActive}" ></g:checkBox>
     80                                </td>
     81                            </tr>
     82                       
    6583                        </tbody>
    6684                    </table>
  • trunk/grails-app/views/systemSectionDetailed/edit.gsp

    r151 r162  
    3232                            <tr class="prop">
    3333                                <td valign="top" class="name">
     34                                    <label for="name">Name:</label>
     35                                </td>
     36                                <td valign="top" class="value ${hasErrors(bean:systemSectionInstance,field:'name','errors')}">
     37                                    <input type="text" id="name" name="name" value="${fieldValue(bean:systemSectionInstance,field:'name')}"/>
     38                                </td>
     39                            </tr>
     40                       
     41                            <tr class="prop">
     42                                <td valign="top" class="name">
     43                                    <label for="description">Description:</label>
     44                                </td>
     45                                <td valign="top" class="value ${hasErrors(bean:systemSectionInstance,field:'description','errors')}">
     46                                    <input type="text" id="description" name="description" value="${fieldValue(bean:systemSectionInstance,field:'description')}"/>
     47                                </td>
     48                            </tr>
     49                       
     50                            <tr class="prop">
     51                                <td valign="top" class="name">
     52                                    <label for="costCode">Cost Code:</label>
     53                                </td>
     54                                <td valign="top" class="value ${hasErrors(bean:systemSectionInstance,field:'costCode','errors')}">
     55                                    <input type="text" id="costCode" name="costCode" value="${fieldValue(bean:systemSectionInstance,field:'costCode')}"/>
     56                                </td>
     57                            </tr>
     58                       
     59                            <tr class="prop">
     60                                <td valign="top" class="name">
     61                                    <label for="department">Department:</label>
     62                                </td>
     63                                <td valign="top" class="value ${hasErrors(bean:systemSectionInstance,field:'department','errors')}">
     64                                    <g:select optionKey="id" from="${Department.list()}" name="department.id" value="${systemSectionInstance?.department?.id}" ></g:select>
     65                                </td>
     66                            </tr>
     67                       
     68                            <tr class="prop">
     69                                <td valign="top" class="name">
     70                                    <label for="site">Site:</label>
     71                                </td>
     72                                <td valign="top" class="value ${hasErrors(bean:systemSectionInstance,field:'site','errors')}">
     73                                    <g:select optionKey="id" from="${Site.list()}" name="site.id" value="${systemSectionInstance?.site?.id}" ></g:select>
     74                                </td>
     75                            </tr>
     76                       
     77                            <tr class="prop">
     78                                <td valign="top" class="name">
     79                                    <label for="isActive">Is Active:</label>
     80                                </td>
     81                                <td valign="top" class="value ${hasErrors(bean:systemSectionInstance,field:'isActive','errors')}">
     82                                    <g:checkBox name="isActive" value="${systemSectionInstance?.isActive}" ></g:checkBox>
     83                                </td>
     84                            </tr>
     85                       
     86                            <tr class="prop">
     87                                <td valign="top" class="name">
    3488                                    <label for="assets">Assets:</label>
    3589                                </td>
     
    4397<g:link controller="assetDetailed" params="['systemSection.id':systemSectionInstance?.id]" action="create">Add Asset</g:link>
    4498
    45                                 </td>
    46                             </tr>
    47                        
    48                             <tr class="prop">
    49                                 <td valign="top" class="name">
    50                                     <label for="description">Description:</label>
    51                                 </td>
    52                                 <td valign="top" class="value ${hasErrors(bean:systemSectionInstance,field:'description','errors')}">
    53                                     <input type="text" id="description" name="description" value="${fieldValue(bean:systemSectionInstance,field:'description')}"/>
    54                                 </td>
    55                             </tr>
    56                        
    57                             <tr class="prop">
    58                                 <td valign="top" class="name">
    59                                     <label for="isActive">Is Active:</label>
    60                                 </td>
    61                                 <td valign="top" class="value ${hasErrors(bean:systemSectionInstance,field:'isActive','errors')}">
    62                                     <g:checkBox name="isActive" value="${systemSectionInstance?.isActive}" ></g:checkBox>
    6399                                </td>
    64100                            </tr>
     
    80116                            </tr>
    81117                       
    82                             <tr class="prop">
    83                                 <td valign="top" class="name">
    84                                     <label for="name">Name:</label>
    85                                 </td>
    86                                 <td valign="top" class="value ${hasErrors(bean:systemSectionInstance,field:'name','errors')}">
    87                                     <input type="text" id="name" name="name" value="${fieldValue(bean:systemSectionInstance,field:'name')}"/>
    88                                 </td>
    89                             </tr>
    90                        
    91                             <tr class="prop">
    92                                 <td valign="top" class="name">
    93                                     <label for="site">Site:</label>
    94                                 </td>
    95                                 <td valign="top" class="value ${hasErrors(bean:systemSectionInstance,field:'site','errors')}">
    96                                     <g:select optionKey="id" from="${Site.list()}" name="site.id" value="${systemSectionInstance?.site?.id}" ></g:select>
    97                                 </td>
    98                             </tr>
    99                        
    100118                        </tbody>
    101119                    </table>
  • trunk/grails-app/views/systemSectionDetailed/show.gsp

    r151 r162  
    3131                   
    3232                        <tr class="prop">
    33                             <td valign="top" class="name">Assets:</td>
     33                            <td valign="top" class="name">Name:</td>
    3434                           
    35                             <td  valign="top" style="text-align:left;" class="value">
    36                                 <ul>
    37                                 <g:each var="a" in="${systemSectionInstance.assets}">
    38                                     <li><g:link controller="assetDetailed" action="show" id="${a.id}">${a?.encodeAsHTML()}</g:link></li>
    39                                 </g:each>
    40                                 </ul>
    41                             </td>
     35                            <td valign="top" class="value">${fieldValue(bean:systemSectionInstance, field:'name')}</td>
    4236                           
    4337                        </tr>
     
    5145                   
    5246                        <tr class="prop">
     47                            <td valign="top" class="name">Cost Code:</td>
     48                           
     49                            <td valign="top" class="value">${fieldValue(bean:systemSectionInstance, field:'costCode')}</td>
     50                           
     51                        </tr>
     52                   
     53                        <tr class="prop">
     54                            <td valign="top" class="name">Department:</td>
     55                           
     56                            <td valign="top" class="value"><g:link controller="department" action="show" id="${systemSectionInstance?.department?.id}">${systemSectionInstance?.department?.encodeAsHTML()}</g:link></td>
     57                           
     58                        </tr>
     59                   
     60                        <tr class="prop">
     61                            <td valign="top" class="name">Site:</td>
     62                           
     63                            <td valign="top" class="value"><g:link controller="site" action="show" id="${systemSectionInstance?.site?.id}">${systemSectionInstance?.site?.encodeAsHTML()}</g:link></td>
     64                           
     65                        </tr>
     66                   
     67                        <tr class="prop">
    5368                            <td valign="top" class="name">Is Active:</td>
    5469                           
    5570                            <td valign="top" class="value">${fieldValue(bean:systemSectionInstance, field:'isActive')}</td>
     71                           
     72                        </tr>
     73                   
     74                        <tr class="prop">
     75                            <td valign="top" class="name">Assets:</td>
     76                           
     77                            <td  valign="top" style="text-align:left;" class="value">
     78                                <ul>
     79                                <g:each var="a" in="${systemSectionInstance.assets}">
     80                                    <li><g:link controller="assetDetailed" action="show" id="${a.id}">${a?.encodeAsHTML()}</g:link></li>
     81                                </g:each>
     82                                </ul>
     83                            </td>
    5684                           
    5785                        </tr>
     
    7098                        </tr>
    7199                   
    72                         <tr class="prop">
    73                             <td valign="top" class="name">Name:</td>
    74                            
    75                             <td valign="top" class="value">${fieldValue(bean:systemSectionInstance, field:'name')}</td>
    76                            
    77                         </tr>
    78                    
    79                         <tr class="prop">
    80                             <td valign="top" class="name">Site:</td>
    81                            
    82                             <td valign="top" class="value"><g:link controller="site" action="show" id="${systemSectionInstance?.site?.id}">${systemSectionInstance?.site?.encodeAsHTML()}</g:link></td>
    83                            
    84                         </tr>
    85                    
    86100                    </tbody>
    87101                </table>
Note: See TracChangeset for help on using the changeset viewer.