cm-admin 0.5.2 → 0.5.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/assets/stylesheets/cm_admin/scaffold.scss +10 -0
- data/app/views/cm_admin/main/_nested_fields.html.slim +6 -5
- data/app/views/cm_admin/main/_nested_table_form.html.slim +3 -2
- data/app/views/cm_admin/main/_top_navbar.html.slim +1 -1
- data/lib/cm_admin/model.rb +3 -2
- data/lib/cm_admin/models/action.rb +1 -1
- data/lib/cm_admin/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bcbb26a08fa072ec95a1363e72c63ebfad6a1c661d303d50af5379f2f5bce0b1
|
4
|
+
data.tar.gz: 2f2526862a9312a48f768eb001ba52f6365182e105556136e2e763e96e21484a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c8d834bc6b9716aeef9b5c82137106c9aae52afd435ef384e7543be09fd4f18cb3f593374aebf5d840c9d17f7d0ecb99a9c9066508a1645fdff32d433d9ef983
|
7
|
+
data.tar.gz: c21ae398e2d2542186251a98bc706e203164e70319e841041527122358cd9cf3162620d8b860570b5f288f2ba1734c73a2a3a83da917c8b159120ad28c8febae
|
@@ -1,7 +1,8 @@
|
|
1
1
|
.nested-fields
|
2
2
|
- @model.available_fields[action_name.to_sym][assoc_name].each do |field|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
3
|
+
.row
|
4
|
+
.col-sm-10
|
5
|
+
= input_field_for_column(f, field)
|
6
|
+
.col-sm-2
|
7
|
+
- if @reflections.select {|x| x if x.name == assoc_name}.first.macro == :has_many
|
8
|
+
= link_to_remove_association "x", f
|
@@ -1,6 +1,7 @@
|
|
1
|
-
|
1
|
+
.nested-field-wrapper
|
2
|
+
label.field-label = table_name.to_s.titleize
|
2
3
|
= f.fields_for table_name do |record|
|
3
4
|
= render partial: '/cm_admin/main/nested_fields', locals: { f: record, assoc_name: table_name }
|
4
5
|
- if @reflections.select {|x| x if x.name == table_name}.first.macro == :has_many
|
5
6
|
.links
|
6
|
-
= link_to_add_association "
|
7
|
+
= link_to_add_association "+ Add #{table_name.to_s.titleize}", f, table_name, partial: '/cm_admin/main/nested_fields', render_options: {locals: { assoc_name: table_name }}
|
@@ -28,7 +28,7 @@
|
|
28
28
|
= link_to custom_action.name.titleize, @model.ar_model.table_name + '/' + custom_action.path, class: 'primary-btn ml-2', method: custom_action.verb
|
29
29
|
- elsif custom_action.display_type == :modal
|
30
30
|
= link_to custom_action.name.titleize, '', class: 'primary-btn ml-2', data: { bs_toggle: "modal", bs_target: "##{custom_action.name.classify}Modal" }
|
31
|
-
- elsif @model.current_action.name == 'show'
|
31
|
+
- elsif @model.current_action.name == 'show' || @action.layout_type == "cm_association_show"
|
32
32
|
- @model.available_actions.select{|act| act if act.route_type == 'member'}.each do |custom_action|
|
33
33
|
- if custom_action.display_type == :button && custom_action.display_if.call(@ar_object)
|
34
34
|
= link_to custom_action.name.titleize, custom_action.path.gsub(':id', params[:id]), class: 'primary-btn ml-2', method: custom_action.verb
|
data/lib/cm_admin/model.rb
CHANGED
@@ -99,6 +99,7 @@ module CmAdmin
|
|
99
99
|
@model = CmAdmin::Model.find_by(name: controller_name.classify)
|
100
100
|
@model.params = params
|
101
101
|
@action = CmAdmin::Models::Action.find_by(@model, name: action_name)
|
102
|
+
@model.current_action = @action
|
102
103
|
@ar_object = @model.try(@action.parent || action_name, params)
|
103
104
|
@ar_object, @associated_model, @associated_ar_object = @model.custom_controller_action(action_name, params.permit!) if !@ar_object.present? && params[:id].present?
|
104
105
|
aar_model = request.url.split('/')[-2].classify.constantize if params[:aar_id]
|
@@ -134,11 +135,11 @@ module CmAdmin
|
|
134
135
|
data = @action.parent == "index" ? @ar_object.data : @ar_object
|
135
136
|
format.html { render action.partial }
|
136
137
|
else
|
137
|
-
redirect_url = request.referrer || "/cm_admin/#{@model.ar_model.table_name}/#{@ar_object.id}"
|
138
138
|
if @action.code_block.call(@ar_object)
|
139
|
+
redirect_url = @action.redirection_url || request.referrer || "/cm_admin/#{@model.ar_model.table_name}/#{@ar_object.id}"
|
139
140
|
format.html { redirect_to redirect_url }
|
140
141
|
else
|
141
|
-
format.html { redirect_to
|
142
|
+
format.html { redirect_to request.referrer }
|
142
143
|
end
|
143
144
|
end
|
144
145
|
elsif action.layout.present?
|
@@ -6,7 +6,7 @@ module CmAdmin
|
|
6
6
|
include Actions::Blocks
|
7
7
|
attr_accessor :name, :verb, :layout_type, :layout, :partial, :path, :page_title, :page_description,
|
8
8
|
:child_records, :is_nested_field, :nested_table_name, :parent, :display_if, :route_type, :code_block,
|
9
|
-
:display_type, :action_type
|
9
|
+
:display_type, :action_type, :redirection_url
|
10
10
|
|
11
11
|
def initialize(attributes = {}, &block)
|
12
12
|
if attributes[:layout_type].present? && attributes[:layout].nil? && attributes[:partial].nil?
|
data/lib/cm_admin/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cm-admin
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- sajinmp
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: exe
|
12
12
|
cert_chain: []
|
13
|
-
date: 2022-
|
13
|
+
date: 2022-02-10 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: pagy
|
@@ -228,7 +228,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
228
228
|
- !ruby/object:Gem::Version
|
229
229
|
version: '0'
|
230
230
|
requirements: []
|
231
|
-
rubygems_version: 3.
|
231
|
+
rubygems_version: 3.0.3
|
232
232
|
signing_key:
|
233
233
|
specification_version: 4
|
234
234
|
summary: This is an admin panel gem
|