From e1c163a929f7813f9b4ef72d72927c555ea3fc14 Mon Sep 17 00:00:00 2001 From: Jah Seng Lee Date: Sun, 10 Dec 2023 18:33:14 +0800 Subject: [PATCH 01/14] Bump pagy --- Gemfile.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile.lock b/Gemfile.lock index e519d65..b128a2a 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -206,7 +206,7 @@ GEM racc (~> 1.4) orm_adapter (0.5.0) os (1.1.4) - pagy (6.0.4) + pagy (6.2.0) pg (1.5.4) pg_search (2.3.6) activerecord (>= 5.2) From e27dcc81e0150f0fcc3e945ed57fc2bec188741d Mon Sep 17 00:00:00 2001 From: Jah Seng Lee Date: Sun, 10 Dec 2023 18:51:38 +0800 Subject: [PATCH 02/14] Better mobile display for Location#show --- app/views/locations/show.html.erb | 79 ++++++++++++------------------- 1 file changed, 31 insertions(+), 48 deletions(-) diff --git a/app/views/locations/show.html.erb b/app/views/locations/show.html.erb index c189338..9e8defd 100644 --- a/app/views/locations/show.html.erb +++ b/app/views/locations/show.html.erb @@ -13,37 +13,7 @@ <%= render partial: "locations/show_location_alerts" %> - <% if current_user&.admin? %> -
- <%= link_to( - upload_banner_image_modal_location_path(@location), - "data-turbo-stream": "", - ) do %> - <% if @location.banner_image.present? %> - - Update banner image - <% else %> - - Add banner image - <% end %> - <% end %> - - <%= link_to edit_location_path(@location), class: "ms-3" do %> - - Update location - <% end %> -
- <% end %> -
-
- <%= @markdown.render( - helper_location_description(location: @location) - ).html_safe %> -
- -
-
@@ -105,25 +75,8 @@
-
- <%= link_to( - location_reviews_path(location_id: @location.id), - class: "btn btn-primary" - ) do %> - - See all reviews - <% end %> - - <%= render partial: "reviews/shared/add_or_update_review", - locals: { - user: current_user, - location: @location - } - %> -
- <% if @location.has_emergency_numbers? %> -
+

Emergency numbers

@@ -139,6 +92,36 @@
<% end %>
+ +
+ +
+ <% if current_user&.admin? %> +
+ <%= link_to( + upload_banner_image_modal_location_path(@location), + "data-turbo-stream": "", + ) do %> + <% if @location.banner_image.present? %> + + Update banner image + <% else %> + + Add banner image + <% end %> + <% end %> + + <%= link_to edit_location_path(@location), class: "ms-3" do %> + + Update location + <% end %> +
+ <% end %> + + <%= @markdown.render( + helper_location_description(location: @location) + ).html_safe %> +
From d85d2698a119a740c6adef6019aeb7bd55e12695 Mon Sep 17 00:00:00 2001 From: Jah Seng Lee Date: Sun, 10 Dec 2023 19:06:11 +0800 Subject: [PATCH 03/14] Show mobile only view for emergency numbers --- app/controllers/locations_controller.rb | 6 +++++ .../controllers/location_tabs_controller.js | 3 +++ app/views/locations/_tabs.html.erb | 10 ++++++++ app/views/locations/emergency_info.html.erb | 23 +++++++++++++++++++ .../shared/_emergency_numbers.html.erb | 14 +++++++++++ app/views/locations/show.html.erb | 22 +++++++----------- config/routes.rb | 1 + 7 files changed, 65 insertions(+), 14 deletions(-) create mode 100644 app/views/locations/emergency_info.html.erb create mode 100644 app/views/locations/shared/_emergency_numbers.html.erb diff --git a/app/controllers/locations_controller.rb b/app/controllers/locations_controller.rb index 86807df..955de02 100644 --- a/app/controllers/locations_controller.rb +++ b/app/controllers/locations_controller.rb @@ -70,6 +70,12 @@ def upload_banner_image_modal end end + def emergency_info + # Intended to be a mobile/small screen only link as normally the + # emergency info is hidden on mobile + @location = Location.find(params[:id]) + end + private def location_params diff --git a/app/javascript/controllers/location_tabs_controller.js b/app/javascript/controllers/location_tabs_controller.js index e8e6752..5942682 100644 --- a/app/javascript/controllers/location_tabs_controller.js +++ b/app/javascript/controllers/location_tabs_controller.js @@ -5,6 +5,7 @@ export default class extends Controller { "overviewLink", "reviewsLink", "visaLink", + "emergencyInfoLink" ]; connect() { @@ -15,6 +16,8 @@ export default class extends Controller { this.visaLinkTarget.classList.add("active"); } else if (pathElements.includes("reviews")) { this.reviewsLinkTarget.classList.add("active"); + } else if (pathElements.includes("emergency_info")) { + this.emergencyInfoLinkTarget.classList.add("active"); } else { this.overviewLinkTarget.classList.add("active"); } diff --git a/app/views/locations/_tabs.html.erb b/app/views/locations/_tabs.html.erb index 225f8ff..423ba4e 100644 --- a/app/views/locations/_tabs.html.erb +++ b/app/views/locations/_tabs.html.erb @@ -30,5 +30,15 @@ } ) %> +
diff --git a/app/views/locations/emergency_info.html.erb b/app/views/locations/emergency_info.html.erb new file mode 100644 index 0000000..6c608ee --- /dev/null +++ b/app/views/locations/emergency_info.html.erb @@ -0,0 +1,23 @@ +<%= render partial: "locations/header", + locals: { + location: @location, + } +%> + +
+ <%= render partial: "locations/tabs", + locals: { + location: @location, + } + %> + + <% if @location.has_emergency_numbers? %> + <%= render partial: "locations/shared/emergency_numbers", + locals: { + location: @location + } + %> + <% else %> +

No emergency information for this location

+ <% end %> +
diff --git a/app/views/locations/shared/_emergency_numbers.html.erb b/app/views/locations/shared/_emergency_numbers.html.erb new file mode 100644 index 0000000..a48d0a9 --- /dev/null +++ b/app/views/locations/shared/_emergency_numbers.html.erb @@ -0,0 +1,14 @@ +
+
+

Emergency numbers

+ + <% location.emergency_numbers.each do |emergency_number| %> +
+ <%= emergency_number[:name].capitalize %>: + + <%= emergency_number[:number] %> + +
+ <% end %> +
+
diff --git a/app/views/locations/show.html.erb b/app/views/locations/show.html.erb index 9e8defd..6ac59f3 100644 --- a/app/views/locations/show.html.erb +++ b/app/views/locations/show.html.erb @@ -76,24 +76,18 @@ <% if @location.has_emergency_numbers? %> -
-
-

Emergency numbers

