mirror of
https://github.com/discourse/discourse.git
synced 2024-11-27 11:20:57 -06:00
Merge pull request #3615 from techAPJ/patch-1
UX: include more details on Permalinks page
This commit is contained in:
commit
45e37d557a
@ -1,7 +1,25 @@
|
||||
<div class="col first url">{{url}}</div>
|
||||
<div class="col topic_id">{{topic_id}}</div>
|
||||
<div class="col post_id">{{post_id}}</div>
|
||||
<div class="col category_id">{{category_id}}</div>
|
||||
<div class="col external_url">{{external_url}}</div>
|
||||
<div class="col topic_id">
|
||||
{{#if topic_id}}
|
||||
{{topic_id}}
|
||||
(<a href='{{unbound topic_url}}'>{{topic_title}}</a>)
|
||||
{{/if}}
|
||||
</div>
|
||||
<div class="col post_id">
|
||||
{{#if post_id}}
|
||||
<a href='{{unbound post_url}}'>{{post_id}}</a>
|
||||
{{/if}}
|
||||
</div>
|
||||
<div class="col category_id">
|
||||
{{#if category_id}}
|
||||
{{category_id}}
|
||||
(<a href='{{unbound category_url}}'>{{category_name}}</a>)
|
||||
{{/if}}
|
||||
</div>
|
||||
<div class="col external_url">
|
||||
{{#if external_url}}
|
||||
<a href='{{unbound external_url}}'>{{external_url}}</a>
|
||||
{{/if}}
|
||||
</div>
|
||||
<div class="col action"><button class="btn btn-danger" {{action "destroy" this}}><i class="fa fa-trash-o"></i></button></div>
|
||||
<div class="clearfix"></div>
|
||||
|
@ -1473,12 +1473,22 @@ table#user-badges {
|
||||
// Permalinks
|
||||
|
||||
.permalinks {
|
||||
.url, .external_url {
|
||||
width: 300px;
|
||||
.url, .topic_id, .category_id, .external_url {
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.action, .topic_id, .post_id, .category_id {
|
||||
.url {
|
||||
width: 200px;
|
||||
}
|
||||
.topic_id, .external_url {
|
||||
width: 220px;
|
||||
}
|
||||
.category_id {
|
||||
width: 160px;
|
||||
}
|
||||
.action, .post_id {
|
||||
text-align: center;
|
||||
width: 9.9099%;
|
||||
width: 8%;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3,12 +3,8 @@ class Admin::PermalinksController < Admin::AdminController
|
||||
before_filter :fetch_permalink, only: [:destroy]
|
||||
|
||||
def index
|
||||
filter = params[:filter]
|
||||
|
||||
permalinks = Permalink
|
||||
permalinks = permalinks.where('url ILIKE :filter OR external_url ILIKE :filter', filter: "%#{params[:filter]}%") if filter.present?
|
||||
permalinks = permalinks.limit(100).order('created_at desc').to_a
|
||||
|
||||
url = params[:filter]
|
||||
permalinks = Permalink.filter_by(url)
|
||||
render_serialized(permalinks, PermalinkSerializer)
|
||||
end
|
||||
|
||||
|
@ -80,6 +80,16 @@ class Permalink < ActiveRecord::Base
|
||||
return category.url if category
|
||||
nil
|
||||
end
|
||||
|
||||
def self.filter_by(url=nil)
|
||||
permalinks = Permalink
|
||||
.includes(:topic, :post, :category)
|
||||
.order('permalinks.created_at desc')
|
||||
|
||||
permalinks.where!('url ILIKE :url OR external_url ILIKE :url', url: "%#{url}%") if url.present?
|
||||
permalinks.limit!(100)
|
||||
permalinks.to_a
|
||||
end
|
||||
end
|
||||
|
||||
# == Schema Information
|
||||
|
@ -1,3 +1,23 @@
|
||||
class PermalinkSerializer < ApplicationSerializer
|
||||
attributes :id, :url, :topic_id, :post_id, :category_id, :external_url
|
||||
attributes :id, :url, :topic_id, :topic_title, :topic_url, :post_id, :post_url, :category_id, :category_name, :category_url, :external_url
|
||||
|
||||
def topic_title
|
||||
object.try(:topic).try(:title)
|
||||
end
|
||||
|
||||
def topic_url
|
||||
object.try(:topic).try(:url)
|
||||
end
|
||||
|
||||
def post_url
|
||||
object.try(:post).try(:url)
|
||||
end
|
||||
|
||||
def category_name
|
||||
object.try(:category).try(:name)
|
||||
end
|
||||
|
||||
def category_url
|
||||
object.try(:category).try(:url)
|
||||
end
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user