select-one-or-new-dialog

96 views
Skip to first unread message

Bryan Larsen

unread,
Jun 30, 2011, 5:44:09 PM6/30/11
to hobo...@googlegroups.com
There are three issues.

Problem 1: fixed, so bundle update hobo-jquery.

The other two only apply to new actions, not to edit's. So the short
answer is "don't use select-one-or-new-dialog on new items."

Problem 2:

On a new action, Hobo cannot resurrect the context from the database,
so it just uses whatever 'this' the controller is spitting out. For

class Story
hobo_model
fields do
name :string
end
belongs_to :story_status
# plus permissions, etc...
end

app/views/stories/new.dryml:

<new-page>
<field-list:>
<story-status-view:>
<select-one-or-new-dialog/>
</story-status-view:>
</field-list:>
</new-page>

The initial action is Story#new, but select-one-or-new-dialog posts to
StoryStatus#create. You can fix this by fiddling with the
controller:

app/controllers/story_statuses_controller.rb:

class StoryStatusesController < ApplicationController
def create
hobo_create do
if request.xhr?
self.this = Story.new
end
end
end
end

You'd think this would break Story#edit, but it doesn't because Hobo
ignores self.this when it can resurrect the story from the database.

Problem 3: The above works in Hobo 1.0, but not in Hobo 1.3.

If you look at the console in Hobo 1.0, it will say:

> Call part: select_one_or_new_dialog_select. this-id = this:city, locals = []
> : form_field_path = ["property", "city"]

Hobo 1.3 says:

> Call part: select_one_or_new_dialog_select. this-id = :city, locals = []
> : form_field_path = ["property", "city"]

I'm still looking into the 3rd problem.

Bryan


On Wed, Jun 29, 2011 at 2:26 PM, kevinpfromnm <kevinp...@gmail.com> wrote:
> Trying to do a select-one-or-new-dialog in Hobo 1.3.0.RC with rails 3.0.9
> and the form comes up and on clicking OK, nothing appears to happen.  the
> new item does get created but looking in the console I get an invalid
> typed-id error.
>
> Call part: select_one_or_new_dialog_select. this-id = :city, locals = []
>          : form_field_path = ["property", "city"]
> Completed 500 Internal Server Error in 600ms
>
> ArgumentError (invalid typed-id: :city):
>

Bob Sleys

unread,
Jun 30, 2011, 6:49:00 PM6/30/11
to hobo...@googlegroups.com
Thanks for all the time and effort you've put into this.

Bob

kevinpfromnm

unread,
Jun 30, 2011, 7:35:42 PM6/30/11
to hobo...@googlegroups.com
there's a bug with the dryml in that version.  a double dash, --, is making xml prevalidation break with malformed comment bug.  line 157

Bryan Larsen

unread,
Jun 30, 2011, 9:45:05 PM6/30/11
to hobo...@googlegroups.com
Fixed. Thanks.

Bryan

Bryan Larsen

unread,
Jul 4, 2011, 9:40:15 PM7/4/11
to Hobo Users

> Problem 3:  The above works in Hobo 1.0, but not in Hobo 1.3.
>

This has now been fixed. So please try select-one-and-new-dialog
again.

thanks,
Bryan

Bob Sleys

unread,
Jul 7, 2011, 11:41:51 AM7/7/11
to hobo...@googlegroups.com
Just want to let you know I finaly got back around to my project using this and it's working fine, with the above code added to the controller for the create action and on the latest hobo 1.3 etc.

On question.  The popup form appears to the top left of the browser window.  Is there some easy way to center it in the browser window?

kevinpfromnm

unread,
Jul 7, 2011, 12:09:21 PM7/7/11
to hobo...@googlegroups.com
Not certain as my css is middling at best but have you tried position: absolute; margin: auto?

Bryan Larsen

unread,
Jul 7, 2011, 12:55:03 PM7/7/11
to hobo...@googlegroups.com
The jquery-ui options on the dialog should be passed through.

http://jqueryui.com/demos/dialog/#option-position

Try this:

<select-one-or-new-dialog>
<hjq-dialog: position="center"/>
</select-one-or-new-dialog>

Bryan