- - <% @location.emergency_numbers.each do |emergency_number| %> -
- <%= emergency_number[:name].capitalize %>: - - <%= emergency_number[:number] %> - -
- <% end %> -
+ <% # Only render on non-mobile/small screens %> +
+ <%= render partial: "locations/shared/emergency_numbers", + locals: { + location: @location + } + %>
<% end %>
-
+
<% if current_user&.admin? %> diff --git a/config/routes.rb b/config/routes.rb index f5c66c2..a0d94ec 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -42,6 +42,7 @@ resources :locations, only: [:show, :edit, :update] do member do get :upload_banner_image_modal + get :emergency_info patch :generate_description end From 0fd325b2d64173b4e9ed85f28345e834dbb0688a Mon Sep 17 00:00:00 2001 From: Jah Seng Lee Date: Sun, 10 Dec 2023 20:45:22 +0800 Subject: [PATCH 04/14] Update emergency numbers at a country level --- app/controllers/countries_controller.rb | 30 +++++++++++ app/controllers/locations_controller.rb | 7 +-- app/models/location.rb | 6 +-- app/policies/country_policy.rb | 6 ++- app/views/countries/edit.html.erb | 39 ++++++++++++++ app/views/locations/_tabs.html.erb | 2 +- app/views/locations/edit.html.erb | 27 ---------- app/views/locations/emergency_info.html.erb | 12 +++-- app/views/locations/show.html.erb | 10 ++++ config/routes.rb | 2 +- ...0646_add_emergency_numbers_to_countries.rb | 7 +++ ...90646_add_emergency_numbers_to_location.rb | 7 --- db/schema.rb | 6 +-- .../features/adding_a_location_review_spec.rb | 8 +-- .../auto_generating_a_location_review_spec.rb | 4 +- .../editing_a_location_review_spec.rb | 2 + spec/features/editing_a_location_spec.rb | 13 ----- spec/features/emergency_numbers_spec.rb | 51 +++++++++++++++++++ spec/requests/locations_spec.rb | 9 ---- 19 files changed, 168 insertions(+), 80 deletions(-) create mode 100644 app/controllers/countries_controller.rb create mode 100644 app/views/countries/edit.html.erb create mode 100644 db/migrate/20231210090646_add_emergency_numbers_to_countries.rb delete mode 100644 db/migrate/20231210090646_add_emergency_numbers_to_location.rb create mode 100644 spec/features/emergency_numbers_spec.rb diff --git a/app/controllers/countries_controller.rb b/app/controllers/countries_controller.rb new file mode 100644 index 0000000..6b275cb --- /dev/null +++ b/app/controllers/countries_controller.rb @@ -0,0 +1,30 @@ +class CountriesController < ApplicationController + def edit + @country = Country.find(params[:id]) + @location = @country.locations.find(params[:location_id]) + + authorize(@country) + end + + def update + @country = Country.find(params[:id]) + @location = @country.locations.find(params[:location_id]) + + authorize(@country) + + # NOTE this is supremely lazy + # however, admin only. Fine for now + @country.update!(country_params) + redirect_to @location + end + + private + + def country_params + params.require(:country).permit( + :ambulance_number, + :police_number, + :fire_number + ) + end +end diff --git a/app/controllers/locations_controller.rb b/app/controllers/locations_controller.rb index 955de02..f3b1dfa 100644 --- a/app/controllers/locations_controller.rb +++ b/app/controllers/locations_controller.rb @@ -79,11 +79,6 @@ def emergency_info private def location_params - params.require(:location).permit( - :description, - :ambulance_number, - :police_number, - :fire_number, - ) + params.require(:location).permit(:description) end end diff --git a/app/models/location.rb b/app/models/location.rb index 819f7c1..18614ed 100644 --- a/app/models/location.rb +++ b/app/models/location.rb @@ -47,9 +47,9 @@ def review_summary def emergency_numbers [ - { name: "ambulance", number: ambulance_number }, - { name: "police", number: police_number }, - { name: "fire", number: fire_number }, + { name: "ambulance", number: country.ambulance_number }, + { name: "police", number: country.police_number }, + { name: "fire", number: country.fire_number }, ] end diff --git a/app/policies/country_policy.rb b/app/policies/country_policy.rb index bb4e232..9ca9a36 100644 --- a/app/policies/country_policy.rb +++ b/app/policies/country_policy.rb @@ -1,5 +1,9 @@ class CountryPolicy < ApplicationPolicy - def update? + def edit? user.admin? end + + def update? + edit? + end end diff --git a/app/views/countries/edit.html.erb b/app/views/countries/edit.html.erb new file mode 100644 index 0000000..7ab351e --- /dev/null +++ b/app/views/countries/edit.html.erb @@ -0,0 +1,39 @@ +
+ <%= render partial: "locations/shared/back_link", + locals: { + location: @location, + } + %> + +

Emergency info. for <%= @country.name %>

+ + <%= form_for [@location, @country] do |f| %> +
+ <%= f.label( + :ambulance_number, + "Ambulance", + class: "form-label fw-bold" + ) %> + <%= f.text_field :ambulance_number, class: "form-control" %> +
+ +
+ <%= f.label( + :police_number, + "Police", + class: "form-label fw-bold" + ) %> + <%= f.text_field :police_number, class: "form-control" %> +
+ +
+ <%= f.label :fire_number, "Fire", class: "form-label fw-bold" %> + <%= f.text_field :fire_number, class: "form-control" %> +
+ + <%= f.button "Save", + type: :submit, + class: "btn btn-primary" + %> + <% end %> +
diff --git a/app/views/locations/_tabs.html.erb b/app/views/locations/_tabs.html.erb index 423ba4e..7e7e1a8 100644 --- a/app/views/locations/_tabs.html.erb +++ b/app/views/locations/_tabs.html.erb @@ -33,7 +33,7 @@
-
-

Emergency numbers

- -
- <%= f.label( - :ambulance_number, - "Ambulance", - class: "form-label fw-bold" - ) %> - <%= f.text_field :ambulance_number, class: "form-control" %> -
- -
- <%= f.label( - :police_number, - "Police", - class: "form-label fw-bold" - ) %> - <%= f.text_field :police_number, class: "form-control" %> -
- -
- <%= f.label :fire_number, "Fire", class: "form-label fw-bold" %> - <%= f.text_field :fire_number, class: "form-control" %> -
-
- <%= f.button "Save", type: :submit, class: "btn btn-primary" diff --git a/app/views/locations/emergency_info.html.erb b/app/views/locations/emergency_info.html.erb index 6c608ee..7197596 100644 --- a/app/views/locations/emergency_info.html.erb +++ b/app/views/locations/emergency_info.html.erb @@ -12,11 +12,13 @@ %> <% if @location.has_emergency_numbers? %> - <%= render partial: "locations/shared/emergency_numbers", - locals: { - location: @location - } - %> +
+ <%= render partial: "locations/shared/emergency_numbers", + locals: { + location: @location + } + %> +
<% else %>

