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

I18n filters #2206

Merged
merged 18 commits into from
Sep 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 0 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ gem "good_job", "~> 4"
# gem "good_job", "~> 3", github: "noesya/good_job"
gem "hal_openscience", "~> 0"
# gem "hal_openscience", path: "../hal_openscience"
gem "has_scope", "~> 0"
gem "hash_dot"
gem "i18n_data", "~> 0"
gem "i18n_date_range"
Expand Down
4 changes: 0 additions & 4 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -298,9 +298,6 @@ GEM
json
net-http
open-uri
has_scope (0.8.2)
actionpack (>= 5.2)
activesupport (>= 5.2)
hash_dot (2.5.0)
hashdiff (1.1.1)
hashie (5.0.0)
Expand Down Expand Up @@ -713,7 +710,6 @@ DEPENDENCIES
gitlab
good_job (~> 4)
hal_openscience (~> 0)
has_scope (~> 0)
hash_dot
i18n_data (~> 0)
i18n_date_range
Expand Down
1 change: 1 addition & 0 deletions app/assets/javascripts/admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
//= require autocomplete-rails
//= require codemirror/lib/codemirror
//= require languagetool/languagetool
//= require select2/dist/js/select2
//= require_self
//= require_tree ./admin/commons
//= require_tree ./application/plugins
Expand Down
11 changes: 11 additions & 0 deletions app/assets/javascripts/admin/plugins/select2.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
$(document).ready(function () {
$("select.select2").each(function () {
$(this)
.wrap("<div class=\"position-relative\"></div>")
.select2({
allowClear: true,
dropdownParent: $(this).parent(),
placeholder: ''
});
});
});
2 changes: 2 additions & 0 deletions app/assets/javascripts/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,14 @@
//= require simple_form_bs5_file_input
//= require sortablejs/Sortable
//= require summernote/summernote-bs5
//= require select2/dist/js/select2
//= require_self
//= require ./admin/commons/nav
//= require ./admin/commons/conditional
//= require ./admin/commons/default_language_selector
//= require_tree ./application/plugins
//= require ./admin/plugins/sortable
//= require ./admin/plugins/select2
//= require_tree ./server

window.osuny = {};
1 change: 1 addition & 0 deletions app/assets/stylesheets/admin.sass
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
@import 'cropperjs/dist/cropper'
@import 'codemirror/lib/codemirror'
@import 'languagetool/styles'
@import 'select2/dist/css/select2'

// Commons
@import 'commons/*'
Expand Down
5 changes: 2 additions & 3 deletions app/assets/stylesheets/admin/_variables.sass
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ $gray-800: $color-flexoki-800
$gray-900: $color-flexoki-900
$black: $color-flexoki-black

$primary: $color-flexoki-blue
$secondary: $color-flexoki-600
$primary: $color-flexoki-black
$secondary: $color-flexoki-100
$success: $color-flexoki-green
$info: $color-flexoki-cyan
$warning: $color-flexoki-yellow
Expand All @@ -47,7 +47,6 @@ $light: $color-flexoki-100
$dark: $color-flexoki-900

$body-bg: $color-bg
$primary: $color-accent
$color-background-alt: #F5F5F5

$font-family-serif: "Adelphe", serif
Expand Down
13 changes: 7 additions & 6 deletions app/assets/stylesheets/admin/design-system/nav.sass
Original file line number Diff line number Diff line change
Expand Up @@ -121,15 +121,16 @@ nav[aria-label="breadcrumb"]

.feature-nav
line-height: 100%
*
margin-right: pxToRem(40)
h1
display: inline-block
a
color: $color-flexoki-600
display: inline-block
font-family: $font-family-serif
font-size: $h1-font-size
h1, a
margin-top: 0
margin-bottom: 0
margin-right: pxToRem(40)
line-height: 100%
display: inline-block
font-size: $h1-font-size !important

#menu-main
.menu-content
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ class Admin::Administration::Alumni::Cohorts::ImportsController < Admin::Adminis
through: :current_university,
through_association: :imports

has_scope :for_status

