Here is something you can do while waiting for the rest of the in-
place editors to come online, of course you could do it with non-ajax
field editors as well.
In application.dryml put:
<def tag="myeditor" ><%=
if !can_edit?
view(attributes)
else
attrs = add_classes(attributes, type_id, type_and_field, "editor")
if (refl = this_field_reflection)
if refl.macro == :belongs_to
belongs_to_editor(attrs)
else
has_many_editor(attrs)
end
else
call_polymorphic_tag("myeditor", attrs) or
raise HoboError.new("<myeditor> not implemented for
#{this.class.name}\##{this_field} " +
"(#{this.inspect}:#{this_type})")
end
end
%></def>
<def tag="myeditor" for="string">
<my-string-editor merge-attrs/>
</def>
<def tag="my-string-editor" attrs="update, values, labels, titleize"><
%
f = ajax_updater(object_url(this_parent, :method => :put),
update,
:method => "put",
:params => { this_parent.class.name.underscore => {
this_field => Hobo.raw_js('this.value')
} })
%>
<input type="text" onchange="#{f}" value="#{this}"
merge-attrs />
</def>
The in the show.dryml you can call:
<myeditor:amount/> (where amount is the string field added to the
ingredient_assignments table)
The context has to be ingredient_assignments, here is how it would
look in the agility demo (show.dryml for project)
<show-page>
<content:>
<section-group>
<section>
<param-content for="content"/>
</section>
<aside>
<h2>Project Members</h2>
<collection:memberships part="members">
<card>
<heading:>
<a:user/><editor:contributor/
>Contributor:<myeditor:amount/>
</heading:>
</card>
</collection>
<form:memberships.new update="members" reset-form refocus-
form>
<div>
Add a member:
<name-one:user complete-target="&@project"
completer="new_member_name"/>
</div>
</form>
</aside>
</section-group>
</content:>
<collection: replace>
<table-plus with="&@stories" fields="this, tasks.count, status">
<prepend-header:>
<div class="filter">
Display by status: <filter-menu param-name="status"
options="&StoryStatus.all"/>
</div>
</prepend-header:>
<empty-message:>No stories match your criteria</empty-message:>
</table-plus>
</collection:>
</show-page>
And just to be complete the model code for ProjectMembership...
....
fields do
contributor :boolean
amount :string
timestamps
end
....
Hope this helps :)
Brett
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Hobo
Users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/hobousers?hl=en
-~----------~----~----~----~------~----~------~--~---