No emergency information for this location

<% end %> diff --git a/app/views/locations/show.html.erb b/app/views/locations/show.html.erb index 6ac59f3..c8adc32 100644 --- a/app/views/locations/show.html.erb +++ b/app/views/locations/show.html.erb @@ -85,6 +85,16 @@ %> <% end %> + + <% if current_user&.admin? %> + <%= link_to edit_location_country_path( + @location.country, + location_id: @location.id + ) do %> + + Add emergency info. + <% end %> + <% end %>
diff --git a/config/routes.rb b/config/routes.rb index a0d94ec..983577d 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -48,7 +48,7 @@ end resources :banner_images, only: [:create, :update] - + resources :countries, only: [:edit, :update] resources :reviews, only: [:index, :show, :new, :create, :edit, :update] do collection do post :generate_review diff --git a/db/migrate/20231210090646_add_emergency_numbers_to_countries.rb b/db/migrate/20231210090646_add_emergency_numbers_to_countries.rb new file mode 100644 index 0000000..7bb85ef --- /dev/null +++ b/db/migrate/20231210090646_add_emergency_numbers_to_countries.rb @@ -0,0 +1,7 @@ +class AddEmergencyNumbersToCountries < ActiveRecord::Migration[7.0] + def change + add_column :countries, :ambulance_number, :text + add_column :countries, :police_number, :text + add_column :countries, :fire_number, :text + end +end diff --git a/db/migrate/20231210090646_add_emergency_numbers_to_location.rb b/db/migrate/20231210090646_add_emergency_numbers_to_location.rb deleted file mode 100644 index a621d8a..0000000 --- a/db/migrate/20231210090646_add_emergency_numbers_to_location.rb +++ /dev/null @@ -1,7 +0,0 @@ -class AddEmergencyNumbersToLocation < ActiveRecord::Migration[7.0] - def change - add_column :locations, :ambulance_number, :text - add_column :locations, :police_number, :text - add_column :locations, :fire_number, :text - end -end diff --git a/db/schema.rb b/db/schema.rb index adfb305..42027ba 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -66,6 +66,9 @@ create_table "countries", force: :cascade do |t| t.text "name", null: false t.integer "region_id" + t.text "ambulance_number" + t.text "police_number" + t.text "fire_number" t.index ["region_id"], name: "index_countries_on_region_id" end @@ -84,9 +87,6 @@ t.datetime "created_at", null: false t.datetime "updated_at", null: false t.text "description" - t.text "ambulance_number" - t.text "police_number" - t.text "fire_number" t.index ["country_id"], name: "index_locations_on_country_id" t.index ["name"], name: "index_locations_on_name" end diff --git a/spec/features/adding_a_location_review_spec.rb b/spec/features/adding_a_location_review_spec.rb index e54fbd6..1becf52 100644 --- a/spec/features/adding_a_location_review_spec.rb +++ b/spec/features/adding_a_location_review_spec.rb @@ -10,20 +10,22 @@ end - describe "logged in as a user " do + describe "logged in as a user" do let(:user) { create(:user) } before do sign_in user end - context "on a location page" do + context "on a location's review page" do before do visit location_path(location) + + click_link "Reviews" end it "shows a 'Add review' link" do expect(page).to have_content( - "No reviews for #{location.name_utf8} yet" + "No reviews yet." ) expect(page).to have_link("Add review") end diff --git a/spec/features/auto_generating_a_location_review_spec.rb b/spec/features/auto_generating_a_location_review_spec.rb index 1dddc14..5cb52fe 100644 --- a/spec/features/auto_generating_a_location_review_spec.rb +++ b/spec/features/auto_generating_a_location_review_spec.rb @@ -22,11 +22,13 @@ context "on a location page" do before do visit location_path(location) + + click_link "Reviews" end it "shows a 'Add review' link" do expect(page).to have_content( - "No reviews for #{location.name_utf8} yet" + "No reviews yet." ) expect(page).to have_link("Add review") end diff --git a/spec/features/editing_a_location_review_spec.rb b/spec/features/editing_a_location_review_spec.rb index b23a271..57f1615 100644 --- a/spec/features/editing_a_location_review_spec.rb +++ b/spec/features/editing_a_location_review_spec.rb @@ -23,6 +23,8 @@ context "on a location page" do before do visit location_path(location) + + click_link "Reviews" end it "shows a 'Edit review' link" do diff --git a/spec/features/editing_a_location_spec.rb b/spec/features/editing_a_location_spec.rb index e2c6e4d..fb3ff0b 100644 --- a/spec/features/editing_a_location_spec.rb +++ b/spec/features/editing_a_location_spec.rb @@ -38,11 +38,6 @@ end before do fill_in "Description", with: new_descsription - - fill_in "Police", with: "111" - fill_in "Ambulance", with: "222" - fill_in "Fire", with: "333" - click_button "Save" end @@ -50,14 +45,6 @@ expect(page).to have_content(new_descsription) expect(page).to have_content("Updated location") - expect(page).to have_content("Emergency numbers") - expect(page).to have_content("Police") - expect(page).to have_content("111") - expect(page).to have_content("Ambulance") - expect(page).to have_content("222") - expect(page).to have_content("Fire") - expect(page).to have_content("333") - # Ensure redirect has occured expect(page).not_to have_content( "Editing #{location.name}, #{location.country.name}" diff --git a/spec/features/emergency_numbers_spec.rb b/spec/features/emergency_numbers_spec.rb new file mode 100644 index 0000000..395e643 --- /dev/null +++ b/spec/features/emergency_numbers_spec.rb @@ -0,0 +1,51 @@ +require 'rails_helper' + +RSpec.describe "Emergency numbers", type: :feature, js: true do + describe "logged in as an admin on a location page" do + let(:admin) { create(:user, admin: true) } + let(:location) { create(:location, country: country) } + let(:country) { create(:country) } + + before do + sign_in admin + + visit location_path(location) + end + + it "renders the 'Add emergency info' link" do + expect(page).to have_content "Add emergency info." + end + + context "clicking on the 'Add emergency info' link" do + before do + click_link "Add emergency info." + end + + it "takes you to a page to add emergency info" do + expect(page).to have_content( + "Emergency info. for #{country.name}" + ) + end + + context "filling out the form and submitting" do + before do + fill_in "Police", with: "111" + fill_in "Ambulance", with: "222" + fill_in "Fire", with: "333" + + click_button "Save" + end + + it "saves and displays the info" do + expect(page).to have_content("Emergency numbers") + expect(page).to have_content("Police") + expect(page).to have_content("111") + expect(page).to have_content("Ambulance") + expect(page).to have_content("222") + expect(page).to have_content("Fire") + expect(page).to have_content("333") + end + end + end + end +end diff --git a/spec/requests/locations_spec.rb b/spec/requests/locations_spec.rb index 86f26d8..6ae6c7c 100644 --- a/spec/requests/locations_spec.rb +++ b/spec/requests/locations_spec.rb @@ -41,16 +41,10 @@ describe "POST #update" do context "with valid params" do let(:new_descsription) { "I think #{location.name} is very cool" } - let(:ambulance_number) { "111" } - let(:police_number) { "222" } - let(:fire_number) { "333" } let(:params) do { location: { description: new_descsription, - ambulance_number: ambulance_number, - police_number: police_number, - fire_number: fire_number, } } end @@ -66,9 +60,6 @@ location.reload expect(location.description).to eq new_descsription - expect(location.ambulance_number).to eq ambulance_number - expect(location.police_number).to eq police_number - expect(location.fire_number).to eq fire_number end end From 14c2cb0f12e4497330bb98d779d1e57345ca7a02 Mon Sep 17 00:00:00 2001 From: Jah Seng Lee Date: Sun, 10 Dec 2023 20:47:18 +0800 Subject: [PATCH 05/14] Conditionally change "Add" to "Update" for link --- app/views/locations/show.html.erb | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/app/views/locations/show.html.erb b/app/views/locations/show.html.erb index c8adc32..07371ee 100644 --- a/app/views/locations/show.html.erb +++ b/app/views/locations/show.html.erb @@ -91,8 +91,13 @@ @location.country, location_id: @location.id ) do %> - - Add emergency info. + <% if @location.has_emergency_numbers? %> + + Update emergency info. + <% else %> + + Add emergency info. + <% end %> <% end %> <% end %> From 9a987dafbb38bd1a658d5f5e9c58af2b98a7a545 Mon Sep 17 00:00:00 2001 From: Jah Seng Lee Date: Sun, 10 Dec 2023 20:52:07 +0800 Subject: [PATCH 06/14] Ensure visa table is responsive --- .../visa_information/_visa_table.html.erb | 120 +++++++++--------- 1 file changed, 61 insertions(+), 59 deletions(-) diff --git a/app/views/visa_information/_visa_table.html.erb b/app/views/visa_information/_visa_table.html.erb index c49c1c6..a94ab90 100644 --- a/app/views/visa_information/_visa_table.html.erb +++ b/app/views/visa_information/_visa_table.html.erb @@ -1,67 +1,69 @@
- - - - - - - <% if user.admin? %> - <% # Empty for controls %> - - <% end %> - - - - <% visas.each do |visa| %> +
+
VisaDescriptionEligible countries
+ - - - - + + + <% if user.admin? %> - + <% # Empty for controls %> + <% end %> - <% end %> - -
- <%= visa.name %> - - <%= @markdown.render(visa.description).html_safe %> - -
    - <% user_citizenships = user&.citizenships.map(&:country) %> - - <% # List the users eligible_countries first... %> - <% user_citizenships.select{ |country| - visa.eligible_countries.include?(country) - }.each do |eligible_country| %> -
  • - <%= eligible_country.name %> -
  • - <% end %> - - <% # ...then the rest %> - <% (visa.eligible_countries - user_citizenships).each do |eligible_country| %> -
  • - <%= eligible_country.name %> -
  • - <% end %> -
