help_center 0.0.7 → 0.0.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c66702dcdd38d04a609a0f9e873f8c4ba66fca9f4f296bf8d46b293ef26212ee
4
- data.tar.gz: aaf2ce14d85b8768e7728626d554ff03b417f08ab1cd0eeacd9f6cc8cbdceae1
3
+ metadata.gz: f3534b830bdcd003af94acb86f4cae1d8f280cdd2a8c35fcf819e1cdd1ecaac0
4
+ data.tar.gz: 29487d7779e372d63f2406e42de48aa75a0853d26062621657689b2d4c7871f8
5
5
  SHA512:
6
- metadata.gz: 4b84e8f6b1a5faba5f2b16e00b74a65ed30fdd350fbce20eb0aee8c9fe7186e87077d64a4a15fb2c009bc5b6cd51a5c57895bbac46f3c50632f086c34812e151
7
- data.tar.gz: 67b0da14fa50df5a60b850bed54151077cb74d0c27435fdb5b3b7aa83cb9f1b2694c1f4dfc224770419bfae92ca6e8d1115b79359c71625b93e17a1e3ab32be1
6
+ metadata.gz: 72da7820d7f986691f5cb18b223968317481aab512ff1e124fb056a9f64b707db998c4cbbf19ac25ac069e011bb3d2d6122d24f138e72a0cf52839664e7e45d8
7
+ data.tar.gz: 35f13cb0c78fcd1caf348d5cd0d4dde93af1b75e384923ca8a562e65cb00a11e328658a60eaeeffe7d806e5fde97d343abfc4b2b6ed53ead1073a6ad8b39a184
@@ -1,14 +1,10 @@
1
1
  class HelpCenter::SupportCategoriesController < HelpCenter::ApplicationController
2
2
  before_action :authenticate_user!, only: [:edit, :update, :destroy]
3
- before_action :set_category, only: [:index, :show, :edit, :update, :destroy]
3
+ before_action :set_category, only: [:show, :edit, :update, :destroy]
4
4
  before_action :require_mod_or_author_for_thread!, only: [:edit, :update, :destroy]
5
5
 
6
6
 
7
7
  def index
8
- @support_threads = SupportThread.where(support_category: @category) if @category.present?
9
- @support_threads = @support_threads.pinned_first.sorted.includes(:user, :support_category)
10
- @pagy, @records = pagy(@support_threads)
11
- render "help_center/support_threads/index"
12
8
  end
13
9
 
14
10
  def new
@@ -49,7 +45,7 @@ class HelpCenter::SupportCategoriesController < HelpCenter::ApplicationControlle
49
45
  def set_category
50
46
  @category = SupportCategory.friendly.find(params[:id])
51
47
  rescue ActiveRecord::RecordNotFound
52
- redirect_to help_center.support_threads_path
48
+ redirect_to help_center.support_categories_path, notice: I18n.t('page_not_found')
53
49
  end
54
50
 
55
51
  def support_category_params
@@ -52,10 +52,12 @@ class HelpCenter::SupportPostsController < HelpCenter::ApplicationController
52
52
  redirect_to help_center.support_thread_path(@support_thread, anchor: ActionView::RecordIdentifier.dom_id(@support_post))
53
53
  end
54
54
 
55
- private
56
-
55
+ private
56
+
57
57
  def set_support_thread
58
58
  @support_thread = SupportThread.friendly.find(params[:support_thread_id])
59
+ rescue ActiveRecord::RecordNotFound
60
+ redirect_to help_center.root_path, notice: I18n.t('page_not_found')
59
61
  end
60
62
 
61
63
  def set_support_post
@@ -4,8 +4,7 @@ class HelpCenter::SupportThreadsController < HelpCenter::ApplicationController
4
4
  before_action :require_mod_or_author_for_thread!, only: [:edit, :update]
5
5
 
6
6
  def index
7
- @support_threads = SupportThread.pinned_first.sorted.includes(:user, :support_category)
8
- @pagy, @records = pagy(@support_threads)
7
+ redirect_to help_center.support_categories_path
9
8
  end
10
9
 
11
10
  def answered
@@ -74,6 +73,8 @@ class HelpCenter::SupportThreadsController < HelpCenter::ApplicationController
74
73
 
75
74
  def set_support_thread
76
75
  @support_thread = SupportThread.friendly.find(params[:id])
76
+ rescue ActiveRecord::RecordNotFound
77
+ redirect_to help_center.support_categories_path, notice: I18n.t('page_not_found')
77
78
  end
78
79
 
79
80
  def support_thread_params
@@ -2,7 +2,7 @@ class SupportCategory < ApplicationRecord
2
2
  extend FriendlyId
