cm-admin 1.2.0 → 1.2.1

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: 255cb085f8e8d797c77241f882c2b6dc7894878572a230158b3376df9c9aa485
4
- data.tar.gz: a4acd31793b97d16d1790ea61a24fd0a2411f756bcbd36226baea380f7b77959
3
+ metadata.gz: 86d2406a7cec46cd375fad274561e1545668f65124652803db2e533c48ba9721
4
+ data.tar.gz: 6a8aa052b4e7264822320a588a95f6aa5187c548383de450a4d287299b818601
5
5
  SHA512:
6
- metadata.gz: 69bd5e4f1753bb6d46028a604defe82dcae819e04c94482594197a984c6d6d648e04c530de0302e6714e6254df2c22bfc59a4ffad9fadfa51b64fe2e4125237b
7
- data.tar.gz: f8eb530cd2e7c41dc04bc3c653dad14a433f38f53a7641fd5ca05c881e44c2b0a0c12594bdba8fc5e78c2e4e4af5e6da68b31cb51fe0bb13ef4f2ad162c06766
6
+ metadata.gz: 79dca0f6279868346d75204aff4fa4188778530b2443f87623f0855737b9008032b4661ca82b40c857c29224a084e243d6571c5cbcdfbde84b59ead69f855df6
7
+ data.tar.gz: 0d5f9f625e5536bed4590f1ec4957bc3b9e4e028beca1be33138972755744b5c6e0f109c295e32f7cd8adfcde18b297968b9b922a5503410a19b42528ba842e9
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- cm-admin (1.2.0)
4
+ cm-admin (1.2.1)
5
5
  caxlsx_rails
6
6
  cocoon (~> 1.2.15)
7
7
  csv-importer (~> 0.8.2)
@@ -44,6 +44,11 @@
44
44
  @extend .form-control;
45
45
  }
46
46
 
47
+ //upload attachment style
48
+ .destroy-attachment {
49
+ margin-top: 4px;
50
+ }
51
+
47
52
  // Nested form styles
