A platform for community discussion. Free, open, simple.
REFACTOR: break search results in multiple sub components
Robert4dcdbd78012e
diff --git a/app/assets/javascripts/discourse/app/components/search-result-entries.js b/app/assets/javascripts/discourse/app/components/search-result-entries.jsnew file mode 100644index 00000000000..44494409ab5--- /dev/null+++ b/app/assets/javascripts/discourse/app/components/search-result-entries.js@@ -0,0 +1,5 @@+import Component from "@ember/component";++export default Component.extend({+ tagName: "",+});diff --git a/app/assets/javascripts/discourse/app/components/search-result-entry.js b/app/assets/javascripts/discourse/app/components/search-result-entry.jsnew file mode 100644index 00000000000..44494409ab5--- /dev/null+++ b/app/assets/javascripts/discourse/app/components/search-result-entry.js@@ -0,0 +1,5 @@+import Component from "@ember/component";++export default Component.extend({+ tagName: "",+});diff --git a/app/assets/javascripts/discourse/app/templates/components/search-result-entries.hbs b/app/assets/javascripts/discourse/app/templates/components/search-result-entries.hbsnew file mode 100644index 00000000000..61c109f9109--- /dev/null+++ b/app/assets/javascripts/discourse/app/templates/components/search-result-entries.hbs@@ -0,0 +1,5 @@+<div class="fps-result-entries">+ {{#each posts as |post|}}+ {{search-result-entry post=post}}+ {{/each}}+</div>diff --git a/app/assets/javascripts/discourse/app/templates/components/search-result-entry.hbs b/app/assets/javascripts/discourse/app/templates/components/search-result-entry.hbsnew file mode 100644index 00000000000..652820e5893--- /dev/null+++ b/app/assets/javascripts/discourse/app/templates/components/search-result-entry.hbs@@ -0,0 +1,66 @@+<div class="fps-result">+ <div class="author">+ <a href={{post.userPath}} data-user-card={{post.username}}>+ {{avatar post imageSize="large"}}+ </a>+ </div>++ <div class="fps-topic">+ <div class="topic">+ {{#if bulkSelectEnabled}}+ {{track-selected selectedList=selected selectedId=post.topic class="bulk-select"}}+ {{/if}}++ <a href={{post.url}} {{action "logClick" post.topic_id}} class="search-link">+ {{raw "topic-status" topic=post.topic showPrivateMessageIcon=true}}+ <span class="topic-title">+ {{#if post.useTopicTitleHeadline}}+ {{html-safe post.topicTitleHeadline}}+ {{else}}+ {{#highlight-search highlight=q}}+ {{html-safe post.topic.fancyTitle}}+ {{/highlight-search}}+ {{/if}}+ </span>+ </a>++ <div class="search-category">+ {{#if post.topic.category.parentCategory}}+ {{category-link post.topic.category.parentCategory}}+ {{/if}}+ {{category-link post.topic.category hideParent=true}}+ {{#if post.topic}}+ {{discourse-tags post.topic}}+ {{/if}}+ {{plugin-outlet name="full-page-search-category" args=(hash post=post)}}+ </div>+ </div>++ <div class="blurb container">+ <span class="date">+ {{format-date post.created_at format="tiny"}}+ {{#if post.blurb}}+ <span class="separator">-</span>+ {{/if}}+ </span>++ {{#if post.blurb}}+ {{#if siteSettings.use_pg_headlines_for_excerpt}}+ {{html-safe post.blurb}}+ {{else}}+ {{#highlight-search highlight=highlightQuery}}+ {{html-safe post.blurb}}+ {{/highlight-search}}+ {{/if}}+ {{/if}}+ </div>++ {{#if showLikeCount}}+ {{#if post.like_count}}+ <span class="like-count">+ <span class="value">{{post.like_count}}</span> {{d-icon "heart"}}+ </span>+ {{/if}}+ {{/if}}+ </div>+</div>diff --git a/app/assets/javascripts/discourse/app/templates/full-page-search.hbs b/app/assets/javascripts/discourse/app/templates/full-page-search.hbsindex 0021d2f5aca..ca1e62d0b22 100644--- a/app/assets/javascripts/discourse/app/templates/full-page-search.hbs+++ b/app/assets/javascripts/discourse/app/templates/full-page-search.hbs@@ -79,74 +79,7 @@{{else}}<div class="search-results">{{#load-more selector=".fps-result" action=(action "loadMore")}}- {{#each model.posts as |result|}}- <div class="fps-result">- <div class="author">- <a href={{result.userPath}} data-user-card={{result.username}}>- {{avatar result imageSize="large"}}- </a>- </div>-- <div class="fps-topic">- <div class="topic">- {{#if bulkSelectEnabled}}- {{track-selected selectedList=selected selectedId=result.topic class="bulk-select"}}- {{/if}}-- <a href={{result.url}} {{action "logClick" result.topic_id}} class="search-link">- {{raw "topic-status" topic=result.topic showPrivateMessageIcon=true}}- <span class="topic-title">- {{#if result.useTopicTitleHeadline}}- {{html-safe result.topicTitleHeadline}}- {{else}}- {{#highlight-search highlight=q}}- {{html-safe result.topic.fancyTitle}}- {{/highlight-search}}- {{/if}}- </span>- </a>-- <div class="search-category">- {{#if result.topic.category.parentCategory}}- {{category-link result.topic.category.parentCategory}}- {{/if}}- {{category-link result.topic.category hideParent=true}}- {{#if result.topic}}- {{discourse-tags result.topic}}- {{/if}}- {{plugin-outlet name="full-page-search-category" args=(hash result=result)}}- </div>- </div>-- <div class="blurb container">- <span class="date">- {{format-date result.created_at format="tiny"}}- {{#if result.blurb}}- -- {{/if}}- </span>-- {{#if result.blurb}}- {{#if siteSettings.use_pg_headlines_for_excerpt}}- {{html-safe result.blurb}}- {{else}}- {{#highlight-search highlight=highlightQuery}}- {{html-safe result.blurb}}- {{/highlight-search}}- {{/if}}- {{/if}}- </div>-- {{#if showLikeCount}}- {{#if result.like_count}}- <span class="like-count">- {{result.like_count}} {{d-icon "heart"}}- </span>- {{/if}}- {{/if}}- </div>- </div>- {{/each}}+ {{search-result-entries posts=model.posts}}{{#conditional-loading-spinner condition=loading }}{{#unless hasResults}}