cm-admin 1.1.7 → 1.1.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5aba23127b4e8223782b919d0c5c767b156262e55198835fb738c72fd9c5fa68
4
- data.tar.gz: 89a3df2239cc6a56eb3360afe1502654c2ad83b1921c5f8f7dedcc1d8eaf3407
3
+ metadata.gz: ba81abd1bda39ffb9374cd1c93320c6459ffb106ac105fc9b6dabca27c941b2b
4
+ data.tar.gz: c43d2423a3aed2e123eb058874d0bcf1b8df3c8b09597715a25720514177a93d
5
5
  SHA512:
6
- metadata.gz: 66c416a85d9e84c5d9122adc0a14d8728ce51934711839db9a261ddba9aeae8d13d3033f3e06f3c359b5a3c7a62ed74c2d253aa1c038865ba77486f7ddc6fbf7
7
- data.tar.gz: 5d91df86bb2cb64be4158688473c316c8e3c16b77bb11ed7a0a1e683f7e2af67e84b7240a45262ab79384cf1fdc238880f2da02525686ba73d43f9c5c98253c2
6
+ metadata.gz: 3b24b0d099f5557d2f6c0cf08ece3efc79129d0bbbcff25b115244cd04eb2ad8e4059bb563e1e63af201c46529a2e15902f8331a8988bec0d62bd3db84655852
7
+ data.tar.gz: 91b506a984661154df8536ace4bbea58cf67eb22fe13c99f02be6e5e3cd99e1f5565a3f363de974d3c9adf8e7a616912519cdd6155e9a861df42d490e56e9a11
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- cm-admin (1.1.7)
4
+ cm-admin (1.1.8)
5
5
  caxlsx_rails
6
6
  cocoon (~> 1.2.15)
7
7
  csv-importer (~> 0.8.2)
@@ -16,7 +16,6 @@ import 'bootstrap'
16
16
  import '@popperjs/core'
17
17
  import 'flatpickr'
18
18
  import 'jgrowl'
19
- jqueryJgrowl()
20
19
  import Select2 from "select2"
21
20
  Select2()
22
21
 
@@ -37,6 +36,7 @@ document.addEventListener("turbo:load", function () {
37
36
  mode: 'range'
38
37
  })
39
38
  $('.select-2').select2();
39
+ jqueryJgrowl()
40
40
  });
41
41
 
