Skip to content

Commit ce39327

Browse files
committed
Merge branch 'admin'
2 parents 53b2a20 + 4749c62 commit ce39327

33 files changed

+1173
-6
lines changed

Gemfile

+3
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,13 @@ gem "dartsass-rails"
2626
# Build JSON APIs with ease [https://github.com/rails/jbuilder]
2727
gem "jbuilder"
2828

29+
gem 'rails-i18n'
30+
2931
gem "csv"
3032

3133
gem 'activeadmin'
3234
gem 'devise'
35+
gem 'devise-i18n'
3336

3437
# sql LIKE search
3538
gem "ransack"

Gemfile.lock

+8
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,9 @@ GEM
128128
railties (>= 4.1.0)
129129
responders
130130
warden (~> 1.2.3)
131+
devise-i18n (1.13.0)
132+
devise (>= 4.9.0)
133+
rails-i18n
131134
drb (2.2.1)
132135
dry-core (1.1.0)
133136
concurrent-ruby (~> 1.0)
@@ -282,6 +285,9 @@ GEM
282285
rails-html-sanitizer (1.6.2)
283286
loofah (~> 2.21)
284287
nokogiri (>= 1.15.7, != 1.16.7, != 1.16.6, != 1.16.5, != 1.16.4, != 1.16.3, != 1.16.2, != 1.16.1, != 1.16.0.rc1, != 1.16.0)
288+
rails-i18n (7.0.10)
289+
i18n (>= 0.7, < 2)
290+
railties (>= 6.0.0, < 8)
285291
railties (7.2.2.1)
286292
actionpack (= 7.2.2.1)
287293
activesupport (= 7.2.2.1)
@@ -402,11 +408,13 @@ DEPENDENCIES
402408
dartsass-rails
403409
debug
404410
devise
411+
devise-i18n
405412
grape
406413
importmap-rails
407414
jbuilder
408415
puma (>= 5.0)
409416
rails (~> 7.2)
417+
rails-i18n
410418
ransack
411419
rubocop-rails-omakase
412420
selenium-webdriver

app/admin/admin_users.rb

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
ActiveAdmin.register AdminUser do
2+
permit_params :email, :password, :password_confirmation
3+
4+
index do
5+
selectable_column
6+
id_column
7+
column :email
8+
column :current_sign_in_at
9+
column :sign_in_count
10+
column :created_at
11+
actions
12+
end
13+
14+
filter :email
15+
filter :current_sign_in_at
16+
filter :sign_in_count
17+
filter :created_at
18+
19+
form do |f|
20+
f.inputs do
21+
f.input :email
22+
f.input :password
23+
f.input :password_confirmation
24+
end
25+
f.actions
26+
end
27+
28+
end

app/admin/dashboard.rb

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# frozen_string_literal: true
2+
ActiveAdmin.register_page "Dashboard" do
3+
menu priority: 1, label: proc { I18n.t("active_admin.dashboard") }
4+
5+
content title: proc { I18n.t("active_admin.dashboard") } do
6+
div class: "blank_slate_container", id: "dashboard_default_message" do
7+
span class: "blank_slate" do
8+
span I18n.t("active_admin.dashboard_welcome.welcome")
9+
small I18n.t("active_admin.dashboard_welcome.call_to_action")
10+
end
11+
end
12+
13+
# Here is an example of a simple dashboard with columns and panels.
14+
#
15+
# columns do
16+
# column do
17+
# panel "Recent Posts" do
18+
# ul do
19+
# Post.recent(5).map do |post|
20+
# li link_to(post.title, admin_post_path(post))
21+
# end
22+
# end
23+
# end
24+
# end
25+
26+
# column do
27+
# panel "Info" do
28+
# para "Welcome to ActiveAdmin."
29+
# end
30+
# end
31+
# end
32+
end # content
33+
end

