-
-
Notifications
You must be signed in to change notification settings - Fork 198
Feature/chapters index page #1069
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
8f1db79
d06f63e
269a950
f2d1698
228785b
26edcf9
91c732d
f907ab9
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 |
|---|---|---|
| @@ -0,0 +1,60 @@ | ||
| %section#banner | ||
| .row | ||
| .large-12.columns | ||
| %h1 Chapters | ||
| = link_to t('.view_all_chapters'), admin_chapters_path | ||
| | ||
| = link_to t('.view_active_chapters'), admin_chapters_path(active: true) | ||
| | ||
| = link_to t('.view_inactive_chapters'), admin_chapters_path(active: false) | ||
| .row | ||
| .large-12.columns | ||
| %hr | ||
| .large-4.columns | ||
| Name / City / Slug | ||
| .large-4.columns | ||
| Email / Twitter | ||
| .large-1.columns | ||
| Active? | ||
|
|
||
| - @chapters.each do |chapter| | ||
| .row | ||
| %hr | ||
| .large-4.columns | ||
| = link_to admin_chapter_path(chapter) do | ||
| %p= chapter.name | ||
| %p= chapter.city | ||
| %p= chapter.slug | ||
| .large-4.columns | ||
| %p= chapter.email | ||
| %p= chapter.twitter | ||
| .large-1.columns | ||
| = check_box_tag :chapter_active, 'true', chapter.active?, class: 'chapter_active', data: { 'chapter-id': chapter.id, } | ||
|
|
||
| - content_for :page_footer do | ||
|
Member
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. I don't mind having javascript available as well, however it should be optional and not the default. Also, a confirmation button to verify disabling chapters before any actions take place. |
||
| :javascript | ||
| $('input.chapter_active').on('click', function() { | ||
| let active = $(this).is(':checked'); | ||
| let message = "#{t('.change_chapter_to_inactive_confirmation')}"; | ||
|
|
||
| if (active) { | ||
| message = "#{t('.change_chapter_to_active_confirmation')}"; | ||
| } | ||
|
|
||
| if (!confirm(message)) { | ||
| return false; | ||
| } | ||
| }); | ||
|
|
||
| $('input.chapter_active').on('change', function() { | ||
| let element = $(this); | ||
| let chapterId = element.data('chapter-id'); | ||
| let active = element.is(':checked'); | ||
| let url = '/admin/chapters/' + chapterId; | ||
|
|
||
| $.ajax({ | ||
| type: "PUT", | ||
| url: url, | ||
| data: { chapter: { active: active } } | ||
| }) | ||
| }); | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| module WaitForAjax | ||
|
Author
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. |
||
| def wait_for_ajax | ||
| Timeout.timeout(Capybara.default_max_wait_time) do | ||
| loop until finished_all_ajax_requests? | ||
| end | ||
| end | ||
|
|
||
| def finished_all_ajax_requests? | ||
| page.evaluate_script('jQuery.active').zero? | ||
| end | ||
| end | ||
|
|
||
| RSpec.configure do |config| | ||
| config.include WaitForAjax, type: :feature | ||
| 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.
a
.rowin foundation should contain column elements, so here there should be alarge-12.columnsto achieve correct alignment.