Changeset 440 for trunk/grails-app


Ignore:
Timestamp:
Mar 16, 2010, 11:33:22 AM (15 years ago)
Author:
gav
Message:

Add Person import feature.
Commit has a small amount of cross over code to the commits will follow.

Location:
trunk/grails-app
Files:
2 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/grails-app/conf/Config.groovy

    r433 r440  
    104104            warn "grails.app.controller"
    105105            info "grails.app.service.AssetCsvService"
     106            info "grails.app.service.PersonCsvService"
    106107            info "grails.app.service.InventoryCsvService"
    107108            break
     
    306307            [order:91, controller:'productionReferenceDetailed', title:'Edit', action:'edit', isVisible: { params.action == 'edit' }]
    307308        ]
     309    ],
     310    [order:170, controller:'costCodeDetailed', title:'costCode', action:'list',
     311        subItems: [
     312            [order:10, controller:'costCodeDetailed', title:'Cost Code List', action:'list', isVisible: { true }],
     313            [order:20, controller:'costCodeDetailed', title:'Create', action:'create', isVisible: { true }],
     314            [order:90, controller:'costCodeDetailed', title:'Show', action:'show', isVisible: { params.action == 'show' }],
     315            [order:91, controller:'costCodeDetailed', title:'Edit', action:'edit', isVisible: { params.action == 'edit' }]
     316        ]
    308317    ]
    309318]
  • trunk/grails-app/controllers/PersonController.groovy

    r403 r440  
    11import org.codehaus.groovy.grails.plugins.springsecurity.Secured
     2import org.codehaus.groovy.grails.commons.ConfigurationHolder
    23
    34@Secured(['ROLE_Manager','ROLE_AppAdmin'])
    45class PersonController extends BaseAppAdminController {
    56
     7    def filterService
     8    def personCsvService
    69    def authenticateService
    7     def filterService
    810
    911    // the delete, save and update actions only accept POST requests
     
    1214    def index = {
    1315        redirect action: list, params: params
     16    }
     17
     18    /**
     19    * Disaply the import view.
     20    */
     21    def importPersons = {
     22    }
     23
     24    /**
     25    * Handle the import save.
     26    */
     27    def importPersonsSave = {
     28        def result = personCsvService.importPersons(request)
     29
     30        if(!result.error) {
     31            response.contentType = ConfigurationHolder.config.grails.mime.types["text"]
     32            response.setHeader("Content-disposition", "attachment; filename=LoginNamesAndPasswords.txt")
     33            render result.loginNamesAndPasswords
     34            return
     35        }
     36
     37        flash.errorMessage = g.message(code: result.error.code, args: result.error.args)
     38        redirect(action: importPersons)
     39    }
     40
     41    /**
     42    * Export a csv template.
     43    * NOTE: IE has a 'validating' bug in dev mode that causes the export to take a long time!
     44    * This does not appear to be a problem once deployed to Tomcat.
     45    */
     46    def exportPersonsTemplate = {
     47        response.contentType = ConfigurationHolder.config.grails.mime.types["csv"]
     48        response.setHeader("Content-disposition", "attachment; filename=personsTemplate.csv")
     49        def s = personCsvService.buildPersonsTemplate()
     50        render s
    1451    }
    1552
  • trunk/grails-app/i18n/messages.properties

    r437 r440  
    77inventory.import.success=Inventory imported.
    88inventory.import.failure=Could not create inventory from supplied file, failed on line {0}, see {1}.
     9
     10inventoryItemPurchase.import.success=Inventory item purchases imported.
     11inventoryItemPurchase.import.failure=Could not create inventory item purchases from supplied file, failed on line {0}, see {1}.
     12
     13person.import.success=Person list imported.
     14person.import.failure=Could not create persons from supplied file, failed on line {0}, see {1}.
    915
    1016asset.copy.subItem.create.failure=Could not complete operation, as sub item failed to save.
     
    138144inventoryMovement.still.associated=Could not complete operation as inventory movements are still associated with this item.
    139145
     146inventoryItemPurchase.invoiceNumber.required=An invoice number must be supplied to approve payment.
     147inventoryItemPurchase.delete.failure.received.exists=Could not delete, items have been received.
     148inventoryItemPurchase.delete.failure.payment.approved=Could not delete, payment has been approved.
     149
    140150assignedGroup.task.not.found=Please select a task and then ''Add Assigned Group''.
    141151assignedPerson.task.not.found=Please select a task and then ''Add Assigned Person''.
  • trunk/grails-app/views/person/list.gsp

    r399 r440  
    2929            Results:${personTotal}
    3030        </div>
     31
     32        <jsUtil:toggleControl toggleId="options"
     33                                                imageId="optionsImg"
     34                                                closedImgUrl="${resource(dir:'images/skin',file:'bullet_arrow_right.png')}"
     35                                                openImgUrl="${resource(dir:'images/skin',file:'bullet_arrow_down.png')}"
     36                                                text="${g.message(code: 'default.options.text')}"
     37                                                />
     38
     39        <div id="options" style="display:none;">
     40            <g:form method="post" >
     41                <g:hiddenField name="params" value="${filterParams}" />
     42                <div class="dialog">
     43                    <table>
     44                        <tbody>
     45
     46                            <tr class="prop">
     47                                <td valign="top" class="name">
     48                                    <label for="max">Persons:</label>
     49                                </td>
     50                                <td valign="top" class="value">
     51                                    <g:link action="exportPersonsTemplate">
     52                                        Template
     53                                    </g:link>
     54                                    /
     55                                    <g:link action="importPersons">
     56                                        Import
     57                                    </g:link>
     58                                </td>
     59                            </tr>
     60
     61                        </tbody>
     62                    </table>
     63                </div>
     64            </g:form>
     65        </div>
     66
     67        <br />
    3168
    3269        <div class="list">
Note: See TracChangeset for help on using the changeset viewer.