3
3
  friendly_id :name, use: :slugged
4
4
 
5
- has_many :support_threads
5
+ has_many :support_threads, dependent: :destroy
6
6
  has_rich_text :description
7
7
 
8
8
  scope :sorted, ->{ order(position: :asc) }
@@ -1,19 +1,21 @@
1
- <% if @support_threads.none? %>
2
- <div><%= t('search_not_found') %>. <%= t('check_out') %> <%= link_to t('latest_questions'), help_center.support_threads_path %> <%= t('instead') %> </div>
1
+ <% if SupportCategory.none? %>
2
+ <div><%= t('search_not_found') %>. <%= link_to t('browse_categories'), help_center.support_categories_path %> <%= t('instead') %> </div>
3
3
  <% else %>
4
- <div class="container mx-auto">
5
- <% if request.url.include?('category') %>
6
- <%# If category, list all articles %>
7
- <div class="w-1/62 text-left p-0">
8
- <h3> <%= @support_threads.first.support_category.name %></h3>
9
- </div>
10
- <hr>
11
- <%= render partial: "help_center/support_threads/support_thread", collection: @support_threads, spacer_template: "shared/spacer" %>
12
- <div class="support-threads-nav text-center">
13
- <%== pagy_nav(@pagy) %>
14
- </div>
15
- <% else %>
16
- <%# Set default index here %>
17
- <% end %>
4
+ <div class="flex flex-wrap mb-8">
5
+
6
+ <div class="md:w-full pr-4 pl-41">
7
+ <h1 class="mb-4 font-bold tracking-normal"> Categories</h1>
8
+
9
+ <div class="flex flex-col items-center">
10
+ <% SupportCategory.all.sorted.each do |category| %>
11
+
12
+ <%= link_to help_center.support_category_path(category), class: "text-base font-semibold py-4 border-b w-full flex justify-between hover:bg-gray-200 px-4" do %>
13
+ <%= category.name %> <i class="fas fa-arrow-right"></i>
14
+ <% end %>
15
+
16
+ <% end %>
17
+ </div>
18
+ </div>
19
+
18
20
  </div>
19
21
  <% end %>
@@ -1,19 +0,0 @@
1
- <% if @support_threads.none? %>
2
- <div><%= t('search_not_found') %>. <%= t('check_out') %> <%= link_to t('latest_questions'), help_center.support_threads_path %> <%= t('instead') %> </div>
3
- <% else %>
4
- <div class="container mx-auto">
5
- <% if request.url.include?('category') %>
6
- <%# If category, list all articles %>
7
- <div class="w-1/62 text-left p-0">
8
- <h3> <%= @support_threads.first.support_category.name %></h3>
9
- </div>
10
- <hr>
11
- <%= render partial: "help_center/support_threads/support_thread", collection: @support_threads, spacer_template: "shared/spacer" %>
12
- <div class="support-threads-nav text-center">
13
- <%== pagy_nav(@pagy) %>
14
- </div>
15
- <% else %>
16
- <%# Set default index here %>
17
- <% end %>
18
- </div>
19
- <% end %>
@@ -2,7 +2,7 @@
2
2
 
3
3
  <% if current_user && (current_user.admin? || current_user.moderator?) %>
4
4
  <div class="container top-0 flex justify-between w-full z-50 bg-blue-600 text-purple-200 text-sm text-center font-brand-semibold px-4 py-3 rounded" role="alert">
5
- <span class="text-base font-normal">Welcome moderator (<%= current_user.email %>)</span>
5
+ <span class="text-base font-normal text-white">Welcome moderator (<%= current_user.email %>)</span>
6
6
  <div>
7
7
  <%= link_to t('add_an_article'), help_center.new_support_thread_path, class: "text-gray-100 hover:text-gray-300 hover:no-underline font-semibold underline mr-4 ml-6" %>
8
8
  <%= link_to t('add_category'), help_center.new_support_category_path, class: "text-gray-100 hover:text-gray-300 hover:no-underline font-semibold underline" %>
@@ -54,3 +54,5 @@ en:
54
54
  instead: instead?
55
55
  written_by_author: "Written by %{author}"
56
56
  content_updated_at: "Updated %{update_time} ago"
57
+ browse_categories: "Browse Categories"
58
+ page_not_found: "Page not found"
@@ -1,3 +1,3 @@
1
1
  module HelpCenter
2
- VERSION = "0.0.7"
2
+ VERSION = "0.0.8"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: help_center
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.7
4
+ version: 0.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ugurcan Kaya
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-05-10 00:00:00.000000000 Z
11
+ date: 2021-06-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: font-awesome-sass