mirror of https://github.com/zulip/zulip.git
user_profile: Deduplicate code for showing custom profile fields.
This commit deduplicates template code for showing custom profile fields in user info popover and full profile modal by extracting it in a new file and then using that template file to render the fields in user info popover and full profile modal. This commit does not change the design or behavior and they are same as before.
This commit is contained in:
parent
bd6b215cdc
commit
33d06af6c2
|
@ -383,6 +383,10 @@ ul {
|
||||||
|
|
||||||
#profile-tab {
|
#profile-tab {
|
||||||
margin: 1px 5px 0;
|
margin: 1px 5px 0;
|
||||||
|
|
||||||
|
li.custom_user_field {
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.top {
|
.top {
|
||||||
|
|
|
@ -0,0 +1,31 @@
|
||||||
|
{{#each profile_fields}}
|
||||||
|
<li data-type="{{this.type}}" class="field-section custom_user_field" data-field-id="{{this.id}}">
|
||||||
|
{{#unless ../for_user_info_popover}}
|
||||||
|
<div class="name">{{this.name}}</div>
|
||||||
|
{{/unless}}
|
||||||
|
{{#if this.is_link}}
|
||||||
|
<a tabindex="0" href="{{this.value}}" target="_blank" rel="noopener noreferrer" class="value custom_profile_fields_link {{#if ../for_user_info_popover}}tippy-zulip-tooltip{{/if}}" data-tippy-content="{{this.name}}">{{this.value}}</a>
|
||||||
|
{{else if this.is_external_account}}
|
||||||
|
<a tabindex="0" href="{{this.link}}" target="_blank" rel="noopener noreferrer" class="value custom_profile_fields_link {{#if ../for_user_info_popover}}tippy-zulip-tooltip{{/if}}" data-tippy-content="{{this.name}}">
|
||||||
|
{{#if ../for_user_info_popover}}
|
||||||
|
{{#if (eq this.subtype "github") }}
|
||||||
|
<i class="fa fa-github" aria-hidden="true"></i>
|
||||||
|
{{else if (eq this.subtype "twitter") }}
|
||||||
|
<i class="fa fa-twitter" aria-hidden="true"></i>
|
||||||
|
{{/if}}
|
||||||
|
{{/if}}
|
||||||
|
{{this.value}}
|
||||||
|
</a>
|
||||||
|
{{else if this.is_user_field}}
|
||||||
|
<div class="pill-container not-editable" data-field-id="{{this.id}}">
|
||||||
|
<div class="input" contenteditable="false" style="display: none;"></div>
|
||||||
|
</div>
|
||||||
|
{{else}}
|
||||||
|
{{#if this.rendered_value}}
|
||||||
|
<span class="value rendered_markdown {{#if ../for_user_info_popover}}tippy-zulip-tooltip{{/if}}" data-tippy-content="{{this.name}}">{{rendered_markdown this.rendered_value}}</span>
|
||||||
|
{{else}}
|
||||||
|
<span class="value {{#if ../for_user_info_popover}}tippy-zulip-tooltip"{{/if}} data-tippy-content="{{this.name}}">{{this.value}}</span>
|
||||||
|
{{/if}}
|
||||||
|
{{/if}}
|
||||||
|
</li>
|
||||||
|
{{/each}}
|
|
@ -50,29 +50,7 @@
|
||||||
<li>{{ user_type }}</li>
|
<li>{{ user_type }}</li>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
{{!-- Display selected custom profile fields in this popover. --}}
|
{{!-- Display selected custom profile fields in this popover. --}}
|
||||||
{{#each display_profile_fields}}
|
{{> user_custom_profile_fields profile_fields=display_profile_fields for_user_info_popover=true}}
|
||||||
<li data-type="{{this.type}}" class="field-section custom_user_field" data-field-id="{{this.id}}">
|
|
||||||
{{#if this.is_link}}
|
|
||||||
<a tabindex="0" href="{{this.value}}" target="_blank" rel="noopener noreferrer" class="value custom_profile_fields_link tippy-zulip-tooltip" data-tippy-content="{{this.name}}">{{this.value}}</a>
|
|
||||||
{{else if this.is_external_account}}
|
|
||||||
<a tabindex="0" href="{{this.link}}" target="_blank" rel="noopener noreferrer" class="value custom_profile_fields_link tippy-zulip-tooltip" data-tippy-content="{{this.name}}">
|
|
||||||
{{#if (eq this.subtype "github") }}
|
|
||||||
<i class="fa fa-github" aria-hidden="true"></i>
|
|
||||||
{{else if (eq this.subtype "twitter") }}
|
|
||||||
<i class="fa fa-twitter" aria-hidden="true"></i>
|
|
||||||
{{/if}}
|
|
||||||
{{this.value}}
|
|
||||||
</a>
|
|
||||||
{{else}}
|
|
||||||
{{#if this.rendered_value}}
|
|
||||||
<span class="value rendered_markdown tippy-zulip-tooltip" data-tippy-content="{{this.name}}">{{rendered_markdown this.rendered_value}}</span>
|
|
||||||
{{else}}
|
|
||||||
<span class="value tippy-zulip-tooltip" data-tippy-content="{{this.name}}">{{this.value}}</span>
|
|
||||||
{{/if}}
|
|
||||||
{{/if}}
|
|
||||||
</li>
|
|
||||||
{{/each}}
|
|
||||||
|
|
||||||
|
|
||||||
<li class="only-visible-for-spectators">{{#tr}}Joined {date_joined}{{/tr}}</li>
|
<li class="only-visible-for-spectators">{{#tr}}Joined {date_joined}{{/tr}}</li>
|
||||||
|
|
||||||
|
|
|
@ -81,26 +81,7 @@
|
||||||
</div>
|
</div>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
{{else}}
|
{{else}}
|
||||||
{{#each profile_data}}
|
{{> user_custom_profile_fields profile_fields=profile_data}}
|
||||||
<div data-type="{{this.type}}" class="field-section custom_user_field" data-field-id="{{this.id}}">
|
|
||||||
<div class="name">{{this.name}}</div>
|
|
||||||
{{#if this.is_user_field}}
|
|
||||||
<div class="pill-container not-editable" data-field-id="{{this.id}}">
|
|
||||||
<div class="input" contenteditable="false" style="display: none;"></div>
|
|
||||||
</div>
|
|
||||||
{{else if this.is_link}}
|
|
||||||
<a href="{{this.value}}" target="_blank" rel="noopener noreferrer" class="value">{{this.value}}</a>
|
|
||||||
{{else if this.is_external_account}}
|
|
||||||
<a href="{{this.link}}" target="_blank" rel="noopener noreferrer" class="value">{{this.value}}</a>
|
|
||||||
{{else}}
|
|
||||||
{{#if this.rendered_value}}
|
|
||||||
<div class="value rendered_markdown">{{rendered_markdown this.rendered_value}}</div>
|
|
||||||
{{else}}
|
|
||||||
<div class="value">{{this.value}}</div>
|
|
||||||
{{/if}}
|
|
||||||
{{/if}}
|
|
||||||
</div>
|
|
||||||
{{/each}}
|
|
||||||
{{/if}}
|
{{/if}}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in New Issue