Fix post-submit updates of flair template entry form.

This commit is contained in:
Logan Hanks
2011-09-20 13:11:44 -07:00
parent d992b18d22
commit fb242d13a5
4 changed files with 11 additions and 6 deletions

View File

@@ -2032,7 +2032,7 @@ class ApiController(RedditController):
@validatedForm(VFlairManager(),
VModhash(),
flair_template_id = nop('id'),
flair_template_id = nop('flair_template_id'),
text = VFlairText('text'),
css_class = VFlairCss('css_class'),
text_editable = VBoolean('text_editable'))
@@ -2070,7 +2070,6 @@ class ApiController(RedditController):
new = True
# TODO(intortus): ...
# Push changes back to client.
if new:
jquery('#empty-flair-template').before(
@@ -2079,10 +2078,13 @@ class ApiController(RedditController):
empty_template._committed = True # to disable unnecessary warning
jquery('#empty-flair-template').html(
FlairTemplateEditor(empty_template).render(style='html'))
form.set_html('.status', _('saved'))
else:
form.set_html('.flaircell:first',
FlairTemplateEditor(ft).render(style='html'))
form.set_html('.status', _('saved'))
jquery('input[name="text"]').data('saved', text)
jquery('input[name="css_class"]').data('saved', css_class)
form.set_html('.status', _('saved'))
@validatedForm(VFlairManager(), VModhash())
def POST_clearflairtemplates(self, form, jquery):

View File

@@ -120,7 +120,9 @@ $(function() {
// Attach event handlers to the various flair forms that may be on page.
$(".flairlist").delegate(".flairtemplate form", "submit",
makeOnSubmit('flairtemplate'));
$(".flairlist").delegate("form.flair-entry", "submit",
$(".flairlist").delegate("form.clearflairtemplates", "submit",
makeOnSubmit('clearflairtemplates'));
$(".flairlist").delegate(".flairgrant form", "submit",
makeOnSubmit('flair'));
$(".flairlist").delegate("form.clearflairtemplates", "submit",
makeOnSubmit('clearflairtemplates'));

View File

@@ -24,7 +24,7 @@
<h2>users with flair</h2>
<div class="flairlist pretty-form">
<div class="flairgrant flairlist pretty-form">
<%utils:line_field title="${_('jump to user (or add):')}" css_class="flair-jump">
<form method="get">
<% name = thing.user.name if thing.user else thing.name %>

View File

@@ -24,9 +24,10 @@
<div class="flairtemplate flairrow">
<form action="/post/flairtemplate"
${'id=%s' % thing.id if thing.id else ''}
method="post" class="medium-text flair-entry">
%if thing.id:
<input type="hidden" name="id" value="${thing.id}" />
<input type="hidden" name="flair_template_id" value="${thing.id}" />
%endif
<span class="flaircell flairsample-${thing.position} tagline">
%if thing.text or thing.css_class: