diff --git a/Gemfile b/Gemfile index c4a403d..1afac9e 100644 --- a/Gemfile +++ b/Gemfile @@ -46,6 +46,7 @@ gem 'autoprefixer-rails' gem 'font-awesome-rails' gem 'nested_form' +gem 'jquery-datatables-rails' group :development do gem 'spring' diff --git a/Gemfile.lock b/Gemfile.lock index a86b83f..2c3bb9c 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -130,6 +130,9 @@ GEM hike (1.2.3) hitimes (1.2.2) i18n (0.6.11) + jquery-datatables-rails (2.2.3) + jquery-rails + sass-rails jquery-rails (3.1.2) railties (>= 3.0, < 5.0) thor (>= 0.14, < 2.0) @@ -296,6 +299,7 @@ DEPENDENCIES font-awesome-rails globalize (~> 4.0.2) guard-rspec + jquery-datatables-rails jquery-rails nested_form pg diff --git a/app/assets/javascripts/management/application.js b/app/assets/javascripts/management/application.js index 9119aa9..334f889 100644 --- a/app/assets/javascripts/management/application.js +++ b/app/assets/javascripts/management/application.js @@ -1,6 +1,8 @@ //= require jquery //= require jquery_ujs //= require jquery_nested_form +//= require dataTables/jquery.dataTables +//= require dataTables/bootstrap/3/jquery.dataTables.bootstrap //= require bootstrap-sprockets //= require metisMenu/metisMenu //= require_directory . diff --git a/app/assets/javascripts/management/tables.js.coffee b/app/assets/javascripts/management/tables.js.coffee new file mode 100644 index 0000000..bbbdf2d --- /dev/null +++ b/app/assets/javascripts/management/tables.js.coffee @@ -0,0 +1,2 @@ +$ -> + $('[data-table]').dataTable(); diff --git a/app/assets/stylesheets/management/_record_tables.css.scss b/app/assets/stylesheets/management/_record_tables.css.scss new file mode 100644 index 0000000..1a021cd --- /dev/null +++ b/app/assets/stylesheets/management/_record_tables.css.scss @@ -0,0 +1,14 @@ +th.actions, td.actions { + width: 150px; + text-align: right; +} + +td.actions { + i.fa { + font-size: 16px; + } +} + +.record-table td { + vertical-align: middle !important; +} \ No newline at end of file diff --git a/app/assets/stylesheets/management/application.css.scss b/app/assets/stylesheets/management/application.css.scss index 9997ddd..67a1f35 100644 --- a/app/assets/stylesheets/management/application.css.scss +++ b/app/assets/stylesheets/management/application.css.scss @@ -5,7 +5,10 @@ @import "font-awesome"; @import "metisMenu/metisMenu"; +@import "dataTables/jquery.dataTables"; +@import "dataTables/bootstrap/3/jquery.dataTables.bootstrap"; @import "layout"; @import "navigation"; -@import "forms"; \ No newline at end of file +@import "forms"; +@import "record_tables"; \ No newline at end of file diff --git a/app/controllers/management/conferences_controller.rb b/app/controllers/management/conferences_controller.rb index 76b9c16..307bc4d 100644 --- a/app/controllers/management/conferences_controller.rb +++ b/app/controllers/management/conferences_controller.rb @@ -16,6 +16,10 @@ module Management def edit end + def index + @conferences = Conference.all.order(start_date: :desc) + end + private def assign_conference diff --git a/app/views/layouts/management.html.slim b/app/views/layouts/management.html.slim index a205d9c..c395da3 100644 --- a/app/views/layouts/management.html.slim +++ b/app/views/layouts/management.html.slim @@ -7,7 +7,7 @@ html meta name="viewport" content="width=device-width, initial-scale=1" title - if content_for? :title - = content_for :title + => content_for :title | | Clarion - else | Clarion diff --git a/app/views/management/conferences/_conference.html.slim b/app/views/management/conferences/_conference.html.slim new file mode 100644 index 0000000..e7aa1ff --- /dev/null +++ b/app/views/management/conferences/_conference.html.slim @@ -0,0 +1,13 @@ +tr + td = conference.title + td = l conference.start_date.to_date, format: :long + td = l conference.end_date.to_date, format: :long + td = conference.events.count + td.actions + div.btn-group.btn-group-sm + = link_to management_conference_path(conference), title: t('actions.view.button', model: Conference.model_name.human), class: 'btn btn-info' + = fa_icon :eye + = link_to edit_management_conference_path(conference), title: t('actions.edit.button', model: Conference.model_name.human), class: 'btn btn-primary' + = fa_icon :edit + = link_to management_conference_path(conference), title: t('actions.destroy.button', model: Conference.model_name.human), class: 'btn btn-danger', method: :delete, data: {confirm: t('actions.are_you_sure')} + = fa_icon :trash diff --git a/app/views/management/conferences/_form_tracks.html.slim b/app/views/management/conferences/_form_tracks.html.slim index 0edc605..db3b338 100644 --- a/app/views/management/conferences/_form_tracks.html.slim +++ b/app/views/management/conferences/_form_tracks.html.slim @@ -7,8 +7,8 @@ div#tracks = ff.input :color, as: :color = ff.input :description .panel-footer.text-right - = ff.link_to_remove t('helpers.destroy', model: Track.model_name.human), class: ['btn', 'btn-danger', ff.object.events.any? ? 'disabled' : nil] + = ff.link_to_remove t('actions.destroy.button', model: Track.model_name.human), class: ['btn', 'btn-danger', ff.object.events.any? ? 'disabled' : nil] .col-lg-6 .panel.panel-default .panel-body.text-right - = form.link_to_add t('helpers.submit.create', model: Track.model_name.human), :tracks, data: {target: '#tracks'}, class: 'btn btn-success' + = form.link_to_add t('actions.create.button', model: Track.model_name.human), :tracks, data: {target: '#tracks'}, class: 'btn btn-success' diff --git a/app/views/management/conferences/edit.html.slim b/app/views/management/conferences/edit.html.slim index 85298ef..2b22db3 100644 --- a/app/views/management/conferences/edit.html.slim +++ b/app/views/management/conferences/edit.html.slim @@ -1,3 +1,6 @@ +- content_for :title + => t 'actions.edit.title', model: Conference.model_name.human + = @conference.title .row .col-lg-12 = render partial: 'form' diff --git a/app/views/management/conferences/index.html.slim b/app/views/management/conferences/index.html.slim new file mode 100644 index 0000000..aa349c1 --- /dev/null +++ b/app/views/management/conferences/index.html.slim @@ -0,0 +1,23 @@ +- content_for :title + = Conference.model_name.human(count: 2).mb_chars.capitalize + +.row + .col-lg-12 + .panel.panel-primary + .panel-heading + h1.panel-title = Conference.model_name.human(count: 2).mb_chars.capitalize + .panel-body + table.table.table-striped.table-hover.record-table + thead + tr + th = Conference.human_attribute_name :title + th = Conference.human_attribute_name :start_date + th = Conference.human_attribute_name :end_date + th = Conference.human_attribute_name :submissions + th.actions + tbody + = render @conferences + .panel-footer + .text-right + = link_to new_management_conference_path, class: 'btn btn-primary' + => fa_icon 'plus fw', text: t('actions.create.button', model: Conference.model_name.human) diff --git a/app/views/management/conferences/new.html.slim b/app/views/management/conferences/new.html.slim index 85298ef..3bf21c2 100644 --- a/app/views/management/conferences/new.html.slim +++ b/app/views/management/conferences/new.html.slim @@ -1,3 +1,5 @@ +- content_for :title + = t 'actions.create.title', model: Conference.model_name.human .row .col-lg-12 = render partial: 'form' diff --git a/config/locales/bg.yml b/config/locales/bg.yml index 521c0d5..606a243 100644 --- a/config/locales/bg.yml +++ b/config/locales/bg.yml @@ -20,8 +20,20 @@ # available at http://guides.rubyonrails.org/i18n.html. bg: - helpers: - destroy: Премахни %{model} + actions: + create: + button: Създай %{model} + title: Създаване на %{model} + destroy: + button: Премахни %{model} + edit: + button: Редактирай %{model} + title: Редакция на %{model} + view: + button: Прегледай %{model} + title: Преглед на %{model} + are_you_sure: Сигурен ли си? + create_new: Създаване на %{model_name} event_mailer: acceptance_notification: