@@ -5,32 +5,32 @@ module Views
55 module Actions
66 class Index < DefaultLayout
77 attr_accessor :actions ,
8- :fields ,
9- :filters ,
10- :links ,
11- :pagination_component ,
12- :prepare_record ,
13- :records ,
14- :slug
8+ :fields ,
9+ :filters ,
10+ :links ,
11+ :pagination_component ,
12+ :prepare_record ,
13+ :records ,
14+ :slug
1515
1616 def view_template
1717 super do
18- div ( class : ' index' ) {
19- div ( class : ' row' ) {
20- div ( class : ' col-4' ) {
21- h1 ( class : ' title' ) {
18+ div ( class : " index" ) {
19+ div ( class : " row" ) {
20+ div ( class : " col-4" ) {
21+ h1 ( class : " title" ) {
2222 title
2323 }
2424 }
25- div ( class : ' col-8' ) {
25+ div ( class : " col-8" ) {
2626 actions_buttons
2727 }
2828 }
2929
30- div ( class : ' row' ) {
31- div_class = filters &.any? ? ' col-9' : ' col-12'
30+ div ( class : " row" ) {
31+ div_class = filters &.any? ? " col-9" : " col-12"
3232 div ( class : div_class ) {
33- table ( class : ' table' ) {
33+ table ( class : " table" ) {
3434 table_header if fields . any?
3535
3636 table_body
@@ -40,7 +40,7 @@ def view_template
4040 }
4141
4242 if filters &.any?
43- div ( class : ' col-3' ) {
43+ div ( class : " col-3" ) {
4444 filters_form = TinyAdmin ::Views ::Components ::FiltersForm . new
4545 filters_form . update_attributes ( section_path : TinyAdmin . route_for ( slug ) , filters : filters )
4646 render filters_form
@@ -75,20 +75,22 @@ def table_body
7575 attributes = prepare_record . call ( record )
7676 attributes . each do |key , value |
7777 field = fields [ key ]
78+ next unless field
79+
7880 td ( class : "field-value-#{ field . name } field-value-type-#{ field . type } " ) {
7981 render TinyAdmin . settings . components [ :field_value ] . new ( field , value , record : record )
8082 }
8183 end
8284
83- td ( class : ' actions p-1' ) {
84- div ( class : ' btn-group btn-group-sm' ) {
85- link_class = ' btn btn-outline-secondary'
85+ td ( class : " actions p-1" ) {
86+ div ( class : " btn-group btn-group-sm" ) {
87+ link_class = " btn btn-outline-secondary"
8688 if links
8789 links . each do |link |
8890 whitespace
89- if link == ' show'
91+ if link == " show"
9092 a ( href : TinyAdmin . route_for ( slug , reference : record . id ) , class : link_class ) {
91- label_for ( ' Show' , options : [ ' actions.index.links.show' ] )
93+ label_for ( " Show" , options : [ " actions.index.links.show" ] )
9294 }
9395 else
9496 a ( href : TinyAdmin . route_for ( slug , reference : record . id , action : link ) , class : link_class ) {
@@ -99,7 +101,7 @@ def table_body
99101 end
100102 else
101103 a ( href : TinyAdmin . route_for ( slug , reference : record . id ) , class : link_class ) {
102- label_for ( ' Show' , options : [ ' actions.index.links.show' ] )
104+ label_for ( " Show" , options : [ " actions.index.links.show" ] )
103105 }
104106 end
105107 }
@@ -110,16 +112,9 @@ def table_body
110112 end
111113
112114 def actions_buttons
113- ul ( class : 'nav justify-content-end' ) {
114- ( actions || { } ) . each do |action , action_class |
115- li ( class : 'nav-item mx-1' ) {
116- href = TinyAdmin . route_for ( slug , action : action )
117- a ( href : href , class : 'nav-link btn btn-outline-secondary' ) {
118- action_class . respond_to? ( :title ) ? action_class . title : action
119- }
120- }
121- end
122- }
115+ buttons = TinyAdmin ::Views ::Components ::ActionsButtons . new
116+ buttons . update_attributes ( actions : actions , slug : slug )
117+ render buttons
123118 end
124119 end
125120 end
0 commit comments