def index
@imports = apply_scopes(@imports.kind_alumni_cohorts).ordered.page(params[:page])
@imports = @imports.kind_alumni_cohorts
.filter_by(params[:filters], current_language)
.ordered.page(params[:page])
breadcrumb
end

Expand Down
17 changes: 5 additions & 12 deletions app/controllers/admin/administration/alumni_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,12 @@ class Admin::Administration::AlumniController < Admin::Administration::Applicati

include Admin::Localizable

has_scope :for_search_term
has_scope :for_alumni_organization
has_scope :for_alumni_program
has_scope :for_alumni_year

def index
@alumni = apply_scopes(@alumni)
.tmp_original # TODO L10N : To remove
.alumni
.accessible_by(current_ability)
.ordered(current_language)
.page(params[:page])
.per(6*5)
@alumni = @alumni.filter_by(params[:filters], current_language)
.tmp_original # TODO L10N : To remove
.alumni
.ordered(current_language)
.page(params[:page])
breadcrumb
end

Expand Down
2 changes: 0 additions & 2 deletions app/controllers/admin/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ class Admin::ApplicationController < ApplicationController
before_action :redirect_if_context_is_not_an_university!
before_action :load_block_copy_cookie

include Admin::Filterable

protected

def current_subnav_context
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@ def index
@alumni = @extranet.alumni
@cohorts = @extranet.cohorts
@years = @extranet.years
@organizations = @extranet.organizations
.tmp_original
.ordered(current_language)
@organizations = @extranet.organizations.tmp_original
breadcrumb
add_breadcrumb Communication::Extranet.human_attribute_name(:feature_alumni)
end
Expand Down
9 changes: 3 additions & 6 deletions app/controllers/admin/communication/extranets_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,10 @@ class Admin::Communication::ExtranetsController < Admin::Communication::Extranet

include Admin::Localizable

has_scope :for_search_term
has_scope :for_about_type

def index
@extranets = apply_scopes(@extranets)
.ordered(current_language)
.page(params[:page])
@extranets = @extranets.filter_by(params[:filters], current_language)
.ordered(current_language)
.page(params[:page])
breadcrumb
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,11 @@ class Admin::Communication::Websites::Agenda::EventsController < Admin::Communic
include Admin::HasStaticAction
include Admin::Localizable

# Allow to override the default load_filters from Admin::Filterable
before_action :load_filters, only: :index

has_scope :for_search_term
has_scope :for_category

def index
@events = apply_scopes(@events).tmp_original # TODO L10N : To remove
.ordered_desc
.page(params[:page])
@events = @events.filter_by(params[:filters], current_language)
.tmp_original # TODO L10N : To remove
.ordered_desc
.page(params[:page])
@feature_nav = 'navigation/admin/communication/website/agenda'
breadcrumb
end
Expand Down Expand Up @@ -93,14 +88,6 @@ def categories
.ordered
end

def load_filters
@filters = ::Filters::Admin::Communication::Websites::Agenda::Events.new(
current_user,
@website,
current_language
).list
end

