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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ee189fda2ffbbbebebbf187b269408ae2b95a17e8373133fe5d0a8046abc4375
4
- data.tar.gz: e6a788a92b95d4492dc86cbdcdc6abd518d3a361f802a88449ed923ebf02cc72
3
+ metadata.gz: bcbb26a08fa072ec95a1363e72c63ebfad6a1c661d303d50af5379f2f5bce0b1
4
+ data.tar.gz: 2f2526862a9312a48f768eb001ba52f6365182e105556136e2e763e96e21484a
5
5
  SHA512:
6
- metadata.gz: 4eff826866357c66a2ff35980f3ef2a66576649b4c9285442f045986ee2a9435fb96dfa7f0761fe6b61df2f26941e62b13385d4aa6c7546808f5736d08437ae3
7
- data.tar.gz: 281ba123d2514c2f51abe820f7f16eee2448b5efcea11ee06acee96b2ac3851663ff836a05cfe91b704f49e11f4c28c0e3490c1cf5ee4076cc68724b22b6c728
6
+ metadata.gz: c8d834bc6b9716aeef9b5c82137106c9aae52afd435ef384e7543be09fd4f18cb3f593374aebf5d840c9d17f7d0ecb99a9c9066508a1645fdff32d433d9ef983
7
+ data.tar.gz: c21ae398e2d2542186251a98bc706e203164e70319e841041527122358cd9cf3162620d8b860570b5f288f2ba1734c73a2a3a83da917c8b159120ad28c8febae
@@ -12,3 +12,13 @@
12
12
  }
13
13
 
14
14
  }
15
+
16
+ .nested-field-wrapper {
17
+ label {
18
+ font-size: 14px;
19
+ margin-bottom: 16px;
20
+ }
21
+ .nested-fields {
22
+ margin-bottom: 16px;
23
+ }
24
+ }
@@ -1,7 +1,8 @@
1
1
  .nested-fields
2
2
  - @model.available_fields[action_name.to_sym][assoc_name].each do |field|
3
- = f.label field.field_name, class: 'field-label'
4
- br
5
- = input_field_for_column(f, field)
6
- - if @reflections.select {|x| x if x.name == assoc_name}.first.macro == :has_many
7
- = link_to_remove_association "remove #{assoc_name}", f
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
- #tasks
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 "add #{table_name}", f, table_name, partial: '/cm_admin/main/nested_fields', render_options: {locals: { assoc_name: table_name }}
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
@@ -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 redirect_url }
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?
@@ -1,3 +1,3 @@
1
1
  module CmAdmin
2
- VERSION = "0.5.2"
2
+ VERSION = "0.5.3"
3
3
  end
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.2
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-01-28 00:00:00.000000000 Z
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.2.32
231
+ rubygems_version: 3.0.3
232
232
  signing_key:
233
233
  specification_version: 4
234
234
  summary: This is an admin panel gem