From fb242d13a5ab0547603ee04784cff4a7f17cd5c1 Mon Sep 17 00:00:00 2001 From: Logan Hanks Date: Tue, 20 Sep 2011 13:11:44 -0700 Subject: [PATCH] Fix post-submit updates of flair template entry form. --- r2/r2/controllers/api.py | 8 +++++--- r2/r2/public/static/js/flair.js | 4 +++- r2/r2/templates/flairlist.html | 2 +- r2/r2/templates/flairtemplateeditor.html | 3 ++- 4 files changed, 11 insertions(+), 6 deletions(-) diff --git a/r2/r2/controllers/api.py b/r2/r2/controllers/api.py index 27eeaf7c9..3a8771421 100644 --- a/r2/r2/controllers/api.py +++ b/r2/r2/controllers/api.py @@ -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): diff --git a/r2/r2/public/static/js/flair.js b/r2/r2/public/static/js/flair.js index f46f7c265..f1a3996df 100644 --- a/r2/r2/public/static/js/flair.js +++ b/r2/r2/public/static/js/flair.js @@ -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')); diff --git a/r2/r2/templates/flairlist.html b/r2/r2/templates/flairlist.html index d379afd05..942b10745 100644 --- a/r2/r2/templates/flairlist.html +++ b/r2/r2/templates/flairlist.html @@ -24,7 +24,7 @@

users with flair

-
+
<%utils:line_field title="${_('jump to user (or add):')}" css_class="flair-jump">
<% name = thing.user.name if thing.user else thing.name %> diff --git a/r2/r2/templates/flairtemplateeditor.html b/r2/r2/templates/flairtemplateeditor.html index c738d7520..d3e6c082e 100644 --- a/r2/r2/templates/flairtemplateeditor.html +++ b/r2/r2/templates/flairtemplateeditor.html @@ -24,9 +24,10 @@
%if thing.id: - + %endif %if thing.text or thing.css_class: