-
Notifications
You must be signed in to change notification settings - Fork 129
Improve admin entry index #567
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
be6c00f
e5e1843
1a8cd15
7107ae4
fc33477
53e03bd
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,36 +3,58 @@ module Pageflow | |
menu :priority => 1 | ||
|
||
config.batch_actions = false | ||
config.clear_sidebar_sections! | ||
|
||
index do | ||
column :title, :sortable => 'title' do |entry| | ||
link_to entry.title, admin_entry_path(entry) | ||
column class: 'publication_state' do |entry| | ||
entry_publication_state_indicator(entry) | ||
end | ||
column I18n.t('pageflow.admin.entries.members'), :class => 'members' do |entry| | ||
column :title, sortable: 'title' do |entry| | ||
link_to(entry.title, admin_entry_path(entry)) | ||
end | ||
column I18n.t('pageflow.admin.entries.members'), class: 'members' do |entry| | ||
entry_user_badge_list(entry) | ||
end | ||
if authorized?(:read, Account) | ||
column :account, :sortable => 'account_id' do |entry| | ||
link_to(entry.account.name, admin_account_path(entry.account), :data => {:id => entry.account.id}) | ||
column :account, sortable: 'account_id' do |entry| | ||
link_to(entry.account.name, | ||
admin_account_path(entry.account), | ||
data: {id: entry.account.id}) | ||
end | ||
end | ||
column :created_at | ||
column :updated_at | ||
column :class => 'buttons' do |entry| | ||
column :edited_at | ||
column :published_at, sortable: 'pageflow_revisions.published_at' | ||
|
||
column class: 'buttons' do |entry| | ||
if authorized?(:edit, Entry) | ||
span(link_to(I18n.t('pageflow.admin.entries.editor'), pageflow.edit_entry_path(entry), :class => 'editor button')) | ||
icon_link_to(pageflow.edit_entry_path(entry), | ||
tooltip: I18n.t('pageflow.admin.entries.editor_hint'), | ||
class: 'editor') | ||
end | ||
span(link_to(I18n.t('pageflow.admin.entries.preview'), preview_admin_entry_path(entry), :class => 'preview button')) | ||
|
||
icon_link_to(preview_admin_entry_path(entry), | ||
tooltip: I18n.t('pageflow.admin.entries.preview'), | ||
class: 'preview') | ||
|
||
if entry.published? | ||
span(link_to(I18n.t('pageflow.admin.entries.show_public'), pretty_entry_url(entry), :class => 'show_public button')) | ||
icon_link_to(pretty_entry_url(entry), | ||
tooltip: I18n.t('pageflow.admin.entries.show_public_hint'), | ||
class: 'show_public') | ||
end | ||
end | ||
end | ||
|
||
filter :title | ||
filter :account | ||
filter :created_at | ||
filter :edited_at | ||
filter :first_published_at | ||
filter :published_revision_published_at, as: :date_range | ||
filter :with_publication_state, as: :select, collection: -> { collection_for_entry_publication_states } | ||
|
||
sidebar :folders, :only => :index do | ||
text_node(link_to(I18n.t('pageflow.admin.entries.add_folder'), new_admin_folder_path, :class => 'new')) | ||
grouped_folder_list(Folder.accessible_by(Ability.new(current_user), :read), | ||
grouped_folder_list(Folder.includes(:account).accessible_by(Ability.new(current_user), :read), | ||
:class => authorized?(:manage, Folder) ? 'editable' : nil, | ||
:active_id => params[:folder_id], | ||
:grouped_by_accounts => authorized?(:read, Account)) | ||
|
@@ -114,6 +136,7 @@ module Pageflow | |
controller do | ||
helper FoldersHelper | ||
helper EntriesHelper | ||
helper Pageflow::Admin::EntriesHelper | ||
helper Pageflow::Admin::FeaturesHelper | ||
helper Pageflow::Admin::RevisionsHelper | ||
helper Pageflow::Admin::FormHelper | ||
|
@@ -130,7 +153,8 @@ def update | |
end | ||
|
||
def scoped_collection | ||
params.key?(:folder_id) ? super.where(:folder_id => params[:folder_id]) : super | ||
result = super.includes(:theming, :account, :users, :published_revision).references(:published_revision) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Line is too long. [112/100] There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Line is too long. [112/100] |
||
params.key?(:folder_id) ? result.where(folder_id: params[:folder_id]) : result | ||
end | ||
|
||
def permitted_params | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
.index_table { | ||
.publication_state { | ||
width: 16px; | ||
padding: 5px; | ||
} | ||
|
||
.buttons { | ||
width: 85px; | ||
padding: 5px; | ||
} | ||
|
||
.members { | ||
max-width: 130px; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#filter_sidebar_section { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Avoid using id selectors There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Avoid using id selectors |
||
display: none; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
$icon-button-color: #fff; | ||
|
||
a.icon_button:link { | ||
@include background-icon-left($font-size: 15px, | ||
$color: $icon-button-color, | ||
$left: 9px, | ||
$top: 50%); | ||
padding-left: 30px; | ||
|
||
&:before { | ||
font-weight: normal; | ||
} | ||
|
||
&.editor { | ||
@include fa-pencil-icon; | ||
} | ||
|
||
&.preview { | ||
@include fa-eye-icon; | ||
} | ||
|
||
&.show_public { | ||
@include fa-external-link-icon; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
$icon-link-color: #555; | ||
|
||
$icon-link-acitve-color: #000; | ||
|
||
.icon_link_to { | ||
a { | ||
@include background-icon-center($font-size: 16px, $color: $icon-link-color); | ||
position: relative; | ||
display: inline-block; | ||
width: 25px; | ||
height: 25px; | ||
vertical-align: bottom; | ||
|
||
&:focus, | ||
&:hover { | ||
@include background-icon-color($icon-link-acitve-color); | ||
} | ||
|
||
&.editor { | ||
@include fa-pencil-icon; | ||
} | ||
|
||
&.preview { | ||
@include fa-eye-icon; | ||
} | ||
|
||
&.show_public { | ||
@include fa-external-link-icon; | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
$publication-state-indicator-color: #5d5d5d; | ||
|
||
.publication_state_indicator { | ||
@include background-icon-center($font-size: 16px, $color: $publication-state-indicator-color); | ||
display: inline-block; | ||
width: 25px; | ||
height: 25px; | ||
vertical-align: bottom; | ||
border-bottom: none; | ||
|
||
&.published_without_password_protection { | ||
@include fa-globe-icon; | ||
} | ||
|
||
&.published_with_password_protection { | ||
@include fa-lock-icon; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
$tooltip-bubble-background-color: rgba(0, 0, 0, 0.7); | ||
|
||
$tooltip-bubble-text-color: #fff; | ||
|
||
.tooltip_bubble { | ||
position: absolute; | ||
display: none; | ||
background-color: $tooltip-bubble-background-color; | ||
color: $tooltip-bubble-text-color; | ||
padding: 5px 10px; | ||
top: -30px; | ||
white-space: nowrap; | ||
border-radius: 2px; | ||
pointer-events: none; | ||
|
||
&:before { | ||
content: ""; | ||
position: absolute; | ||
top: 100%; | ||
left: 8px; | ||
@include triangle(10px, $tooltip-bubble-background-color, down); | ||
} | ||
} | ||
|
||
:focus, | ||
:hover { | ||
> .tooltip_bubble { | ||
display: block; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
module Pageflow | ||
module Admin | ||
module EntriesHelper | ||
def collection_for_entry_publication_states | ||
[ | ||
'published_without_password_protection', | ||
'published_with_password_protection', | ||
'not_published' | ||
].index_by do |state| | ||
I18n.t(state, scope: 'activerecord.values.pageflow/entry.publication_states') | ||
end | ||
end | ||
end | ||
end | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
module Pageflow | ||
module EntryPublicationStates | ||
extend ActiveSupport::Concern | ||
|
||
included do | ||
scope(:published, -> { joins(:published_revision) }) | ||
|
||
scope(:published_without_password_protection, | ||
-> { published.merge(Revision.without_password_protection) }) | ||
|
||
scope(:published_with_password_protection, | ||
-> { published.merge(Revision.with_password_protection) }) | ||
|
||
scope(:not_published, | ||
lambda do | ||
includes(:published_revision) | ||
.references(:pageflow_revisions) | ||
.where(pageflow_revisions: {id: nil}) | ||
end) | ||
end | ||
|
||
def publication_state | ||
if published_with_password_protection? | ||
'published_with_password_protection' | ||
elsif published? | ||
'published_without_password_protection' | ||
else | ||
'not_published' | ||
end | ||
end | ||
|
||
def published_with_password_protection? | ||
published? && published_revision.password_protected? | ||
end | ||
|
||
def published? | ||
published_revision.present? | ||
end | ||
|
||
def published_at | ||
published? ? published_revision.published_at : nil | ||
end | ||
|
||
def published_until | ||
published? ? published_revision.published_until : nil | ||
end | ||
|
||
module ClassMethods | ||
def with_publication_state(state) | ||
case state | ||
when 'published_with_password_protection' | ||
published_with_password_protection | ||
when 'published_without_password_protection' | ||
published_without_password_protection | ||
when 'not_published' | ||
not_published | ||
else | ||
fail(ArgumentError, "Unknown publication state #{state}") | ||
end | ||
end | ||
end | ||
end | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Line is too long. [107/100]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Line is too long. [107/100]