app/admin/description.rb

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
ActiveAdmin.register Description do
2+
# Permit all parameters by default
3+
permit_params do
4+
Description.column_names.map(&:to_sym)
5+
end
6+
7+
# Index page customization
8+
index do
9+
selectable_column
10+
id_column
11+
Description.column_names.each do |column|
12+
column column.to_sym unless column == 'id'
13+
end
14+
actions
15+
end
16+
17+
# Show page customization
18+
show do
19+
attributes_table do
20+
Description.column_names.each do |column|
21+
row column.to_sym
22+
end
23+
end
24+
end
25+
26+
# Form customization
27+
form do |f|
28+
f.inputs do
29+
Description.column_names.each do |column|
30+
f.input column.to_sym unless column == 'id' || column.end_with?('_at') || column == 'created_at' || column == 'updated_at'
31+
end
32+
end
33+
f.actions
34+
end
35+
end

app/admin/example.rb

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
ActiveAdmin.register Example do
2+
# Permit all parameters by default
3+
permit_params do
4+
Example.column_names.map(&:to_sym)
5+
end
6+
7+
# Index page customization
8+
index do
9+
selectable_column
10+
id_column
11+
Example.column_names.each do |column|
12+
column column.to_sym unless column == 'id'
13+
end
14+
actions
15+
end
16+
17+
# Show page customization
18+
show do
19+
attributes_table do
20+
Example.column_names.each do |column|
21+
row column.to_sym
22+
end
23+
end
24+
end
25+
26+
# Form customization
27+
form do |f|
28+
f.inputs do
29+
Example.column_names.each do |column|
30+
f.input column.to_sym unless column == 'id' || column.end_with?('_at') || column == 'created_at' || column == 'updated_at'
31+
end
32+
end
33+
f.actions
34+
end
35+
end

app/admin/stem.rb

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
ActiveAdmin.register Stem do
2+
# Permit all parameters by default
3+
permit_params do
4+
Stem.column_names.map(&:to_sym)
5+
end
6+
7+
# Index page customization
8+
index do
9+
selectable_column
10+
id_column
11+
Stem.column_names.each do |column|
12+
column column.to_sym unless column == 'id'
13+
end
14+
actions
15+
end
16+
17+
# Show page customization
18+
show do
19+
attributes_table do
20+
Stem.column_names.each do |column|
21+
row column.to_sym
22+
end
23+
end
24+
end
25+
26+
# Form customization
27+
form do |f|
28+
f.inputs do
29+
Stem.column_names.each do |column|
30+
f.input column.to_sym unless column == 'id' || column.end_with?('_at') || column == 'created_at' || column == 'updated_at'
31+
end
32+
end
33+
f.actions
34+
end
35+
end

app/admin/synonym.rb

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
ActiveAdmin.register Synonym do
2+
# Permit all parameters by default
3+
permit_params do
4+
Synonym.column_names.map(&:to_sym)
5+
end
6+
7+
# Index page customization
8+
index do
9+
selectable_column
10+
id_column
11+
Synonym.column_names.each do |column|
12+
column column.to_sym unless column == 'id'
13+
end
14+
actions
15+
end
16+
17+
# Show page customization
18+
show do
19+
attributes_table do
20+
Synonym.column_names.each do |column|
21+
row column.to_sym
22+
end
23+
end
24+
end
25+
26+
# Form customization
27+
form do |f|
28+
f.inputs do
29+
Synonym.column_names.each do |column|
30+
f.input column.to_sym unless column == 'id' || column.end_with?('_at') || column == 'created_at' || column == 'updated_at'
31+
end
32+
end
33+
f.actions
34+
end
35+
end