-
VisaDescriptionEligible countries - <%= link_to( - edit_country_location_visa_path( - visa, - location_id: location.id, - country_id: country.id - ), - aria: { - label: "Edit visa" - } - ) do %> - - <% end %> -
+ + + <% visas.each do |visa| %> + + + <%= visa.name %> + + + <%= @markdown.render(visa.description).html_safe %> + + +
    + <% user_citizenships = user&.citizenships.map(&:country) %> + + <% # List the users eligible_countries first... %> + <% user_citizenships.select{ |country| + visa.eligible_countries.include?(country) + }.each do |eligible_country| %> +
  • + <%= eligible_country.name %> +
  • + <% end %> + + <% # ...then the rest %> + <% (visa.eligible_countries - user_citizenships).each do |eligible_country| %> +
  • + <%= eligible_country.name %> +
  • + <% end %> +
+ + + <% if user.admin? %> + + <%= link_to( + edit_country_location_visa_path( + visa, + location_id: location.id, + country_id: country.id + ), + aria: { + label: "Edit visa" + } + ) do %> + + <% end %> + + <% end %> + + <% end %> + + +
From a9a2f4304eb7bebfc7007d56c313eb1070579e9d Mon Sep 17 00:00:00 2001 From: Jah Seng Lee Date: Sun, 10 Dec 2023 20:57:21 +0800 Subject: [PATCH 07/14] Ensure form select always large enough --- app/assets/stylesheets/application.bootstrap.scss | 1 + app/assets/stylesheets/reviews.scss | 6 ++++++ app/views/reviews/shared/_form.html.erb | 2 +- 3 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 app/assets/stylesheets/reviews.scss diff --git a/app/assets/stylesheets/application.bootstrap.scss b/app/assets/stylesheets/application.bootstrap.scss index 6bf2c8b..90dce17 100644 --- a/app/assets/stylesheets/application.bootstrap.scss +++ b/app/assets/stylesheets/application.bootstrap.scss @@ -9,6 +9,7 @@ $primary: #262626; @import 'home'; @import 'location'; @import 'profiles'; +@import 'reviews'; @import 'search_location'; @import 'visas'; diff --git a/app/assets/stylesheets/reviews.scss b/app/assets/stylesheets/reviews.scss new file mode 100644 index 0000000..aafad91 --- /dev/null +++ b/app/assets/stylesheets/reviews.scss @@ -0,0 +1,6 @@ +.review-form { + .form-select { + width: 4rem; + min-width: 4rem; + } +} diff --git a/app/views/reviews/shared/_form.html.erb b/app/views/reviews/shared/_form.html.erb index 1d45552..10ed301 100644 --- a/app/views/reviews/shared/_form.html.erb +++ b/app/views/reviews/shared/_form.html.erb @@ -1,4 +1,4 @@ -<%= turbo_frame_tag "review-form" do %> +<%= turbo_frame_tag "review-form", class: "review-form" do %> <% if flash[:error_save_review].present? %> <% end %> -
+
-
+
<% if @user.profile_picture.present? %>
<%= image_tag( @@ -51,9 +51,26 @@ <% end %>
+
+ <%= link_to( + "Update password", + edit_user_registration_path, + class: "btn btn-secondary" + ) %> +
+ <%= form_for @user, data: { turbo_frame: "_top" } do |f| %> - <%= f.label :display_name %> +
+ <%= f.label :email %> + <%= f.text_field( + :email, + class: "form-control-plaintext", + disabled: true + ) %> +
+
+ <%= f.label :display_name %>
<%= f.text_field( @@ -76,25 +93,7 @@ ) %>
- -
- <%= f.label :email %> - <%= f.text_field( - :email, - class: "form-control-plaintext", - disabled: true - ) %> -
<% end %> - -
- <%= link_to( - "Update password", - edit_user_registration_path, - class: "btn btn-secondary" - ) %> -
-
From 5af8f4775894e11966ebb3ec6f86dd955d06fdae Mon Sep 17 00:00:00 2001 From: Jah Seng Lee Date: Mon, 11 Dec 2023 16:36:56 +0800 Subject: [PATCH 09/14] Make chat mobile friendly --- app/assets/stylesheets/channels.scss | 4 ++++ app/assets/stylesheets/chats.scss | 11 ++++++++++ app/controllers/channels_controller.rb | 18 ++-------------- .../channels/_chat_message_section.html.erb | 21 +++++++++++++++++++ .../current_user_list.turbo_stream.erb | 17 +++++++++++++++ app/views/channels/joinable.turbo_stream.erb | 14 +++++++++++++ .../chats/_current_user_channel_list.html.erb | 5 ++++- .../chats/_joinable_channel_list.html.erb | 2 +- app/views/chats/show.html.erb | 16 +++++++------- 9 files changed, 83 insertions(+), 25 deletions(-) create mode 100644 app/views/channels/current_user_list.turbo_stream.erb create mode 100644 app/views/channels/joinable.turbo_stream.erb diff --git a/app/assets/stylesheets/channels.scss b/app/assets/stylesheets/channels.scss index d292cc2..5250cc4 100644 --- a/app/assets/stylesheets/channels.scss +++ b/app/assets/stylesheets/channels.scss @@ -12,6 +12,10 @@ border-bottom: 1px solid $primary; + .dropdown { + flex: 1; + } + .leave-channel-button { color: $danger; } diff --git a/app/assets/stylesheets/chats.scss b/app/assets/stylesheets/chats.scss index 6d929ff..0b9548c 100644 --- a/app/assets/stylesheets/chats.scss +++ b/app/assets/stylesheets/chats.scss @@ -28,6 +28,17 @@ body { display: flex; flex-direction: column; + &.offcanvas-body { + padding: 0; + } + + .channel-list-frame { + flex: 1; + + display: flex; + flex-direction: column; + } + .channel-list { flex: 1; diff --git a/app/controllers/channels_controller.rb b/app/controllers/channels_controller.rb index 09e8b55..2aa74a4 100644 --- a/app/controllers/channels_controller.rb +++ b/app/controllers/channels_controller.rb @@ -79,27 +79,13 @@ def joinable .order(:last_action_at) respond_to do |format| - format.turbo_stream do - render turbo_stream: turbo_stream.replace( - "channel-list", - partial: "chats/joinable_channel_list", - locals: { channels: @channels } - ) - end + format.turbo_stream end end def current_user_list respond_to do |format| - format.turbo_stream do - render turbo_stream: turbo_stream.replace( - "joinable-channel-list", - partial: "chats/current_user_channel_list", - locals: { - user: current_user - } - ) - end + format.turbo_stream end end diff --git a/app/views/channels/_chat_message_section.html.erb b/app/views/channels/_chat_message_section.html.erb index 737af76..5f8e42a 100644 --- a/app/views/channels/_chat_message_section.html.erb +++ b/app/views/channels/_chat_message_section.html.erb @@ -50,6 +50,27 @@
<% end %> + +
+ + +
+
+ +
+
+ <%= render partial: "chats/current_user_channel_list", + locals: { + user: current_user, + turbo_id: "mobile-channel-list" + } + %> +
+
+
diff --git a/app/views/channels/current_user_list.turbo_stream.erb b/app/views/channels/current_user_list.turbo_stream.erb new file mode 100644 index 0000000..2570be0 --- /dev/null +++ b/app/views/channels/current_user_list.turbo_stream.erb @@ -0,0 +1,17 @@ +<%= turbo_stream.replace( + "joinable-channel-list", + partial: "chats/current_user_channel_list", + locals: { + user: current_user + } +) %> + +<%= turbo_stream.replace( + "mobile-joinable-channel-list", + partial: "chats/current_user_channel_list", + locals: { + user: current_user, + turbo_id: "mobile-channel-list" + } +) %> + diff --git a/app/views/channels/joinable.turbo_stream.erb b/app/views/channels/joinable.turbo_stream.erb new file mode 100644 index 0000000..747c839 --- /dev/null +++ b/app/views/channels/joinable.turbo_stream.erb @@ -0,0 +1,14 @@ +<%= turbo_stream.replace( + "channel-list", + partial: "chats/joinable_channel_list", + locals: { channels: @channels } +) %> + +<%= turbo_stream.replace( + "mobile-channel-list", + partial: "chats/joinable_channel_list", + locals: { + channels: @channels, + turbo_id: "mobile-joinable-channel-list" + } +) %> diff --git a/app/views/chats/_current_user_channel_list.html.erb b/app/views/chats/_current_user_channel_list.html.erb index 8fdbde2..a254dc1 100644 --- a/app/views/chats/_current_user_channel_list.html.erb +++ b/app/views/chats/_current_user_channel_list.html.erb @@ -1,4 +1,7 @@ -<%= turbo_frame_tag "channel-list", class: "channel-list-container col pe-0" do %> +<%= turbo_frame_tag( + local_assigns[:turbo_id] ? turbo_id : "channel-list", + class: "channel-list-frame" +) do %>
<%= render partial: "chats/shared/channel_list", locals: { diff --git a/app/views/chats/_joinable_channel_list.html.erb b/app/views/chats/_joinable_channel_list.html.erb index cf3c9e3..8d6ffe3 100644 --- a/app/views/chats/_joinable_channel_list.html.erb +++ b/app/views/chats/_joinable_channel_list.html.erb @@ -1,5 +1,5 @@ <%= turbo_frame_tag( - "joinable-channel-list", + local_assigns[:turbo_id] ? turbo_id : "joinable-channel-list", class: "channel-list-container col pe-0", data: { controller: "joinable-channel-list" diff --git a/app/views/chats/show.html.erb b/app/views/chats/show.html.erb index 1b3dd5c..88f52f4 100644 --- a/app/views/chats/show.html.erb +++ b/app/views/chats/show.html.erb @@ -23,20 +23,22 @@ <%= turbo_stream_from "user-#{current_user.id}-chat" %>
- <%= render partial: "chats/current_user_channel_list", - locals: { - user: current_user - } - %> +
+ <%= render partial: "chats/current_user_channel_list", + locals: { + user: current_user + } + %> +
<% if @channel.present? %> -
+
<%= render partial: "channels/chat_message_section", locals: { channel: @channel, message: @message } %>
<% else %> -
+

Click on one of channels on the left to start chatting

From 37f62fb48f26ef5d7c016b6b9a16fba84e471bb0 Mon Sep 17 00:00:00 2001 From: Jah Seng Lee Date: Mon, 11 Dec 2023 16:51:26 +0800 Subject: [PATCH 10/14] Ensure chat looks decent on mobile --- .../channels/_chat_message_section.html.erb | 23 ++++--------------- .../shared/_mobile_user_channel_list.html.erb | 18 +++++++++++++++ app/views/chats/show.html.erb | 13 +++++++++-- 3 files changed, 34 insertions(+), 20 deletions(-) create mode 100644 app/views/chats/shared/_mobile_user_channel_list.html.erb diff --git a/app/views/channels/_chat_message_section.html.erb b/app/views/channels/_chat_message_section.html.erb index 5f8e42a..f0de329 100644 --- a/app/views/channels/_chat_message_section.html.erb +++ b/app/views/channels/_chat_message_section.html.erb @@ -52,24 +52,11 @@ <% end %>
- - -
-
- -
-
- <%= render partial: "chats/current_user_channel_list", - locals: { - user: current_user, - turbo_id: "mobile-channel-list" - } - %> -
-
+ <%= render partial: "chats/shared/mobile_user_channel_list", + locals: { + user: current_user + } + %>
diff --git a/app/views/chats/shared/_mobile_user_channel_list.html.erb b/app/views/chats/shared/_mobile_user_channel_list.html.erb new file mode 100644 index 0000000..688e037 --- /dev/null +++ b/app/views/chats/shared/_mobile_user_channel_list.html.erb @@ -0,0 +1,18 @@ + + +
+
+ +
+
+ <%= render partial: "chats/current_user_channel_list", + locals: { + user: user, + turbo_id: "mobile-channel-list" + } + %> +
+
diff --git a/app/views/chats/show.html.erb b/app/views/chats/show.html.erb index 88f52f4..a515140 100644 --- a/app/views/chats/show.html.erb +++ b/app/views/chats/show.html.erb @@ -39,8 +39,17 @@
<% else %>
-

- Click on one of channels on the left to start chatting +

+ Click on one of the channels to start chatting +

+ +
+ <%= render partial: "chats/shared/mobile_user_channel_list", + locals: { + user: current_user, + button_label: "Browse channels" + } + %>

<% end %> From c8439de80c851aca06935acde05245275dd08ac1 Mon Sep 17 00:00:00 2001 From: Jah Seng Lee Date: Mon, 11 Dec 2023 17:16:02 +0800 Subject: [PATCH 11/14] Use js version of Pagy for responsiveness --- app/javascript/controllers/index.js | 3 +++ app/javascript/controllers/pagy_controller.js | 8 ++++++++ app/javascript/pagy-module.js | 1 + .../search_locations/_location_search_section.html.erb | 4 ++-- 4 files changed, 14 insertions(+), 2 deletions(-) create mode 100644 app/javascript/controllers/pagy_controller.js create mode 120000 app/javascript/pagy-module.js diff --git a/app/javascript/controllers/index.js b/app/javascript/controllers/index.js index a7854b4..7384098 100644 --- a/app/javascript/controllers/index.js +++ b/app/javascript/controllers/index.js @@ -25,6 +25,9 @@ application.register("modal", ModalController) import NavbarLinkController from "./navbar_link_controller" application.register("navbar-link", NavbarLinkController) +import PagyController from "./pagy_controller" +application.register("pagy", PagyController) + import SearchCountriesController from "./search_countries_controller" application.register("search-countries", SearchCountriesController) diff --git a/app/javascript/controllers/pagy_controller.js b/app/javascript/controllers/pagy_controller.js new file mode 100644 index 0000000..c6c62a9 --- /dev/null +++ b/app/javascript/controllers/pagy_controller.js @@ -0,0 +1,8 @@ +import { Controller } from "@hotwired/stimulus" +import Pagy from "../pagy-module.js" + +export default class extends Controller { + connect() { + Pagy.init(this.element); + } +} diff --git a/app/javascript/pagy-module.js b/app/javascript/pagy-module.js new file mode 120000 index 0000000..cd43bb8 --- /dev/null +++ b/app/javascript/pagy-module.js @@ -0,0 +1 @@ +/Users/jahsenglee/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/pagy-6.2.0/lib/javascripts/pagy-module.js \ No newline at end of file diff --git a/app/views/search_locations/_location_search_section.html.erb b/app/views/search_locations/_location_search_section.html.erb index c2df58c..b1d637c 100644 --- a/app/views/search_locations/_location_search_section.html.erb +++ b/app/views/search_locations/_location_search_section.html.erb @@ -121,7 +121,7 @@ <% end %>
-
- <%== pagy_bootstrap_nav(@pagy) %> +
+ <%== pagy_bootstrap_nav_js(@pagy) %>
From 2f62108a36f2c5ea45bcb3e46f70dd13788dfb94 Mon Sep 17 00:00:00 2001 From: Jah Seng Lee Date: Mon, 11 Dec 2023 17:30:20 +0800 Subject: [PATCH 12/14] Delete file accidentally added via symlink --- app/javascript/pagy-module.js | 1 - 1 file changed, 1 deletion(-) delete mode 120000 app/javascript/pagy-module.js diff --git a/app/javascript/pagy-module.js b/app/javascript/pagy-module.js deleted file mode 120000 index cd43bb8..0000000 --- a/app/javascript/pagy-module.js +++ /dev/null @@ -1 +0,0 @@ -/Users/jahsenglee/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/pagy-6.2.0/lib/javascripts/pagy-module.js \ No newline at end of file From f1b4e5ccfa8594246d09f60c517faad0baed8157 Mon Sep 17 00:00:00 2001 From: Jah Seng Lee Date: Mon, 11 Dec 2023 17:36:27 +0800 Subject: [PATCH 13/14] Revert changes for JS pagy --- app/javascript/controllers/index.js | 3 - app/javascript/controllers/pagy_controller.js | 8 - .../_location_search_section.html.erb | 4 +- config/initializers/pagy.rb | 248 ++++++++++++++++++ 4 files changed, 250 insertions(+), 13 deletions(-) delete mode 100644 app/javascript/controllers/pagy_controller.js diff --git a/app/javascript/controllers/index.js b/app/javascript/controllers/index.js index 7384098..a7854b4 100644 --- a/app/javascript/controllers/index.js +++ b/app/javascript/controllers/index.js @@ -25,9 +25,6 @@ application.register("modal", ModalController) import NavbarLinkController from "./navbar_link_controller" application.register("navbar-link", NavbarLinkController) -import PagyController from "./pagy_controller" -application.register("pagy", PagyController) - import SearchCountriesController from "./search_countries_controller" application.register("search-countries", SearchCountriesController) diff --git a/app/javascript/controllers/pagy_controller.js b/app/javascript/controllers/pagy_controller.js deleted file mode 100644 index c6c62a9..0000000 --- a/app/javascript/controllers/pagy_controller.js +++ /dev/null @@ -1,8 +0,0 @@ -import { Controller } from "@hotwired/stimulus" -import Pagy from "../pagy-module.js" - -export default class extends Controller { - connect() { - Pagy.init(this.element); - } -} diff --git a/app/views/search_locations/_location_search_section.html.erb b/app/views/search_locations/_location_search_section.html.erb index b1d637c..c2df58c 100644 --- a/app/views/search_locations/_location_search_section.html.erb +++ b/app/views/search_locations/_location_search_section.html.erb @@ -121,7 +121,7 @@ <% end %>
-
- <%== pagy_bootstrap_nav_js(@pagy) %> +
+ <%== pagy_bootstrap_nav(@pagy) %>
diff --git a/config/initializers/pagy.rb b/config/initializers/pagy.rb index b711101..e498187 100644 --- a/config/initializers/pagy.rb +++ b/config/initializers/pagy.rb @@ -1,2 +1,250 @@ +# frozen_string_literal: true + +# Pagy initializer file (6.2.0) +# Customize only what you really need and notice that the core Pagy works also without any of the following lines. +# Should you just cherry pick part of this file, please maintain the require-order of the extras + + +# Pagy DEFAULT Variables +# See https://ddnexus.github.io/pagy/docs/api/pagy#variables +# All the Pagy::DEFAULT are set for all the Pagy instances but can be overridden per instance by just passing them to +# Pagy.new|Pagy::Countless.new|Pagy::Calendar::*.new or any of the #pagy* controller methods + + +# Instance variables +# See https://ddnexus.github.io/pagy/docs/api/pagy#instance-variables +# Pagy::DEFAULT[:page] = 1 # default +# Pagy::DEFAULT[:items] = 20 # default +# Pagy::DEFAULT[:outset] = 0 # default + + +# Other Variables +# See https://ddnexus.github.io/pagy/docs/api/pagy#other-variables +# Pagy::DEFAULT[:size] = [1,4,4,1] # default +# Pagy::DEFAULT[:page_param] = :page # default +# The :params can be also set as a lambda e.g ->(params){ params.exclude('useless').merge!('custom' => 'useful') } +# Pagy::DEFAULT[:params] = {} # default +# Pagy::DEFAULT[:fragment] = '#fragment' # example +# Pagy::DEFAULT[:link_extra] = 'data-remote="true"' # example +# Pagy::DEFAULT[:i18n_key] = 'pagy.item_name' # default +# Pagy::DEFAULT[:cycle] = true # example +# Pagy::DEFAULT[:request_path] = "/foo" # example + + +# Extras +# See https://ddnexus.github.io/pagy/categories/extra + + +# Backend Extras + +# Arel extra: For better performance utilizing grouped ActiveRecord collections: +# See: https://ddnexus.github.io/pagy/docs/extras/arel +# require 'pagy/extras/arel' + +# Array extra: Paginate arrays efficiently, avoiding expensive array-wrapping and without overriding +# See https://ddnexus.github.io/pagy/docs/extras/array +# require 'pagy/extras/array' + +# Calendar extra: Add pagination filtering by calendar time unit (year, quarter, month, week, day) +# See https://ddnexus.github.io/pagy/docs/extras/calendar +# require 'pagy/extras/calendar' +# Default for each unit +# Pagy::Calendar::Year::DEFAULT[:order] = :asc # Time direction of pagination +# Pagy::Calendar::Year::DEFAULT[:format] = '%Y' # strftime format +# +# Pagy::Calendar::Quarter::DEFAULT[:order] = :asc # Time direction of pagination +# Pagy::Calendar::Quarter::DEFAULT[:format] = '%Y-Q%q' # strftime format +# +# Pagy::Calendar::Month::DEFAULT[:order] = :asc # Time direction of pagination +# Pagy::Calendar::Month::DEFAULT[:format] = '%Y-%m' # strftime format +# +# Pagy::Calendar::Week::DEFAULT[:order] = :asc # Time direction of pagination +# Pagy::Calendar::Week::DEFAULT[:format] = '%Y-%W' # strftime format +# +# Pagy::Calendar::Day::DEFAULT[:order] = :asc # Time direction of pagination +# Pagy::Calendar::Day::DEFAULT[:format] = '%Y-%m-%d' # strftime format +# +# Uncomment the following lines, if you need calendar localization without using the I18n extra +# module LocalizePagyCalendar +# def localize(time, opts) +# ::I18n.l(time, **opts) +# end +# end +# Pagy::Calendar.prepend LocalizePagyCalendar + +# Countless extra: Paginate without any count, saving one query per rendering +# See https://ddnexus.github.io/pagy/docs/extras/countless +# require 'pagy/extras/countless' +# Pagy::DEFAULT[:countless_minimal] = false # default (eager loading) + +# Elasticsearch Rails extra: Paginate `ElasticsearchRails::Results` objects +# See https://ddnexus.github.io/pagy/docs/extras/elasticsearch_rails +# Default :pagy_search method: change only if you use also +# the searchkick or meilisearch extra that defines the same +# Pagy::DEFAULT[:elasticsearch_rails_pagy_search] = :pagy_search +# Default original :search method called internally to do the actual search +# Pagy::DEFAULT[:elasticsearch_rails_search] = :search +# require 'pagy/extras/elasticsearch_rails' + +# Headers extra: http response headers (and other helpers) useful for API pagination +# See http://ddnexus.github.io/pagy/extras/headers +# require 'pagy/extras/headers' +# Pagy::DEFAULT[:headers] = { page: 'Current-Page', +# items: 'Page-Items', +# count: 'Total-Count', +# pages: 'Total-Pages' } # default + +# Meilisearch extra: Paginate `Meilisearch` result objects +# See https://ddnexus.github.io/pagy/docs/extras/meilisearch +# Default :pagy_search method: change only if you use also +# the elasticsearch_rails or searchkick extra that define the same method +# Pagy::DEFAULT[:meilisearch_pagy_search] = :pagy_search +# Default original :search method called internally to do the actual search +# Pagy::DEFAULT[:meilisearch_search] = :ms_search +# require 'pagy/extras/meilisearch' + +# Metadata extra: Provides the pagination metadata to Javascript frameworks like Vue.js, react.js, etc. +# See https://ddnexus.github.io/pagy/docs/extras/metadata +# you must require the frontend helpers internal extra (BEFORE the metadata extra) ONLY if you need also the :sequels +# require 'pagy/extras/frontend_helpers' +# require 'pagy/extras/metadata' +# For performance reasons, you should explicitly set ONLY the metadata you use in the frontend +# Pagy::DEFAULT[:metadata] = %i[scaffold_url page prev next last] # example + +# Searchkick extra: Paginate `Searchkick::Results` objects +# See https://ddnexus.github.io/pagy/docs/extras/searchkick +# Default :pagy_search method: change only if you use also +# the elasticsearch_rails or meilisearch extra that defines the same +# DEFAULT[:searchkick_pagy_search] = :pagy_search +# Default original :search method called internally to do the actual search +# Pagy::DEFAULT[:searchkick_search] = :search +# require 'pagy/extras/searchkick' +# uncomment if you are going to use Searchkick.pagy_search +# Searchkick.extend Pagy::Searchkick + + +# Frontend Extras + +# Bootstrap extra: Add nav, nav_js and combo_nav_js helpers and templates for Bootstrap pagination +# See https://ddnexus.github.io/pagy/docs/extras/bootstrap require 'pagy/extras/bootstrap' +# Bulma extra: Add nav, nav_js and combo_nav_js helpers and templates for Bulma pagination +# See https://ddnexus.github.io/pagy/docs/extras/bulma +# require 'pagy/extras/bulma' + +# Foundation extra: Add nav, nav_js and combo_nav_js helpers and templates for Foundation pagination +# See https://ddnexus.github.io/pagy/docs/extras/foundation +# require 'pagy/extras/foundation' + +# Materialize extra: Add nav, nav_js and combo_nav_js helpers for Materialize pagination +# See https://ddnexus.github.io/pagy/docs/extras/materialize +# require 'pagy/extras/materialize' + +# Navs extra: Add nav_js and combo_nav_js javascript helpers +# Notice: the other frontend extras add their own framework-styled versions, +# so require this extra only if you need the unstyled version +# See https://ddnexus.github.io/pagy/docs/extras/navs +# require 'pagy/extras/navs' + +# Semantic extra: Add nav, nav_js and combo_nav_js helpers for Semantic UI pagination +# See https://ddnexus.github.io/pagy/docs/extras/semantic +# require 'pagy/extras/semantic' + +# UIkit extra: Add nav helper and templates for UIkit pagination +# See https://ddnexus.github.io/pagy/docs/extras/uikit +# require 'pagy/extras/uikit' + +# Multi size var used by the *_nav_js helpers +# See https://ddnexus.github.io/pagy/docs/extras/navs#steps +# Pagy::DEFAULT[:steps] = { 0 => [2,3,3,2], 540 => [3,5,5,3], 720 => [5,7,7,5] } # example + + +# Feature Extras + +# Gearbox extra: Automatically change the number of items per page depending on the page number +# See https://ddnexus.github.io/pagy/docs/extras/gearbox +# require 'pagy/extras/gearbox' +# set to false only if you want to make :gearbox_extra an opt-in variable +# Pagy::DEFAULT[:gearbox_extra] = false # default true +# Pagy::DEFAULT[:gearbox_items] = [15, 30, 60, 100] # default + +# Items extra: Allow the client to request a custom number of items per page with an optional selector UI +# See https://ddnexus.github.io/pagy/docs/extras/items +# require 'pagy/extras/items' +# set to false only if you want to make :items_extra an opt-in variable +# Pagy::DEFAULT[:items_extra] = false # default true +# Pagy::DEFAULT[:items_param] = :items # default +# Pagy::DEFAULT[:max_items] = 100 # default + +# Overflow extra: Allow for easy handling of overflowing pages +# See https://ddnexus.github.io/pagy/docs/extras/overflow +# require 'pagy/extras/overflow' +# Pagy::DEFAULT[:overflow] = :empty_page # default (other options: :last_page and :exception) + +# Support extra: Extra support for features like: incremental, infinite, auto-scroll pagination +# See https://ddnexus.github.io/pagy/docs/extras/support +# require 'pagy/extras/support' + +# Trim extra: Remove the page=1 param from links +# See https://ddnexus.github.io/pagy/docs/extras/trim +# require 'pagy/extras/trim' +# set to false only if you want to make :trim_extra an opt-in variable +# Pagy::DEFAULT[:trim_extra] = false # default true + +# Standalone extra: Use pagy in non Rack environment/gem +# See https://ddnexus.github.io/pagy/docs/extras/standalone +# require 'pagy/extras/standalone' +# Pagy::DEFAULT[:url] = 'http://www.example.com/subdir' # optional default + + +# Rails +# Enable the .js file required by the helpers that use javascript +# (pagy*_nav_js, pagy*_combo_nav_js, and pagy_items_selector_js) +# See https://ddnexus.github.io/pagy/docs/api/javascript + +# With the asset pipeline +# Sprockets need to look into the pagy javascripts dir, so add it to the assets paths +Rails.application.config.assets.paths << Pagy.root.join('javascripts') + +# I18n + +# Pagy internal I18n: ~18x faster using ~10x less memory than the i18n gem +# See https://ddnexus.github.io/pagy/docs/api/i18n +# Notice: No need to configure anything in this section if your app uses only "en" +# or if you use the i18n extra below +# +# Examples: +# load the "de" built-in locale: +# Pagy::I18n.load(locale: 'de') +# +# load the "de" locale defined in the custom file at :filepath: +# Pagy::I18n.load(locale: 'de', filepath: 'path/to/pagy-de.yml') +# +# load the "de", "en" and "es" built-in locales: +# (the first passed :locale will be used also as the default_locale) +# Pagy::I18n.load({ locale: 'de' }, +# { locale: 'en' }, +# { locale: 'es' }) +# +# load the "en" built-in locale, a custom "es" locale, +# and a totally custom locale complete with a custom :pluralize proc: +# (the first passed :locale will be used also as the default_locale) +# Pagy::I18n.load({ locale: 'en' }, +# { locale: 'es', filepath: 'path/to/pagy-es.yml' }, +# { locale: 'xyz', # not built-in +# filepath: 'path/to/pagy-xyz.yml', +# pluralize: lambda{ |count| ... } ) + + +# I18n extra: uses the standard i18n gem which is ~18x slower using ~10x more memory +# than the default pagy internal i18n (see above) +# See https://ddnexus.github.io/pagy/docs/extras/i18n +# require 'pagy/extras/i18n' + +# Default i18n key +# Pagy::DEFAULT[:i18n_key] = 'pagy.item_name' # default + + +# When you are done setting your own default freeze it, so it will not get changed accidentally +Pagy::DEFAULT.freeze From 750fedc05e4e1cb8db544b5531d7e42876a90165 Mon Sep 17 00:00:00 2001 From: Jah Seng Lee Date: Mon, 11 Dec 2023 17:46:04 +0800 Subject: [PATCH 14/14] Try fix for nav --- app/assets/stylesheets/home.scss | 1 + 1 file changed, 1 insertion(+) diff --git a/app/assets/stylesheets/home.scss b/app/assets/stylesheets/home.scss index 010f99e..1c70c45 100644 --- a/app/assets/stylesheets/home.scss +++ b/app/assets/stylesheets/home.scss @@ -6,6 +6,7 @@ .pagination-nav-container { width: 100%; + max-width: 100vw; display: flex; justify-content: center; }