Skip to content
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

Major rework with Rails 6 & webpacker support + other extras #196

Open
wants to merge 40 commits into
base: master
Choose a base branch
from
Open
Changes from 8 commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
a61988f
Initial commit after Rails 6 regeneration.
ljachymczyk Mar 25, 2021
3f99e5b
Initial node package
ljachymczyk Mar 26, 2021
a6298fc
Initial working example.
ljachymczyk Mar 29, 2021
5d6ec6c
Add stimulus
marcinTichoniuk Mar 30, 2021
e6639e7
Stimulus controller setup.
ljachymczyk Mar 30, 2021
eedf844
Register
marcinTichoniuk Mar 31, 2021
edebbab
Add microbundle setup.
ljachymczyk Apr 1, 2021
470b114
Register fixes
marcinTichoniuk Apr 6, 2021
527a965
Change naming
marcinTichoniuk Apr 6, 2021
6887acf
Adjust controller name and add update method (ajax)
marcinTichoniuk Apr 6, 2021
2812892
Create tailwind kaminari theme.
ljachymczyk May 6, 2021
d5acb5d
Set up generator.
ljachymczyk May 6, 2021
8323069
Style all pages of pagination
marcinTichoniuk May 12, 2021
ea498df
Style 'pagination per page'
marcinTichoniuk May 12, 2021
5fc07bc
Adjust default pagination style
marcinTichoniuk May 13, 2021
a039a26
Add initial implementation of actions handling.
ljachymczyk May 20, 2021
9c8c326
Add actions implementation in stimulus controller
marcinTichoniuk May 24, 2021
cad754a
Refactor class definitions
marcinTichoniuk May 24, 2021
b4e91c7
Add overlay to content when request is pending
marcinTichoniuk May 25, 2021
c1a92ad
Merge branch 'feature/pagination-styling-178050813' into ng
ljachymczyk May 25, 2021
98e6b56
Merge branch 'ng' into initial_stimulus
ljachymczyk May 25, 2021
a9c1ff0
Refactor pagination.
ljachymczyk May 25, 2021
414e1dc
Add custom events
marcinTichoniuk May 26, 2021
11121aa
Refactor controller
marcinTichoniuk May 26, 2021
099d2fd
Change this.content to this.element
marcinTichoniuk May 26, 2021
12fa07c
Stimulus controller inheritance tweaks.
ljachymczyk May 27, 2021
c4026de
Separate actions
marcinTichoniuk May 27, 2021
262cb29
Pagination style tweaks
marcinTichoniuk May 27, 2021
e26ab78
Add initial in-place editing.
ljachymczyk May 28, 2021
dea30c1
Merge branch 'initial_stimulus' into ng
ljachymczyk May 28, 2021
cb3cdc5
Refactoring.
ljachymczyk Jun 7, 2021
394e527
Add dist build.
ljachymczyk Jun 8, 2021
b150000
Add 'remove' action.
ljachymczyk Jun 9, 2021
f833ddb
Tweak tailwind opacity.
ljachymczyk Jun 9, 2021
8f86cf9
Add autoload.
ljachymczyk Jun 9, 2021
5e42acf
More changes.
ljachymczyk Oct 6, 2021
a5d9d0e
Replace history state instead of push.
ljachymczyk Oct 6, 2021
30eaa94
Minor tweaks.
ljachymczyk Oct 20, 2021
0bd279b
Some tweaks
ljachymczyk Jun 13, 2022
e826149
Change the controls form
ljachymczyk Jun 23, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions app/views/kaminari/smart_listing_tailwind/_first_page.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<%# Link to the "First" page
- available local variables
url: url to the first page
current_page: a page object for the currently displayed page
total_pages: total number of pages
per_page: number of items to fetch per page
remote: data-remote
-%>
<% unless current_page.first? %>
<li class="<%= smart_listing_config.classes(:pagination_list_item) %>">
<%= link_to_unless current_page.first?, raw(t 'views.pagination.first'), url, :remote => remote, :class => "block text-sm border -ml-px px-3 py-1.5 #{smart_listing_config.classes(:pagination_page)}" %>
</li>
<% end %>
8 changes: 8 additions & 0 deletions app/views/kaminari/smart_listing_tailwind/_gap.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<%# Non-link tag that stands for skipped pages...
- available local variables
current_page: a page object for the currently displayed page
total_pages: total number of pages
per_page: number of items to fetch per page
remote: data-remote
-%>
<li class="page gap disabled"><a href="#" onclick="return false;"><%= raw(t 'views.pagination.truncate') %></a></li>
13 changes: 13 additions & 0 deletions app/views/kaminari/smart_listing_tailwind/_last_page.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<%# Link to the "Last" page
- available local variables
url: url to the last page
current_page: a page object for the currently displayed page
total_pages: total number of pages
per_page: number of items to fetch per page
remote: data-remote
-%>
<% unless current_page.last? %>
<li class="<%= smart_listing_config.classes(:pagination_list_item) %>">
<%= link_to_unless current_page.last?, raw(t 'views.pagination.last'), url, {:remote => remote, :class => "block text-sm border -ml-px px-3 py-1.5 #{smart_listing_config.classes(:pagination_page)}"} %>
</li>
<% end %>
13 changes: 13 additions & 0 deletions app/views/kaminari/smart_listing_tailwind/_next_page.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<%# Link to the "Next" page
- available local variables
url: url to the next page
current_page: a page object for the currently displayed page
total_pages: total number of pages
per_page: number of items to fetch per page
remote: data-remote
-%>
<% unless current_page.last? %>
<li class="<%= smart_listing_config.classes(:pagination_list_item) %>">
<%= link_to_unless current_page.last?, raw(t 'views.pagination.next'), url, :rel => 'next', :remote => remote, class: "block text-sm border -ml-px px-3 py-1.5 #{smart_listing_config.classes(:pagination_page)}" %>
</li>
<% end %>
12 changes: 12 additions & 0 deletions app/views/kaminari/smart_listing_tailwind/_page.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<%# Link showing page number
- available local variables
page: a page object for "this" page
url: url to this page
current_page: a page object for the currently displayed page
total_pages: total number of pages
per_page: number of items to fetch per page
remote: data-remote
-%>
<li class="<%= smart_listing_config.classes(:pagination_list_item) %>">
<%= link_to page, url, opts = {:remote => remote, :rel => page.next? ? 'next' : page.prev? ? 'prev' : nil, :class => "block relative text-sm border -ml-px px-3 py-1.5 #{smart_listing_config.classes(:pagination_page)} #{'active' if page.current?}"} %>
</li>
25 changes: 25 additions & 0 deletions app/views/kaminari/smart_listing_tailwind/_paginator.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<%# The container tag
- available local variables
current_page: a page object for the currently displayed page
total_pages: total number of pages
per_page: number of items to fetch per page
remote: data-remote
paginator: the paginator that renders the pagination tags inside
-%>
<%= paginator.render do -%>
<div class="flex justify-center items-center mb-1 <%= smart_listing_config.classes(:pagination_wrapper) %>">
<ul class="flex items-center <%= smart_listing_config.classes(:pagination_list) %>">
<%= first_page_tag unless current_page.first? %>
<%= prev_page_tag unless current_page.first? %>
<% each_page do |page| -%>
<% if page.left_outer? || page.right_outer? || page.inside_window? -%>
<%= page_tag page %>
<% elsif !page.was_truncated? -%>
<%= gap_tag %>
<% end -%>
<% end -%>
<%= next_page_tag unless current_page.last? %>
<%= last_page_tag unless current_page.last? %>
</ul>
</div>
<% end -%>
13 changes: 13 additions & 0 deletions app/views/kaminari/smart_listing_tailwind/_prev_page.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<%# Link to the "Previous" page
- available local variables
url: url to the previous page
current_page: a page object for the currently displayed page
total_pages: total number of pages
per_page: number of items to fetch per page
remote: data-remote
-%>
<% unless current_page.first? %>
<li class="<%= smart_listing_config.classes(:pagination_list_item) %>">
<%= link_to_unless current_page.first?, raw(t 'views.pagination.previous'), url, :rel => 'prev', :remote => remote, :class => "block text-sm border -ml-px px-3 py-1.5 #{smart_listing_config.classes(:pagination_page)}" %>
</li>
<% end %>
2 changes: 1 addition & 1 deletion app/views/smart_listing/_pagination_per_page_link.html.erb
Original file line number Diff line number Diff line change
@@ -9,4 +9,4 @@
-%>

