Concept for a grails app - grails

I am working on a Grails project, its an accounting project. We have multiple clients and they can have multiple types of accounts. I have to create the 'create' page for client, there should be a way to add multiple types of account to the client.
So I was thinking of making a drop-down list with account types and few text boxes to enter account name and other info about account. Also, as a client can have multiple accounts, so I want to create a 'add' button, when clicked it would display a new row to add a new client. I have done this kind of UI before using javascript but in this case, as there is a drop-down list and other components, I think it would be very hard and may not work.
I was thinking of creating a partial view which would render each time user clicked the 'add' button with additional row, problem with this would be during validation errors, edit page and i would also have to pass all values each time user clicks 'add' button.
Is there any other for doing this?

For the template approach you must use ajax if you don't want to carry on the params that the user has already set.
It is possible to make new drop-down lists appear (or any group of elements inside a <div>) when a user clicks a button, since Grails already comes with jQuery you might want to take a look at the .clone() method.
The problem with the two listed approeaches is that it will be possible to have duplicates.
Now, another option is to use checkboxes, so you can check just the type of account you want.
But to be honest it does seems a bit odd or even inapropiate to let the user choose the type of account he wants with such freedom.

Related

f.select - disabling option based on the first one selected in Rails

I have a form in which user can select two players from a list (two separate select fields). I managed to do it using options_for_select helper, but
user shouldn’t be allowed to select the same player twice - it obviously can't be something like player1 vs player1. I was experimenting with ‘disabled’ option, but without success, because list of available users should change dynamically after selecting first user, which probably can't be done in Rails?
This is a very broad question, with little details, hence my answer will be generic to cover the majority of cases.
You'll have to use JavaScript to hide the same options from the other list. Rails works server-side, therefore you should reload the page if you want Rails to re-render the list without the selected option. But this is a terrible user experience.
However, you should also perform a server-side check. Even if you add the JS in place, it will still be possible to send a crafted request where the players are the same. This is something that must ultimately be verified at server-side level, in your Rails controller or wherever you have the logic to handle the comparison.

Is it possible to have options on select change from when other select changes without javascript

There are a bunch of question on this but no answers on how to do it without javascript.
If you have one form that has 2 select boxes. The second select box has different options based on what you choose for the first select box. Here is a js example. Not all users have js enabled so for these users this option would be unavailable.
Can this be achieved solely using CSS3, HTML5 and Ruby? I would show what I've got so far in trying this but I got nothing.
What you are asking is how to manipulate the DOM after it has loaded without a client-side scripting language. This is not possible as far as I am aware; unfortunately that is not what you want to hear.
The proper solution in this case would be to have the user submit the page and generate the second selection box at that time. You will have to rely entirely on server-side logic to handle the problem. So basically something like:
Serve a page with just a single selection box
When the page is posted generate a similar page where the first selection is locked and display a second selection box with the possible options.
Continue the iteration until you have all of the required selections filled out by the user.
Serve the result that the user requested.

gui with multiple interfaces?

I am trying to create a GUI using jquery and html to allow users to enter information into a system. The problem is, I don't know how to create a GUI that will show different interfaces for each step.
For example, I want to have users enter in their personal information in step 1. When they click next, they can choose a photo from a set of photos that appear, and so on.
I suppose I can name different html divs and make them show and hide at certain times as desired. But is there a cleaner technique for doing something like this?
You could use one of the JQuery Form Wizard extensions.
For example:
http://thecodemine.org

How to have previous and next button in the django admin (change_form)

I want to modify the django admin for a particular model to provide the following behaviour.
A user make a search on the change_list page. The the user click a specific entry and he lands on the change_form for that entry. Nothing different to the usual.
Now, what I want is a mean to navigate the former search results. Basically next and previous buttons on the edit page.
What would be the best approach to implement this feature without modifying the admin site too much?
I will need to memorize the search in the user session, then when an entry is clicked I will need to known which place it has within the results to place my "cursor" accordingly. But I'm a bit in the cloud as the implementation side.
One way is to just put the next and previous button in the template for that particular model.
This can be implemented using simple javascript.
I ended writing a fully custom admin for that.

Parameters through postback

I'm working with Ruby on rails 2.3.4 and I'd like to pass some parameters from one page to another ones the first one is submitted.
For example:
On the first page, I have a form that when it's filled a Preview button can be clicked to check all the info entered before submitting the form. That button redirects to another page with the info entered before, but I don't know how to get it in the second page.
There are two possible solutions:
You can emulate the stepped form filling by creating a record in first form and saving it with status "unverified" or "pending". This way you won't have to deal with hidden form fields in 2nd and 3rd pages. All you'll need to pass is the id of pending record. You'll just need to update record status to "active" once the data is confirmed.
Use client side paginated from (all popular JS frameworks have plugins for this). Hence you will only display different <div>s in single loaded page (something like an interface for a setup wizard).

Resources