app/admin/term.rb

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
ActiveAdmin.register Term do
2+
# Permit all parameters by default
3+
permit_params do
4+
Term.column_names.map(&:to_sym)
5+
end
6+
7+
# Index page customization
8+
index do
9+
selectable_column
10+
id_column
11+
Term.column_names.each do |column|
12+
column column.to_sym unless column == 'id'
13+
end
14+
actions
15+
end
16+
17+
# Show page customization
18+
show do
19+
attributes_table do
20+
Term.column_names.each do |column|
21+
row column.to_sym
22+
end
23+
end
24+
end
25+
26+
# Form customization
27+
form do |f|
28+
f.inputs do
29+
Term.column_names.each do |column|
30+
f.input column.to_sym unless column == 'id' || column.end_with?('_at') || column == 'created_at' || column == 'updated_at'
31+
end
32+
end
33+
f.actions
34+
end
35+
end
+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
//= require active_admin/base
+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// Sass variable overrides must be declared before loading up Active Admin's styles.
2+
//
3+
// To view the variables that Active Admin provides, take a look at
4+
// `app/assets/stylesheets/active_admin/mixins/_variables.scss` in the
5+
// Active Admin source.
6+
//
7+
// For example, to change the sidebar width:
8+
// $sidebar-width: 242px;
9+
10+
// Active Admin's got SASS!
11+
@import "active_admin/mixins";
12+
@import "active_admin/base";
13+
14+
// Overriding any non-variable Sass must be done after the fact.
15+
// For example, to change the default status-tag color:
16+
//
17+
// .status_tag { background: #6090DB; }

app/models/admin_user.rb

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
class AdminUser < ApplicationRecord
2+
# Include default devise modules. Others available are:
3+
# :confirmable, :lockable, :timeoutable, :trackable and :omniauthable
4+
devise :database_authenticatable,
5+
:recoverable, :rememberable, :validatable
6+
7+
def self.ransackable_attributes(auth_object = nil)
8+
%w[created_at email encrypted_password id id_value remember_created_at reset_password_sent_at reset_password_token updated_at]
9+
end
10+
end

app/models/description.rb

+8-1
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,15 @@ class Description < ApplicationRecord
3030

3131
before_save :clean_content
3232

33+
def self.ransackable_associations(auth_object = nil)
34+
%w[examples synonyms term]
35+
end
36+
3337
def self.ransackable_attributes(auth_object = nil)
34-
%w[content]
38+
%w[id term_id content description_type created_at updated_at glossary_serial glossary_level
39+
customized_text content_zh content_en content_fr
40+
image1 image1_alt image1_provider image2 image2_alt image2_provider
41+
image3 image3_alt image3_provider focus category]
3542
end
3643

3744
def image1_url

app/models/dictionary.rb

+4
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ class Dictionary < ApplicationRecord
2525
"原住民族語言線上辭典" => "indigo"
2626
}.freeze
2727

28+
def self.ransackable_attributes(auth_object = nil)
29+
%w[created_at dialect id id_value name updated_at]
30+
end
31+
2832
def color
2933
COLOR[name]
3034
end

app/models/example.rb

+5-1
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,12 @@ class Example < ApplicationRecord
2525

2626
before_save :clean_content
2727

28+
def self.ransackable_associations(auth_object = nil)
29+
%w[description]
30+
end
31+
2832
def self.ransackable_attributes(auth_object = nil)
29-
%w[content content_zh]
33+
%w[content content_zh content_amis content_en content_fr id description_id created_at updated_at customized_text]
3034
end
3135

3236
def audio_url

app/models/stem.rb

+8
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,12 @@ class Stem < ApplicationRecord
1414
has_many :terms
1515

1616
validates :name, uniqueness: true
17+
18+
def self.ransackable_associations(auth_object = nil)
19+
%w[terms]
20+
end
21+
22+
def self.ransackable_attributes(auth_object = nil)
23+
%w[created_at id id_value name updated_at]
24+
end
1725
end

app/models/synonym.rb

+8
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,14 @@ class Synonym < ApplicationRecord
2222

2323
before_save :clean_content
2424

25+
def self.ransackable_associations(auth_object = nil)
26+
%w[description]
27+
end
28+
29+
def self.ransackable_attributes(auth_object = nil)
30+
%w[content created_at description_id id id_value term_type updated_at]
31+
end
32+
2533
private
2634

2735
def clean_content

0 commit comments

Comments
 (0)