<% name = page == 0 ? t('views.pagination.unlimited') : page %>
<%= url ? link_to(name, url, :remote => smart_listing.remote?) : content_tag(:span, name) %>
<%= url ? link_to(name, url, :remote => smart_listing.remote?, class: "#{smart_listing_config.classes(:pagination_per_page_link)}") : content_tag(:span, name) %>
Original file line number Diff line number Diff line change
@@ -8,7 +8,7 @@
builder: current builder instance
-%>

<%= content_tag(:div, :class => container_classes ) do %>
<%= content_tag(:div, :class => "text-center text-sm" ) do %>
<% if smart_listing.options[:paginate] && (smart_listing.count > smart_listing.page_sizes.first) %>
<%= t('views.pagination.per_page') %>
<% per_page_sizes.each do |p| %><%= builder.pagination_per_page_link p %><% break if p >= smart_listing.count %><% end %>
20 changes: 20 additions & 0 deletions lib/generators/smart_listing/install_generator.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
module SmartListing
module Generators
class InstallGenerator < Rails::Generators::Base
source_root File.expand_path('../templates', __FILE__)

def self.banner #:nodoc:
<<-BANNER.chomp
rails g smart_listing:install

Copies initializer file
BANNER
end

desc ''
def copy_views
template 'initializer.rb', 'config/initializers/smart_listing.rb'
end
end
end
end
91 changes: 91 additions & 0 deletions lib/generators/smart_listing/templates/initializer.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
SmartListing.configure do |config|
config.global_options({
#:param_names => { # param names
#:page => :page,
#:per_page => :per_page,
#:sort => :sort,
#},
#:array => false, # controls whether smart list should be using arrays or AR collections
#:max_count => nil, # limit number of rows
#:unlimited_per_page => false, # allow infinite page size
#:paginate => true, # allow pagination
#:memorize_per_page => false, # save per page settings in the cookie
#:page_sizes => DEFAULT_PAGE_SIZES, # set available page sizes array
#:kaminari_options => {:theme => "smart_listing"}, # Kaminari's paginate helper options
#:sort_dirs => [nil, "asc", "desc"], # Default sorting directions cycle of sortables
})

