/*
 * Author       : muzzopuzzo
 * Generated on : 23-Nov-2009 01:59:07
 * Version      : 3.0
 */
application "Copy of DynamicPicklistExample"
{
    type = public
    date format = "dd-MMM-yyyy"
    time zone = "America/Los_Angeles"
    section Home
    {
        form  Country
        {
            
            Provincia
            (
                displayname  =  "PROVINCIA"
                type  =  text
            )

            actions
            {
                on add
                {
                    Submit
                    (
                        type  =  submit
                        displayname  =  "Submit"
                    )
                    Reset
                    (
                        type  =  reset
                        displayname  =  "Reset"
                    )
                }
                on edit
                {
                    Update
                    (
                        type  =  submit
                        displayname  =  "Update"
                    )
                    Cancel
                    (
                        type  =  cancel
                        displayname  =  "Cancel"
                    )
                }
            }
        }

        list  Country_View
        {
            displayname = "Country View"
            show  all  rows  from  Country 
            (
                Provincia as "Country"
            )
            options
            (
                display rows = 100
            )
        }

        form  CountryAndStates
        {
            
            CountryName
            (
                displayname  =  "PROVINCIA"
                type  =  picklist
                values  =  Country.Provincia
                sortorder  =  ascending
            )

            State
            (
                displayname  =  "CIUDAD"
                type  =  text
            )

            actions
            {
                on add
                {
                    Submit
                    (
                        type  =  submit
                        displayname  =  "Submit"
                    )
                    Reset
                    (
                        type  =  reset
                        displayname  =  "Reset"
                    )
                }
                on edit
                {
                    Update
                    (
                        type  =  submit
                        displayname  =  "Update"
                    )
                    Cancel
                    (
                        type  =  cancel
                        displayname  =  "Cancel"
                    )
                }
            }
        }

        list  CountryAndStates_View
        {
            displayname = "CountryAndStates View"
            show  all  rows  from  CountryAndStates 
            (
                CountryName
                State
            )
            filters 
            (
                CountryName
            )
            options
            (
                display rows = 100
            )
        }

        form  Main
        {
            
            Location
            (
                type  =  picklist
                values  =  Country.Provincia
                on user input
                {
                    if (input.Location  !=  "-Select-")
                    {
                        for each dat in CountryAndStates  [CountryName == input.Location]
                        {
                            States:ui.add(dat.State);
                        }
                    }
                    else
                    {
                        for each dat1 in CountryAndStates  [ID != 0]
                        {
                            States:ui.add(dat1.State);
                        }
                    }
                }
            )

            States
            (
                type  =  picklist
                values  =  CountryAndStates.State
                sortorder  =  ascending
                on user input
                {
                    if (input.States  !=  "-Select-")
                    {
                        for each dat in StatesandCities  [State == input.States]
                        {
                            City:ui.add(dat.City);
                        }
                    }
                }
            )

            City
            (
                type  =  picklist
                values  =  StatesandCities.City
            )

            actions
            {
                on add
                {
                    Submit
                    (
                        type  =  submit
                        displayname  =  "Submit"
                    )
                    Reset
                    (
                        type  =  reset
                        displayname  =  "Reset"
                    )
                }
                on edit
                {
                    Update
                    (
                        type  =  submit
                        displayname  =  "Update"
                    )
                    Cancel
                    (
                        type  =  cancel
                        displayname  =  "Cancel"
                    )
                }
            }
        }

        list  Main_View
        {
            displayname = "Main View"
            show  all  rows  from  Main 
            (
                Location
                States
                City
            )
            filters 
            (
                Location
                States
                City
            )
            options
            (
                display rows = 100
            )
        }

        form  StatesandCities
        {
            
            State
            (
                displayname  =  "CIUDAD"
                type  =  picklist
                values  =  CountryAndStates.State
            )

            City
            (
                displayname  =  "DIRECCION"
                type  =  text
            )

            actions
            {
                on add
                {
                    Submit
                    (
                        type  =  submit
                        displayname  =  "Submit"
                    )
                    Reset
                    (
                        type  =  reset
                        displayname  =  "Reset"
                    )
                }
                on edit
                {
                    Update
                    (
                        type  =  submit
                        displayname  =  "Update"
                    )
                    Cancel
                    (
                        type  =  cancel
                        displayname  =  "Cancel"
                    )
                }
            }
        }

        list  StatesandCities_View
        {
            displayname = "StatesandCities View"
            show  all  rows  from  StatesandCities 
            (
                State
                City
            )
            filters 
            (
                State
            )
            options
            (
                display rows = 100
            )
        }

    }

}