def event_params
params.require(:communication_website_agenda_event)
.permit(
Expand Down
13 changes: 5 additions & 8 deletions app/controllers/admin/communication/websites/pages_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,6 @@ class Admin::Communication::Websites::PagesController < Admin::Communication::We
include Admin::HasStaticAction
include Admin::Localizable

has_scope :for_search_term
has_scope :for_published
has_scope :for_full_width

def index
@homepage = @website.special_page(Communication::Website::Page::Home)
@first_level_pages = @homepage.children.ordered
Expand All @@ -17,10 +13,11 @@ def index
end

def index_list
@filters = ::Filters::Admin::Communication::Websites::Pages.new(current_user).list
@pages = apply_scopes(@pages).tmp_original # TODO L10N : To remove
.ordered_by_title(current_language)
.page(params[:page])
@pages = @pages.filter_by(params[:filters], current_language)
.tmp_original # TODO L10N : To remove
.ordered_by_title(current_language)
.page(params[:page])
# @pages = Communication::Website::Page.none.page(params[:page])
breadcrumb
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,11 @@ class Admin::Communication::Websites::Portfolio::ProjectsController < Admin::Com
include Admin::HasStaticAction
include Admin::Localizable

# Allow to override the default load_filters from Admin::Filterable
before_action :load_filters, only: :index

has_scope :for_search_term
has_scope :for_category

def index
@projects = apply_scopes(@projects).tmp_original # TODO L10N : To remove
.ordered(current_language)
.page(params[:page])
@projects = @projects.filter_by(params[:filters], current_language)
.tmp_original # TODO L10N : To remove
.ordered(current_language)
.page(params[:page])
@feature_nav = 'navigation/admin/communication/website/portfolio'
breadcrumb
end
Expand Down Expand Up @@ -91,14 +86,6 @@ def categories
.ordered
end

def load_filters
@filters = ::Filters::Admin::Communication::Websites::Portfolio::Projects.new(
current_user,
@website,
current_language
).list
end

def project_params
params.require(:communication_website_portfolio_project)
.permit(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
class Admin::Communication::Websites::Posts::AuthorsController < Admin::Communication::Websites::Posts::ApplicationController

has_scope :for_search_term

def index
@authors = apply_scopes(@website.authors.accessible_by(current_ability))
.ordered(current_language)
.page(params[:page])
@authors = @website.authors
.filter_by(params[:filters], current_language)
.accessible_by(current_ability)
.tmp_original
.ordered(current_language)
.page(params[:page])
@feature_nav = 'navigation/admin/communication/website/posts'
breadcrumb
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ class Admin::Communication::Websites::Posts::CategoriesController < Admin::Commu
include Admin::HasStaticAction

def index
@root_categories = categories.root.tmp_original # TODO L10N : To remove
@root_categories = categories.root
.tmp_original # TODO L10N : To remove
.ordered
@categories_class = categories_class
@feature_nav = 'navigation/admin/communication/website/posts'
breadcrumb
Expand Down
22 changes: 4 additions & 18 deletions app/controllers/admin/communication/websites/posts_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,11 @@ class Admin::Communication::Websites::PostsController < Admin::Communication::We
include Admin::HasStaticAction
include Admin::Localizable

# Allow to override the default load_filters from Admin::Filterable
before_action :load_filters, only: :index

has_scope :for_search_term
has_scope :for_author
has_scope :for_category

def index
@posts = apply_scopes(@posts).tmp_original # TODO L10N : To remove
.ordered(current_language)
.page(params[:page])
@posts = @posts.filter_by(params[:filters], current_language)
.tmp_original # TODO L10N : To remove
.ordered(current_language)
.page(params[:page])
@feature_nav = 'navigation/admin/communication/website/posts'
breadcrumb
end
Expand Down Expand Up @@ -120,14 +114,6 @@ def post_params
.merge(university_id: current_university.id)
end

def load_filters
@filters = ::Filters::Admin::Communication::Website::Posts.new(
current_user,
@website,
current_language
).list
end

def categories
@website.post_categories
.tmp_original # TODO L10N : To remove
Expand Down
10 changes: 3 additions & 7 deletions app/controllers/admin/communication/websites_controller.rb
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
class Admin::Communication::WebsitesController < Admin::Communication::Websites::ApplicationController
include Admin::Localizable

has_scope :for_search_term
has_scope :for_about_type

before_action :set_feature_nav, only: [:edit, :update]

def index
@websites = apply_scopes(@websites)
.ordered(current_language)
.page(params[:page])
.per(30)
@websites = @websites.filter_by(params[:filters], current_language)
.ordered(current_language)
.page(params[:page])
breadcrumb
end

Expand Down
13 changes: 4 additions & 9 deletions app/controllers/admin/education/programs_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,11 @@ class Admin::Education::ProgramsController < Admin::Education::ApplicationContro
include Admin::HasStaticAction
include Admin::Localizable

has_scope :for_search_term
has_scope :for_diploma
has_scope :for_school
has_scope :for_publication

def index
@programs = apply_scopes(@programs)
.tmp_original # TODO L10N : To remove.
.ordered_by_name(current_language)
.page(params[:page])
@programs = @programs.filter_by(params[:filters], current_language)
.tmp_original # TODO L10N : To remove.
.ordered_by_name(current_language)
.page(params[:page])
breadcrumb
end

Expand Down
Loading
Loading