config.constants :classes, {
#:main => "smart-listing",
#:editable => "editable",
#:content => "content",
#:loading => "loading",
#:status => "smart-listing-status",
#:item_actions => "actions",
#:new_item_placeholder => "new-item-placeholder",
#:new_item_action => "new-item-action",
#:new_item_button => "btn",
#:hidden => "hidden",
#:autoselect => "autoselect",
#:callback => "callback",
#:pagination_wrapper => "text-center",
#:pagination_container => "pagination",
#:pagination_per_page => "pagination-per-page text-center",
#:inline_editing => "info",
#:no_records => "no-records",
#:limit => "smart-listing-limit",
#:limit_alert => "smart-listing-limit-alert",
#:controls => "smart-listing-controls",
#:controls_reset => "reset",
#:filtering => "filter",
#:filtering_search => "glyphicon-search",
#:filtering_cancel => "glyphicon-remove",
#:filtering_disabled => "disabled",
#:sortable => "sortable",
#:icon_new => "glyphicon glyphicon-plus",
#:icon_edit => "glyphicon glyphicon-pencil",
#:icon_trash => "glyphicon glyphicon-trash",
#:icon_inactive => "glyphicon glyphicon-circle",
#:icon_show => "glyphicon glyphicon-share-alt",
#:icon_sort_none => "glyphicon glyphicon-resize-vertical",
#:icon_sort_up => "glyphicon glyphicon-chevron-up",
#:icon_sort_down => "glyphicon glyphicon-chevron-down",
#:muted => "text-muted",
}

config.constants :data_attributes, {
#:main => "smart-listing",
#:controls_initialized => "smart-listing-controls-initialized",
#:confirmation => "confirmation",
#:id => "id",
#:href => "href",
#:callback_href => "callback-href",
#:max_count => "max-count",
#:item_count => "item-count",
#:inline_edit_backup => "smart-listing-edit-backup",
#:params => "params",
#:observed => "observed",
#:autoshow => "autoshow",
#:popover => "slpopover",
}

config.constants :selectors, {
#:item_action_destroy => "a.destroy",
#:edit_cancel => "button.cancel",
#:row => "tr",
#:head => "thead",
#:filtering_icon => "i"
#:filtering_button => "button",
#:filtering_icon => "button span",
#:filtering_input => ".filter input",
#:pagination_count => ".pagination-per-page .count",
}

config.constants :element_templates, {
#:row => "<tr />",
}

config.constants :bootstrap_commands, {
#:popover_destroy => "destroy", # Bootstrap 4 requries dipsose instead of destroy
}
end
23 changes: 23 additions & 0 deletions lib/generators/smart_listing/views_generator.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
module SmartListing
module Generators
class ViewsGenerator < Rails::Generators::Base
source_root File.expand_path('../../../../app/views/smart_listing', __FILE__)

def self.banner #:nodoc:
<<-BANNER.chomp
rails g smart_listing:views

Copies all smart listing partials templates to your application.
BANNER
end

desc ''
def copy_views
filename_pattern = File.join self.class.source_root, "*.html.erb"
Dir.glob(filename_pattern).map {|f| File.basename f}.each do |f|
copy_file f, "app/views/smart_listing/#{f}"
end
end
end
end
end
6 changes: 3 additions & 3 deletions lib/smart_listing/config.rb
Original file line number Diff line number Diff line change
@@ -47,9 +47,9 @@ class Configuration
:hidden => "hidden",
:autoselect => "autoselect",
:callback => "callback",
:pagination_wrapper => "text-center",
:pagination_container => "pagination",
:pagination_per_page => "pagination-per-page text-center",
# :pagination_wrapper => "text-center",
# :pagination_container => "pagination",
# :pagination_per_page => "text-center text-sm",
:inline_editing => "info",
:no_records => "no-records",
:limit => "smart-listing-limit",