48
53
  .nested-field-wrapper {
49
54
  .nested-single-field {
@@ -3,7 +3,7 @@
3
3
 
4
4
  .entity-header {
5
5
  @extend .d-flex.justify-content-between.align-items-start.p-4;
6
- min-height: 109px; // Height needs to be removed once all the layouts are revamped
6
+ // min-height: 109px; // Height needs to be removed once all the layouts are revamped
7
7
  background-color: var(--bs-white);
8
8
  &__info {
9
9
  .breadcrumb {
@@ -252,58 +252,30 @@
252
252
  }
253
253
  }
254
254
 
255
- .cm-pagination {
256
- position: sticky;
255
+ .pagination-bar {
256
+ @extend .position-sticky,
257
+ .bottom-0,
258
+ .start-0,
259
+ .d-flex,
260
+ .justify-content-between,
261
+ .align-items-center,
262
+ .w-100,
263
+ .py-2,
264
+ .px-4,
265
+ .bg-white !optional;
257
266
  bottom: 0;
258
267
  left: 0;
259
- display: flex;
260
- justify-content: space-between;
261
- align-items: center;
262
- width: 100%;
263
- padding: 16px 24px;
264
- background-color: $white;
265
268
  border: 1px solid $grey-lighter-clr;
266
269
  box-shadow: inset 0px 1px 0px rgba(148, 151, 155, 0.3);
267
270
  z-index: 2;
268
- &__lhs {
269
- @include font($size: $t4-text, $color: $ink-lightest-clr, $weight: bold);
270
- line-height: 22px;
271
+ .count-text {
272
+ @include font($size: $t4-text, $color: var(--bs-body-color));
271
273
  }
272
- &__rhs {
273
- display: inline-flex;
274
- align-items: center;
275
- .page-move-btn {
276
- @include font($size: 10px, $color: $primary-text-clr);
277
- line-height: 12px;
278
- padding: 10px 11px;
279
- cursor: pointer;
280
- &.disabled {
281
- color: $disabled-clr;
282
- cursor: initial;
283
- pointer-events: none;
284
- }
285
- }
286
- .page-num-btn {
287
- @include font($size: $t4-text, $color: $primary-text-clr, $weight: bold);
288
- display: inline-flex;
289
- justify-content: center;
290
- align-items: center;
291
- width: 32px;
292
- height: 32px;
293
- margin: 0 8px;
294
- border-radius: 4px;
295
- cursor: pointer;
296
- &:hover {
297
- border: 1px solid $grey-light-clr;
298
- }
299
- &.active {
300
- color: $primary-text-clr;
301
- background-color: $grey-lightest-clr;
302
- border: 1px solid $grey-light-clr;
303
- border-radius: $radius-4;
304
- cursor: initial;
305
- pointer-events: none;
306
- }
274
+ .pagination-actions {
275
+ @extend .pagination;
276
+ gap: 4px;
277
+ span {
278
+ @extend .d-inline-flex;
307
279
  }
308
280
  }
309
281
  }
@@ -1,37 +1,39 @@
1
1
  @import "../helpers/index.scss";
2
2
  @import "../dependency/bootstrap/scss/bootstrap";
3
3
 
4
- // Custom style for icon btn
5
- .btn-icon {
6
- i {
7
- margin-right: 4px;
8
- }
4
+ .btn-icon-spacing {
5
+ @extend .d-inline-flex, .align-items-center, .justify-content-center;
6
+ gap: 4px;
9
7
  }
10
8
 
11
9
  // New buttons with bootstrap button styles
12
10
  .cm-admin .btn-cta {
13
- @include button-variant($primary, $primary);
14
- @extend .btn.btn-sm.btn-icon;
11
+ --bs-btn-color: var(--bs-white) !important;
12
+ --bs-btn-bg: var(--bs-primary) !important;
13
+ --bs-btn-border-color: var(--bs-primary);
14
+ --bs-btn-hover-color: var(--bs-white);
15
+ --bs-btn-hover-bg: #{shade-color($primary, 10%)};
16
+ @extend .btn, .btn-sm, .btn-icon-spacing;
15
17
  }
16
18
 
17
19
  .cm-admin .btn-primary {
18
- @extend .btn.btn-outline-primary.btn-sm.btn-icon;
20
+ @extend .btn, .btn-outline-primary, .btn-sm, .btn-icon-spacing;
19
21
  }
20
22
 
21
23
  .cm-admin .btn-secondary {
22
- @extend .btn.btn-outline-secondary.btn-sm.btn-icon;
24
+ @extend .btn, .btn-outline-secondary, .btn-sm, .btn-icon-spacing;
23
25
  }
24
26
 
25
27
  .cm-admin .btn-ghost {
26
- @extend .btn.btn-light.btn-sm.btn-icon;
28
+ @extend .btn, .btn-light, .btn-sm, .btn-icon-spacing;
27
29
  }
28
30
 
29
31
  .cm-admin .btn-danger {
30
- @extend .btn.btn-outline-danger.btn-sm.btn-icon;
32
+ @extend .btn, .btn-outline-danger, .btn-sm, .btn-icon-spacing;
31
33
  }
32
34
 
33
35
  .cm-admin .btn-link {
34
- @extend .btn.btn-link.btn-sm.btn-icon;
36
+ @extend .btn, .btn-link, .btn-sm, .btn-icon-spacing;
35
37
  text-decoration: underline;
36
38
  }
37
39
 
@@ -34,30 +34,6 @@
34
34
  }
35
35
  }
36
36
 
37
- //Search input styles
38
- .search-input {
39
- position: relative;
40
- width: 100%;
41
- padding: 5px 0 5px 38px;
42
- @include font($size: $t4-text, $color: $primary-text-clr);
43
- line-height: 22px;
44
- background-color: $white;
45
- border: 1px solid $grey-light-clr;
46
- border-radius: $radius-4;
47
- &::placeholder {
48
- color: $ink-lightest-clr;
49
- }
50
- &:focus {
51
- outline: 3px auto rgba(47, 128, 237, 0.3);
52
- }
53
- }
54
- .search-input-icon {
55
- position: absolute;
56
- top: 8px;
57
- left: 16px;
58
- @include font($size: $t4-text, $color: $ink-lightest-clr);
59
- }
60
-
61
37
  //Normal input styles
62
38
  .normal-input {
63
39
  width: 100%;
@@ -1,15 +1,43 @@
1
1
  @import "../helpers/index.scss";
2
+ @import "../dependency/bootstrap/scss/bootstrap";
2
3
 
3
4
  .status-tag {
4
- font-size: $t4-text;
5
- line-height: 22px;
6
- padding: 4px;
7
- color: $primary-text-clr;
8
- background: $grey-lighter-clr;
9
- border-radius: 2px;
10
- &.success {
11
- color: $green-regular-clr;
12
- background: $green-lightest-clr;
5
+ @extend .badge;
6
+ &.active {
7
+ background: var(--blue-100, #e7f1ff);
8
+ color: var(--blue-700, #084298);
9
+ }
10
+ &.active-one {
11
+ background: var(--Blue-100, #e7f1ff);
12
+ color: var(--Blue-700, #084298);
13
+ }
14
+ &.active-two {
15
+ background: var(--Yellow-100, #fff3cd);
16
+ color: var(--Yellow-700, #997404);
17
+ }
18
+ &.active-three {
19
+ background: var(--Orange-100, #ffe5d0);
20
+ color: var(--Orange-700, #984c0c);
21
+ }
22
+ &.active-four {
23
+ background: var(--Indigo-100, #e0cffc);
24
+ color: var(--Indigo-700, #3d0a91);
25
+ }
26
+ &.active-five {
27
+ background: var(--Cyan-100, #cff4fc);
28
+ color: var(--Cyan-700, #087990);
29
+ }
30
+ &.completed {
31
+ background: var(--green-100, #d1e7dd);
32
+ color: var(--green-700, #0f5132);
33
+ }
34
+ &.neutral {
35
+ background: var(--bs-gray-300);
36
+ color: var(--bs-gray-700);
37
+ }
38
+ &.danger {
39
+ background: var(--red-100, #f8d7da);
40
+ color: var(--red-700, #842029);
13
41
  }
14
42
  }
15
43
 
@@ -1,23 +1,23 @@
1
1
  - link = pagy_link_proc(pagy)
2
2
 
3
- nav.pagy_nav.pagination role="navigation" aria-label="pager"
3
+ nav.pagination-actions role="navigation" aria-label="pager"
4
4
 
5
5
  - if pagy.prev
6
- span ==> link.call(pagy.prev, '<', 'aria-label="previous" class="page-move-btn"')
6
+ span ==> link.call(pagy.prev, '<i class="fas fa-chevron-left"></i>'.html_safe, 'aria-label="previous" class="btn-ghost"')
7
7
  - else
8
- span ==> link.call('#', '<', 'class="page-move-btn disabled"')
8
+ span ==> link.call('#', '<i class="fas fa-chevron-left"></i>'.html_safe, 'class="btn-ghost disabled"')
9
9
 
10
10
  - pagy.series.each do |item| # series example: [1, :gap, 7, 8, "9", 10, 11, :gap, 36]
11
11
  - if item.is_a?(Integer) # page link
12
- span ==> link.call(item, item, 'class="page-num-btn"')
12
+ span ==> link.call(item, item, 'class="btn-ghost"')
13
13
 
14
14
  - elsif item.is_a?(String) # current page
15
- span ==> link.call(item, item, 'class="page-num-btn active"')
15
+ span ==> link.call(item, item, 'class="btn-ghost active"')
16
16
 
17
17
  - elsif item == :gap # page gap
18
18
  span.page.gap ==> pagy_t('pagy.nav.gap')
19
19
 
20
20
  - if pagy.next
21
- span == link.call(pagy.next, '>', 'aria-label="next" class="page-move-btn"')
21
+ span == link.call(pagy.next, '<i class="fas fa-chevron-right"></i>'.html_safe, 'aria-label="next" class="btn-ghost"')
22
22
  - else
23
- span ==> link.call('#', '>', 'class="page-move-btn disabled"')
23
+ span ==> link.call('#', '<i class="fas fa-chevron-right"></i>'.html_safe, 'class="btn-ghost disabled"')
@@ -1,46 +1,7 @@
1
- - if fields.count == 1
2
- .nested-single-field.nested-fields
3
- - fields.each do |field|
4
- .field-input
5
- = input_field_for_column(f, field)
6
- .field-remove-action
7
- - unless field.input_type == :hidden
8
- - if @reflections.select {|x| x if x.name == assoc_name}.first.macro == :has_many
9
- = link_to_remove_association "", f, class: 'fa fa-times'
10
- - else
11
- tr
12
- td.item-delete-cell
13
- - if @reflections.select {|x| x if x.name == assoc_name}.first.macro == :has_many
14
- = link_to_remove_association "", f, class: 'fa fa-trash btn-ghost'
15
- - fields.each do |field|
16
- td
17
- = input_field_for_column(f, field)
18
-
19
-
20
- / .field-remove-action
21
- / - if @reflections.select {|x| x if x.name == assoc_name}.first.macro == :has_many
22
- / .accordion-delete-btn
23
- / = link_to_remove_association "", f, class: 'fa fa-trash btn-ghost'
24
- / - fields.each do |field|
25
- / .form-field
26
- / .field-label-wrapper
27
- / label.field-label = field.field_name.to_s.titleize
28
- / .field-input-wrapper
29
- / = input_field_for_column(f, field)
30
-
31
- / .accordion-item.nested-fields
32
- / h2#headingOne.accordion-header
33
- / button.accordion-button[type="button" data-bs-toggle="collapse" data-bs-target="##{assoc_name}-#{f.object.id}" aria-expanded="true" aria-controls="collapseOne"]
34
- / | Chapter 1
35
- / .field-remove-action
36
- / - if @reflections.select {|x| x if x.name == assoc_name}.first.macro == :has_many
37
- / .accordion-delete-btn
38
- / = link_to_remove_association "", f, class: 'fa fa-trash btn-ghost'
39
- / div.accordion-collapse.collapse.show[aria-labelledby="headingOne" id="#{assoc_name}-#{f.object.id}"]
40
- / .accordion-body
41
- / - fields.each do |field|
42
- / .form-field
43
- / .field-label-wrapper
44
- / label.field-label = field.field_name.to_s.titleize
45
- / .field-input-wrapper
46
- / = input_field_for_column(f, field)
1
+ tr.nested-fields
2
+ td.item-delete-cell
3
+ - if @reflections.select {|x| x if x.name == assoc_name}.first.macro == :has_many
4
+ = link_to_remove_association "", f, class: 'fa-regular fa-trash-can btn-ghost'
5
+ - fields.each do |field|
6
+ td
7
+ = input_field_for_column(f, field)
@@ -12,8 +12,8 @@
12
12
  = field.field_name.to_s.titleize
13
13
  tbody.insert-cocoon-position
14
14
  = f.fields_for table_name do |record|
15
- - if record.object.persisted?
15
+ - if record.object.persisted? || @ar_object.errors.present?
16
16
  = render partial: '/cm_admin/main/nested_fields', locals: { f: record, assoc_name: assoc_name, section: section, fields: fields }
17
17
  - if @reflections.select {|x| x if x.name == assoc_name}.first.macro == :has_many
18
18
  .links
19
- = link_to_add_association "+ Add #{assoc_name.to_s.titleize}", f, table_name, partial: '/cm_admin/main/nested_fields', render_options: {locals: { assoc_name: assoc_name, section: section, fields: fields }}, data: { association_insertion_node: '.insert-cocoon-position', association_insertion_method: 'append' }, class: 'btn-secondary'
19
+ = link_to_add_association "+ Add #{assoc_name.to_s.titleize}", f, table_name, partial: '/cm_admin/main/nested_fields', render_options: {locals: { assoc_name: assoc_name, section: section, fields: fields }}, data: { association_insertion_node: '.insert-cocoon-position', association_insertion_method: 'append' }, class: 'btn-primary'
@@ -49,9 +49,8 @@
49
49
  - if @model
50
50
  == render partial: 'cm_admin/main/actions_dropdown', locals: { cm_model: @model, ar_object: ar_object }
51
51
 
52
- .cm-pagination
53
- .cm-pagination__lhs Showing #{@ar_object.pagy.from} to #{@ar_object.pagy.to} out of #{@ar_object.pagy.count}
54
- .cm-pagination__rhs
55
- == render partial: 'cm_admin/main/cm_pagy_nav', locals: { pagy: @ar_object.pagy }
52
+ .pagination-bar
53
+ p.count-text.m-0 Showing #{@ar_object.pagy.from} to #{@ar_object.pagy.to} out of #{@ar_object.pagy.count}
54
+ == render partial: 'cm_admin/main/cm_pagy_nav', locals: { pagy: @ar_object.pagy }
56
55
 
57
56
  / = render partial: 'cm_admin/main/member_custom_action_modal', locals: { cm_model: @model, ar_collection: @ar_object }
@@ -4,7 +4,8 @@
4
4
  .breadcrumb
5
5
  = link_to "#{@model.name.titleize.pluralize} /", cm_admin.send(:"#{@model.name.underscore}_index_path"), class: 'text-reset'
6
6
  h4 = action_title
7
- p.mb-0.text-body-secondary = action_description
7
+ - if @model.current_action.page_description
8
+ p.mb-0.text-body-secondary = @model.current_action.page_description
8
9
  .entity-header__actions
9
10
  - if @model.current_action.name == 'index'
10
11
  - if has_valid_policy(@model.name, :exportable)
@@ -1,3 +1,3 @@
1
1
  module CmAdmin
2
- VERSION = '1.2.0'
2
+ VERSION = '1.2.1'
3
3
  end
@@ -19,8 +19,9 @@ module CmAdmin
19
19
  end
20
20
 
21
21
  def add_filters_dropdown(filters)
22
- concat(content_tag(:div, class: 'dropdown add-filter-btn', data: {bs_toggle: 'dropdown'}) do
23
- tag.span '+ Add filter'
22
+ concat(content_tag(:button, class: 'dropdown btn-ghost', data: {bs_toggle: 'dropdown'}) do
23
+ concat tag.i(class: 'fas fa-filter')
24
+ concat tag.span 'Filter'
24
25
  end)
25
26
 
26
27
  concat(content_tag(:div, class: 'dropdown-menu dropdown-popup') do
@@ -86,15 +87,12 @@ module CmAdmin
86
87
 
87
88
  def add_search_filter(filter)
88
89
  tag.div class: 'filter-search mr-3' do
89
- tag.div class: 'form-field' do
90
- tag.div class: 'field-input-wrapper' do
91
- concat(content_tag(:input, class: 'search-input', value: "#{params.dig(:filters, :search)}", placeholder: "#{filter.placeholder}", data: {behaviour: 'input-search'}) do
92
- tag.span class: 'search-input-icon' do
93
- tag.i class: 'fa fa-search'
94
- end
95
- end)
96
- end
97
- end
90
+ concat(content_tag(:div, class: 'input-group input-group-sm') do
91
+ concat(content_tag(:span, class: 'input-group-text') do
92
+ tag.i class: 'fa fa-search'
93
+ end)
94
+ concat tag.input type: 'string', class: 'form-control', value: "#{params.dig(:filters, :search)}", placeholder: "#{filter.placeholder}", data: {behaviour: 'input-search'}
95
+ end)
98
96
  end
99
97
  end
100
98
 
@@ -90,14 +90,14 @@ module CmAdmin
90
90
 
91
91
  def cm_single_file_upload_field(form_obj, cm_field, _value, required_class, _target_action)
92
92
  content_tag(:div) do
93
- concat form_obj.file_field cm_field.field_name, class: "normal-input #{required_class}"
93
+ concat form_obj.file_field cm_field.field_name, class: "form-control #{required_class}"
94
94
  concat attachment_list(form_obj, cm_field, _value, required_class, _target_action)
95
95
  end
96
96
  end
97
97
 
98
98
  def cm_multi_file_upload_field(form_obj, cm_field, _value, required_class, _target_action)
99
99
  content_tag(:div) do
100
- concat form_obj.file_field cm_field.field_name, multiple: true, class: "normal-input #{required_class}"
100
+ concat form_obj.file_field cm_field.field_name, multiple: true, class: "form-control #{required_class}"
101
101
  concat attachment_list(form_obj, cm_field, _value, required_class, _target_action)
102
102
  end
103
103
  end
@@ -117,8 +117,10 @@ module CmAdmin
117
117
 
118
118
  def attachment_with_icon(attachment)
119
119
  content_tag(:div, class: 'destroy-attachment', data: { ar_id: attachment.id}) do
120
- concat content_tag(:i, '', class: 'fa-solid fa-trash-can')
121
- concat content_tag(:span, attachment.filename.to_s)
120
+ concat(content_tag(:button, '', class: 'btn-ghost') do
121
+ concat tag.i(class: 'fa-regular fa-trash-can')
122
+ end)
123
+ concat content_tag(:span, attachment.filename.to_s, class: 'btn-link')
122
124
  end
123
125
  end
124
126
 
@@ -42,6 +42,8 @@ module CmAdmin
42
42
  if entity.class == CmAdmin::Models::Row
43
43
  concat create_rows(resource, form_obj, entity)
44
44
  elsif entity.class == CmAdmin::Models::Section
45
+ next unless entity.display_if.call(form_obj.object)
46
+
45
47
  concat(content_tag(:div, class: 'row') do
46
48
  concat create_sections(resource, form_obj, entity)
47
49
  end)
@@ -53,6 +55,8 @@ module CmAdmin
53
55
  def create_rows(resource, form_obj, row)
54
56
  content_tag :div, class: 'row' do
55
57
  row.sections.each do |section|
58
+ next unless section.display_if.call(form_obj.object)
59
+
56
60
  concat create_sections(resource, form_obj, section)
57
61
  end
58
62
  end
@@ -23,25 +23,6 @@ module CmAdmin
23
23
  end
24
24
  end
25
25
 
26
- def action_description
27
- show_action = CmAdmin::Models::Action.find_by(@model, name: 'show')
28
- if @model.current_action.page_description
29
- title = @model.current_action.page_description
30
- elsif show_action.page_description
31
- title = show_action.page_description
32
- else
33
- title = "#{@model.name}"
34
- case action_name
35
- when 'index'
36
- title + " list record"
37
- when 'new'
38
- title + " new record"
39
- when 'edit'
40
- title + " edit record"
41
- end
42
- end
43
- end
44
-
45
26
  def page_url(action_name=@action.name, ar_object=nil)
46
27
  base_path = CmAdmin::Engine.mount_path + '/' + @model.name.downcase.pluralize
47
28
  case action_name
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.2.0
4
+ version: 1.2.1
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-09-21 00:00:00.000000000 Z
13
+ date: 2023-09-25 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rails