swop 0.1.1 → 1.0.0
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/README.md +47 -9
- data/app/assets/images/swop/favicon.ico +0 -0
- data/app/assets/stylesheets/rails_admin/application.scss.erb +11 -20
- data/app/assets/stylesheets/{rails_admin/themes/base/base.scss → swop/swop-base/swop-base.scss} +1 -5
- data/app/assets/stylesheets/swop/swop-base/swop-typography.scss +11 -0
- data/app/assets/stylesheets/swop/swop-colors/swop-colors.scss +2 -0
- data/app/assets/stylesheets/swop/swop-core/swop-bootstrap-variables.scss +172 -0
- data/app/assets/stylesheets/swop/swop-core/swop-variables.scss +34 -0
- data/app/assets/stylesheets/swop/swop-themes/swop-simple/swop-base/swop-base.scss +3 -0
- data/app/assets/stylesheets/swop/swop-themes/swop-simple/swop-base/swop-main.scss +25 -0
- data/app/assets/stylesheets/swop/swop-themes/swop-simple/swop-base/swop-typography.scss +4 -0
- data/app/assets/stylesheets/swop/swop-themes/swop-simple/swop-colors/swop-amethyst.scss +29 -0
- data/app/assets/stylesheets/swop/swop-themes/swop-simple/swop-colors/swop-dark.scss +29 -0
- data/app/assets/stylesheets/swop/swop-themes/swop-simple/swop-colors/swop-forest.scss +29 -0
- data/app/assets/stylesheets/swop/swop-themes/swop-simple/swop-colors/swop-light.scss +29 -0
- data/app/assets/stylesheets/swop/swop-themes/swop-simple/swop-colors/swop-royal.scss +29 -0
- data/app/assets/stylesheets/swop/swop-themes/swop-simple/swop-components/swop-alerts.scss +12 -0
- data/app/assets/stylesheets/swop/swop-themes/swop-simple/swop-components/swop-badges.scss +31 -0
- data/app/assets/stylesheets/swop/swop-themes/swop-simple/swop-components/swop-buttons.scss +133 -0
- data/app/assets/stylesheets/swop/swop-themes/swop-simple/swop-components/swop-dropdowns.scss +26 -0
- data/app/assets/stylesheets/swop/swop-themes/swop-simple/swop-components/swop-filters.scss +57 -0
- data/app/assets/stylesheets/swop/swop-themes/swop-simple/swop-components/swop-forms.scss +158 -0
- data/app/assets/stylesheets/swop/swop-themes/swop-simple/swop-components/swop-images.scss +31 -0
- data/app/assets/stylesheets/swop/swop-themes/swop-simple/swop-components/swop-input-groups.scss +18 -0
- data/app/assets/stylesheets/swop/swop-themes/swop-simple/swop-components/swop-loading.scss +14 -0
- data/app/assets/stylesheets/swop/swop-themes/swop-simple/swop-components/swop-navbar.scss +15 -0
- data/app/assets/stylesheets/swop/swop-themes/swop-simple/swop-components/swop-navs.scss +77 -0
- data/app/assets/stylesheets/swop/swop-themes/swop-simple/swop-components/swop-offcanvas.scss +64 -0
- data/app/assets/stylesheets/swop/swop-themes/swop-simple/swop-components/swop-pagination.scss +21 -0
- data/app/assets/stylesheets/swop/swop-themes/swop-simple/swop-components/swop-progress.scss +3 -0
- data/app/assets/stylesheets/swop/swop-themes/swop-simple/swop-components/swop-sidebars.scss +49 -0
- data/app/assets/stylesheets/swop/swop-themes/swop-simple/swop-components/swop-tables.scss +82 -0
- data/app/assets/stylesheets/swop/swop-themes/swop-simple/swop-components/swop-tiles.scss +20 -0
- data/app/assets/stylesheets/swop/swop-themes/swop-simple/swop-core/swop-bootstrap-variables.scss +149 -0
- data/app/assets/stylesheets/swop/swop-themes/swop-simple/swop-core/swop-variables.scss +41 -0
- data/app/assets/stylesheets/{rails_admin/themes/simple/components/containers.scss → swop/swop-themes/swop-simple/swop-layouts/swop-containers.scss} +9 -0
- data/app/assets/stylesheets/swop/swop-themes/swop-simple/swop-layouts/swop-header.scss +15 -0
- data/app/assets/stylesheets/swop/swop-themes/swop-simple/swop-simple-amethyst.scss +35 -0
- data/app/assets/stylesheets/swop/swop-themes/swop-simple/swop-simple-base.scss +3 -0
- data/app/assets/stylesheets/swop/swop-themes/swop-simple/swop-simple-components.scss +17 -0
- data/app/assets/stylesheets/swop/swop-themes/swop-simple/swop-simple-dark.scss +35 -0
- data/app/assets/stylesheets/swop/swop-themes/swop-simple/swop-simple-forest.scss +35 -0
- data/app/assets/stylesheets/swop/swop-themes/swop-simple/swop-simple-layouts.scss +2 -0
- data/app/assets/stylesheets/swop/swop-themes/swop-simple/swop-simple-light.scss +35 -0
- data/app/assets/stylesheets/swop/swop-themes/swop-simple/swop-simple-royal.scss +35 -0
- data/app/assets/stylesheets/swop/swop.scss +8 -0
- data/app/views/kaminari/ra-twitter-bootstrap/_next_page.html.erb +7 -0
- data/app/views/kaminari/ra-twitter-bootstrap/_prev_page.html.erb +5 -0
- data/app/views/kaminari/ra-twitter-bootstrap/default/_next_page.html.erb +9 -0
- data/app/views/kaminari/ra-twitter-bootstrap/default/_prev_page.html.erb +9 -0
- data/app/views/kaminari/ra-twitter-bootstrap/swop-simple/_next_page.html.erb +9 -0
- data/app/views/kaminari/ra-twitter-bootstrap/swop-simple/_prev_page.html.erb +9 -0
- data/app/views/layouts/rails_admin/_head.html.erb +5 -32
- data/app/views/layouts/rails_admin/_sidebar_navigation.html.erb +5 -3
- data/app/views/layouts/rails_admin/application.html.erb +5 -27
- data/app/views/layouts/rails_admin/content.html.erb +4 -11
- data/app/views/layouts/rails_admin/default/_application.html.erb +27 -0
- data/app/views/layouts/rails_admin/default/_content.html.erb +22 -0
- data/app/views/layouts/rails_admin/default/_head.html.erb +32 -0
- data/app/views/layouts/rails_admin/default/_sidebar_navigation.html.erb +5 -0
- data/app/views/layouts/rails_admin/swop-simple/_application.html.erb +17 -0
- data/app/views/layouts/rails_admin/swop-simple/_content.html.erb +41 -0
- data/app/views/layouts/rails_admin/swop-simple/_head.html.erb +42 -0
- data/app/views/layouts/rails_admin/swop-simple/_sidebar_navigation.html.erb +12 -0
- data/app/views/rails_admin/main/_delete_notice.html.erb +7 -0
- data/app/views/rails_admin/main/default/_delete.html.erb +21 -0
- data/app/views/rails_admin/main/default/_delete_notice.html.erb +34 -0
- data/app/views/rails_admin/main/default/_edit.html.erb +3 -0
- data/app/views/rails_admin/main/default/_export.html.erb +149 -0
- data/app/views/rails_admin/main/default/_history.html.erb +80 -0
- data/app/views/rails_admin/main/default/_index.html.erb +184 -0
- data/app/views/rails_admin/main/default/_new.html.erb +3 -0
- data/app/views/rails_admin/main/default/_show.html.erb +30 -0
- data/app/views/rails_admin/main/delete.html.erb +5 -0
- data/app/views/rails_admin/main/edit.html.erb +5 -0
- data/app/views/rails_admin/main/export.html.erb +5 -128
- data/app/views/rails_admin/main/history.html.erb +4 -86
- data/app/views/rails_admin/main/index.html.erb +4 -173
- data/app/views/rails_admin/main/new.html.erb +5 -0
- data/app/views/rails_admin/main/show.html.erb +5 -20
- data/app/views/rails_admin/main/swop-simple/_delete.html.erb +11 -0
- data/app/views/rails_admin/main/swop-simple/_delete_notice.html.erb +23 -0
- data/app/views/rails_admin/main/swop-simple/_edit.html.erb +3 -0
- data/app/views/rails_admin/main/swop-simple/_export.html.erb +90 -0
- data/app/views/rails_admin/main/swop-simple/_history.html.erb +80 -0
- data/app/views/rails_admin/main/swop-simple/_index.html.erb +169 -0
- data/app/views/rails_admin/main/swop-simple/_new.html.erb +3 -0
- data/app/views/rails_admin/main/swop-simple/_show.html.erb +18 -0
- data/lib/swop/engine.rb +8 -3
- data/lib/swop/railtie.rb +7 -0
- data/lib/swop/version.rb +1 -1
- data/lib/swop.rb +20 -2
- metadata +102 -98
- data/CHANGELOG.md +0 -5
- data/CODE_OF_CONDUCT.md +0 -132
- data/LICENSE +0 -201
- data/Rakefile +0 -4
- data/app/assets/javascripts/rails_admin/application.js.erb +0 -33
- data/app/assets/javascripts/rails_admin/custom/abstract-select.js +0 -30
- data/app/assets/javascripts/rails_admin/custom/filter-box.js +0 -363
- data/app/assets/javascripts/rails_admin/custom/filtering-multiselect.js +0 -387
- data/app/assets/javascripts/rails_admin/custom/filtering-select.js +0 -304
- data/app/assets/stylesheets/rails_admin/themes/base/bootstrap-variables.scss +0 -252
- data/app/assets/stylesheets/rails_admin/themes/base/theming.scss +0 -22
- data/app/assets/stylesheets/rails_admin/themes/base/variables.scss +0 -71
- data/app/assets/stylesheets/rails_admin/themes/simple/base/typography.scss +0 -22
- data/app/assets/stylesheets/rails_admin/themes/simple/base/variables-dark.scss +0 -74
- data/app/assets/stylesheets/rails_admin/themes/simple/base/variables-light.scss +0 -77
- data/app/assets/stylesheets/rails_admin/themes/simple/base/variables-navy.scss +0 -74
- data/app/assets/stylesheets/rails_admin/themes/simple/base/variables.scss +0 -129
- data/app/assets/stylesheets/rails_admin/themes/simple/components/alerts.scss +0 -88
- data/app/assets/stylesheets/rails_admin/themes/simple/components/breadcrumbs.scss +0 -44
- data/app/assets/stylesheets/rails_admin/themes/simple/components/buttons.scss +0 -138
- data/app/assets/stylesheets/rails_admin/themes/simple/components/dropdowns.scss +0 -12
- data/app/assets/stylesheets/rails_admin/themes/simple/components/filter-box.scss +0 -8
- data/app/assets/stylesheets/rails_admin/themes/simple/components/filtering-multiselect.scss +0 -40
- data/app/assets/stylesheets/rails_admin/themes/simple/components/filtering-select.scss +0 -42
- data/app/assets/stylesheets/rails_admin/themes/simple/components/forms.scss +0 -27
- data/app/assets/stylesheets/rails_admin/themes/simple/components/images.scss +0 -19
- data/app/assets/stylesheets/rails_admin/themes/simple/components/links.scss +0 -25
- data/app/assets/stylesheets/rails_admin/themes/simple/components/navs.scss +0 -73
- data/app/assets/stylesheets/rails_admin/themes/simple/components/progress.scss +0 -4
- data/app/assets/stylesheets/rails_admin/themes/simple/components/sidebar.scss +0 -84
- data/app/assets/stylesheets/rails_admin/themes/simple/components/tables.scss +0 -84
- data/app/assets/stylesheets/rails_admin/themes/simple/layouts/rows.scss +0 -34
- data/app/assets/stylesheets/rails_admin/themes/simple/light/components/links.scss +0 -15
- data/app/assets/stylesheets/rails_admin/themes/simple/light/components/sidebar.scss +0 -25
- data/app/assets/stylesheets/rails_admin/themes/simple.scss.erb +0 -37
- data/app/helpers/rails_admin/application_helper.rb +0 -258
- data/app/helpers/rails_admin/form_builder.rb +0 -166
- data/app/views/layouts/rails_admin/_custom_navigation.html.erb +0 -10
- data/app/views/layouts/rails_admin/_header.html.erb +0 -43
- data/app/views/rails_admin/main/_form_polymorphic_association.html.erb +0 -15
- data/app/views/rails_admin/main/_submit_buttons.html.erb +0 -29
- data/app/views/rails_admin/main/dashboard.html.erb +0 -64
- data/config/locales/rails_admin.en.yml +0 -158
- data/sig/swop.rbs +0 -4
- /data/app/assets/stylesheets/{rails_admin/themes/base/mixins.scss → swop/swop-core/swop-mixins.scss} +0 -0
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
.sidebar {
|
|
2
|
-
-ms-overflow-style: none; /* Internet Explorer 10+ */
|
|
3
|
-
scrollbar-width: none; /* Firefox */
|
|
4
|
-
|
|
5
|
-
&::-webkit-scrollbar {
|
|
6
|
-
display: none; /* Safari and Chrome */
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
@include media-breakpoint-up(xl) {
|
|
10
|
-
height: rem(100px);
|
|
11
|
-
min-height: 100%;
|
|
12
|
-
overflow: scroll;
|
|
13
|
-
padding-right: $spacer-7;
|
|
14
|
-
width: rem(229px);
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
&-wrapper {
|
|
18
|
-
|
|
19
|
-
@include media-breakpoint-up(xl) {
|
|
20
|
-
position: relative;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
&::after {
|
|
24
|
-
|
|
25
|
-
@include media-breakpoint-up(xl) {
|
|
26
|
-
background-color: rgba($border-color, 0.5);
|
|
27
|
-
content: "";
|
|
28
|
-
height: calc(100% - #{$spacer-10});
|
|
29
|
-
position: absolute;
|
|
30
|
-
right: 0;
|
|
31
|
-
top: $spacer-7;
|
|
32
|
-
width: $border-width;
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
.nav-link {
|
|
38
|
-
border-radius: 0.625em;
|
|
39
|
-
line-height: $line-height-lg;
|
|
40
|
-
padding: $spacer-1 $spacer-4;
|
|
41
|
-
|
|
42
|
-
&:hover {
|
|
43
|
-
background-color: $light;
|
|
44
|
-
color: $white;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
&.active {
|
|
48
|
-
background-color: $primary;
|
|
49
|
-
color: $white;
|
|
50
|
-
font-weight: $font-weight-semibold;
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
.btn-toggle {
|
|
55
|
-
border-radius: 0;
|
|
56
|
-
border: 0;
|
|
57
|
-
color: $white;
|
|
58
|
-
display: flex;
|
|
59
|
-
font-weight: $font-weight-semibold;
|
|
60
|
-
line-height: $line-height-lg;
|
|
61
|
-
margin-top: $spacer-2;
|
|
62
|
-
padding: $spacer-1 $spacer-4;
|
|
63
|
-
transition: all $transition;
|
|
64
|
-
width: 100%;
|
|
65
|
-
|
|
66
|
-
*[class^="fa"] {
|
|
67
|
-
color: $white;
|
|
68
|
-
margin-left: auto;
|
|
69
|
-
transition: all $transition;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
&:active {
|
|
73
|
-
color: $white;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
&.collapsed *[class^="fa"] {
|
|
77
|
-
transform: rotate(180deg);
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
&-nav {
|
|
81
|
-
margin-bottom: 0 !important;
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
}
|
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
.table {
|
|
2
|
-
margin-bottom: 0;
|
|
3
|
-
border-collapse: unset;
|
|
4
|
-
|
|
5
|
-
td, th {
|
|
6
|
-
vertical-align: middle !important;
|
|
7
|
-
white-space: nowrap !important;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
thead th,
|
|
11
|
-
thead tr {
|
|
12
|
-
color: $body-secondary-color !important;
|
|
13
|
-
padding-top: 0;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
thead,
|
|
17
|
-
tbody {
|
|
18
|
-
|
|
19
|
-
th,
|
|
20
|
-
td {
|
|
21
|
-
|
|
22
|
-
&:first-child {
|
|
23
|
-
padding-left: 0;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
&:last-child {
|
|
27
|
-
padding-right: 0;
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
.header {
|
|
33
|
-
position: relative;
|
|
34
|
-
cursor: pointer;
|
|
35
|
-
|
|
36
|
-
&:hover::after {
|
|
37
|
-
@extend .fa-solid;
|
|
38
|
-
@extend .fa-xs;
|
|
39
|
-
border: unset;
|
|
40
|
-
content: "\f077";
|
|
41
|
-
float: unset;
|
|
42
|
-
margin-top: unset;
|
|
43
|
-
position: absolute;
|
|
44
|
-
right: rem(5px);
|
|
45
|
-
top: 37.5%;
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
.headerSortUp::after {
|
|
50
|
-
@extend .fa-solid;
|
|
51
|
-
@extend .fa-xs;
|
|
52
|
-
content: "\f078";
|
|
53
|
-
position: absolute;
|
|
54
|
-
right: rem(5px);
|
|
55
|
-
top: 37.5%;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
&-responsive {
|
|
59
|
-
-ms-overflow-style: none; // Internet Explorer 10+
|
|
60
|
-
margin-left: -$spacer-4;
|
|
61
|
-
margin-right: -$spacer-4;
|
|
62
|
-
padding-left: $spacer-4;
|
|
63
|
-
padding-right: $spacer-4;
|
|
64
|
-
scrollbar-width: none; // Firefox
|
|
65
|
-
|
|
66
|
-
@include media-breakpoint-up(md) {
|
|
67
|
-
margin-left: -$spacer-6;
|
|
68
|
-
margin-right: -$spacer-6;
|
|
69
|
-
padding-left: $spacer-6;
|
|
70
|
-
padding-right: $spacer-6;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
@include media-breakpoint-up(lg) {
|
|
74
|
-
margin-left: -$spacer-7;
|
|
75
|
-
margin-right: -$spacer-7;
|
|
76
|
-
padding-left: $spacer-7;
|
|
77
|
-
padding-right: $spacer-7;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
&::-webkit-scrollbar {
|
|
81
|
-
display: none; // Safari and Chrome
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
.row {
|
|
2
|
-
|
|
3
|
-
&-application-layout {
|
|
4
|
-
|
|
5
|
-
@include media-breakpoint-up(xl) {
|
|
6
|
-
height: 100% !important;
|
|
7
|
-
position: fixed !important;
|
|
8
|
-
width: 100% !important;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
.col-content {
|
|
12
|
-
-ms-overflow-style: none; // Internet Explorer 10+
|
|
13
|
-
scrollbar-width: none; // Firefox
|
|
14
|
-
|
|
15
|
-
@include media-breakpoint-up(xl) {
|
|
16
|
-
height: 100% !important;
|
|
17
|
-
overflow: scroll !important;
|
|
18
|
-
padding-left: $spacer-7;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
&::-webkit-scrollbar {
|
|
22
|
-
display: none; // Safari and Chrome
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
.container-fluid {
|
|
26
|
-
|
|
27
|
-
@include media-breakpoint-up(xl) {
|
|
28
|
-
height: 100% !important;
|
|
29
|
-
padding-left: 0;
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
.sidebar {
|
|
2
|
-
|
|
3
|
-
.nav-link {
|
|
4
|
-
|
|
5
|
-
&:hover {
|
|
6
|
-
color: $dark;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
&.active:hover {
|
|
10
|
-
color: $white;
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
.btn-toggle {
|
|
15
|
-
color: $dark;
|
|
16
|
-
|
|
17
|
-
*[class^="fa"] {
|
|
18
|
-
color: $dark;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
&:active {
|
|
22
|
-
color: $dark;
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
}
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
// Variables
|
|
2
|
-
@import "simple/base/variables";
|
|
3
|
-
|
|
4
|
-
@import "simple/base/variables-light";
|
|
5
|
-
|
|
6
|
-
// Shared - Bootstrap variables (Funnel)
|
|
7
|
-
@import "base/bootstrap-variables";
|
|
8
|
-
|
|
9
|
-
// Bootstrap
|
|
10
|
-
@import "rails_admin/bootstrap/bootstrap";
|
|
11
|
-
|
|
12
|
-
// Base
|
|
13
|
-
@import "simple/base/typography";
|
|
14
|
-
|
|
15
|
-
// Layouts
|
|
16
|
-
@import "simple/layouts/rows";
|
|
17
|
-
|
|
18
|
-
// Components
|
|
19
|
-
@import "simple/components/alerts";
|
|
20
|
-
@import "simple/components/breadcrumbs";
|
|
21
|
-
@import "simple/components/buttons";
|
|
22
|
-
@import "simple/components/containers";
|
|
23
|
-
@import "simple/components/dropdowns";
|
|
24
|
-
@import "simple/components/filter-box";
|
|
25
|
-
@import "simple/components/filtering-multiselect";
|
|
26
|
-
@import "simple/components/filtering-select";
|
|
27
|
-
@import "simple/components/forms";
|
|
28
|
-
@import "simple/components/images";
|
|
29
|
-
@import "simple/components/links";
|
|
30
|
-
@import "simple/components/navs";
|
|
31
|
-
@import "simple/components/progress";
|
|
32
|
-
@import "simple/components/sidebar";
|
|
33
|
-
@import "simple/components/tables";
|
|
34
|
-
|
|
35
|
-
// Light - Components
|
|
36
|
-
@import "simple/light/components/sidebar";
|
|
37
|
-
@import "simple/light/components/links";
|
|
@@ -1,258 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module RailsAdmin
|
|
4
|
-
module ApplicationHelper
|
|
5
|
-
def authorized?(action_name, abstract_model = nil, object = nil)
|
|
6
|
-
object = nil if object.try :new_record?
|
|
7
|
-
action(action_name, abstract_model, object).try(:authorized?)
|
|
8
|
-
end
|
|
9
|
-
|
|
10
|
-
def current_action
|
|
11
|
-
params[:action].in?(%w[create new]) ? 'create' : 'update'
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
def current_action?(action, abstract_model = @abstract_model, object = @object)
|
|
15
|
-
@action.custom_key == action.custom_key &&
|
|
16
|
-
abstract_model.try(:to_param) == @abstract_model.try(:to_param) &&
|
|
17
|
-
(@object.try(:persisted?) ? @object.id == object.try(:id) : !object.try(:persisted?))
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
def action(key, abstract_model = nil, object = nil)
|
|
21
|
-
RailsAdmin::Config::Actions.find(key, controller: controller, abstract_model: abstract_model, object: object)
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
def actions(scope = :all, abstract_model = nil, object = nil)
|
|
25
|
-
RailsAdmin::Config::Actions.all(scope, controller: controller, abstract_model: abstract_model, object: object)
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
def edit_user_link
|
|
29
|
-
return nil unless _current_user.try(:email).present?
|
|
30
|
-
return nil unless (abstract_model = RailsAdmin.config(_current_user.class).abstract_model)
|
|
31
|
-
|
|
32
|
-
edit_action = action(:edit, abstract_model, _current_user)
|
|
33
|
-
authorized = edit_action.try(:authorized?)
|
|
34
|
-
content = edit_user_link_label
|
|
35
|
-
|
|
36
|
-
if authorized
|
|
37
|
-
edit_url = rails_admin.url_for(
|
|
38
|
-
action: edit_action.action_name,
|
|
39
|
-
model_name: abstract_model.to_param,
|
|
40
|
-
controller: 'rails_admin/main',
|
|
41
|
-
id: _current_user.id,
|
|
42
|
-
)
|
|
43
|
-
|
|
44
|
-
link_to content, edit_url, class: 'dropdown-item'
|
|
45
|
-
else
|
|
46
|
-
content_tag :span, content, class: 'dropdown-item'
|
|
47
|
-
end
|
|
48
|
-
end
|
|
49
|
-
|
|
50
|
-
def logout_path
|
|
51
|
-
if defined?(Devise)
|
|
52
|
-
scope = Devise::Mapping.find_scope!(_current_user)
|
|
53
|
-
begin
|
|
54
|
-
main_app.send("destroy_#{scope}_session_path")
|
|
55
|
-
rescue StandardError
|
|
56
|
-
false
|
|
57
|
-
end
|
|
58
|
-
elsif main_app.respond_to?(:logout_path)
|
|
59
|
-
main_app.logout_path
|
|
60
|
-
end
|
|
61
|
-
end
|
|
62
|
-
|
|
63
|
-
def logout_method
|
|
64
|
-
return [Devise.sign_out_via].flatten.first if defined?(Devise)
|
|
65
|
-
|
|
66
|
-
:delete
|
|
67
|
-
end
|
|
68
|
-
|
|
69
|
-
def wording_for(label, action = @action, abstract_model = @abstract_model, object = @object)
|
|
70
|
-
model_config = abstract_model.try(:config)
|
|
71
|
-
object = nil unless abstract_model && object.is_a?(abstract_model.model)
|
|
72
|
-
action = RailsAdmin::Config::Actions.find(action.to_sym) if action.is_a?(Symbol) || action.is_a?(String)
|
|
73
|
-
|
|
74
|
-
I18n.t(
|
|
75
|
-
"admin.actions.#{action.i18n_key}.#{label}",
|
|
76
|
-
model_label: model_config&.label,
|
|
77
|
-
model_label_plural: model_config&.label_plural,
|
|
78
|
-
object_label: model_config && object.try(model_config.object_label_method),
|
|
79
|
-
)
|
|
80
|
-
end
|
|
81
|
-
|
|
82
|
-
def main_navigation
|
|
83
|
-
nodes_stack = RailsAdmin::Config.visible_models(controller: controller)
|
|
84
|
-
node_model_names = nodes_stack.collect { |c| c.abstract_model.model_name }
|
|
85
|
-
parent_groups = nodes_stack.group_by { |n| n.parent&.to_s }
|
|
86
|
-
|
|
87
|
-
nodes_stack.group_by(&:navigation_label).collect do |navigation_label, nodes|
|
|
88
|
-
nodes = nodes.select { |n| n.parent.nil? || !n.parent.to_s.in?(node_model_names) }
|
|
89
|
-
li_stack = navigation parent_groups, nodes
|
|
90
|
-
|
|
91
|
-
label = navigation_label || t('admin.misc.navigation')
|
|
92
|
-
collapsible_stack(label, 'main', li_stack)
|
|
93
|
-
end.join.html_safe
|
|
94
|
-
end
|
|
95
|
-
|
|
96
|
-
def root_navigation
|
|
97
|
-
actions(:root).select(&:show_in_sidebar).group_by(&:sidebar_label).collect do |label, nodes|
|
|
98
|
-
li_stack = nodes.map do |node|
|
|
99
|
-
url = rails_admin.url_for(action: node.action_name, controller: 'rails_admin/main')
|
|
100
|
-
nav_icon = node.link_icon ? %(<i class="#{node.link_icon}"></i>).html_safe : ''
|
|
101
|
-
content_tag :li do
|
|
102
|
-
link_to nav_icon + " " + wording_for(:menu, node), url, class: "nav-link"
|
|
103
|
-
end
|
|
104
|
-
end.join.html_safe
|
|
105
|
-
label ||= t('admin.misc.root_navigation')
|
|
106
|
-
|
|
107
|
-
collapsible_stack(label, 'action', li_stack)
|
|
108
|
-
end.join.html_safe
|
|
109
|
-
end
|
|
110
|
-
|
|
111
|
-
def static_navigation
|
|
112
|
-
li_stack = RailsAdmin::Config.navigation_static_links.collect do |title, url|
|
|
113
|
-
content_tag(:li, link_to(title.to_s, url, target: '_blank', rel: 'noopener noreferrer', class: 'nav-link'))
|
|
114
|
-
end.join.html_safe
|
|
115
|
-
|
|
116
|
-
label = RailsAdmin::Config.navigation_static_label || t('admin.misc.navigation_static_label')
|
|
117
|
-
collapsible_stack(label, 'static', li_stack) || ''
|
|
118
|
-
end
|
|
119
|
-
|
|
120
|
-
def navigation(parent_groups, nodes, level = 0)
|
|
121
|
-
nodes.collect do |node|
|
|
122
|
-
abstract_model = node.abstract_model
|
|
123
|
-
model_param = abstract_model.to_param
|
|
124
|
-
url = rails_admin.url_for(action: :index, controller: 'rails_admin/main', model_name: model_param)
|
|
125
|
-
nav_icon = node.navigation_icon ? %(<i class="#{node.navigation_icon}"></i>).html_safe : ''
|
|
126
|
-
css_classes = ['nav-link']
|
|
127
|
-
css_classes.push("nav-level-#{level}") if level > 0
|
|
128
|
-
css_classes.push('active') if @action && current_action?(@action, model_param)
|
|
129
|
-
li = content_tag :li, class: "nav-item", data: {model: model_param} do
|
|
130
|
-
link_to nav_icon + " " + node.label_plural, url, class: css_classes.join(' ')
|
|
131
|
-
end
|
|
132
|
-
child_nodes = parent_groups[abstract_model.model_name]
|
|
133
|
-
child_nodes ? li + navigation(parent_groups, child_nodes, level + 1) : li
|
|
134
|
-
end.join.html_safe
|
|
135
|
-
end
|
|
136
|
-
|
|
137
|
-
def breadcrumb(action = @action, _acc = [])
|
|
138
|
-
begin
|
|
139
|
-
(parent_actions ||= []) << action
|
|
140
|
-
end while action.breadcrumb_parent && (action = action(*action.breadcrumb_parent)) # rubocop:disable Lint/Loop
|
|
141
|
-
|
|
142
|
-
content_tag(:ol, class: 'breadcrumb mb-0 mb-md-1') do
|
|
143
|
-
parent_actions.collect do |a|
|
|
144
|
-
am = a.send(:eval, 'bindings[:abstract_model]')
|
|
145
|
-
o = a.send(:eval, 'bindings[:object]')
|
|
146
|
-
content_tag(:li, class: ['breadcrumb-item', current_action?(a, am, o) && 'active']) do
|
|
147
|
-
if current_action?(a, am, o)
|
|
148
|
-
wording_for(:breadcrumb, a, am, o)
|
|
149
|
-
elsif a.http_methods.include?(:get)
|
|
150
|
-
link_to rails_admin.url_for(action: a.action_name, controller: 'rails_admin/main', model_name: am.try(:to_param), id: (o.try(:persisted?) && o.try(:id) || nil)) do
|
|
151
|
-
wording_for(:breadcrumb, a, am, o)
|
|
152
|
-
end
|
|
153
|
-
else
|
|
154
|
-
content_tag(:span, wording_for(:breadcrumb, a, am, o))
|
|
155
|
-
end
|
|
156
|
-
end
|
|
157
|
-
end.reverse.join.html_safe
|
|
158
|
-
end
|
|
159
|
-
end
|
|
160
|
-
|
|
161
|
-
# parent => :root, :collection, :member
|
|
162
|
-
# perf matters here (no action view trickery)
|
|
163
|
-
def menu_for(parent, abstract_model = nil, object = nil, only_icon = false)
|
|
164
|
-
actions = actions(parent, abstract_model, object).select { |a| a.http_methods.include?(:get) && a.show_in_menu }
|
|
165
|
-
actions.collect do |action|
|
|
166
|
-
wording = wording_for(:menu, action)
|
|
167
|
-
li_class = ['nav-item', 'icon', "#{action.key}_#{parent}_link"].
|
|
168
|
-
concat(action.enabled? ? [] : ['disabled'])
|
|
169
|
-
content_tag(:li, {class: li_class}.merge(only_icon ? {title: wording, rel: 'tooltip'} : {})) do
|
|
170
|
-
label = content_tag(:i, '', {class: "fa-sm #{action.link_icon}"}) + ' ' + content_tag(:span, wording, (only_icon ? {style: 'display:none'} : {}))
|
|
171
|
-
if action.enabled? || !only_icon
|
|
172
|
-
href =
|
|
173
|
-
if action.enabled?
|
|
174
|
-
rails_admin.url_for(action: action.action_name, controller: 'rails_admin/main', model_name: abstract_model.try(:to_param), id: (object.try(:persisted?) && object.try(:id) || nil))
|
|
175
|
-
else
|
|
176
|
-
'javascript:void(0)'
|
|
177
|
-
end
|
|
178
|
-
content_tag(:a, label, {href: href, target: action.link_target, class: ['nav-link', current_action?(action) && 'active', !action.enabled? && 'disabled'].compact}.merge(action.turbo? ? {} : {data: {turbo: 'false'}}))
|
|
179
|
-
else
|
|
180
|
-
content_tag(:span, label)
|
|
181
|
-
end
|
|
182
|
-
end
|
|
183
|
-
end.join(' ').html_safe
|
|
184
|
-
end
|
|
185
|
-
|
|
186
|
-
def bulk_menu(abstract_model = @abstract_model)
|
|
187
|
-
actions = actions(:bulkable, abstract_model)
|
|
188
|
-
return '' if actions.empty?
|
|
189
|
-
|
|
190
|
-
content_tag :li, class: 'nav-item dropdown dropdown-menu-end' do
|
|
191
|
-
content_tag(:a, class: 'nav-link dropdown-toggle', data: {'bs-toggle': 'dropdown'}, href: '#') { t('admin.misc.bulk_menu_title').html_safe + ' ' + '<b class="caret"></b>'.html_safe } +
|
|
192
|
-
content_tag(:ul, class: 'dropdown-menu', style: 'left:auto; right:0;') do
|
|
193
|
-
actions.collect do |action|
|
|
194
|
-
content_tag :li do
|
|
195
|
-
link_to wording_for(:bulk_link, action, abstract_model), '#', class: 'dropdown-item bulk-link', data: {action: action.action_name}
|
|
196
|
-
end
|
|
197
|
-
end.join.html_safe
|
|
198
|
-
end
|
|
199
|
-
end.html_safe
|
|
200
|
-
end
|
|
201
|
-
|
|
202
|
-
def flash_alert_class(flash_key)
|
|
203
|
-
case flash_key.to_s
|
|
204
|
-
when 'error' then 'alert-danger'
|
|
205
|
-
when 'alert' then 'alert-warning'
|
|
206
|
-
when 'notice' then 'alert-info'
|
|
207
|
-
else "alert-#{flash_key}"
|
|
208
|
-
end
|
|
209
|
-
end
|
|
210
|
-
|
|
211
|
-
def handle_asset_dependency_error
|
|
212
|
-
yield
|
|
213
|
-
rescue LoadError => e
|
|
214
|
-
if /sassc/.match?(e.message)
|
|
215
|
-
e = e.exception <<~MSG
|
|
216
|
-
#{e.message}
|
|
217
|
-
RailsAdmin requires the gem sassc-rails, make sure to put `gem 'sassc-rails'` to Gemfile.
|
|
218
|
-
MSG
|
|
219
|
-
end
|
|
220
|
-
raise e
|
|
221
|
-
end
|
|
222
|
-
|
|
223
|
-
# Workaround for https://github.com/rails/rails/issues/31325
|
|
224
|
-
def image_tag(source, options = {})
|
|
225
|
-
if %w[ActiveStorage::Variant ActiveStorage::VariantWithRecord ActiveStorage::Preview].include? source.class.to_s
|
|
226
|
-
super main_app.route_for(ActiveStorage.resolve_model_to_route, source), options
|
|
227
|
-
else
|
|
228
|
-
super
|
|
229
|
-
end
|
|
230
|
-
end
|
|
231
|
-
|
|
232
|
-
private
|
|
233
|
-
|
|
234
|
-
def edit_user_link_label
|
|
235
|
-
"#{icon('fa-solid', 'user', class: 'fa-sm fa-fw me-2')}Your account".html_safe
|
|
236
|
-
end
|
|
237
|
-
|
|
238
|
-
def gravatar_url(email)
|
|
239
|
-
"https://secure.gravatar.com/avatar/#{Digest::MD5.hexdigest email}?s=30"
|
|
240
|
-
end
|
|
241
|
-
|
|
242
|
-
def collapsible_stack(label, class_prefix, li_stack)
|
|
243
|
-
return nil unless li_stack.present?
|
|
244
|
-
|
|
245
|
-
collapse_classname = "#{class_prefix}-#{Digest::MD5.hexdigest(label)[0..7]}"
|
|
246
|
-
content_tag(:li) do
|
|
247
|
-
content_tag(:button, 'aria-expanded': true, class: 'btn btn-toggle align-items-center', data: {bs_toggle: "collapse", bs_target: ".sidebar .#{collapse_classname}"}) do
|
|
248
|
-
html_escape(' ' + label) + content_tag(:i, '', class: 'fas fa-sm fa-angle-up')
|
|
249
|
-
end +
|
|
250
|
-
content_tag(:div, class: "collapse show #{collapse_classname}") do
|
|
251
|
-
content_tag(:ul, class: 'btn-toggle-nav list-unstyled') do
|
|
252
|
-
li_stack
|
|
253
|
-
end
|
|
254
|
-
end
|
|
255
|
-
end
|
|
256
|
-
end
|
|
257
|
-
end
|
|
258
|
-
end
|