cm-admin 1.5.33 → 1.5.35
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/app/assets/stylesheets/cm_admin/base/auth.scss +0 -2
- data/app/assets/stylesheets/cm_admin/base/cardView.scss +0 -3
- data/app/assets/stylesheets/cm_admin/base/comments.scss +0 -3
- data/app/assets/stylesheets/cm_admin/base/common.scss +0 -2
- data/app/assets/stylesheets/cm_admin/base/filters.scss +2 -6
- data/app/assets/stylesheets/cm_admin/base/form.scss +0 -3
- data/app/assets/stylesheets/cm_admin/base/kanban.scss +0 -3
- data/app/assets/stylesheets/cm_admin/base/navbar.scss +0 -3
- data/app/assets/stylesheets/cm_admin/base/quicksearch.scss +0 -3
- data/app/assets/stylesheets/cm_admin/base/scaffold.scss +0 -2
- data/app/assets/stylesheets/cm_admin/base/show.scss +5 -4
- data/app/assets/stylesheets/cm_admin/base/sidebar.scss +0 -2
- data/app/assets/stylesheets/cm_admin/base/table.scss +5 -4
- data/app/assets/stylesheets/cm_admin/cm_admin.css.scss +22 -34
- data/app/assets/stylesheets/cm_admin/components/_accordion.scss +0 -1
- data/app/assets/stylesheets/cm_admin/components/_alerts.scss +0 -1
- data/app/assets/stylesheets/cm_admin/components/_buttons.scss +0 -1
- data/app/assets/stylesheets/cm_admin/components/_status-tag.scss +0 -1
- data/app/assets/stylesheets/cm_admin/pages/history_page.scss +0 -2
- data/app/assets/stylesheets/cm_admin/pages/import_page.scss +10 -4
- data/app/assets/stylesheets/cm_admin/scaffold.scss +1 -2
- data/app/views/cm_admin/main/_card.html.slim +1 -1
- data/app/views/cm_admin/main/_nested_fields.html.slim +4 -3
- data/app/views/cm_admin/main/_nested_table_form.html.slim +2 -1
- data/app/views/cm_admin/main/_nested_table_section.html.slim +2 -1
- data/app/views/cm_admin/main/_table.html.slim +1 -1
- data/app/views/cm_admin/main/_top_navbar.html.slim +1 -1
- data/lib/cm_admin/model.rb +14 -4
- data/lib/cm_admin/models/field.rb +1 -0
- data/lib/cm_admin/models/filter.rb +1 -1
- data/lib/cm_admin/models/form_field.rb +1 -1
- data/lib/cm_admin/version.rb +1 -1
- data/lib/cm_admin/view_helpers/field_display_helper.rb +2 -2
- data/lib/cm_admin/view_helpers/filter_helper.rb +46 -33
- data/lib/cm_admin/view_helpers/form_helper.rb +5 -2
- data/lib/cm_admin/view_helpers/navigation_helper.rb +21 -21
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e040c173b4dc72d86d645df5fd314f10cee91457e38589ebe85cc6ce4d15936a
|
4
|
+
data.tar.gz: 0d423f9be6c3b5b99f44ff8618b11aaf67032404875a251eb346b10edf0c5389
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f1c2c45019460ba876581ff9bfd28a56e94192212718610f37ccc6d7f13d88294f9fb72c85e41a074c68c3bc4b1eea645867a7d80228ed11bd68a1375a4dcc1c
|
7
|
+
data.tar.gz: 516878f3063839d82fc0393dd6b66abd3e250671508f0d738d4689249e42f3ccce227e21e197cccb59c0dbad4875739ff6c483676bc66fd1d2528700cf8ebed1
|
data/Gemfile.lock
CHANGED
@@ -1,5 +1,3 @@
|
|
1
|
-
@import "../helpers/index.scss";
|
2
|
-
|
3
1
|
.cm-filters-v2 {
|
4
2
|
padding: 16px 24px;
|
5
3
|
background-color: transparent;
|
@@ -78,8 +76,7 @@
|
|
78
76
|
&:focus {
|
79
77
|
border-color: $brand-color !important;
|
80
78
|
outline: 0 !important;
|
81
|
-
box-shadow:
|
82
|
-
inset 0 1px 1px rgba(0, 0, 0, 0.075),
|
79
|
+
box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075),
|
83
80
|
0 0 8px rgba(102, 175, 233, 0.6) !important;
|
84
81
|
}
|
85
82
|
}
|
@@ -97,8 +94,7 @@
|
|
97
94
|
&:focus {
|
98
95
|
border-color: $brand-color;
|
99
96
|
outline: 0;
|
100
|
-
box-shadow:
|
101
|
-
inset 0 1px 1px rgba(0, 0, 0, 0.075),
|
97
|
+
box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075),
|
102
98
|
0 0 8px rgba(102, 175, 233, 0.6);
|
103
99
|
}
|
104
100
|
.select2-selection__rendered {
|
@@ -1,6 +1,3 @@
|
|
1
|
-
@import "../helpers/index.scss";
|
2
|
-
@import "../dependency/bootstrap/scss/bootstrap";
|
3
|
-
|
4
1
|
.show-page {
|
5
2
|
height: 100vh;
|
6
3
|
overflow: auto;
|
@@ -40,7 +37,11 @@
|
|
40
37
|
margin-bottom: 0;
|
41
38
|
}
|
42
39
|
&__title {
|
43
|
-
@include font(
|
40
|
+
@include font(
|
41
|
+
$size: $t4-text,
|
42
|
+
$color: $primary-text-clr,
|
43
|
+
$weight: 600
|
44
|
+
);
|
44
45
|
}
|
45
46
|
&__label {
|
46
47
|
@include font($size: $t4-text, $color: $ink-lighter-clr);
|
@@ -1,6 +1,3 @@
|
|
1
|
-
@import "../helpers/index.scss";
|
2
|
-
@import "../dependency/bootstrap/scss/bootstrap";
|
3
|
-
|
4
1
|
.cm-index-page {
|
5
2
|
background-color: $white;
|
6
3
|
overflow: auto;
|
@@ -115,7 +112,11 @@
|
|
115
112
|
.popup-card {
|
116
113
|
.popup-option {
|
117
114
|
a {
|
118
|
-
@include font(
|
115
|
+
@include font(
|
116
|
+
$size: $t4-text,
|
117
|
+
$color: $ink-regular-clr,
|
118
|
+
$weight: 500
|
119
|
+
);
|
119
120
|
line-height: 22px;
|
120
121
|
}
|
121
122
|
}
|
@@ -1,34 +1,22 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
*= require 'cm_admin/base/filters'
|
24
|
-
*= require 'cm_admin/base/comments'
|
25
|
-
*= require 'cm_admin/base/common'
|
26
|
-
*= require 'cm_admin/base/cardView'
|
27
|
-
*= require 'cm_admin/base/kanban'
|
28
|
-
*= require 'cm_admin/components/index'
|
29
|
-
*= require 'cm_admin/dependency/flatpickr.min'
|
30
|
-
*= require 'cm_admin/dependency/fontawesome.all'
|
31
|
-
*= require 'cm_admin/dependency/jquery-jgrowl.min'
|
32
|
-
*= require 'cm_admin/scaffold'
|
33
|
-
*= require_self
|
34
|
-
*/
|
1
|
+
@import "./dependency/bootstrap/scss/bootstrap";
|
2
|
+
@import "./helpers/index.scss";
|
3
|
+
@import "./pages/import_page";
|
4
|
+
@import "./pages/history_page";
|
5
|
+
@import "./base/table";
|
6
|
+
@import "./base/navbar";
|
7
|
+
@import "./base/sidebar";
|
8
|
+
@import "./base/show";
|
9
|
+
@import "./base/form";
|
10
|
+
@import "./base/quicksearch";
|
11
|
+
@import "./base/scaffold";
|
12
|
+
@import "./base/auth";
|
13
|
+
@import "./base/filters";
|
14
|
+
@import "./base/comments";
|
15
|
+
@import "./base/common";
|
16
|
+
@import "./base/cardView";
|
17
|
+
@import "./base/kanban";
|
18
|
+
@import "./components/index";
|
19
|
+
@import "./dependency/flatpickr.min";
|
20
|
+
@import "./dependency/fontawesome.all";
|
21
|
+
@import "./dependency/jquery-jgrowl.min";
|
22
|
+
@import "./scaffold";
|
@@ -1,5 +1,3 @@
|
|
1
|
-
@import "../helpers/index.scss";
|
2
|
-
|
3
1
|
@function size($size) {
|
4
2
|
@return map-get($font-size, $size);
|
5
3
|
}
|
@@ -42,7 +40,11 @@
|
|
42
40
|
background: $green-lightest-clr;
|
43
41
|
border-radius: $radius-4;
|
44
42
|
.success-title {
|
45
|
-
@include font(
|
43
|
+
@include font(
|
44
|
+
$size: size(12),
|
45
|
+
$color: $green-regular-clr,
|
46
|
+
$weight: bold
|
47
|
+
);
|
46
48
|
font-family: $primary-font;
|
47
49
|
margin-bottom: 16px;
|
48
50
|
text-transform: uppercase;
|
@@ -82,7 +84,11 @@
|
|
82
84
|
background: $blue-lightest-clr;
|
83
85
|
border-radius: $radius-4;
|
84
86
|
.note-title {
|
85
|
-
@include font(
|
87
|
+
@include font(
|
88
|
+
$size: size(12),
|
89
|
+
$color: $blue-regular-clr,
|
90
|
+
$weight: bold
|
91
|
+
);
|
86
92
|
font-family: $primary-font;
|
87
93
|
margin-bottom: 16px;
|
88
94
|
text-transform: uppercase;
|
@@ -3,7 +3,7 @@
|
|
3
3
|
.jGrowl {
|
4
4
|
color: $ink-regular-clr !important;
|
5
5
|
font-size: $t4-text !important;
|
6
|
-
.success{
|
6
|
+
.success {
|
7
7
|
background-color: $green-light-clr !important;
|
8
8
|
}
|
9
9
|
.notice {
|
@@ -12,7 +12,6 @@
|
|
12
12
|
.error {
|
13
13
|
background-color: $red-light-clr !important;
|
14
14
|
}
|
15
|
-
|
16
15
|
}
|
17
16
|
|
18
17
|
.nested-field-wrapper {
|
@@ -1,7 +1,7 @@
|
|
1
1
|
// Card view right now is application specific, so card partial will be overwritten in the application
|
2
2
|
|
3
3
|
.table-top
|
4
|
-
p.table-top__total-count = "#{humanized_ar_collection_count(@ar_object.pagy.count, @model.
|
4
|
+
p.table-top__total-count = "#{humanized_ar_collection_count(@ar_object.pagy.count, @model.table_name)}"
|
5
5
|
.table-top__column-action
|
6
6
|
.btn-group[role="group" aria-label="Basic example"]
|
7
7
|
a.btn.btn-ghost href="#{cm_admin.send("#{@model.name.underscore}_index_path")}?page=#{params[:page] || 1}"
|
@@ -19,10 +19,11 @@
|
|
19
19
|
div
|
20
20
|
- nested_table_field.fields.each do |field|
|
21
21
|
.form-field
|
22
|
-
.
|
23
|
-
|
22
|
+
- if field.label
|
23
|
+
.field-label-wrapper
|
24
|
+
label.field-label = field.field_name.to_s.titleize
|
24
25
|
.field-input-wrapper
|
25
26
|
= input_field_for_column(f, field)
|
26
27
|
- if nested_table_field.associated_fields.present?
|
27
28
|
- nested_table_field.associated_fields.each do |associated_nested_field|
|
28
|
-
= render partial: '/cm_admin/main/nested_table_form', locals: { f: f, nested_table_field: associated_nested_field }
|
29
|
+
= render partial: '/cm_admin/main/nested_table_form', locals: { f: f, nested_table_field: associated_nested_field }
|
@@ -12,7 +12,8 @@
|
|
12
12
|
|
|
13
13
|
- nested_table_field.fields.each do |field|
|
14
14
|
th data-field-type="#{field.input_type}"
|
15
|
-
|
15
|
+
- if field.label
|
16
|
+
= field.label.to_s.titleize || field.field_name.to_s.titleize
|
16
17
|
tbody class="insert-cocoon-position-#{uniq_no}"
|
17
18
|
= f.fields_for table_name do |record|
|
18
19
|
- if record.object.persisted? || @ar_object.errors.present?
|
@@ -9,7 +9,8 @@
|
|
9
9
|
tr
|
10
10
|
- nested_field.fields.each do |field|
|
11
11
|
th scope="col" data-field-type="#{field.field_type}"
|
12
|
-
|
12
|
+
- if field.label
|
13
|
+
= field.label || field.field_name.to_s.titleize
|
13
14
|
tbody
|
14
15
|
- associated_records.each do |record|
|
15
16
|
tr
|
@@ -1,5 +1,5 @@
|
|
1
1
|
.table-top
|
2
|
-
p.table-top__total-count = "#{humanized_ar_collection_count(@ar_object.pagy.count, @model.
|
2
|
+
p.table-top__total-count = "#{humanized_ar_collection_count(@ar_object.pagy.count, @model.table_name)}"
|
3
3
|
.table-top__column-action
|
4
4
|
- if @current_action.view_type == :card_view
|
5
5
|
.btn-group[role="group" aria-label="Card Toggle"]
|
@@ -2,7 +2,7 @@
|
|
2
2
|
.entity-header__info
|
3
3
|
- if cm_admin.method_defined?(:"#{@model.name.underscore}_index_path") && (@model.current_action.name == 'show'|| @model.current_action.name == 'history' || @model.current_action.layout_type.present?)
|
4
4
|
.breadcrumb
|
5
|
-
= link_to "#{@model.
|
5
|
+
= link_to "#{@model.model_name.titleize.pluralize} /", cm_admin.send(:"#{@model.name.underscore}_index_path"), class: 'text-reset'
|
6
6
|
h4 = action_title
|
7
7
|
/ - if @model.current_action.page_description
|
8
8
|
/ p.mb-0.text-body-secondary = @model.current_action.page_description
|
data/lib/cm_admin/model.rb
CHANGED
@@ -29,7 +29,7 @@ module CmAdmin
|
|
29
29
|
include CmAdmin::Engine.routes.url_helpers
|
30
30
|
|
31
31
|
attr_accessor :available_actions, :actions_set, :available_fields, :additional_permitted_fields,
|
32
|
-
|
32
|
+
:current_action, :params, :filters, :available_tabs, :icon_name, :bulk_actions, :display_name
|
33
33
|
attr_reader :name, :ar_model, :is_visible_on_sidebar, :importer
|
34
34
|
|
35
35
|
def initialize(entity, &block)
|
@@ -100,10 +100,22 @@ module CmAdmin
|
|
100
100
|
@icon_name = name
|
101
101
|
end
|
102
102
|
|
103
|
+
def set_display_name(name)
|
104
|
+
@display_name = name
|
105
|
+
end
|
106
|
+
|
103
107
|
def permit_additional_fields(fields=[])
|
104
108
|
@additional_permitted_fields = fields
|
105
109
|
end
|
106
110
|
|
111
|
+
def table_name
|
112
|
+
@display_name.present? ? @display_name : @ar_model.table_name
|
113
|
+
end
|
114
|
+
|
115
|
+
def model_name
|
116
|
+
@display_name.present? ? @display_name : @name
|
117
|
+
end
|
118
|
+
|
107
119
|
# Shared between export controller and resource controller
|
108
120
|
def filter_params(params)
|
109
121
|
# OPTIMIZE: Need to check if we can permit the filter_params in a better way
|
@@ -126,7 +138,6 @@ module CmAdmin
|
|
126
138
|
|
127
139
|
$available_actions.each do |action|
|
128
140
|
define_method action.name.to_sym do
|
129
|
-
|
130
141
|
# controller_name & action_name from ActionController
|
131
142
|
@model = CmAdmin::Model.find_by(name: controller_name.classify)
|
132
143
|
@model.params = params
|
@@ -140,6 +151,7 @@ module CmAdmin
|
|
140
151
|
def pundit_user
|
141
152
|
Current.user
|
142
153
|
end
|
154
|
+
|
143
155
|
private
|
144
156
|
|
145
157
|
def user_not_authorized
|
@@ -149,7 +161,5 @@ module CmAdmin
|
|
149
161
|
end if $available_actions.present?
|
150
162
|
CmAdmin.const_set "#{@name}Controller", klass
|
151
163
|
end
|
152
|
-
|
153
|
-
|
154
164
|
end
|
155
165
|
end
|
@@ -5,7 +5,7 @@ module CmAdmin
|
|
5
5
|
class Filter
|
6
6
|
include Utils::Helpers
|
7
7
|
|
8
|
-
attr_accessor :db_column_name, :filter_type, :placeholder, :collection, :filter_with
|
8
|
+
attr_accessor :db_column_name, :filter_type, :placeholder, :collection, :filter_with, :helper_method
|
9
9
|
|
10
10
|
VALID_FILTER_TYPES = Set[:date, :multi_select, :range, :search, :single_select].freeze
|
11
11
|
|
@@ -6,7 +6,7 @@ module CmAdmin
|
|
6
6
|
include Utils::Helpers
|
7
7
|
|
8
8
|
attr_accessor :field_name, :label, :header, :input_type, :collection, :disabled, :helper_method,
|
9
|
-
:placeholder, :display_if, :html_attrs, :target, :col_size, :ajax_url
|
9
|
+
:placeholder, :display_if, :html_attrs, :target, :col_size, :ajax_url, :helper_text
|
10
10
|
|
11
11
|
VALID_INPUT_TYPES = %i[
|
12
12
|
integer decimal string single_select multi_select date date_time text
|
data/lib/cm_admin/version.rb
CHANGED
@@ -4,7 +4,7 @@ module CmAdmin
|
|
4
4
|
def show_field(ar_object, field)
|
5
5
|
return unless field.display_if.call(ar_object)
|
6
6
|
content_tag(:div, class: "card-info") do
|
7
|
-
concat show_field_label(ar_object, field)
|
7
|
+
concat show_field_label(ar_object, field) if field.label
|
8
8
|
concat value_with_prefix_and_suffix(ar_object, field)
|
9
9
|
end
|
10
10
|
end
|
@@ -17,7 +17,7 @@ module CmAdmin
|
|
17
17
|
|
18
18
|
content_tag(:div, class: "col-#{col_size}") do
|
19
19
|
content_tag(:div, class: "card-info") do
|
20
|
-
concat show_field_label(ar_object, field)
|
20
|
+
concat show_field_label(ar_object, field) if field.label
|
21
21
|
concat value_with_prefix_and_suffix(ar_object, field)
|
22
22
|
end
|
23
23
|
end
|
@@ -1,10 +1,9 @@
|
|
1
1
|
module CmAdmin
|
2
2
|
module ViewHelpers
|
3
3
|
module FilterHelper
|
4
|
-
|
5
4
|
def generate_filters(filters)
|
6
|
-
search_filter = filters.select{ |x| x.filter_type.eql?(:search) }.last
|
7
|
-
other_filters = filters.reject{ |x| x.filter_type.eql?(:search) }
|
5
|
+
search_filter = filters.select { |x| x.filter_type.eql?(:search) }.last
|
6
|
+
other_filters = filters.reject { |x| x.filter_type.eql?(:search) }
|
8
7
|
concat(content_tag(:div, class: 'cm-filters-v2') do
|
9
8
|
concat(content_tag(:div, class: 'cm-filters-v2__inner') do
|
10
9
|
concat add_search_filter(search_filter) if search_filter
|
@@ -15,11 +14,11 @@ module CmAdmin
|
|
15
14
|
concat clear_filters
|
16
15
|
end)
|
17
16
|
end)
|
18
|
-
|
17
|
+
nil
|
19
18
|
end
|
20
19
|
|
21
20
|
def add_filters_dropdown(filters)
|
22
|
-
concat(content_tag(:button, class: 'dropdown btn-ghost', data: {bs_toggle: 'dropdown'}) do
|
21
|
+
concat(content_tag(:button, class: 'dropdown btn-ghost', data: { bs_toggle: 'dropdown' }) do
|
23
22
|
concat tag.i(class: 'fas fa-filter')
|
24
23
|
concat tag.span 'Filter'
|
25
24
|
end)
|
@@ -28,11 +27,11 @@ module CmAdmin
|
|
28
27
|
concat(content_tag(:div, class: 'popup-base') do
|
29
28
|
concat(content_tag(:div, class: 'popup-inner') do
|
30
29
|
concat(content_tag(:div, class: 'search-area') do
|
31
|
-
concat tag.input placeholder: 'Search for filter', data: {behaviour: 'dropdown-filter-search'}
|
30
|
+
concat tag.input placeholder: 'Search for filter', data: { behaviour: 'dropdown-filter-search' }
|
32
31
|
end)
|
33
32
|
concat(content_tag(:div, class: 'list-area') do
|
34
33
|
filters.each do |filter|
|
35
|
-
concat(content_tag(:div, class: 'pointer list-item', data: {behaviour: 'filter-option', filter_type: "#{filter.filter_type}", db_column: "#{filter.db_column_name}"}) do
|
34
|
+
concat(content_tag(:div, class: 'pointer list-item', data: { behaviour: 'filter-option', filter_type: "#{filter.filter_type}", db_column: "#{filter.db_column_name}" }) do
|
36
35
|
tag.span filter.placeholder.to_s.titleize
|
37
36
|
end)
|
38
37
|
end
|
@@ -40,14 +39,14 @@ module CmAdmin
|
|
40
39
|
end)
|
41
40
|
end)
|
42
41
|
end)
|
43
|
-
|
42
|
+
nil
|
44
43
|
end
|
45
44
|
|
46
45
|
def clear_filters
|
47
46
|
concat(content_tag(:div, class: "clear-btn #{params.dig(:filters) ? '' : 'hidden'}") do
|
48
47
|
tag.span 'Clear all'
|
49
48
|
end)
|
50
|
-
|
49
|
+
nil
|
51
50
|
end
|
52
51
|
|
53
52
|
def filter_ui(filters)
|
@@ -63,11 +62,11 @@ module CmAdmin
|
|
63
62
|
concat add_multi_select_filter(filter)
|
64
63
|
end
|
65
64
|
end
|
66
|
-
|
65
|
+
nil
|
67
66
|
end
|
68
67
|
|
69
68
|
def filter_chip(value, filter)
|
70
|
-
data_hash = {behaviour: 'filter-input', filter_type: "#{filter.filter_type}", db_column: "#{filter.db_column_name}"}
|
69
|
+
data_hash = { behaviour: 'filter-input', filter_type: "#{filter.filter_type}", db_column: "#{filter.db_column_name}" }
|
71
70
|
data_hash.merge!(bs_toggle: 'dropdown') if filter.filter_type.to_s.eql?('single_select')
|
72
71
|
|
73
72
|
if value && filter.filter_type.to_s.eql?('multi_select')
|
@@ -82,7 +81,7 @@ module CmAdmin
|
|
82
81
|
tag.i class: 'fa fa-times bolder'
|
83
82
|
end)
|
84
83
|
end)
|
85
|
-
|
84
|
+
nil
|
86
85
|
end
|
87
86
|
|
88
87
|
def add_search_filter(filter)
|
@@ -91,7 +90,7 @@ module CmAdmin
|
|
91
90
|
concat(content_tag(:span, class: 'input-group-text') do
|
92
91
|
tag.i class: 'fa fa-search'
|
93
92
|
end)
|
94
|
-
concat tag.input type: 'string', class: 'form-control', value: "#{params.dig(:filters, :search)}", placeholder: "#{filter.placeholder}", data: {behaviour: 'input-search'}
|
93
|
+
concat tag.input type: 'string', class: 'form-control', value: "#{params.dig(:filters, :search)}", placeholder: "#{filter.placeholder}", data: { behaviour: 'input-search' }
|
95
94
|
end)
|
96
95
|
end
|
97
96
|
end
|
@@ -102,11 +101,11 @@ module CmAdmin
|
|
102
101
|
concat filter_chip(value, filter)
|
103
102
|
|
104
103
|
concat(content_tag(:div, class: 'position-absolute mt-2 range-container hidden') do
|
105
|
-
concat tag.input type: 'number', min: '0', step: '1', class: 'range-item', value: "#{value ? value.split(' to ')[0] : ''}", placeholder: 'From', data: {behaviour: 'filter', filter_type: "#{filter.filter_type}", db_column: "#{filter.db_column_name}"}
|
106
|
-
concat tag.input type: 'number', min: '0', step: '1', class: 'range-item', value: "#{value ? value.split(' to ')[1] : ''}", placeholder: 'To', data: {behaviour: 'filter', filter_type: "#{filter.filter_type}", db_column: "#{filter.db_column_name}"}
|
104
|
+
concat tag.input type: 'number', min: '0', step: '1', class: 'range-item', value: "#{value ? value.split(' to ')[0] : ''}", placeholder: 'From', data: { behaviour: 'filter', filter_type: "#{filter.filter_type}", db_column: "#{filter.db_column_name}" }
|
105
|
+
concat tag.input type: 'number', min: '0', step: '1', class: 'range-item', value: "#{value ? value.split(' to ')[1] : ''}", placeholder: 'To', data: { behaviour: 'filter', filter_type: "#{filter.filter_type}", db_column: "#{filter.db_column_name}" }
|
107
106
|
end)
|
108
107
|
end)
|
109
|
-
|
108
|
+
nil
|
110
109
|
end
|
111
110
|
|
112
111
|
def add_date_filter(filter)
|
@@ -115,37 +114,44 @@ module CmAdmin
|
|
115
114
|
concat filter_chip(value, filter)
|
116
115
|
|
117
116
|
concat(content_tag(:div, class: 'date-filter-wrapper w-100') do
|
118
|
-
concat tag.input class: 'w-100 pb-1', value: "#{value
|
117
|
+
concat tag.input class: 'w-100 pb-1', value: "#{value || ''}", data: { behaviour: 'filter', filter_type: "#{filter.filter_type}", db_column: "#{filter.db_column_name}" }
|
119
118
|
end)
|
120
119
|
end)
|
121
|
-
|
120
|
+
nil
|
122
121
|
end
|
123
122
|
|
124
123
|
def add_single_select_filter(filter)
|
125
124
|
value = params.dig(:filters, :"#{filter.filter_type}", :"#{filter.db_column_name}")
|
125
|
+
select_options = if filter.helper_method
|
126
|
+
send(filter.helper_method)
|
127
|
+
elsif filter.collection
|
128
|
+
filter.collection
|
129
|
+
else
|
130
|
+
[]
|
131
|
+
end
|
126
132
|
concat(content_tag(:div, class: "position-relative me-3 #{value ? '' : 'hidden'}") do
|
127
|
-
if value &&
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
133
|
+
selected_value_text = if value && select_options[0].class == Array
|
134
|
+
select_options.map { |collection| collection[0] if collection[1].to_s.eql?(value) }.compact.join(', ')
|
135
|
+
else
|
136
|
+
value
|
137
|
+
end
|
132
138
|
concat filter_chip(selected_value_text, filter)
|
133
139
|
|
134
140
|
concat(content_tag(:div, class: 'dropdown-menu dropdown-popup') do
|
135
141
|
concat(content_tag(:div, class: 'popup-base') do
|
136
142
|
concat(content_tag(:div, class: 'popup-inner') do
|
137
143
|
concat(content_tag(:div, class: 'search-area') do
|
138
|
-
concat tag.input placeholder: "#{filter.placeholder}", data: {behaviour: 'dropdown-filter-search'}
|
144
|
+
concat tag.input placeholder: "#{filter.placeholder}", data: { behaviour: 'dropdown-filter-search' }
|
139
145
|
end)
|
140
146
|
concat(content_tag(:div, class: 'list-area') do
|
141
|
-
|
147
|
+
select_options.each do |val|
|
142
148
|
if val.class.eql?(Array)
|
143
149
|
filter_value = val[1]
|
144
150
|
filter_text = val[0]
|
145
151
|
elsif val.class.eql?(String)
|
146
152
|
filter_value = filter_text = val
|
147
153
|
end
|
148
|
-
concat(content_tag(:div, class: "pointer list-item #{
|
154
|
+
concat(content_tag(:div, class: "pointer list-item #{value.present? && value.eql?(filter_value.to_s) ? 'selected' : ''}", data: { behaviour: 'select-option', filter_type: "#{filter.filter_type}", db_column: "#{filter.db_column_name}", value: filter_value }) do
|
149
155
|
concat tag.span filter_text.to_s
|
150
156
|
end)
|
151
157
|
end
|
@@ -154,14 +160,21 @@ module CmAdmin
|
|
154
160
|
end)
|
155
161
|
end)
|
156
162
|
end)
|
157
|
-
|
163
|
+
nil
|
158
164
|
end
|
159
165
|
|
160
166
|
def add_multi_select_filter(filter)
|
161
167
|
value = params.dig(:filters, :"#{filter.filter_type}", :"#{filter.db_column_name}")
|
162
|
-
|
168
|
+
select_options = if filter.helper_method
|
169
|
+
send(filter.helper_method)
|
170
|
+
elsif filter.collection
|
171
|
+
filter.collection
|
172
|
+
else
|
173
|
+
[]
|
174
|
+
end
|
175
|
+
if value && select_options[0].class == Array
|
163
176
|
value_mapped_text = []
|
164
|
-
|
177
|
+
select_options.each do |array|
|
165
178
|
value_mapped_text << array[0].titleize if value.include?(array[1].to_s)
|
166
179
|
end
|
167
180
|
else
|
@@ -185,17 +198,17 @@ module CmAdmin
|
|
185
198
|
end)
|
186
199
|
end
|
187
200
|
end
|
188
|
-
concat tag.input placeholder: "#{filter.placeholder}", data: {behaviour: 'dropdown-filter-search'}
|
201
|
+
concat tag.input placeholder: "#{filter.placeholder}", data: { behaviour: 'dropdown-filter-search' }
|
189
202
|
end)
|
190
203
|
concat(content_tag(:div, class: 'list-area') do
|
191
|
-
|
204
|
+
select_options.each do |val|
|
192
205
|
if val.class.eql?(Array)
|
193
206
|
filter_value = val[1]
|
194
207
|
filter_text = val[0]
|
195
208
|
elsif val.class.eql?(String)
|
196
209
|
filter_value = filter_text = val
|
197
210
|
end
|
198
|
-
concat(content_tag(:div, class: "pointer list-item #{
|
211
|
+
concat(content_tag(:div, class: "pointer list-item #{value && (value.eql?(val) || value.include?(filter_value.to_s)) ? 'selected' : ''}", data: { behaviour: 'select-option', filter_type: "#{filter.filter_type}", db_column: "#{filter.db_column_name}", value: filter_value }) do
|
199
212
|
concat tag.input class: 'cm-checkbox', type: 'checkbox', checked: value ? value.include?(filter_value.to_s) : false
|
200
213
|
concat tag.label filter_text.to_s.titleize, class: 'pointer'
|
201
214
|
end)
|
@@ -206,7 +219,7 @@ module CmAdmin
|
|
206
219
|
end)
|
207
220
|
end)
|
208
221
|
end)
|
209
|
-
|
222
|
+
nil
|
210
223
|
end
|
211
224
|
end
|
212
225
|
end
|
@@ -108,9 +108,12 @@ module CmAdmin
|
|
108
108
|
concat input_field_for_column(form_obj, field)
|
109
109
|
else
|
110
110
|
concat(content_tag(:div, class: "form-field #{field.disabled ? 'disabled' : ''}") do
|
111
|
-
|
112
|
-
|
111
|
+
if field.label
|
112
|
+
concat form_obj.label field.label, field.label, class: 'field-label'
|
113
|
+
concat tag.br
|
114
|
+
end
|
113
115
|
concat input_field_for_column(form_obj, field)
|
116
|
+
concat tag.small field.helper_text, class: 'form-text text-muted' if field.helper_text.present?
|
114
117
|
concat tag.p resource.errors[field.field_name].first if resource.errors[field.field_name].present?
|
115
118
|
end)
|
116
119
|
end
|
@@ -4,34 +4,34 @@ module CmAdmin
|
|
4
4
|
module NavigationHelper
|
5
5
|
include Pagy::Frontend
|
6
6
|
def navigation_links(navigation_type)
|
7
|
-
CmAdmin.config.cm_admin_models.map
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
7
|
+
CmAdmin.config.cm_admin_models.map do |model|
|
8
|
+
next unless model.is_visible_on_sidebar
|
9
|
+
|
10
|
+
path = CmAdmin::Engine.mount_path + '/' + model.name.underscore.pluralize
|
11
|
+
if policy([:cm_admin, model.name.classify.constantize]).index?
|
12
|
+
if navigation_type == 'sidebar'
|
13
|
+
content_tag(:a, href: path) do
|
14
|
+
content_tag(:div, class: 'menu-item') do
|
15
|
+
content_tag(:span, class: 'menu-icon') do
|
16
|
+
concat tag.i class: "#{model.icon_name}"
|
17
|
+
end +
|
18
|
+
model.model_name.titleize.pluralize
|
19
19
|
end
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
20
|
+
end
|
21
|
+
elsif navigation_type == 'quick_links'
|
22
|
+
content_tag(:a, href: path, class: 'visible') do
|
23
|
+
content_tag(:div, class: 'result-item') do
|
24
|
+
content_tag(:span) do
|
25
|
+
concat tag.i class: "#{model.icon_name}"
|
26
|
+
end +
|
26
27
|
content_tag(:span) do
|
27
|
-
|
28
|
+
model.model_name
|
28
29
|
end
|
29
|
-
end
|
30
30
|
end
|
31
31
|
end
|
32
32
|
end
|
33
33
|
end
|
34
|
-
|
34
|
+
end.join.html_safe
|
35
35
|
end
|
36
36
|
end
|
37
37
|
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: 1.5.
|
4
|
+
version: 1.5.35
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael
|
@@ -13,7 +13,7 @@ authors:
|
|
13
13
|
autorequire:
|
14
14
|
bindir: exe
|
15
15
|
cert_chain: []
|
16
|
-
date: 2024-07-
|
16
|
+
date: 2024-07-12 00:00:00.000000000 Z
|
17
17
|
dependencies:
|
18
18
|
- !ruby/object:Gem::Dependency
|
19
19
|
name: caxlsx_rails
|