Changes for default index:
- remove approvable and filterable - add display_option - change params Update web link and gallery index
This commit is contained in:
parent
af0ab9f0d3
commit
1dc7884ec0
|
@ -1,6 +1,5 @@
|
||||||
$(function () {
|
$(function () {
|
||||||
var $fileList = $('.file-list'),
|
var $fileType = $('.file-type'),
|
||||||
$fileType = $('.file-type'),
|
|
||||||
$type = ['pdf', 'psd', 'ai', 'fla', 'swf', 'in', 'acc', 'do', 'xl', 'pp', 'zip', 'rar', '7z', 'txt', 'jp', 'gif', 'png', 'mp3', 'wav'];
|
$type = ['pdf', 'psd', 'ai', 'fla', 'swf', 'in', 'acc', 'do', 'xl', 'pp', 'zip', 'rar', '7z', 'txt', 'jp', 'gif', 'png', 'mp3', 'wav'];
|
||||||
|
|
||||||
$fileType.each(function (i) {
|
$fileType.each(function (i) {
|
||||||
|
|
|
@ -53,27 +53,14 @@
|
||||||
text-overflow: ellipsis;
|
text-overflow: ellipsis;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
}
|
}
|
||||||
.main-list td .file-list {
|
|
||||||
display: inline-block;
|
|
||||||
margin: 0 0 -6px;
|
|
||||||
}
|
|
||||||
.main-list td .file-list:after {
|
|
||||||
content: "";
|
|
||||||
clear: both;
|
|
||||||
display: block;
|
|
||||||
height: 0;
|
|
||||||
visibility: hidden;
|
|
||||||
}
|
|
||||||
.main-list td .file-type {
|
.main-list td .file-type {
|
||||||
position: relative;
|
position: relative;
|
||||||
list-style: none;
|
list-style: none;
|
||||||
float: left;
|
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
}
|
}
|
||||||
.main-list td .file-type a {
|
.main-list td .file-type a {
|
||||||
background-color: #A6A6A6;
|
background-color: #A6A6A6;
|
||||||
color: #FFFFFF;
|
color: #FFFFFF;
|
||||||
margin-right: 10px;
|
|
||||||
padding: 2px 5px 2px 3px;
|
padding: 2px 5px 2px 3px;
|
||||||
border-radius: 3px;
|
border-radius: 3px;
|
||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
|
|
|
@ -82,11 +82,40 @@ module OrbitBackendHelper
|
||||||
res = ''
|
res = ''
|
||||||
case field[:type]
|
case field[:type]
|
||||||
when 'associated'
|
when 'associated'
|
||||||
res << object.send(field[:db_field]).send(field[:associated_value]) rescue ''
|
sorted_objects = get_sorted_objects(object.send(field[:db_field]), field[:model_field]) rescue ''
|
||||||
when 'date'
|
when 'id'
|
||||||
res << (object.send(field[:db_field]) ? display_date_time(object.send(field[:db_field])) : t(:no_date))
|
sorted_objects = get_sorted_objects(field[:model].find(object.send(field[:db_field])), field[:model_field]) rescue ''
|
||||||
when 'field'
|
when 'status'
|
||||||
res << with_link?(field, object, object.send(field[:db_field]))
|
status = []
|
||||||
|
if object.is_top?
|
||||||
|
status << content_tag(:span, t(:top), class: "label label-success")
|
||||||
|
end
|
||||||
|
if object.is_hot?
|
||||||
|
status << content_tag(:span, t(:hot), class: "label label-important")
|
||||||
|
end
|
||||||
|
if object.is_hidden?
|
||||||
|
status << content_tag(:span, t(:hidden), class: "label")
|
||||||
|
end
|
||||||
|
if @approvable
|
||||||
|
if object.is_pending?
|
||||||
|
status << content_tag(:span, t(:pending), class: "label")
|
||||||
|
end
|
||||||
|
if object.is_checked?
|
||||||
|
status << content_tag(:span, t(:passed), class: "label")
|
||||||
|
end
|
||||||
|
if object.is_rejected?
|
||||||
|
status << content_tag(:span, t(:rejected), class: "label")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
res << status.join(' ')
|
||||||
|
when 'tags'
|
||||||
|
sorted_objects = get_sorted_objects(object.tags, 'name') rescue ''
|
||||||
|
else
|
||||||
|
sorted_values = object.send(field[:db_field])
|
||||||
|
sorted_values = sorted_values.sort if sorted_values.is_a?(Array)
|
||||||
|
end
|
||||||
|
res << display_value_from_object(object, sorted_values, field[:display_option]) if sorted_values
|
||||||
|
res << display_value_from_objects(sorted_objects, field[:model_field], field[:display_option]) if sorted_objects
|
||||||
if field[:quick_edit]
|
if field[:quick_edit]
|
||||||
res << (content_tag :div, class: "quick-edit" do
|
res << (content_tag :div, class: "quick-edit" do
|
||||||
content_tag :ul, class: "nav nav-pills" do
|
content_tag :ul, class: "nav nav-pills" do
|
||||||
|
@ -96,35 +125,6 @@ module OrbitBackendHelper
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
when 'status'
|
|
||||||
if object.is_top?
|
|
||||||
res << content_tag(:span, t(:top), class: "label label-success") + ' '
|
|
||||||
end
|
|
||||||
if object.is_hot?
|
|
||||||
res << content_tag(:span, t(:hot), class: "label label-important") + ' '
|
|
||||||
end
|
|
||||||
if object.is_hidden?
|
|
||||||
res << content_tag(:span, t(:hidden), class: "label") + ' '
|
|
||||||
end
|
|
||||||
if @approvable
|
|
||||||
if object.is_pending?
|
|
||||||
res << content_tag(:span, t(:pending), class: "label") + ' '
|
|
||||||
end
|
|
||||||
if object.is_checked?
|
|
||||||
res << content_tag(:span, t(:passed), class: "label") + ' '
|
|
||||||
end
|
|
||||||
if object.is_rejected?
|
|
||||||
res << content_tag(:span, t(:rejected), class: "label") + ' '
|
|
||||||
end
|
|
||||||
end
|
|
||||||
when 'tags'
|
|
||||||
object.sorted_tags.each do |tag|
|
|
||||||
res << content_tag(:span, tag.name, class: "label label-warning")
|
|
||||||
end if object.tags
|
|
||||||
res.html_safe
|
|
||||||
when 'id'
|
|
||||||
res << field[:id_model].constantize.find(object.send(field[:db_field])).name rescue ''
|
|
||||||
end
|
|
||||||
res.html_safe
|
res.html_safe
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -134,7 +134,7 @@ module OrbitBackendHelper
|
||||||
(content_tag :tr, class: "sort-header" do
|
(content_tag :tr, class: "sort-header" do
|
||||||
@fields.each do |field|
|
@fields.each do |field|
|
||||||
concat (content_tag :th, "data-hide" => field[:hide], class: "#{field[:header_class]} #{'active' if params[:sort].eql?(field[:sort])}" do
|
concat (content_tag :th, "data-hide" => field[:hide], class: "#{field[:header_class]} #{'active' if params[:sort].eql?(field[:sort])}" do
|
||||||
if @sortable && field[:sort]
|
if field[:sort]
|
||||||
link_to is_sort_active?(field), url_for({:filter => @filter}.merge(sortable_options(field[:sort]).merge(:sort_options => field[:db_field])))
|
link_to is_sort_active?(field), url_for({:filter => @filter}.merge(sortable_options(field[:sort]).merge(:sort_options => field[:db_field])))
|
||||||
else
|
else
|
||||||
t(field[:translation])
|
t(field[:translation])
|
||||||
|
@ -163,12 +163,48 @@ module OrbitBackendHelper
|
||||||
@filterable = false
|
@filterable = false
|
||||||
@index_footer = nil
|
@index_footer = nil
|
||||||
@quick_edit = []
|
@quick_edit = []
|
||||||
@sortable = false
|
|
||||||
block.call
|
block.call
|
||||||
end
|
end
|
||||||
|
|
||||||
protected
|
protected
|
||||||
|
|
||||||
|
def display_value(value)
|
||||||
|
case value.class.name
|
||||||
|
when 'DateTime'
|
||||||
|
display_date_time(value)
|
||||||
|
when 'Date'
|
||||||
|
display_date(value)
|
||||||
|
when 'Time'
|
||||||
|
display_time(value)
|
||||||
|
when /Uploader/
|
||||||
|
image_tag(value.url)
|
||||||
|
else
|
||||||
|
value
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def display_value_from_object(object, value, display_option)
|
||||||
|
if display_option
|
||||||
|
eval(display_option)
|
||||||
|
else
|
||||||
|
display_value(value)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def display_value_from_objects(objects, field, display_option)
|
||||||
|
if display_option
|
||||||
|
objects = Array(objects).map do |object|
|
||||||
|
eval(display_option)
|
||||||
|
end
|
||||||
|
objects.join(' ')
|
||||||
|
else
|
||||||
|
objects = Array(objects).map do |object|
|
||||||
|
display_value(object.send(field))
|
||||||
|
end
|
||||||
|
objects.join(', ')
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
# ===============================================================
|
# ===============================================================
|
||||||
# type:
|
# type:
|
||||||
# check "get_value"
|
# check "get_value"
|
||||||
|
@ -189,15 +225,22 @@ module OrbitBackendHelper
|
||||||
# (only available for type 'field' for now)
|
# (only available for type 'field' for now)
|
||||||
# ===============================================================
|
# ===============================================================
|
||||||
def field(args={})
|
def field(args={})
|
||||||
if !args.blank? && args[:type] && args[:translation] && args[:db_field]
|
if !args.blank? && args[:translation] && args[:db_field]
|
||||||
case args[:type]
|
case args[:type]
|
||||||
when 'status', 'field', 'date', 'tags'
|
|
||||||
@fields << args
|
|
||||||
when 'associated'
|
when 'associated'
|
||||||
@fields << args if args[:associated_value]
|
@fields << args if args[:model_field] || args[:display_option]
|
||||||
when 'id'
|
when 'id'
|
||||||
@fields << args if args[:id_model]
|
@fields << args if args[:model] && (args[:model_field] || args[:display_option])
|
||||||
|
when 'image'
|
||||||
|
args[:header_class] ||= 'span2'
|
||||||
|
@fields << args
|
||||||
|
else
|
||||||
|
@fields << args
|
||||||
end
|
end
|
||||||
|
elsif !args.blank? && args[:type].eql?('tags')
|
||||||
|
args[:translation] ||= 'tags'
|
||||||
|
args[:display_option] ||= "content_tag(:span, object.name, class: 'label label-warning')"
|
||||||
|
@fields << args
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -209,13 +252,10 @@ module OrbitBackendHelper
|
||||||
when 'objects'
|
when 'objects'
|
||||||
@filter_fields << args if args[:object_field]
|
@filter_fields << args if args[:object_field]
|
||||||
end
|
end
|
||||||
|
@filterable ||= true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def filterable
|
|
||||||
@filterable = true
|
|
||||||
end
|
|
||||||
|
|
||||||
# ===============================================================
|
# ===============================================================
|
||||||
# args:
|
# args:
|
||||||
# - paginate: default true, there'es no need to specify it
|
# - paginate: default true, there'es no need to specify it
|
||||||
|
@ -258,6 +298,17 @@ module OrbitBackendHelper
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def get_sorted_objects(objects, field)
|
||||||
|
if field
|
||||||
|
objects_array = Array(objects).inject([]){ |result, value|
|
||||||
|
result << [value.send(field), value]
|
||||||
|
}
|
||||||
|
objects_array.sort.map{|d| d[1]}
|
||||||
|
else
|
||||||
|
objects
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def is_approvable(object)
|
def is_approvable(object)
|
||||||
current_or_guest_user.admin? || (!object.is_rejected? && !object.is_checked?)
|
current_or_guest_user.admin? || (!object.is_rejected? && !object.is_checked?)
|
||||||
end
|
end
|
||||||
|
@ -274,10 +325,6 @@ module OrbitBackendHelper
|
||||||
@objects = objects
|
@objects = objects
|
||||||
end
|
end
|
||||||
|
|
||||||
def sortable
|
|
||||||
@sortable = true
|
|
||||||
end
|
|
||||||
|
|
||||||
def with_link?(field, object, value)
|
def with_link?(field, object, value)
|
||||||
if field[:link] && @approvable
|
if field[:link] && @approvable
|
||||||
if object.class.instance_methods.include?(:is_checked?) && object.is_checked?
|
if object.class.instance_methods.include?(:is_checked?) && object.is_checked?
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
<% set_default_index do
|
<% set_default_index do
|
||||||
objects @bulletins
|
objects @bulletins
|
||||||
filterable
|
|
||||||
sortable
|
|
||||||
quick_edit_link type: 'edit',
|
quick_edit_link type: 'edit',
|
||||||
link: 'edit_panel_announcement_back_end_bulletin_path'
|
link: 'edit_panel_announcement_back_end_bulletin_path'
|
||||||
quick_edit_link type: 'detail'
|
quick_edit_link type: 'detail'
|
||||||
|
@ -10,42 +8,42 @@
|
||||||
quick_edit_link type: 'approval',
|
quick_edit_link type: 'approval',
|
||||||
link: 'panel_announcement_back_end_bulletin_approval_preview_path'
|
link: 'panel_announcement_back_end_bulletin_approval_preview_path'
|
||||||
quick_edit_link type: 'reject_reason'
|
quick_edit_link type: 'reject_reason'
|
||||||
|
field type: 'image',
|
||||||
|
db_field: 'image',
|
||||||
|
translation: 'preview',
|
||||||
|
hide: 'phone'
|
||||||
field type: 'status',
|
field type: 'status',
|
||||||
db_field: @statuses,
|
db_field: @statuses,
|
||||||
translation: 'status',
|
translation: 'status',
|
||||||
hide: 'phone',
|
hide: 'phone',
|
||||||
sort: 'status'
|
sort: 'status'
|
||||||
field type: 'associated',
|
field type: 'associated',
|
||||||
associated_value: 'title',
|
|
||||||
db_field: 'category',
|
db_field: 'category',
|
||||||
|
model_field: 'title',
|
||||||
translation: 'category',
|
translation: 'category',
|
||||||
hide: 'phone',
|
hide: 'phone',
|
||||||
sort: 'category'
|
sort: 'category'
|
||||||
field type: 'field',
|
field db_field: 'title',
|
||||||
db_field: 'title',
|
|
||||||
translation: 'title',
|
translation: 'title',
|
||||||
sort: 'title',
|
sort: 'title',
|
||||||
link: 'panel_announcement_front_end_bulletin_path',
|
display_option: 'link_to value, panel_announcement_front_end_bulletin_path(object)',
|
||||||
quick_edit: true,
|
quick_edit: true,
|
||||||
header_class: 'span5'
|
header_class: 'span5'
|
||||||
field type: 'date',
|
field db_field: 'postdate',
|
||||||
db_field: 'postdate',
|
|
||||||
translation: 'start_date',
|
translation: 'start_date',
|
||||||
hide: 'phone',
|
hide: 'phone',
|
||||||
sort: 'start_date'
|
sort: 'start_date'
|
||||||
field type: 'date',
|
field db_field: 'deadline',
|
||||||
db_field: 'deadline',
|
|
||||||
translation: 'end_date',
|
translation: 'end_date',
|
||||||
hide: 'phone',
|
hide: 'phone',
|
||||||
sort: 'end_date'
|
sort: 'end_date'
|
||||||
field type: 'tags',
|
field type: 'tags',
|
||||||
db_field: 'tags',
|
|
||||||
translation: 'tags',
|
|
||||||
hide: 'all',
|
hide: 'all',
|
||||||
sort: 'tags'
|
sort: 'tags'
|
||||||
field type: 'id',
|
field type: 'id',
|
||||||
id_model: 'User',
|
|
||||||
db_field: 'update_user_id',
|
db_field: 'update_user_id',
|
||||||
|
model: User,
|
||||||
|
model_field: 'name',
|
||||||
translation: 'last_modified',
|
translation: 'last_modified',
|
||||||
hide: 'phone',
|
hide: 'phone',
|
||||||
sort: 'last_modified'
|
sort: 'last_modified'
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
<% set_default_index do
|
<% set_default_index do
|
||||||
objects @archive_files
|
objects @archive_files
|
||||||
filterable
|
|
||||||
sortable
|
|
||||||
quick_edit_link type: 'edit',
|
quick_edit_link type: 'edit',
|
||||||
link: 'edit_panel_archive_back_end_archive_file_path'
|
link: 'edit_panel_archive_back_end_archive_file_path'
|
||||||
quick_edit_link type: 'detail'
|
quick_edit_link type: 'detail'
|
||||||
|
@ -14,23 +12,27 @@
|
||||||
sort: 'status',
|
sort: 'status',
|
||||||
header_class: 'span2'
|
header_class: 'span2'
|
||||||
field type: 'associated',
|
field type: 'associated',
|
||||||
associated_value: 'title',
|
|
||||||
db_field: 'category',
|
db_field: 'category',
|
||||||
|
model_field: 'title',
|
||||||
translation: 'category',
|
translation: 'category',
|
||||||
hide: 'phone',
|
hide: 'phone',
|
||||||
sort: 'category',
|
sort: 'category',
|
||||||
header_class: 'span2'
|
header_class: 'span2'
|
||||||
field type: 'field',
|
field db_field: 'title',
|
||||||
db_field: 'title',
|
|
||||||
translation: 'title',
|
translation: 'title',
|
||||||
sort: 'title',
|
sort: 'title',
|
||||||
link: 'panel_archive_front_end_archive_file_path',
|
display_option: 'link_to value, panel_archive_front_end_archive_file_path(object)',
|
||||||
quick_edit: true
|
quick_edit: true,
|
||||||
|
header_class: 'span5'
|
||||||
field type: 'tags',
|
field type: 'tags',
|
||||||
db_field: 'tags',
|
|
||||||
translation: 'tags',
|
|
||||||
hide: 'all',
|
hide: 'all',
|
||||||
sort: 'tags'
|
sort: 'tags'
|
||||||
|
field type: 'associated',
|
||||||
|
db_field: 'archive_file_multiples',
|
||||||
|
translation: 'file_',
|
||||||
|
display_option: "content_tag(:span, link_to(content_tag(:i) + object.file_identifier, object.file.url, target: '_blank'), class: 'file-type') unless object.file.blank?",
|
||||||
|
hide: 'all',
|
||||||
|
header_class: 'span2'
|
||||||
filter_field type: 'array',
|
filter_field type: 'array',
|
||||||
values: @statuses,
|
values: @statuses,
|
||||||
translation: 'status'
|
translation: 'status'
|
||||||
|
@ -46,3 +48,7 @@
|
||||||
end %>
|
end %>
|
||||||
|
|
||||||
<%= render 'admin/default_index/index' %>
|
<%= render 'admin/default_index/index' %>
|
||||||
|
|
||||||
|
<% content_for :page_specific_javascript do %>
|
||||||
|
<%= javascript_include_tag "lib/file-type" %>
|
||||||
|
<% end %>
|
||||||
|
|
|
@ -1,29 +1,24 @@
|
||||||
<% set_default_index do
|
<% set_default_index do
|
||||||
objects @albums
|
objects @albums
|
||||||
filterable
|
|
||||||
filter_field type: 'objects',
|
filter_field type: 'objects',
|
||||||
values: @tags,
|
values: @tags,
|
||||||
translation: 'tags',
|
translation: 'tags',
|
||||||
object_field: 'name'
|
object_field: 'name'
|
||||||
|
footer link: 'new_panel_gallery_back_end_album_path',
|
||||||
|
paginate: false
|
||||||
end %>
|
end %>
|
||||||
<%= render 'admin/default_index/index' %>
|
<%= render 'admin/default_index/index' %>
|
||||||
|
|
||||||
<%= stylesheet_link_tag "gallery" %>
|
<ul id="orbit_gallery" class="gallery" data-gallery-id="gallery">
|
||||||
<%#= stylesheet_link_tag "filter" %>
|
|
||||||
|
|
||||||
<!-- Bottom Nav -->
|
|
||||||
<div class="bottomnav clearfix">
|
|
||||||
<div class="action pull-right">
|
|
||||||
<a href="<%= new_panel_gallery_back_end_album_path %>" class="btn btn-primary"><i class="icons-plus"></i> Add New</a>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<ul id="orbit_gallery" class="gallery" data-gallery-id="gallery">
|
|
||||||
<% @albums.each do |album| %>
|
<% @albums.each do |album| %>
|
||||||
<%= render :partial => "album", :object => album %>
|
<%= render :partial => "album", :object => album %>
|
||||||
<% end %>
|
<% end %>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
|
<% content_for :page_specific_css do %>
|
||||||
|
<%= stylesheet_link_tag "gallery" %>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
<% content_for :page_specific_javascript do %>
|
<% content_for :page_specific_javascript do %>
|
||||||
<%= javascript_include_tag "jquery.masonry.min.js" %>
|
<%= javascript_include_tag "jquery.masonry.min.js" %>
|
||||||
<%= javascript_include_tag "jquery.mu.image.resize.js" %>
|
<%= javascript_include_tag "jquery.mu.image.resize.js" %>
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
<% set_default_index do
|
<% set_default_index do
|
||||||
objects @web_links
|
objects @web_links
|
||||||
filterable
|
|
||||||
sortable
|
|
||||||
quick_edit_link type: 'edit',
|
quick_edit_link type: 'edit',
|
||||||
link: 'edit_panel_web_resource_back_end_web_link_path'
|
link: 'edit_panel_web_resource_back_end_web_link_path'
|
||||||
quick_edit_link type: 'detail'
|
quick_edit_link type: 'detail'
|
||||||
|
@ -14,22 +12,19 @@
|
||||||
sort: 'status',
|
sort: 'status',
|
||||||
header_class: 'span2'
|
header_class: 'span2'
|
||||||
field type: 'associated',
|
field type: 'associated',
|
||||||
associated_value: 'title',
|
|
||||||
db_field: 'category',
|
db_field: 'category',
|
||||||
|
model_field: 'title',
|
||||||
translation: 'category',
|
translation: 'category',
|
||||||
hide: 'phone',
|
hide: 'phone',
|
||||||
sort: 'category',
|
sort: 'category',
|
||||||
header_class: 'span2'
|
header_class: 'span2'
|
||||||
field type: 'field',
|
field db_field: 'title',
|
||||||
db_field: 'title',
|
|
||||||
translation: 'title',
|
translation: 'title',
|
||||||
sort: 'title',
|
sort: 'title',
|
||||||
link: 'panel_web_resource_front_end_web_link_path',
|
display_option: 'link_to value, panel_web_resource_front_end_web_link_path(object)',
|
||||||
quick_edit: true,
|
quick_edit: true,
|
||||||
header_class: 'span5'
|
header_class: 'span5'
|
||||||
field type: 'tags',
|
field type: 'tags',
|
||||||
db_field: 'tags',
|
|
||||||
translation: 'tags',
|
|
||||||
hide: 'all',
|
hide: 'all',
|
||||||
sort: 'tags'
|
sort: 'tags'
|
||||||
filter_field type: 'array',
|
filter_field type: 'array',
|
||||||
|
|
Loading…
Reference in New Issue