cm-admin 1.1.9 → 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 +4 -4
- data/Gemfile.lock +1 -1
- data/app/assets/javascripts/cm_admin/scaffolds.js +6 -0
- data/app/assets/javascripts/cm_admin/shared_scaffolds.js +97 -81
- data/app/assets/stylesheets/cm_admin/base/form.scss +36 -225
- data/app/assets/stylesheets/cm_admin/base/navbar.scss +2 -2
- data/app/assets/stylesheets/cm_admin/base/scaffold.scss +8 -5
- data/app/assets/stylesheets/cm_admin/base/show.scss +15 -22
- data/app/assets/stylesheets/cm_admin/base/table.scss +24 -46
- data/app/assets/stylesheets/cm_admin/components/_buttons.scss +15 -13
- data/app/assets/stylesheets/cm_admin/components/_input.scss +0 -24
- data/app/assets/stylesheets/cm_admin/components/_modal.scss +7 -30
- data/app/assets/stylesheets/cm_admin/components/_status-tag.scss +37 -9
- data/app/assets/stylesheets/cm_admin/dependency/bootstrap/scss/_accordion.scss +158 -0
- data/app/assets/stylesheets/cm_admin/dependency/bootstrap/scss/_alert.scss +68 -0
- data/app/assets/stylesheets/cm_admin/dependency/bootstrap/scss/_badge.scss +38 -0
- data/app/assets/stylesheets/cm_admin/dependency/bootstrap/scss/_breadcrumb.scss +40 -0
- data/app/assets/stylesheets/cm_admin/dependency/bootstrap/scss/_button-group.scss +142 -0
- data/app/assets/stylesheets/cm_admin/dependency/bootstrap/scss/_buttons.scss +207 -0
- data/app/assets/stylesheets/cm_admin/dependency/bootstrap/scss/_card.scss +239 -0
- data/app/assets/stylesheets/cm_admin/dependency/bootstrap/scss/_carousel.scss +244 -0
- data/app/assets/stylesheets/cm_admin/dependency/bootstrap/scss/_close.scss +63 -0
- data/app/assets/stylesheets/cm_admin/dependency/bootstrap/scss/_containers.scss +41 -0
- data/app/assets/stylesheets/cm_admin/dependency/bootstrap/scss/_dropdown.scss +250 -0
- data/app/assets/stylesheets/cm_admin/dependency/bootstrap/scss/_forms.scss +9 -0
- data/app/assets/stylesheets/cm_admin/dependency/bootstrap/scss/_functions.scss +302 -0
- data/app/assets/stylesheets/cm_admin/dependency/bootstrap/scss/_grid.scss +39 -0
- data/app/assets/stylesheets/cm_admin/dependency/bootstrap/scss/_helpers.scss +12 -0
- data/app/assets/stylesheets/cm_admin/dependency/bootstrap/scss/_images.scss +42 -0
- data/app/assets/stylesheets/cm_admin/dependency/bootstrap/scss/_list-group.scss +197 -0
- data/app/assets/stylesheets/cm_admin/dependency/bootstrap/scss/_maps.scss +174 -0
- data/app/assets/stylesheets/cm_admin/dependency/bootstrap/scss/_mixins.scss +42 -0
- data/app/assets/stylesheets/cm_admin/dependency/bootstrap/scss/_modal.scss +237 -0
- data/app/assets/stylesheets/cm_admin/dependency/bootstrap/scss/_nav.scss +197 -0
- data/app/assets/stylesheets/cm_admin/dependency/bootstrap/scss/_navbar.scss +289 -0
- data/app/assets/stylesheets/cm_admin/dependency/bootstrap/scss/_offcanvas.scss +146 -0
- data/app/assets/stylesheets/cm_admin/dependency/bootstrap/scss/_pagination.scss +109 -0
- data/app/assets/stylesheets/cm_admin/dependency/bootstrap/scss/_placeholders.scss +51 -0
- data/app/assets/stylesheets/cm_admin/dependency/bootstrap/scss/_popover.scss +196 -0
- data/app/assets/stylesheets/cm_admin/dependency/bootstrap/scss/_progress.scss +68 -0
- data/app/assets/stylesheets/cm_admin/dependency/bootstrap/scss/_reboot.scss +610 -0
- data/app/assets/stylesheets/cm_admin/dependency/bootstrap/scss/_root.scss +184 -0
- data/app/assets/stylesheets/cm_admin/dependency/bootstrap/scss/_spinners.scss +85 -0
- data/app/assets/stylesheets/cm_admin/dependency/bootstrap/scss/_tables.scss +171 -0
- data/app/assets/stylesheets/cm_admin/dependency/bootstrap/scss/_toasts.scss +73 -0
- data/app/assets/stylesheets/cm_admin/dependency/bootstrap/scss/_tooltip.scss +119 -0
- data/app/assets/stylesheets/cm_admin/dependency/bootstrap/scss/_transitions.scss +27 -0
- data/app/assets/stylesheets/cm_admin/dependency/bootstrap/scss/_type.scss +106 -0
- data/app/assets/stylesheets/cm_admin/dependency/bootstrap/scss/_utilities.scss +806 -0
- data/app/assets/stylesheets/cm_admin/dependency/bootstrap/scss/_variables-dark.scss +85 -0
- data/app/assets/stylesheets/cm_admin/dependency/bootstrap/scss/_variables.scss +1745 -0
- data/app/assets/stylesheets/cm_admin/dependency/bootstrap/scss/bootstrap-grid.scss +62 -0
- data/app/assets/stylesheets/cm_admin/dependency/bootstrap/scss/bootstrap-reboot.scss +10 -0
- data/app/assets/stylesheets/cm_admin/dependency/bootstrap/scss/bootstrap-utilities.scss +19 -0
- data/app/assets/stylesheets/cm_admin/dependency/bootstrap/scss/bootstrap.scss +52 -0
- data/app/assets/stylesheets/cm_admin/dependency/bootstrap/scss/forms/_floating-labels.scss +95 -0
- data/app/assets/stylesheets/cm_admin/dependency/bootstrap/scss/forms/_form-check.scss +188 -0
- data/app/assets/stylesheets/cm_admin/dependency/bootstrap/scss/forms/_form-control.scss +214 -0
- data/app/assets/stylesheets/cm_admin/dependency/bootstrap/scss/forms/_form-range.scss +91 -0
- data/app/assets/stylesheets/cm_admin/dependency/bootstrap/scss/forms/_form-select.scss +80 -0
- data/app/assets/stylesheets/cm_admin/dependency/bootstrap/scss/forms/_form-text.scss +11 -0
- data/app/assets/stylesheets/cm_admin/dependency/bootstrap/scss/forms/_input-group.scss +132 -0
- data/app/assets/stylesheets/cm_admin/dependency/bootstrap/scss/forms/_labels.scss +36 -0
- data/app/assets/stylesheets/cm_admin/dependency/bootstrap/scss/forms/_validation.scss +12 -0
- data/app/assets/stylesheets/cm_admin/dependency/bootstrap/scss/helpers/_clearfix.scss +3 -0
- data/app/assets/stylesheets/cm_admin/dependency/bootstrap/scss/helpers/_color-bg.scss +7 -0
- data/app/assets/stylesheets/cm_admin/dependency/bootstrap/scss/helpers/_colored-links.scss +30 -0
- data/app/assets/stylesheets/cm_admin/dependency/bootstrap/scss/helpers/_focus-ring.scss +5 -0
- data/app/assets/stylesheets/cm_admin/dependency/bootstrap/scss/helpers/_icon-link.scss +25 -0
- data/app/assets/stylesheets/cm_admin/dependency/bootstrap/scss/helpers/_position.scss +36 -0
- data/app/assets/stylesheets/cm_admin/dependency/bootstrap/scss/helpers/_ratio.scss +26 -0
- data/app/assets/stylesheets/cm_admin/dependency/bootstrap/scss/helpers/_stacks.scss +15 -0
- data/app/assets/stylesheets/cm_admin/dependency/bootstrap/scss/helpers/_stretched-link.scss +15 -0
- data/app/assets/stylesheets/cm_admin/dependency/bootstrap/scss/helpers/_text-truncation.scss +7 -0
- data/app/assets/stylesheets/cm_admin/dependency/bootstrap/scss/helpers/_visually-hidden.scss +8 -0
- data/app/assets/stylesheets/cm_admin/dependency/bootstrap/scss/helpers/_vr.scss +8 -0
- data/app/assets/stylesheets/cm_admin/dependency/bootstrap/scss/mixins/_alert.scss +18 -0
- data/app/assets/stylesheets/cm_admin/dependency/bootstrap/scss/mixins/_backdrop.scss +14 -0
- data/app/assets/stylesheets/cm_admin/dependency/bootstrap/scss/mixins/_banner.scss +7 -0
- data/app/assets/stylesheets/cm_admin/dependency/bootstrap/scss/mixins/_border-radius.scss +78 -0
- data/app/assets/stylesheets/cm_admin/dependency/bootstrap/scss/mixins/_box-shadow.scss +18 -0
- data/app/assets/stylesheets/cm_admin/dependency/bootstrap/scss/mixins/_breakpoints.scss +127 -0
- data/app/assets/stylesheets/cm_admin/dependency/bootstrap/scss/mixins/_buttons.scss +70 -0
- data/app/assets/stylesheets/cm_admin/dependency/bootstrap/scss/mixins/_caret.scss +69 -0
- data/app/assets/stylesheets/cm_admin/dependency/bootstrap/scss/mixins/_clearfix.scss +9 -0
- data/app/assets/stylesheets/cm_admin/dependency/bootstrap/scss/mixins/_color-mode.scss +21 -0
- data/app/assets/stylesheets/cm_admin/dependency/bootstrap/scss/mixins/_color-scheme.scss +7 -0
- data/app/assets/stylesheets/cm_admin/dependency/bootstrap/scss/mixins/_container.scss +11 -0
- data/app/assets/stylesheets/cm_admin/dependency/bootstrap/scss/mixins/_deprecate.scss +10 -0
- data/app/assets/stylesheets/cm_admin/dependency/bootstrap/scss/mixins/_forms.scss +153 -0
- data/app/assets/stylesheets/cm_admin/dependency/bootstrap/scss/mixins/_gradients.scss +47 -0
- data/app/assets/stylesheets/cm_admin/dependency/bootstrap/scss/mixins/_grid.scss +151 -0
- data/app/assets/stylesheets/cm_admin/dependency/bootstrap/scss/mixins/_image.scss +16 -0
- data/app/assets/stylesheets/cm_admin/dependency/bootstrap/scss/mixins/_list-group.scss +26 -0
- data/app/assets/stylesheets/cm_admin/dependency/bootstrap/scss/mixins/_lists.scss +7 -0
- data/app/assets/stylesheets/cm_admin/dependency/bootstrap/scss/mixins/_pagination.scss +10 -0
- data/app/assets/stylesheets/cm_admin/dependency/bootstrap/scss/mixins/_reset-text.scss +17 -0
- data/app/assets/stylesheets/cm_admin/dependency/bootstrap/scss/mixins/_resize.scss +6 -0
- data/app/assets/stylesheets/cm_admin/dependency/bootstrap/scss/mixins/_table-variants.scss +24 -0
- data/app/assets/stylesheets/cm_admin/dependency/bootstrap/scss/mixins/_text-truncate.scss +8 -0
- data/app/assets/stylesheets/cm_admin/dependency/bootstrap/scss/mixins/_transition.scss +26 -0
- data/app/assets/stylesheets/cm_admin/dependency/bootstrap/scss/mixins/_utilities.scss +97 -0
- data/app/assets/stylesheets/cm_admin/dependency/bootstrap/scss/mixins/_visually-hidden.scss +33 -0
- data/app/assets/stylesheets/cm_admin/dependency/bootstrap/scss/tests/jasmine.js +16 -0
- data/app/assets/stylesheets/cm_admin/dependency/bootstrap/scss/tests/mixins/_color-modes.test.scss +69 -0
- data/app/assets/stylesheets/cm_admin/dependency/bootstrap/scss/tests/mixins/_media-query-color-mode-full.test.scss +8 -0
- data/app/assets/stylesheets/cm_admin/dependency/bootstrap/scss/tests/mixins/_utilities.test.scss +393 -0
- data/app/assets/stylesheets/cm_admin/dependency/bootstrap/scss/tests/sass-true/register.js +14 -0
- data/app/assets/stylesheets/cm_admin/dependency/bootstrap/scss/tests/sass-true/runner.js +17 -0
- data/app/assets/stylesheets/cm_admin/dependency/bootstrap/scss/tests/utilities/_api.test.scss +75 -0
- data/app/assets/stylesheets/cm_admin/dependency/bootstrap/scss/utilities/_api.scss +47 -0
- data/app/assets/stylesheets/cm_admin/dependency/bootstrap/scss/vendor/_rfs.scss +348 -0
- data/app/controllers/cm_admin/resource_controller.rb +22 -5
- data/app/helpers/cm_admin/application_helper.rb +4 -4
- data/app/views/cm_admin/main/_actions_dropdown.html.slim +2 -2
- data/app/views/cm_admin/main/_cm_pagy_nav.html.slim +7 -7
- data/app/views/cm_admin/main/_custom_action_modal_form.html.slim +6 -0
- data/app/views/cm_admin/main/_nested_fields.html.slim +7 -27
- data/app/views/cm_admin/main/_nested_table_form.html.slim +17 -8
- data/app/views/cm_admin/main/_nested_table_section.html.slim +17 -0
- data/app/views/cm_admin/main/_show_section.html.slim +10 -0
- data/app/views/cm_admin/main/_table.html.slim +3 -4
- data/app/views/cm_admin/main/_tabs.html.slim +1 -1
- data/app/views/cm_admin/main/_top_navbar.html.slim +11 -4
- data/app/views/cm_admin/main/associated_show.html.slim +5 -4
- data/app/views/cm_admin/main/edit.html.slim +18 -18
- data/app/views/cm_admin/main/history.html.slim +3 -3
- data/app/views/cm_admin/main/import_form.html.slim +1 -1
- data/app/views/cm_admin/main/new.html.slim +17 -17
- data/app/views/cm_admin/main/show.html.slim +10 -10
- data/app/views/layouts/_custom_action_modal.html.slim +11 -0
- data/app/views/layouts/_custom_action_modals.html.slim +13 -9
- data/app/views/layouts/_destroy_action_modal.html.slim +16 -0
- data/app/views/layouts/cm_admin.html.slim +5 -5
- data/config/routes.rb +1 -3
- data/lib/cm_admin/model.rb +1 -0
- data/lib/cm_admin/models/custom_action.rb +6 -0
- data/lib/cm_admin/models/dsl_method.rb +9 -4
- data/lib/cm_admin/models/field.rb +2 -1
- data/lib/cm_admin/models/form_field.rb +2 -1
- data/lib/cm_admin/models/row.rb +40 -0
- data/lib/cm_admin/models/section.rb +20 -3
- data/lib/cm_admin/version.rb +1 -1
- data/lib/cm_admin/view_helpers/field_display_helper.rb +3 -3
- data/lib/cm_admin/view_helpers/filter_helper.rb +9 -11
- data/lib/cm_admin/view_helpers/form_field_helper.rb +42 -14
- data/lib/cm_admin/view_helpers/form_helper.rb +63 -22
- data/lib/cm_admin/view_helpers/page_info_helper.rb +4 -23
- data/lib/cm_admin/view_helpers.rb +1 -1
- metadata +107 -2
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
== render 'cm_admin/main/top_navbar'
|
|
2
1
|
.form-page
|
|
3
|
-
.form-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
2
|
+
.form-page__header
|
|
3
|
+
== render 'cm_admin/main/top_navbar'
|
|
4
|
+
.form-page__body
|
|
5
|
+
- if @ar_object.errors.present?
|
|
6
|
+
.flag-alert.mb-4
|
|
7
|
+
p.alert-header
|
|
8
|
+
span
|
|
9
|
+
i.fa.fa-exclamation-triangle
|
|
10
|
+
| Attention
|
|
11
|
+
.alert-body
|
|
12
|
+
p.body-title
|
|
13
|
+
| Error heading
|
|
14
|
+
p.body-info
|
|
15
|
+
ul
|
|
16
|
+
- @ar_object.errors.full_messages.each do |error_message|
|
|
17
|
+
li = error_message
|
|
18
|
+
.form-container
|
|
19
|
+
= generate_form(@ar_object, @model)
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
.show-page
|
|
2
|
-
.show-page__header.
|
|
1
|
+
.show-page
|
|
2
|
+
.show-page__header.page-top-bar
|
|
3
3
|
== render 'cm_admin/main/top_navbar'
|
|
4
4
|
== render 'cm_admin/main/tabs'
|
|
5
|
-
.show-page__inner
|
|
5
|
+
.show-page__inner
|
|
6
6
|
.history-box
|
|
7
7
|
- @ar_object.action_trails.each do |at|
|
|
8
8
|
.history-item
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
/ p.success-msg-info An email will be sent once the process is completed. If there are any problems with the import, we'll let you know through an email.
|
|
14
14
|
.actions-wrapper
|
|
15
15
|
a.btn-secondary href="#{cm_admin.send(:"#{@model.name.underscore}_import_path")}" Import new data
|
|
16
|
-
/ button.cta-btn.
|
|
16
|
+
/ button.cta-btn.ms-2 Back to Page_Name
|
|
17
17
|
- else
|
|
18
18
|
= simple_form_for(FileImport.new, url: "/admin/#{@model.ar_model.table_name}/import", method: :post, html: { class: "csv-import-form" }) do |f|
|
|
19
19
|
.form-card
|
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
== render 'cm_admin/main/top_navbar'
|
|
2
1
|
.form-page
|
|
3
|
-
.form-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
2
|
+
.form-page__header
|
|
3
|
+
== render 'cm_admin/main/top_navbar'
|
|
4
|
+
.form-page__body
|
|
5
|
+
- if @ar_object.errors.present?
|
|
6
|
+
.flag-alert.mb-4
|
|
7
|
+
p.alert-header
|
|
8
|
+
span
|
|
9
|
+
i.fa.fa-exclamation-triangle
|
|
10
|
+
| Attention
|
|
11
|
+
.alert-body
|
|
12
|
+
p.body-title
|
|
13
|
+
| Error saving #{@ar_object.class}
|
|
14
|
+
p.body-info
|
|
15
|
+
ul
|
|
16
|
+
- @ar_object.errors.full_messages.each do |error_message|
|
|
17
|
+
li = error_message
|
|
18
18
|
|
|
19
|
-
|
|
19
|
+
= generate_form(@ar_object, @model)
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
.show-page
|
|
2
|
-
.show-page__header.
|
|
1
|
+
.show-page
|
|
2
|
+
.show-page__header.page-top-bar
|
|
3
3
|
== render 'cm_admin/main/top_navbar'
|
|
4
4
|
== render 'cm_admin/main/tabs'
|
|
5
|
-
.show-page__inner
|
|
5
|
+
.show-page__inner
|
|
6
6
|
- if @action.partial
|
|
7
7
|
== render @action.partial
|
|
8
8
|
- else
|
|
9
|
-
- @model.available_fields[:show].each do |
|
|
10
|
-
|
|
11
|
-
.
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
9
|
+
- @model.available_fields[:show].each do |entity|
|
|
10
|
+
.row
|
|
11
|
+
- if entity.class == CmAdmin::Models::Row
|
|
12
|
+
- entity.sections.each do |section|
|
|
13
|
+
= render partial: 'cm_admin/main/show_section', locals: { section: section }
|
|
14
|
+
- elsif entity.class == CmAdmin::Models::Section
|
|
15
|
+
= render partial: 'cm_admin/main/show_section', locals: { section: entity }
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
.modal.fade id="#{custom_action.name.classify}Modal-#{ar_object.id}" aria-hidden="true" aria-labelledby="#{custom_action.name.classify}ModalLabel" tabindex="1"
|
|
2
|
+
.modal-dialog
|
|
3
|
+
.modal-content
|
|
4
|
+
.modal-header
|
|
5
|
+
h5.modal-title id="#{custom_action.name.classify}ModalLabel" = custom_action.modal_configuration[:title] || custom_action.name.classify
|
|
6
|
+
button.btn-close aria-label="Close" data-bs-dismiss="modal" type="button"
|
|
7
|
+
.modal-body
|
|
8
|
+
- if custom_action.partial
|
|
9
|
+
= render partial: custom_action.partial
|
|
10
|
+
- else
|
|
11
|
+
= render partial: 'cm_admin/main/custom_action_modal_form', locals: { custom_action: custom_action, ar_object: ar_object }
|
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
- custom_action_with_modals = @model.available_actions.select{ |act| act if act.display_type == :modal }
|
|
2
|
+
- destroy_action = available_actions(@model, 'destroy')
|
|
2
3
|
- if @associated_model
|
|
3
4
|
- custom_action_with_modals += @associated_model.available_actions.select{ |act| act if act.display_type == :modal }
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
5
|
+
|
|
6
|
+
- if @current_action&.name == 'index'
|
|
7
|
+
- @ar_object.data.each do |ar_object|
|
|
8
|
+
- custom_action_with_modals.each do |custom_action|
|
|
9
|
+
= render partial: '/layouts/custom_action_modal', locals: { custom_action: custom_action, ar_object: ar_object }
|
|
10
|
+
- if destroy_action
|
|
11
|
+
= render partial: '/layouts/destroy_action_modal', locals: { ar_object: ar_object }
|
|
12
|
+
- elsif @current_action&.name == 'show'
|
|
13
|
+
- custom_action_with_modals.each do |custom_action|
|
|
14
|
+
= render partial: '/layouts/custom_action_modal', locals: { custom_action: custom_action, ar_object: @ar_object }
|
|
15
|
+
- if destroy_action
|
|
16
|
+
= render partial: '/layouts/destroy_action_modal', locals: { ar_object: @ar_object }
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
.modal.fade id="#{@model.name.classify}DestroyModal-#{ar_object.id}" aria-hidden="true" aria-labelledby="#{@model.name.classify}DestroyModalLabel" tabindex="1"
|
|
2
|
+
.modal-dialog
|
|
3
|
+
.modal-content
|
|
4
|
+
.modal-header
|
|
5
|
+
h5.modal-title id="#{@model.name.classify}DestroyModalLabel" = "#{@model.name.classify} Destroy"
|
|
6
|
+
button.btn-close aria-label="Close" data-bs-dismiss="modal" type="button"
|
|
7
|
+
.modal-body
|
|
8
|
+
.custom-modal-body
|
|
9
|
+
.modal-info data-section="bulk-action"
|
|
10
|
+
| Are you sure you want to delete this #{@model.name.classify}
|
|
11
|
+
.modal-footer
|
|
12
|
+
= button_to cm_admin.send("#{@model.name.underscore}_destroy_path", ar_object.id), method: :delete, class: "btn btn-primary" do
|
|
13
|
+
span
|
|
14
|
+
i.fa.fa-trash
|
|
15
|
+
| Destroy
|
|
16
|
+
|
|
@@ -24,15 +24,15 @@ html
|
|
|
24
24
|
= render 'layouts/left_sidebar_nav'
|
|
25
25
|
.panel-area
|
|
26
26
|
- if defined?(@action) && (@action&.layout_type.to_s == 'cm_association_show' || @action.parent == "show")
|
|
27
|
-
.show-page
|
|
28
|
-
.show-page__header.
|
|
27
|
+
.show-page
|
|
28
|
+
.show-page__header.page-top-bar
|
|
29
29
|
== render 'cm_admin/main/top_navbar'
|
|
30
30
|
== render 'cm_admin/main/tabs'
|
|
31
|
-
.show-page__inner
|
|
31
|
+
.show-page__inner
|
|
32
32
|
= yield
|
|
33
33
|
- elsif defined?(@action) && (@action&.layout_type.to_s == 'cm_association_index' || @action.parent == "index")
|
|
34
|
-
.show-page
|
|
35
|
-
.show-page__header.
|
|
34
|
+
.show-page
|
|
35
|
+
.show-page__header.page-top-bar
|
|
36
36
|
== render 'cm_admin/main/top_navbar'
|
|
37
37
|
- if @ar_object.model_name
|
|
38
38
|
== render 'cm_admin/main/tabs'
|
data/config/routes.rb
CHANGED
|
@@ -21,9 +21,7 @@ CmAdmin::Engine.routes.draw do
|
|
|
21
21
|
scope model.name.tableize do
|
|
22
22
|
# Define route only when action trail related field is present
|
|
23
23
|
if act.name == 'history'
|
|
24
|
-
|
|
25
|
-
send(:get, ':id/history', to: "#{model.name.underscore}#history", as: "#{model.name.underscore}_history")
|
|
26
|
-
end
|
|
24
|
+
send(:get, ':id/history', to: "#{model.name.underscore}#history", as: "#{model.name.underscore}_history")
|
|
27
25
|
else
|
|
28
26
|
send(act.verb, act.path.present? ? act.path : act.name, to: "#{model.name.underscore}##{act.name}", as: "#{model.name.underscore}_#{act.name}")
|
|
29
27
|
end
|
data/lib/cm_admin/model.rb
CHANGED
|
@@ -10,6 +10,7 @@ require_relative 'models/column'
|
|
|
10
10
|
require_relative 'models/filter'
|
|
11
11
|
require_relative 'models/export'
|
|
12
12
|
require_relative 'models/section'
|
|
13
|
+
require_relative 'models/row'
|
|
13
14
|
require_relative 'models/tab'
|
|
14
15
|
require_relative 'models/dsl_method'
|
|
15
16
|
require 'pagy'
|
|
@@ -3,6 +3,12 @@ require_relative 'actions/blocks'
|
|
|
3
3
|
module CmAdmin
|
|
4
4
|
module Models
|
|
5
5
|
class CustomAction < Action
|
|
6
|
+
attr_accessor :modal_configuration
|
|
7
|
+
|
|
8
|
+
def initialize(attributes = {}, &block)
|
|
9
|
+
super
|
|
10
|
+
end
|
|
11
|
+
|
|
6
12
|
class << self
|
|
7
13
|
def find_by(model, search_hash)
|
|
8
14
|
model.available_actions.find { |i| i.name == search_hash[:name] }
|
|
@@ -60,9 +60,14 @@ module CmAdmin
|
|
|
60
60
|
yield if block
|
|
61
61
|
end
|
|
62
62
|
|
|
63
|
-
def
|
|
63
|
+
def row(display_if: nil, &block)
|
|
64
64
|
@available_fields[@current_action.name.to_sym] ||= []
|
|
65
|
-
@available_fields[@current_action.name.to_sym] << CmAdmin::Models::
|
|
65
|
+
@available_fields[@current_action.name.to_sym] << CmAdmin::Models::Row.new(@current_action, @model, display_if, &block)
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
def cm_section(section_name, display_if: nil, col_size: nil, &block)
|
|
69
|
+
@available_fields[@current_action.name.to_sym] ||= []
|
|
70
|
+
@available_fields[@current_action.name.to_sym] << CmAdmin::Models::Section.new(section_name, @current_action, @model, display_if, col_size, &block)
|
|
66
71
|
end
|
|
67
72
|
|
|
68
73
|
# This method is deprecated. Use cm_section instead.
|
|
@@ -116,13 +121,13 @@ module CmAdmin
|
|
|
116
121
|
# end
|
|
117
122
|
# end
|
|
118
123
|
# end
|
|
119
|
-
def custom_action(name: nil, page_title: nil, page_description: nil, display_name: nil, verb: nil, layout: nil, layout_type: nil, partial: nil, path: nil, display_type: nil, display_if: lambda { |arg| return true }, route_type: nil, icon_name: 'fa fa-th-large', &block)
|
|
124
|
+
def custom_action(name: nil, page_title: nil, page_description: nil, display_name: nil, verb: nil, layout: nil, layout_type: nil, partial: nil, path: nil, display_type: nil, modal_configuration: {}, display_if: lambda { |arg| return true }, route_type: nil, icon_name: 'fa fa-th-large', &block)
|
|
120
125
|
action = CmAdmin::Models::CustomAction.new(
|
|
121
126
|
page_title: page_title, page_description: page_description,
|
|
122
127
|
name: name, display_name: display_name, verb: verb, layout: layout,
|
|
123
128
|
layout_type: layout_type, partial: partial, path: path,
|
|
124
129
|
parent: self.current_action.name, display_type: display_type, display_if: display_if,
|
|
125
|
-
action_type: :custom, route_type: route_type, icon_name: icon_name, &block)
|
|
130
|
+
action_type: :custom, route_type: route_type, icon_name: icon_name, modal_configuration: modal_configuration, &block)
|
|
126
131
|
@available_actions << action
|
|
127
132
|
# self.class.class_eval(&block)
|
|
128
133
|
end
|
|
@@ -7,7 +7,7 @@ module CmAdmin
|
|
|
7
7
|
|
|
8
8
|
attr_accessor :field_name, :label, :header, :field_type, :format, :precision, :height,
|
|
9
9
|
:width, :helper_method, :preview, :custom_link, :prefix, :suffix, :tag_class,
|
|
10
|
-
:display_if, :association_name, :association_type
|
|
10
|
+
:display_if, :association_name, :association_type, :col_size
|
|
11
11
|
|
|
12
12
|
def initialize(field_name, attributes = {})
|
|
13
13
|
@field_name = field_name
|
|
@@ -24,6 +24,7 @@ module CmAdmin
|
|
|
24
24
|
|
|
25
25
|
def set_default_values
|
|
26
26
|
self.tag_class = {}
|
|
27
|
+
self.col_size = nil
|
|
27
28
|
end
|
|
28
29
|
end
|
|
29
30
|
end
|
|
@@ -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_attr, :target
|
|
9
|
+
:placeholder, :display_if, :html_attr, :target, :col_size
|
|
10
10
|
|
|
11
11
|
VALID_INPUT_TYPES = %i[
|
|
12
12
|
integer decimal string single_select multi_select date date_time text
|
|
@@ -30,6 +30,7 @@ module CmAdmin
|
|
|
30
30
|
self.input_type = :string
|
|
31
31
|
self.html_attr = {}
|
|
32
32
|
self.target = {}
|
|
33
|
+
self.col_size = nil
|
|
33
34
|
end
|
|
34
35
|
|
|
35
36
|
def set_default_placeholder
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
module CmAdmin
|
|
2
|
+
module Models
|
|
3
|
+
class Row
|
|
4
|
+
|
|
5
|
+
# Description
|
|
6
|
+
# A row is like a container which holds a list of form_field or section.
|
|
7
|
+
# These list of fields or section are iterated and displayed on new/edit page.
|
|
8
|
+
# A row is like a wrapper on the HTML, which adds a div element 'row' class from bootstrap.
|
|
9
|
+
|
|
10
|
+
attr_accessor :sections, :display_if, :row_fields
|
|
11
|
+
|
|
12
|
+
def initialize(current_action, cm_model, display_if, &block)
|
|
13
|
+
@sections = []
|
|
14
|
+
@row_fields = []
|
|
15
|
+
@display_if = display_if || lambda { |arg| return true }
|
|
16
|
+
@current_action = current_action
|
|
17
|
+
@cm_model = cm_model
|
|
18
|
+
instance_eval(&block)
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def form_field(field_name, options={}, arg=nil)
|
|
22
|
+
if @current_action.is_nested_field
|
|
23
|
+
@nested_table_fields[@current_action.nested_table_name] ||= []
|
|
24
|
+
@nested_table_fields[@current_action.nested_table_name] << CmAdmin::Models::FormField.new(field_name, options[:input_type], options)
|
|
25
|
+
else
|
|
26
|
+
@row_fields << CmAdmin::Models::FormField.new(field_name, options[:input_type], options)
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def cm_section(section_name, col_size: nil, display_if: nil, &block)
|
|
31
|
+
@sections << CmAdmin::Models::Section.new(section_name, @current_action, @model, display_if, col_size, &block)
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
# This method is deprecated. Use cm_section instead.
|
|
35
|
+
def cm_show_section(section_name, col_size: nil, display_if: nil, &block)
|
|
36
|
+
cm_section(section_name, col_size: col_size, display_if: display_if, &block)
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
end
|
|
@@ -2,11 +2,18 @@ module CmAdmin
|
|
|
2
2
|
module Models
|
|
3
3
|
class Section
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
# Description
|
|
6
|
+
# A section is like a container which holds a list of fields or form fields
|
|
7
|
+
# These list of fields are iterated and displayed on show/new/edit page.
|
|
8
|
+
# It also contains rows, which contains sections and fields.
|
|
6
9
|
|
|
7
|
-
|
|
10
|
+
attr_accessor :section_name, :section_fields, :display_if, :current_action, :cm_model, :nested_table_fields, :rows, :col_size
|
|
11
|
+
|
|
12
|
+
def initialize(section_name, current_action, cm_model, display_if, col_size, &block)
|
|
8
13
|
@section_fields = []
|
|
14
|
+
@rows = []
|
|
9
15
|
@nested_table_fields = {}
|
|
16
|
+
@col_size = col_size
|
|
10
17
|
@section_name = section_name
|
|
11
18
|
@current_action = current_action
|
|
12
19
|
@cm_model = cm_model
|
|
@@ -15,7 +22,12 @@ module CmAdmin
|
|
|
15
22
|
end
|
|
16
23
|
|
|
17
24
|
def field(field_name, options={})
|
|
18
|
-
@
|
|
25
|
+
if @current_action.is_nested_field
|
|
26
|
+
@nested_table_fields[@current_action.nested_table_name] ||= []
|
|
27
|
+
@nested_table_fields[@current_action.nested_table_name] << CmAdmin::Models::Field.new(field_name, options)
|
|
28
|
+
else
|
|
29
|
+
@section_fields << CmAdmin::Models::Field.new(field_name, options)
|
|
30
|
+
end
|
|
19
31
|
end
|
|
20
32
|
|
|
21
33
|
def form_field(field_name, options={}, arg=nil)
|
|
@@ -33,6 +45,11 @@ module CmAdmin
|
|
|
33
45
|
yield
|
|
34
46
|
end
|
|
35
47
|
|
|
48
|
+
def row(display_if: nil, &block)
|
|
49
|
+
@rows ||= []
|
|
50
|
+
@rows << CmAdmin::Models::Row.new(@current_action, @model, display_if, &block)
|
|
51
|
+
end
|
|
52
|
+
|
|
36
53
|
end
|
|
37
54
|
end
|
|
38
55
|
end
|
data/lib/cm_admin/version.rb
CHANGED
|
@@ -3,14 +3,14 @@ module CmAdmin
|
|
|
3
3
|
module FieldDisplayHelper
|
|
4
4
|
def show_field(ar_object, field)
|
|
5
5
|
return unless field.display_if.call(ar_object)
|
|
6
|
-
content_tag(:div, class: "info
|
|
6
|
+
content_tag(:div, class: "card-info") do
|
|
7
7
|
concat show_field_label(ar_object, field)
|
|
8
8
|
concat value_with_prefix_and_suffix(ar_object, field)
|
|
9
9
|
end
|
|
10
10
|
end
|
|
11
11
|
|
|
12
12
|
def show_field_label(ar_object, field)
|
|
13
|
-
content_tag(:div, class: "
|
|
13
|
+
content_tag(:div, class: "card-info__label") do
|
|
14
14
|
field_label = if field.label.present?
|
|
15
15
|
field.label.to_s
|
|
16
16
|
elsif field.association_type.to_s == "polymorphic"
|
|
@@ -24,7 +24,7 @@ module CmAdmin
|
|
|
24
24
|
|
|
25
25
|
def value_with_prefix_and_suffix(ar_object, field)
|
|
26
26
|
value = show_field_value(ar_object, field)
|
|
27
|
-
content_tag(:div, class: "
|
|
27
|
+
content_tag(:div, class: "card-info__description") do
|
|
28
28
|
concat field.prefix
|
|
29
29
|
concat value
|
|
30
30
|
concat field.suffix
|
|
@@ -19,8 +19,9 @@ module CmAdmin
|
|
|
19
19
|
end
|
|
20
20
|
|
|
21
21
|
def add_filters_dropdown(filters)
|
|
22
|
-
concat(content_tag(:
|
|
23
|
-
tag.
|
|
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
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
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
|
|
|
@@ -13,7 +13,7 @@ module CmAdmin
|
|
|
13
13
|
|
|
14
14
|
def cm_integer_field(form_obj, cm_field, value, required_class, _target_action)
|
|
15
15
|
form_obj.text_field cm_field.field_name,
|
|
16
|
-
class: "
|
|
16
|
+
class: "field-control #{required_class}",
|
|
17
17
|
disabled: cm_field.disabled,
|
|
18
18
|
value: value,
|
|
19
19
|
placeholder: cm_field.placeholder,
|
|
@@ -22,7 +22,7 @@ module CmAdmin
|
|
|
22
22
|
|
|
23
23
|
def cm_decimal_field(form_obj, cm_field, value, required_class, _target_action)
|
|
24
24
|
form_obj.number_field cm_field.field_name,
|
|
25
|
-
class: "
|
|
25
|
+
class: "field-control #{required_class}",
|
|
26
26
|
disabled: cm_field.disabled,
|
|
27
27
|
value: value,
|
|
28
28
|
placeholder: cm_field.placeholder,
|
|
@@ -31,7 +31,7 @@ module CmAdmin
|
|
|
31
31
|
|
|
32
32
|
def cm_string_field(form_obj, cm_field, value, required_class, _target_action)
|
|
33
33
|
form_obj.text_field cm_field.field_name,
|
|
34
|
-
class: "
|
|
34
|
+
class: "field-control #{required_class}",
|
|
35
35
|
disabled: cm_field.disabled,
|
|
36
36
|
value: value,
|
|
37
37
|
placeholder: cm_field.placeholder
|
|
@@ -40,7 +40,7 @@ module CmAdmin
|
|
|
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
42
|
{ include_blank: cm_field.placeholder },
|
|
43
|
-
class: "
|
|
43
|
+
class: "field-control #{required_class} select-2",
|
|
44
44
|
disabled: cm_field.disabled,
|
|
45
45
|
data: {
|
|
46
46
|
field_name: cm_field.field_name,
|
|
@@ -54,13 +54,13 @@ module CmAdmin
|
|
|
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
56
|
{ include_blank: cm_field.placeholder },
|
|
57
|
-
class: "
|
|
57
|
+
class: "field-control #{required_class} select-2",
|
|
58
58
|
disabled: cm_field.disabled, multiple: true
|
|
59
59
|
end
|
|
60
60
|
|
|
61
61
|
def cm_date_field(form_obj, cm_field, value, required_class, _target_action)
|
|
62
62
|
form_obj.text_field cm_field.field_name,
|
|
63
|
-
class: "
|
|
63
|
+
class: "field-control #{required_class}",
|
|
64
64
|
disabled: cm_field.disabled,
|
|
65
65
|
value: value&.strftime('%d-%m-%Y'),
|
|
66
66
|
placeholder: cm_field.placeholder,
|
|
@@ -69,7 +69,7 @@ module CmAdmin
|
|
|
69
69
|
|
|
70
70
|
def cm_date_time_field(form_obj, cm_field, value, required_class, _target_action)
|
|
71
71
|
form_obj.text_field cm_field.field_name,
|
|
72
|
-
class: "
|
|
72
|
+
class: "field-control #{required_class}",
|
|
73
73
|
disabled: cm_field.disabled,
|
|
74
74
|
value: value,
|
|
75
75
|
placeholder: cm_field.placeholder,
|
|
@@ -78,22 +78,50 @@ module CmAdmin
|
|
|
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
|
-
class: "
|
|
81
|
+
class: "field-control #{required_class}",
|
|
82
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
|
-
class: "
|
|
87
|
+
class: "field-control #{required_class}",
|
|
88
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)
|
|
92
|
-
|
|
92
|
+
content_tag(:div) do
|
|
93
|
+
concat form_obj.file_field cm_field.field_name, class: "form-control #{required_class}"
|
|
94
|
+
concat attachment_list(form_obj, cm_field, _value, required_class, _target_action)
|
|
95
|
+
end
|
|
93
96
|
end
|
|
94
97
|
|
|
95
98
|
def cm_multi_file_upload_field(form_obj, cm_field, _value, required_class, _target_action)
|
|
96
|
-
|
|
99
|
+
content_tag(:div) do
|
|
100
|
+
concat form_obj.file_field cm_field.field_name, multiple: true, class: "form-control #{required_class}"
|
|
101
|
+
concat attachment_list(form_obj, cm_field, _value, required_class, _target_action)
|
|
102
|
+
end
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
def attachment_list(form_obj, cm_field, _value, required_class, _target_action)
|
|
106
|
+
attached = form_obj.object.send(cm_field.field_name)
|
|
107
|
+
content_tag(:div) do
|
|
108
|
+
if attached.class == ActiveStorage::Attached::Many
|
|
109
|
+
attached.each do |attachment|
|
|
110
|
+
concat attachment_with_icon(attachment)
|
|
111
|
+
end
|
|
112
|
+
else
|
|
113
|
+
concat attachment_with_icon(attached)
|
|
114
|
+
end
|
|
115
|
+
end
|
|
116
|
+
end
|
|
117
|
+
|
|
118
|
+
def attachment_with_icon(attachment)
|
|
119
|
+
content_tag(:div, class: 'destroy-attachment', data: { ar_id: attachment.id}) do
|
|
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')
|
|
124
|
+
end
|
|
97
125
|
end
|
|
98
126
|
|
|
99
127
|
def cm_check_box_field(form_obj, cm_field, value, required_class, target_action)
|
|
@@ -128,7 +156,7 @@ module CmAdmin
|
|
|
128
156
|
else
|
|
129
157
|
form_obj.check_box cm_field.field_name,
|
|
130
158
|
{
|
|
131
|
-
class: "
|
|
159
|
+
class: "field-control cm-checkbox #{required_class} #{target_action.present? ? 'linked-field-request' : ''}",
|
|
132
160
|
disabled: cm_field.disabled,
|
|
133
161
|
data: {
|
|
134
162
|
field_name: cm_field.field_name,
|
|
@@ -158,7 +186,7 @@ module CmAdmin
|
|
|
158
186
|
content_tag :div, class: 'cm-radio-tag' do
|
|
159
187
|
concat form_obj.check_box cm_field.field_name,
|
|
160
188
|
{
|
|
161
|
-
class: "
|
|
189
|
+
class: "field-control cm-checkbox #{required_class} #{target_action.present? ? 'linked-field-request' : ''}",
|
|
162
190
|
disabled: cm_field.disabled,
|
|
163
191
|
name: "#{@model.name.underscore}[#{cm_field.field_name}][]",
|
|
164
192
|
data: {
|
|
@@ -186,7 +214,7 @@ module CmAdmin
|
|
|
186
214
|
|
|
187
215
|
def format_radio_button(val, form_obj)
|
|
188
216
|
content_tag :div, class: 'cm-radio-tag' do
|
|
189
|
-
concat form_obj.radio_button :level, val, class: '
|
|
217
|
+
concat form_obj.radio_button :level, val, class: 'field-control cm-radio'
|
|
190
218
|
end
|
|
191
219
|
end
|
|
192
220
|
end
|