mirror of
https://github.com/reddit-archive/reddit.git
synced 2026-01-25 14:58:27 -05:00
Fix UI updates when flair templates are edited.
This commit is contained in:
@@ -2349,12 +2349,17 @@ class ApiController(RedditController):
|
||||
|
||||
# Push changes back to client.
|
||||
if new:
|
||||
jquery('#empty-flair-template').before(
|
||||
empty_ids = {
|
||||
USER_FLAIR: '#empty-user-flair-template',
|
||||
LINK_FLAIR: '#empty-link-flair-template',
|
||||
}
|
||||
empty_id = empty_ids[flair_type]
|
||||
jquery(empty_id).before(
|
||||
FlairTemplateEditor(flair_template, flair_type)
|
||||
.render(style='html'))
|
||||
empty_template = FlairTemplate()
|
||||
empty_template._committed = True # to disable unnecessary warning
|
||||
jquery('#empty-flair-template').html(
|
||||
jquery(empty_id).html(
|
||||
FlairTemplateEditor(empty_template, flair_type)
|
||||
.render(style='html'))
|
||||
form.set_html('.status', _('saved'))
|
||||
|
||||
@@ -2626,7 +2626,7 @@ class FlairTemplateEditor(Templated):
|
||||
class FlairTemplateSample(Templated):
|
||||
"""Like a read-only version of FlairTemplateEditor."""
|
||||
def __init__(self, flair_template, flair_type):
|
||||
if flair_type is USER_FLAIR:
|
||||
if flair_type == USER_FLAIR:
|
||||
wrapped_user = WrappedUser(c.user, subreddit=c.site,
|
||||
force_show_flair=True,
|
||||
flair_template=flair_template)
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
################################################################################
|
||||
|
||||
<%!
|
||||
from r2.models import FlairTemplate
|
||||
from r2.models import FlairTemplate, USER_FLAIR, LINK_FLAIR
|
||||
from r2.lib.pages.pages import FlairTemplateEditor
|
||||
|
||||
empty_template = FlairTemplate()
|
||||
@@ -39,7 +39,14 @@
|
||||
%for flair_template in thing.templates:
|
||||
${flair_template}
|
||||
%endfor
|
||||
<div id="empty-flair-template">
|
||||
|
||||
<%
|
||||
if thing.flair_type == USER_FLAIR:
|
||||
empty_id = 'empty-user-flair-template'
|
||||
elif thing.flair_type == LINK_FLAIR:
|
||||
empty_id = 'empty-link-flair-template'
|
||||
%>
|
||||
<div id="${empty_id}">
|
||||
${FlairTemplateEditor(empty_template, thing.flair_type)}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -37,9 +37,9 @@ from r2.models import USER_FLAIR, LINK_FLAIR
|
||||
</%def>
|
||||
|
||||
|
||||
%if thing.flair_type is USER_FLAIR:
|
||||
%if thing.flair_type == USER_FLAIR:
|
||||
${thing.wrapped_user}
|
||||
%elif thing.flair_type is LINK_FLAIR:
|
||||
%elif thing.flair_type == LINK_FLAIR:
|
||||
<div class="thing">
|
||||
<p class="title">
|
||||
%if c.site.link_flair_position == 'left':
|
||||
|
||||
Reference in New Issue
Block a user