42
42
  $(document).on('click', '.menu-item', function(e) {
@@ -11,6 +11,7 @@
11
11
  padding: 24px;
12
12
  background-color: $white;
13
13
  z-index: 2;
14
+ gap: 16px;
14
15
  &__lhs {
15
16
  .bread-crumb-area {
16
17
  .breadcrumb-text {
@@ -46,12 +47,12 @@
46
47
  top: 45px;
47
48
  width: 156px;
48
49
  padding: 8px 0;
49
- animation: fadeIn .2s ease-in-out;
50
+ animation: fadeIn 0.2s ease-in-out;
50
51
  .popup-option {
51
52
  padding: 8px 16px;
52
53
  @include font($size: $t4-text, $color: $primary-text-clr);
53
54
  line-height: 22px;
54
- transition: all .2s linear;
55
+ transition: all 0.2s linear;
55
56
  cursor: pointer;
56
57
  &:hover {
57
58
  background-color: $grey-lighter-clr;
@@ -26,6 +26,7 @@
26
26
  *= require 'cm_admin/dependency/bootstrap.min'
27
27
  *= require 'cm_admin/dependency/flatpickr.min'
28
28
  *= require 'cm_admin/dependency/fontawesome.all'
29
+ *= require 'cm_admin/dependency/jquery-jgrowl.min'
29
30
  *= require 'cm_admin/scaffold'
30
31
  *= require_self
31
32
  */
@@ -1,4 +1,4 @@
1
- @import '../helpers/index.scss';
1
+ @import "../helpers/index.scss";
2
2
 
3
3
  .cta-btn {
4
4
  padding: 5px 10px;
@@ -6,7 +6,8 @@
6
6
  background-color: $brand-color;
7
7
  border: none;
8
8
  border-radius: $radius-4;
9
- transition: all .2s linear;
9
+ transition: all 0.2s linear;
10
+ white-space: nowrap;
10
11
  &:hover {
11
12
  color: $white;
12
13
  background: $cta-hover-gradient;
@@ -32,10 +33,11 @@
32
33
  background-color: $white;
33
34
  border: 1px solid $brand-color;
34
35
  border-radius: $radius-4;
35
- transition: all .2s linear;
36
+ transition: all 0.2s linear;
37
+ white-space: nowrap;
36
38
  &:hover {
37
39
  color: $brand-color;
38
- background-color: #E6E4FA;
40
+ background-color: $brand-hover-color;
39
41
  transform: scale(1.05);
40
42
  }
41
43
  &:focus {
@@ -55,11 +57,12 @@
55
57
 
56
58
  .secondary-btn {
57
59
  padding: 5px 10px;
58
- @include font($size: $t4-text, $color: $primary-text-clr, $weight: bold);
60
+ @include font($size: $t4-text, $color: $primary-text-clr, $weight: bold);
59
61
  background-color: $white;
60
62
  border: 1px solid $ink-regular-clr;
61
63
  border-radius: $radius-4;
62
- transition: all .2s linear;
64
+ transition: all 0.2s linear;
65
+ white-space: nowrap;
63
66
  &:hover {
64
67
  color: $primary-text-clr;
65
68
  background-color: $grey-light-clr;
@@ -82,17 +85,18 @@
82
85
  margin: 0 4px 0 8px;
83
86
  }
84
87
  span:nth-child(3) {
85
- @include font($size: 10px, $color: $ink-lighter-clr, $weight: bold);
88
+ @include font($size: 10px, $color: $ink-lighter-clr, $weight: bold);
86
89
  }
87
90
  }
88
91
 
89
92
  .gray-border-btn {
90
93
  padding: 5px 10px;
91
- @include font($size: $t4-text, $color: $primary-text-clr, $weight: bold);
94
+ @include font($size: $t4-text, $color: $primary-text-clr, $weight: bold);
92
95
  background-color: $white;
93
96
  border: 1px solid $ink-regular-clr;
94
97
  border-radius: $radius-4;
95
- transition: all .2s linear;
98
+ transition: all 0.2s linear;
99
+ white-space: nowrap;
96
100
  &:hover {
97
101
  color: $primary-text-clr;
98
102
  background-color: $grey-light-clr;
@@ -115,11 +119,12 @@
115
119
 
116
120
  .ghost-btn {
117
121
  padding: 5px 10px;
118
- @include font($size: $t4-text, $color: $primary-text-clr, $weight: bold);
122
+ @include font($size: $t4-text, $color: $primary-text-clr, $weight: bold);
119
123
  background-color: transparent;
120
124
  border: none;
121
125
  border-radius: $radius-4;
122
- transition: all .2s linear;
126
+ transition: all 0.2s linear;
127
+ white-space: nowrap;
123
128
  &:hover {
124
129
  color: $primary-text-clr;
125
130
  background: $grey-light-clr;
@@ -142,6 +147,7 @@
142
147
  .text-btn {
143
148
  border: none;
144
149
  background-color: transparent;
150
+ white-space: nowrap;
145
151
  &:focus {
146
152
  outline: none;
147
153
  }
@@ -0,0 +1 @@
1
+ .jGrowl{z-index:9999;color:#fff;font-size:12px;font-family:"Helvetica Neue",Helvetica,Arial,sans-serif;position:fixed}.jGrowl.top-left{left:0;top:0}.jGrowl.top-right{right:0;top:0}.jGrowl.bottom-left{left:0;bottom:0}.jGrowl.bottom-right{right:0;bottom:0}.jGrowl.center{top:0;width:50%;left:25%}.jGrowl.center .jGrowl-closer,.jGrowl.center .jGrowl-notification{margin-left:auto;margin-right:auto}.jGrowl-notification{background-color:#000;opacity:.9;zoom:1;width:250px;padding:10px;margin:10px;text-align:left;display:none;border-radius:5px;min-height:40px}.jGrowl-notification .ui-state-highlight,.jGrowl-notification .ui-widget-content .ui-state-highlight,.jGrowl-notification .ui-widget-header .ui-state-highlight{border:1px solid #000;background:#000;color:#fff}.jGrowl-notification .jGrowl-header{font-weight:700;font-size:.85em}.jGrowl-notification .jGrowl-close{background-color:transparent;color:inherit;border:none;z-index:99;float:right;font-weight:700;font-size:1em;cursor:pointer}.jGrowl-closer{background-color:#000;opacity:.9;zoom:1;width:250px;padding:10px;margin:10px;text-align:left;display:none;border-radius:5px;padding-top:4px;padding-bottom:4px;cursor:pointer;font-size:.9em;font-weight:700;text-align:center}.jGrowl-closer .ui-state-highlight,.jGrowl-closer .ui-widget-content .ui-state-highlight,.jGrowl-closer .ui-widget-header .ui-state-highlight{border:1px solid #000;background:#000;color:#fff}@media print{.jGrowl{display:none}}
@@ -1,54 +1,55 @@
1
1
  /* ==== Color Variables ==== */
2
2
 
3
3
  /* Brand Color */
4
- $brand-color: #6554E0;
4
+ $brand-color: #6554e0;
5
+ $brand-hover-color: #e6e4fa;
5
6
 
6
7
  /* Semantic Color */
7
- $informative-clr: #2F80ED;
8
- $error-clr: #F83636;
9
- $warning-clr: #FFC845;
10
- $positive-clr: #30C39E;
11
- $disabled-clr: #9CA7AE;
8
+ $informative-clr: #2f80ed;
9
+ $error-clr: #f83636;
10
+ $warning-clr: #ffc845;
11
+ $positive-clr: #30c39e;
12
+ $disabled-clr: #9ca7ae;
12
13
 
13
14
  /* Blue Colors */
14
- $blue-regular-clr: #2F80ED;
15
- $blue-light-clr: #CDE1FB;
16
- $blue-lightest-clr: #EEF5FE;
15
+ $blue-regular-clr: #2f80ed;
16
+ $blue-light-clr: #cde1fb;
17
+ $blue-lightest-clr: #eef5fe;
17
18
 
18
19
  /* Red Colors */
19
- $red-regular-clr: #F83636;
20
- $red-light-clr: #FDCFCF;
21
- $red-lightest-clr: #FEEFEF;
20
+ $red-regular-clr: #f83636;
21
+ $red-light-clr: #fdcfcf;
22
+ $red-lightest-clr: #feefef;
22
23
 
23
24
  /* Yellow Colors */
24
- $yellow-regular-clr: #FFC845;
25
- $yellow-light-clr: #FFEFC7;
26
- $yellow-lightest-clr: #FFF8E9;
25
+ $yellow-regular-clr: #ffc845;
26
+ $yellow-light-clr: #ffefc7;
27
+ $yellow-lightest-clr: #fff8e9;
27
28
 
28
29
  /* Green Colors */
29
- $green-regular-clr: #30C39E;
30
- $green-light-clr: #C1EDE2;
31
- $green-lightest-clr: #EEFAF7;
30
+ $green-regular-clr: #30c39e;
31
+ $green-light-clr: #c1ede2;
32
+ $green-lightest-clr: #eefaf7;
32
33
 
33
34
  /* Grey Colors */
34
- $grey-regular-clr: #C7CED5;
35
- $grey-light-clr: #D9DEE3;
36
- $grey-lighter-clr: #F3F4F6;
37
- $grey-lightest-clr: #F8F9FA;
35
+ $grey-regular-clr: #c7ced5;
36
+ $grey-light-clr: #d9dee3;
37
+ $grey-lighter-clr: #f3f4f6;
38
+ $grey-lightest-clr: #f8f9fa;
38
39
  $grey-dark-clr: #828282;
39
40
 
40
41
  /* Ink Colors */
41
- $ink-regular-clr: #1D2129;
42
- $ink-light-clr: #3B4352;
43
- $ink-lighter-clr: #6B7586;
44
- $ink-lightest-clr: #9CA7AE;
42
+ $ink-regular-clr: #1d2129;
43
+ $ink-light-clr: #3b4352;
44
+ $ink-lighter-clr: #6b7586;
45
+ $ink-lightest-clr: #9ca7ae;
45
46
 
46
47
  /* Text Colors */
47
- $primary-text-clr: #1D2129;
48
- $subdued-text-clr: #D9DEE3;
48
+ $primary-text-clr: #1d2129;
49
+ $subdued-text-clr: #d9dee3;
49
50
 
50
51
  /* Common Colors */
51
- $white: #FFFFFF;
52
+ $white: #ffffff;
52
53
  $black: #000000;
53
54
 
54
55
  // Gradient Colors
@@ -56,7 +57,7 @@ $gradient-one: linear-gradient(270deg, $grey-lighter-clr 81.75%, rgba(243, 244,
56
57
  $cta-hover-gradient: linear-gradient(0deg, rgba(0, 0, 0, 0.24), rgba(0, 0, 0, 0.24)), $brand-color;
57
58
 
58
59
  /* Typography */
59
- $primary-font: 'Open Sans', sans-serif;
60
+ $primary-font: "Open Sans", sans-serif;
60
61
  $font-size: (
61
62
  24: 24px,
62
63
  18: 18px,
@@ -137,15 +137,19 @@ module CmAdmin
137
137
  data = @action.parent == "index" ? @ar_object.data : @ar_object
138
138
  format.html { render @action.partial }
139
139
  else
140
- response_object = @action.code_block.call(@response_object)
141
- if response_object.class == Hash
142
- format.json { render json: response_object }
143
- elsif response_object.errors.empty?
144
- redirect_url = @model.current_action.redirection_url || @action.redirection_url || request.referrer || "/cm_admin/#{@model.ar_model.table_name}/#{@response_object.id}"
145
- format.html { redirect_to redirect_url, notice: "#{@action.name.titleize} is successful" }
146
- else
147
- error_messages = response_object.errors.full_messages.map{|error_message| "<li>#{error_message}</li>"}.join
148
- format.html { redirect_to request.referrer, alert: "<b>#{@action.name.titleize} is unsuccessful</b><br /><ul>#{error_messages}</ul>" }
140
+ begin
141
+ response_object = @action.code_block.call(@response_object)
142
+ if response_object.class == Hash
143
+ format.json { render json: response_object }
144
+ elsif response_object.errors.empty?
145
+ redirect_url = @model.current_action.redirection_url || @action.redirection_url || request.referrer || "/cm_admin/#{@model.ar_model.table_name}/#{@response_object.id}"
146
+ format.html { redirect_to redirect_url, notice: "#{@action.name.titleize} is successful" }
147
+ else
148
+ error_messages = response_object.errors.full_messages.map{|error_message| "<li>#{error_message}</li>"}.join
149
+ format.html { redirect_to request.referrer, alert: "<b>#{@action.name.titleize} is unsuccessful</b><br /><ul>#{error_messages}</ul>" }
150
+ end
151
+ rescue => exception
152
+ format.html { redirect_to request.referrer, alert: "<b>#{@action.name.titleize} is unsuccessful</b><br /><p>#{exception.message}</p>" }
149
153
  end
150
154
  end
151
155
  end
@@ -1,9 +1,9 @@
1
1
  - if flash[:notice].present?
2
2
  javascript:
3
- $.jGrowl("#{flash[:notice]}", {theme: 'notice'})
3
+ $.jGrowl("#{flash[:notice]}", { theme: 'notice' })
4
4
  - elsif flash[:success].present?
5
5
  javascript:
6
- $.jGrowl("#{flash[:success]}", {theme: 'success'})
6
+ $.jGrowl("#{flash[:success]}", { theme: 'success' })
7
7
  - elsif flash[:alert].present?
8
8
  javascript:
9
- $.jGrowl("#{flash[:alert].html_safe}", {theme: 'error'})
9
+ $.jGrowl("#{flash[:alert].html_safe}", { theme: 'error' })
@@ -1,6 +1,10 @@
1
+ require_relative 'utils/helpers'
2
+
1
3
  module CmAdmin
2
4
  module Models
3
5
  class Filter
6
+ include Utils::Helpers
7
+
4
8
  attr_accessor :db_column_name, :filter_type, :placeholder, :collection
5
9
 
6
10
  VALID_FILTER_TYPES = Set[:date, :multi_select, :range, :search, :single_select].freeze
@@ -8,37 +12,55 @@ module CmAdmin
8
12
  def initialize(db_column_name:, filter_type:, options: {})
9
13
  raise TypeError, "Can't have array of multiple columns for #{filter_type} filter" if db_column_name.is_a?(Array) && db_column_name.size > 1 && !filter_type.to_sym.eql?(:search)
10
14
  raise ArgumentError, "Kindly select a valid filter type like #{VALID_FILTER_TYPES.sort.to_sentence(last_word_connector: ', or ')} instead of #{filter_type} for column #{db_column_name}" unless VALID_FILTER_TYPES.include?(filter_type.to_sym)
15
+
11
16
  @db_column_name, @filter_type = structure_data(db_column_name, filter_type)
17
+ set_default_values
12
18
  options.each do |key, value|
13
- self.send("#{key.to_s}=", value)
19
+ send("#{key}=", value)
14
20
  end
15
21
  end
16
22
 
17
23
  def structure_data(db_column_name, filter_type)
18
24
  filter_type = filter_type.is_a?(Array) ? filter_type[0].to_sym : filter_type.to_sym
19
25
 
20
- case filter_type
21
- when :search
22
- db_column_name = (Array.new << db_column_name).flatten.map{|x| x.class.eql?(Hash) ? x : x.to_sym}
23
- else
24
- db_column_name = db_column_name.is_a?(Array) ? db_column_name[0].to_sym : db_column_name.to_sym
25
- end
26
+ db_column_name = case filter_type
27
+ when :search
28
+ ([] << db_column_name).flatten.map { |x| x.instance_of?(Hash) ? x : x.to_sym }
29
+ else
30
+ db_column_name.is_a?(Array) ? db_column_name[0].to_sym : db_column_name.to_sym
31
+ end
26
32
  [db_column_name, filter_type]
27
33
  end
28
34
 
35
+ # Set default placeholder for the filter.
36
+ # Date and range filter will not have any placeholder.
37
+ # Else condition is added for fallback.
38
+ def set_default_values
39
+ placeholder = case filter_type
40
+ when :search
41
+ 'Search'
42
+ when :single_select, :multi_select
43
+ "Select/search #{humanized_field_value(db_column_name)}"
44
+ else
45
+ "Enter #{humanized_field_value(db_column_name)}"
46
+ end
47
+ self.placeholder = placeholder
48
+ end
49
+
29
50
  # Methods to filter the records based on the filter type.
30
51
  class << self
31
52
  def filtered_data(filter_params, records, filters)
32
53
  if filter_params
33
54
  filter_params.each do |scope_type, scope_value|
34
- scope_name = if scope_type.eql?('date') || scope_type.eql?('range')
35
- 'date_and_range'
36
- elsif scope_type.eql?('single_select') || scope_type.eql?('multi_select')
37
- 'dropdown'
38
- else
39
- scope_type
40
- end
41
- records = self.send("cm_#{scope_name}_filter", scope_value, records, filters) if scope_value.present?
55
+ scope_name = case scope_type
56
+ when 'date', 'range'
57
+ 'date_and_range'
58
+ when 'single_select', 'multi_select'
59
+ 'dropdown'
60
+ else
61
+ scope_type
62
+ end
63
+ records = send("cm_#{scope_name}_filter", scope_value, records, filters) if scope_value.present?
42
64
  end
43
65
  end
44
66
  records
@@ -46,15 +68,17 @@ module CmAdmin
46
68
 
47
69
  def cm_search_filter(scope_value, records, filters)
48
70
  return nil if scope_value.blank?
71
+
49
72
  table_name = records.table_name
50
- filters.select{|x| x if x.filter_type.eql?(:search)}.each do |filter|
73
+ filters.select { |x| x if x.filter_type.eql?(:search) }.each do |filter|
51
74
  query_variables = []
52
75
  filter.db_column_name.each do |col|
53
- if col.is_a?(Symbol)
76
+ case col
77
+ when Symbol
54
78
  query_variables << "#{table_name.pluralize}.#{col}"
55
- elsif col.is_a?(Hash)
79
+ when Hash
56
80
  col.map do |key, value|
57
- value.map {|val| query_variables << "#{key.to_s.pluralize}.#{val}" }
81
+ value.map { |val| query_variables << "#{key.to_s.pluralize}.#{val}" }
58
82
  end
59
83
  end
60
84
  end
@@ -62,14 +86,14 @@ module CmAdmin
62
86
  terms = terms.map { |e|
63
87
  (e.gsub('*', '%').prepend('%') + '%').gsub(/%+/, '%')
64
88
  }
65
- sql = ""
89
+ sql = ''
66
90
  query_variables.each.with_index do |column, i|
67
91
  sql.concat("#{column} ILIKE ?")
68
- sql.concat(' OR ') unless query_variables.size.eql?(i+1)
92
+ sql.concat(' OR ') unless query_variables.size.eql?(i + 1)
69
93
  end
70
94
 
71
- if filter.db_column_name.map{|x| x.is_a?(Hash)}.include?(true)
72
- associations_hash = filter.db_column_name.select{|x| x if x.is_a?(Hash)}.last
95
+ if filter.db_column_name.map { |x| x.is_a?(Hash) }.include?(true)
96
+ associations_hash = filter.db_column_name.select { |x| x if x.is_a?(Hash) }.last
73
97
  records = records.left_joins(associations_hash.keys).distinct
74
98
  end
75
99
 
@@ -85,19 +109,21 @@ module CmAdmin
85
109
 
86
110
  def cm_date_and_range_filter(scope_value, records, filters)
87
111
  return nil if scope_value.nil?
112
+
88
113
  scope_value.each do |key, value|
89
- if value.present?
90
- value = value.split(' to ')
91
- from = value[0].presence
92
- to = value[1].presence
93
- records = records.where(key => from..to)
94
- end
114
+ next unless value.present?
115
+
116
+ value = value.split(' to ')
117
+ from = value[0].presence
118
+ to = value[1].presence
119
+ records = records.where(key => from..to)
95
120
  end
96
121
  records
97
122
  end
98
123
 
99
124
  def cm_dropdown_filter(scope_value, records, filters)
100
125
  return nil if scope_value.nil?
126
+
101
127
  scope_value.each do |key, value|
102
128
  records = records.where(key => value) if value.present?
103
129
  end
@@ -1,6 +1,10 @@
1
+ require_relative 'utils/helpers'
2
+
1
3
  module CmAdmin
2
4
  module Models
3
5
  class FormField
6
+ include Utils::Helpers
7
+
4
8
  attr_accessor :field_name, :label, :header, :input_type, :collection, :disabled, :helper_method,
5
9
  :placeholder, :display_if, :html_attr, :target
6
10
 
@@ -13,9 +17,10 @@ module CmAdmin
13
17
  @field_name = field_name
14
18
  set_default_values
15
19
  attributes.each do |key, value|
16
- self.send("#{key.to_s}=", value)
20
+ send("#{key}=", value)
17
21
  end
18
- self.display_if = lambda { |arg| return true } if self.display_if.nil?
22
+ set_default_placeholder
23
+ self.display_if = lambda { |arg| return true } if display_if.nil?
19
24
  raise ArgumentError, "Kindly select a valid input type like #{VALID_INPUT_TYPES.sort.to_sentence(last_word_connector: ', or ')} instead of #{self.input_type} for form field #{field_name}" unless VALID_INPUT_TYPES.include?(self.input_type.to_sym)
20
25
  end
21
26
 
@@ -23,10 +28,20 @@ module CmAdmin
23
28
  self.disabled = false
24
29
  self.label = self.field_name.to_s.titleize
25
30
  self.input_type = :string
26
- self.placeholder = "Enter #{self.field_name.to_s.downcase.gsub('_', ' ')}"
27
31
  self.html_attr = {}
28
32
  self.target = {}
29
33
  end
34
+
35
+ def set_default_placeholder
36
+ return unless placeholder.nil?
37
+
38
+ self.placeholder = case input_type&.to_sym
39
+ when :single_select, :multi_select, :date, :date_time
40
+ "Select #{humanized_field_value(field_name)}"
41
+ else
42
+ "Enter #{humanized_field_value(field_name)}"
43
+ end
44
+ end
30
45
  end
31
46
  end
32
47
  end
@@ -0,0 +1,14 @@
1
+ module CmAdmin
2
+ module Models
3
+ module Utils
4
+ module Helpers
5
+ extend ActiveSupport::Concern
6
+
7
+ # Returns the humanized value of the field.
8
+ def humanized_field_value(name, capitalize: false)
9
+ name.to_s.humanize(capitalize: capitalize)
10
+ end
11
+ end
12
+ end
13
+ end
14
+ end
@@ -1,3 +1,3 @@
1
1
  module CmAdmin
2
- VERSION = '1.1.7'
2
+ VERSION = '1.1.8'
3
3
  end
@@ -169,7 +169,7 @@ module CmAdmin
169
169
  else
170
170
  value_mapped_text = value
171
171
  end
172
-
172
+
173
173
  concat(content_tag(:div, class: "position-relative mr-3 #{value ? '' : 'hidden'}") do
174
174
  concat filter_chip(value_mapped_text, filter)
175
175
 
@@ -7,7 +7,7 @@ module CmAdmin
7
7
  value = cm_field.helper_method ? send(cm_field.helper_method, form_obj.object, cm_field.field_name) : form_obj.object.send(cm_field.field_name)
8
8
  is_required = form_obj.object._validators[cm_field.field_name].map(&:kind).include?(:presence)
9
9
  required_class = is_required ? 'required' : ''
10
- target_action = @model.available_actions.select{|x| x.name == cm_field.target[:action_name].to_s}.first if cm_field.target.present?
10
+ target_action = @model.available_actions.select { |x| x.name == cm_field.target[:action_name].to_s }.first if cm_field.target.present?
11
11
  send("cm_#{cm_field.input_type}_field", form_obj, cm_field, value, required_class, target_action)
12
12
  end
13
13
 
@@ -16,7 +16,7 @@ module CmAdmin
16
16
  class: "normal-input #{required_class}",
17
17
  disabled: cm_field.disabled,
18
18
  value: value,
19
- placeholder: "Enter #{cm_field.field_name.to_s.humanize.downcase}",
19
+ placeholder: cm_field.placeholder,
20
20
  data: { behaviour: 'integer-only' }
21
21
  end
22
22
 
@@ -25,7 +25,7 @@ module CmAdmin
25
25
  class: "normal-input #{required_class}",
26
26
  disabled: cm_field.disabled,
27
27
  value: value,
28
- placeholder: "Enter #{cm_field.field_name.to_s.downcase.gsub('_', ' ')}",
28
+ placeholder: cm_field.placeholder,
29
29
  data: { behaviour: 'decimal-only' }
30
30
  end
31
31
 
@@ -34,12 +34,12 @@ module CmAdmin
34
34
  class: "normal-input #{required_class}",
35
35
  disabled: cm_field.disabled,
36
36
  value: value,
37
- placeholder: "Enter #{cm_field.field_name.to_s.downcase.gsub('_', ' ')}"
37
+ placeholder: cm_field.placeholder
38
38
  end
39
39
 
40
40
  def cm_single_select_field(form_obj, cm_field, value, required_class, target_action)
41
41
  form_obj.select cm_field.field_name, options_for_select(select_collection_value(form_obj.object, cm_field), form_obj.object.send(cm_field.field_name)),
42
- { include_blank: cm_field.placeholder.to_s.presence || "Select #{cm_field.field_name.to_s.humanize(capitalize: false)}}" },
42
+ { include_blank: cm_field.placeholder },
43
43
  class: "normal-input #{required_class} select-2",
44
44
  disabled: cm_field.disabled,
45
45
  data: {
@@ -53,7 +53,7 @@ module CmAdmin
53
53
  def cm_multi_select_field(form_obj, cm_field, value, required_class, target_action)
54
54
  form_obj.select cm_field.field_name,
55
55
  options_for_select(select_collection_value(form_obj.object, cm_field), form_obj.object.send(cm_field.field_name)),
56
- { include_blank: cm_field.placeholder.to_s.presence || "Select #{cm_field.field_name.to_s.humanize(capitalize: false)}" },
56
+ { include_blank: cm_field.placeholder },
57
57
  class: "normal-input #{required_class} select-2",
58
58
  disabled: cm_field.disabled, multiple: true
59
59
  end
@@ -63,7 +63,7 @@ module CmAdmin
63
63
  class: "normal-input #{required_class}",
64
64
  disabled: cm_field.disabled,
65
65
  value: value&.strftime('%d-%m-%Y'),
66
- placeholder: "Enter #{cm_field.field_name.to_s.downcase.gsub('_', ' ')}",
66
+ placeholder: cm_field.placeholder,
67
67
  data: { behaviour: 'date-only' }
68
68
  end
69
69
 
@@ -72,20 +72,20 @@ module CmAdmin
72
72
  class: "normal-input #{required_class}",
73
73
  disabled: cm_field.disabled,
74
74
  value: value,
75
- placeholder: "Enter #{cm_field.field_name.to_s.downcase.gsub('_', ' ')}",
75
+ placeholder: cm_field.placeholder,
76
76
  data: { behaviour: 'date-time' }
77
77
  end
78
78
 
79
79
  def cm_text_field(form_obj, cm_field, value, required_class, _target_action)
80
80
  form_obj.text_area cm_field.field_name,
81
81
  class: "normal-input #{required_class}",
82
- placeholder: "Enter #{cm_field.field_name.to_s.downcase.gsub('_', ' ')}"
82
+ placeholder: cm_field.placeholder
83
83
  end
84
84
 
85
85
  def cm_rich_text_field(form_obj, cm_field, value, required_class, _target_action)
86
86
  form_obj.rich_text_area cm_field.field_name,
87
87
  class: "normal-input #{required_class}",
88
- placeholder: "Enter #{cm_field.field_name.to_s.downcase.gsub('_', ' ')}"
88
+ placeholder: cm_field.placeholder
89
89
  end
90
90
 
91
91
  def cm_single_file_upload_field(form_obj, cm_field, _value, required_class, _target_action)
@@ -114,16 +114,16 @@ module CmAdmin
114
114
  # helper_method argument will accept a method where value can be passed.
115
115
  def select_collection_value(object, cm_field)
116
116
  if cm_field.helper_method
117
- collection = send(cm_field.helper_method, object, cm_field.field_name)
117
+ send(cm_field.helper_method, object, cm_field.field_name)
118
118
  elsif cm_field.collection
119
- collection = cm_field.collection
119
+ cm_field.collection
120
120
  else
121
- collection = []
121
+ []
122
122
  end
123
123
  end
124
124
 
125
125
  def format_check_box_options(value, form_obj, cm_field, required_class, target_action)
126
- if value.class == Array
126
+ if value.instance_of?(Array)
127
127
  format_check_box_array(value, form_obj, cm_field, required_class, target_action)
128
128
  else
129
129
  form_obj.check_box cm_field.field_name,
@@ -131,7 +131,7 @@ module CmAdmin
131
131
  class: "normal-input cm-checkbox #{required_class} #{target_action.present? ? 'linked-field-request' : ''}",
132
132
  disabled: cm_field.disabled,
133
133
  data: {
134
- field_name: cm_field.field_name,
134
+ field_name: cm_field.field_name,
135
135
  target_action: target_action&.name,
136
136
  target_url: target_action&.name ? cm_admin.send("#{@model.name.underscore}_#{target_action&.name}_path") : ''
137
137
  }
@@ -169,7 +169,6 @@ module CmAdmin
169
169
  end
170
170
  end
171
171
 
172
-
173
172
  def format_radio_button_options(options, form_obj)
174
173
  content_tag :div do
175
174
  options.each do |val, key|
@@ -177,7 +176,7 @@ module CmAdmin
177
176
  end
178
177
  end
179
178
  end
180
-
179
+
181
180
  def format_radio_option(val, key, form_obj)
182
181
  content_tag :div, class: 'cm-radio-section' do
183
182
  concat format_radio_button(val, form_obj)
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: 1.1.7
4
+ version: 1.1.8
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: 2023-08-04 00:00:00.000000000 Z
13
+ date: 2023-08-11 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rails
@@ -224,6 +224,7 @@ files:
224
224
  - app/assets/stylesheets/cm_admin/dependency/bootstrap.min.css
225
225
  - app/assets/stylesheets/cm_admin/dependency/flatpickr.min.css
226
226
  - app/assets/stylesheets/cm_admin/dependency/fontawesome.all.css
227
+ - app/assets/stylesheets/cm_admin/dependency/jquery-jgrowl.min.css
227
228
  - app/assets/stylesheets/cm_admin/helpers/_mixins.scss
228
229
  - app/assets/stylesheets/cm_admin/helpers/_variable.scss
229
230
  - app/assets/stylesheets/cm_admin/helpers/index.scss
@@ -310,6 +311,7 @@ files:
310
311
  - lib/cm_admin/models/section.rb
311
312
  - lib/cm_admin/models/tab.rb
312
313
  - lib/cm_admin/models/utils/associations.rb
314
+ - lib/cm_admin/models/utils/helpers.rb
313
315
  - lib/cm_admin/utils.rb
314
316
  - lib/cm_admin/version.rb
315
317
  - lib/cm_admin/version_manager.rb