-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3161528
commit 9d1df5f
Showing
60 changed files
with
752 additions
and
142 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
class Admin::LinksController < Admin::BaseController | ||
before_action :_set_link, except: %i[index search new create] | ||
|
||
def index | ||
@datatable = LinksDatatable.new view_context | ||
end | ||
|
||
def search | ||
render json: LinksDatatable.new(view_context) | ||
end | ||
|
||
def show; end | ||
|
||
def new | ||
@link = Link.new | ||
render partial: 'form', layout: false | ||
end | ||
|
||
def edit | ||
render partial: 'form', layout: false | ||
end | ||
|
||
def create | ||
@link = Link.new | ||
|
||
update_and_render_or_redirect_in_js @link, _link_params, ->(id) { link_path(id) } | ||
end | ||
|
||
def update | ||
update_and_render_or_redirect_in_js @link, _link_params, link_path(@link) | ||
end | ||
|
||
def destroy | ||
@link.destroy! | ||
redirect_to admin_links_path, notice: helpers.t_notice('successfully_deleted', Link) | ||
end | ||
|
||
def _set_link | ||
@link = Link.find(params[:id]) | ||
end | ||
|
||
def _link_params | ||
params.require(:link).permit( | ||
*Link::FIELDS | ||
) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
class LinksController < ApplicationUserController | ||
before_action :_set_link, except: %i[index search new create] | ||
|
||
def index | ||
@datatable = LinksDatatable.new view_context | ||
end | ||
|
||
def search | ||
render json: LinksDatatable.new(view_context) | ||
end | ||
|
||
def show; end | ||
|
||
def new | ||
if params[:happening_id].present? | ||
linkable_id = params[:happening_id] | ||
linkable_type = 'Happening' | ||
elsif params[:club_id].present? | ||
linkable_id = params[:club_id] | ||
linkable_type = 'Club' | ||
else | ||
raise "do_not_know_linkable_type params=#{params}" | ||
end | ||
@link = Link.new( | ||
linkable_id: linkable_id, | ||
linkable_type: linkable_type, | ||
) | ||
render partial: 'form', layout: false | ||
end | ||
|
||
def edit | ||
render partial: 'form', layout: false | ||
end | ||
|
||
def create | ||
@link = Link.new | ||
update_and_render_or_redirect_in_js @link, _link_params, nil | ||
end | ||
|
||
def update | ||
update_and_render_or_redirect_in_js @link, _link_params, link_path(@link) | ||
end | ||
|
||
def destroy | ||
@link.destroy! | ||
redirect_to links_path, notice: helpers.t_notice('successfully_deleted', Link) | ||
end | ||
|
||
def _set_link | ||
@link = Link.find(params[:id]) | ||
end | ||
|
||
def _link_params | ||
params.require(:link).permit( | ||
*Link::FIELDS | ||
) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
class VenuesController < ApplicationUserController | ||
before_action :_set_venue, except: %i[index new create] | ||
|
||
def index | ||
@venues = Venue.all | ||
end | ||
|
||
def show; end | ||
|
||
def new | ||
@venue = Venue.new | ||
render partial: 'form', layout: false | ||
end | ||
|
||
def edit | ||
render partial: 'form', layout: false | ||
end | ||
|
||
# JS | ||
def create | ||
@venue = Venue.new | ||
update_and_render_or_redirect_in_js @venue, _venue_params, ->(id) { venue_path(id) } | ||
end | ||
|
||
# JS | ||
def update | ||
update_and_render_or_redirect_in_js @venue, _venue_params, venue_path(@venue) | ||
end | ||
|
||
def destroy | ||
@venue.destroy! | ||
redirect_to venues_path, notice: helpers.t_notice('successfully_deleted', Venue) | ||
end | ||
|
||
def _set_venue | ||
@venue = Venue.find params[:id] | ||
end | ||
|
||
def _venue_params | ||
params.require(:venue).permit( | ||
*Venue::FIELDS | ||
) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
class LinksDatatable < TrkDatatables::ActiveRecord | ||
def columns | ||
{ | ||
'links.id': {}, | ||
'links.linkable_type': {}, | ||
'links.linkable_id': {}, | ||
'links.kind': {}, | ||
'links.url': {}, | ||
} | ||
end | ||
|
||
def all_items | ||
# you can use @view.params | ||
Link.all | ||
end | ||
|
||
def rows(filtered) | ||
# you can use @view.link_to and other helpers | ||
filtered.map do |link| | ||
[ | ||
@view.link_to(link.id, link), | ||
link.linkable_type, | ||
link.linkable_id, | ||
link.kind, | ||
link.url, | ||
] | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
class Link < ApplicationRecord | ||
FIELDS = %i[linkable_id linkable_type kind url].freeze | ||
KINDS = %i[ | ||
club_website | ||
club_facebook_page | ||
happening_website | ||
happening_results | ||
happening_photos | ||
].each_with_object({}) { |k, o| o[k] = k.to_s } | ||
enum kind: KINDS | ||
|
||
belongs_to :linkable, polymorphic: true | ||
validates :url, presence: true | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<div id='remote-form'> | ||
<%= bootstrap_form_with model: @link, layout: :horizontal do |f| %> | ||
<%= f.text_field :linkable_id %> | ||
<%= f.text_field :kind %> | ||
<%= f.text_field :url %> | ||
<div class='remote-form__actions'> | ||
<% unless @link.new_record? %> | ||
<%= link_to admin_link_path(@link), method: :delete, 'data-confirm': t_are_you_sure_to_remove_item_name(@link.linkable_id), title: t_crud('delete', Link), class: 'btn btn-outline-danger' do %> | ||
<%= t('delete') %> | ||
<i class="demo-icon icon-trash-empty" aria-hidden="true"></i> | ||
<% end %> | ||
<% end %> | ||
<%= f.submit class: 'btn btn-primary' %> | ||
</div> | ||
<% end %> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<% | ||
breadcrumb Link.model_name.human(count: 2) => nil | ||
%> | ||
|
||
<div class='float-left'> | ||
<%= button_tag_open_modal new_admin_link_path do %> | ||
<i class="demo-icon icon-plus" aria-hidden="true"></i> | ||
<%= t_crud('add_new', Link) %> | ||
<% end %> | ||
</div> | ||
<%= @datatable.render_html search_admin_links_path(format: :json) %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<% | ||
breadcrumb Link.model_name.human(count: 2) => links_path, @link.linkable_id => nil | ||
%> | ||
<div class='card'> | ||
<div class='card-body'> | ||
<%= button_tag_open_modal edit_link_path(@link), title: t_crud('edit', Link), pull_right: true %> | ||
<%= detail_view_list @link, *Link::FIELDS %> | ||
</div> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.