> --
> You received this message because you are subscribed to the Google Groups
> "Hobo Users" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/hobousers/-/ply_Q8Y9E7sJ.
> To post to this group, send email to hobo...@googlegroups.com.
> To unsubscribe from this group, send email to
> hobousers+...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/hobousers?hl=en.
>

Bob Sleys

unread,
Jul 7, 2011, 1:39:16 PM7/7/11
to hobo...@googlegroups.com
Ok this appears to be a problem with Chromium 12.0.742.112 (90304) Ubuntu 11.04

If I open the page with Firefox the pop positions fine.

Bob

Bryan Larsen

unread,
Jul 7, 2011, 1:42:09 PM7/7/11
to hobo...@googlegroups.com
Interesting. Hopefully it's an already-fixed JQuery-UI bug. Try
switching to the latest version. They're at 1.8.14 but hobo-jquery
only includes 1.8.11.

cheers,
Bryan

> --
> You received this message because you are subscribed to the Google Groups
> "Hobo Users" group.
> To view this discussion on the web visit

> https://groups.google.com/d/msg/hobousers/-/g_gyKKJAtlEJ.

Bob Sleys

unread,
Jul 25, 2011, 12:18:37 PM7/25/11
to hobo...@googlegroups.com
How do I go about changing the field-list in the formlet?  I'd like to do something along the lines of

<def tag="input" for="Material">
  <select-one include-none="&false"/>
  <formlet merge>
    <field-list: fields="name"/>
  </formlet>
</def>

But this isn't working, I obviously have the <formet merge> wrong but have run out of ideas on how to pass the desired field-list off the formlet.  I'm sure it's something simple and obvious but am not seeing it.

Bob

Bryan Larsen

unread,
Jul 25, 2011, 12:54:48 PM7/25/11
to hobo...@googlegroups.com
A form or formlet doesn't have any standard default inner content.
Form's get their default inner content from the generators in
app/views/taglibs/auto/rapid/forms.dryml.

So you can either specify all of the inner content:

<def tag="input" for="Material">
<select-one include-none="&false"/>
<formlet merge>
<field-list fields="name"/>

<hjq-submit/>
<or-cancel/>
</formlet>
</def>

Or you can copy the appropriate form definition from forms.dryml into
application.dryml, and replace "form" with "formlet".

Bryan

> --
> You received this message because you are subscribed to the Google Groups
> "Hobo Users" group.
> To view this discussion on the web visit

> https://groups.google.com/d/msg/hobousers/-/1WTA9z1poecJ.

Bob Sleys

unread,
Jul 26, 2011, 9:07:55 AM7/26/11
to hobo...@googlegroups.com
I tried both methods and neither worked for me.  Don't know what I'm doing wrong here.

Bob Sleys

unread,
Jul 26, 2011, 9:59:44 AM7/26/11
to hobo...@googlegroups.com
The first option:

<def tag="input" for="Material">
  <select-one include-none="&false"/>
  <formlet merge>
    <field-list fields="name"/>
    <hjq-submit/>
    <or-cancel/>
  </formlet>
</def>

creates the attached screen shot.  The formlet created by the tag isn't getting merged but displayed right between the select list and the New button.  Also the formlet that appears when clicking the New button is unchanged.

Bob
Screenshot.png

Bob Sleys

unread,
Jul 26, 2011, 10:06:15 AM7/26/11
to hobo...@googlegroups.com
Wish I could edit posts.

Another problem I've run across is if the <select-one-or-new-dialog/> is inside a <input-many> if there are more then one input showed the additional <select-one-or-new-dialog/>'s don't work.  You can select from the select list but the Formlet shown by the New button is disabled.  IE the form shows but all inputs are disabled.  If you go to the first record the New button works but only that select list is updated with the new item.

While not perfect I could live with the new item only being added to the select list that is paired with the new button.

Mike

unread,
Sep 12, 2012, 6:06:49 PM9/12/12
to hobo...@googlegroups.com
Hi Bryan,

It took me a while to figure out that if you have a "set-default-order" on the model you are using for the select-one-or-new then you get the last one in that order, not the one you just created.

Mike
Reply all
Reply to author
Forward
0 new messages