feature/share-libs
rb 63 lines 1.61 KB
Raw
1 ActiveAdmin.register Chord do
2 menu priority: 7, parent: 'Music Database'
3 permit_params :song_provider_id, :chord, :user_id, :title
4
5 index do
6 selectable_column
7 column :title
8 column :song_provider
9 column :user
10 column :status
11 column 'Histories' do |chord|
12 if chord.chord_histories.count.positive?
13 chord.chord_histories.order(updated_at: :desc).each_with_index do |history, _index|
14 a history.name, href: admin_chord_history_url(history)
15 text_node '</br>'.html_safe
16 end
17 nil
18 else
19 # Only add add link if no history.
20 link_to 'Tambah',
21 "#{new_admin_chord_history_path}?chord_id=#{chord.id}&created_at=#{chord.created_at}&user_id=#{chord.user_id}"
22 end
23 end
24 column :views_count
25 actions
26 end
27
28 filter :song_provider
29 filter :views_count
30 filter :lyric
31 filter :status
32 filter :created_at
33 filter :updated_at
34
35 show do
36 attributes_table do
37 row :title
38 row :song_provider
39 row :user
40 row :status
41 row :chord do |chord|
42 raw chord.chord
43 end
44 row :created_at
45 row :updated_at
46 end
47 end
48
49 form do |f|
50 f.inputs do
51 f.input :title, include_blank: false
52 if f.object.new_record?
53 f.input :song_provider, include_blank: true, selected: params[:song_provider_id]
54 else
55 f.input :song_provider, include_blank: true
56 end
57 f.input :user, include_blank: true
58 f.input :status, input_html: { readonly: true, disabled: true }, include_blank: false, selected: 0
59 f.input :chord, as: :quill_editor
60 end
61 actions
62 end
63 end