ditty 0.8.0 → 0.10.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (169) hide show
  1. checksums.yaml +4 -4
  2. data/.env.test +2 -0
  3. data/.gitignore +3 -0
  4. data/.pryrc +2 -0
  5. data/.rubocop.yml +23 -4
  6. data/.travis.yml +4 -8
  7. data/CNAME +1 -0
  8. data/Dockerfile +18 -0
  9. data/Gemfile.ci +0 -17
  10. data/Rakefile +2 -2
  11. data/_config.yml +1 -0
  12. data/config.ru +4 -4
  13. data/ditty.gemspec +28 -18
  14. data/docs/CNAME +1 -0
  15. data/docs/_config.yml +1 -0
  16. data/docs/index.md +34 -0
  17. data/exe/ditty +2 -0
  18. data/lib/ditty/cli.rb +41 -5
  19. data/lib/ditty/components/{app.rb → ditty.rb} +18 -16
  20. data/lib/ditty/controllers/{application.rb → application_controller.rb} +63 -34
  21. data/lib/ditty/controllers/{audit_logs.rb → audit_logs_controller.rb} +4 -2
  22. data/lib/ditty/controllers/{auth.rb → auth_controller.rb} +22 -18
  23. data/lib/ditty/controllers/{component.rb → component_controller.rb} +23 -20
  24. data/lib/ditty/controllers/{main.rb → main_controller.rb} +6 -2
  25. data/lib/ditty/controllers/roles_controller.rb +23 -0
  26. data/lib/ditty/controllers/user_login_traits_controller.rb +46 -0
  27. data/lib/ditty/controllers/{users.rb → users_controller.rb} +13 -11
  28. data/lib/ditty/db.rb +7 -5
  29. data/lib/ditty/emails/base.rb +37 -32
  30. data/lib/ditty/generators/crud_generator.rb +114 -0
  31. data/lib/ditty/generators/migration_generator.rb +26 -0
  32. data/lib/ditty/generators/project_generator.rb +52 -0
  33. data/lib/ditty/helpers/component.rb +2 -1
  34. data/lib/ditty/helpers/pundit.rb +24 -8
  35. data/lib/ditty/helpers/response.rb +15 -13
  36. data/lib/ditty/helpers/views.rb +28 -6
  37. data/lib/ditty/listener.rb +6 -4
  38. data/lib/ditty/memcached.rb +8 -0
  39. data/lib/ditty/middleware/accept_extension.rb +2 -2
  40. data/lib/ditty/middleware/error_catchall.rb +2 -2
  41. data/lib/ditty/models/base.rb +9 -0
  42. data/lib/ditty/models/identity.rb +11 -7
  43. data/lib/ditty/models/role.rb +1 -0
  44. data/lib/ditty/models/user.rb +23 -2
  45. data/lib/ditty/policies/role_policy.rb +1 -1
  46. data/lib/ditty/policies/user_login_trait_policy.rb +1 -1
  47. data/lib/ditty/policies/user_policy.rb +1 -1
  48. data/lib/ditty/services/authentication.rb +27 -16
  49. data/lib/ditty/services/email.rb +19 -15
  50. data/lib/ditty/services/logger.rb +26 -20
  51. data/lib/ditty/services/pagination_wrapper.rb +7 -5
  52. data/lib/ditty/services/settings.rb +7 -6
  53. data/lib/ditty/tasks/ditty.rake +19 -1
  54. data/lib/ditty/tasks/omniauth-ldap.rake +2 -2
  55. data/lib/ditty/templates/.gitignore +5 -0
  56. data/lib/ditty/templates/.rspec +2 -0
  57. data/lib/ditty/templates/.rubocop.yml +7 -0
  58. data/lib/ditty/templates/Rakefile +12 -0
  59. data/lib/ditty/templates/application.rb +12 -0
  60. data/lib/ditty/templates/config.ru +37 -0
  61. data/lib/ditty/templates/controller.rb.erb +64 -0
  62. data/lib/ditty/templates/env.example +4 -0
  63. data/lib/ditty/templates/lib/project.rb.erb +5 -0
  64. data/lib/ditty/templates/logs/.empty_directory +0 -0
  65. data/lib/ditty/templates/migration.rb.erb +7 -0
  66. data/lib/ditty/templates/model.rb.erb +26 -0
  67. data/lib/ditty/templates/pids/.empty_directory +0 -0
  68. data/lib/ditty/templates/policy.rb.erb +48 -0
  69. data/{public → lib/ditty/templates/public}/browserconfig.xml +0 -0
  70. data/lib/ditty/templates/public/css/sb-admin-2.min.css +10 -0
  71. data/lib/ditty/templates/public/css/styles.css +13 -0
  72. data/lib/ditty/templates/public/favicon.ico +0 -0
  73. data/{public → lib/ditty/templates/public}/images/apple-icon.png +0 -0
  74. data/{public → lib/ditty/templates/public}/images/favicon-16x16.png +0 -0
  75. data/{public → lib/ditty/templates/public}/images/favicon-32x32.png +0 -0
  76. data/{public → lib/ditty/templates/public}/images/launcher-icon-1x.png +0 -0
  77. data/{public → lib/ditty/templates/public}/images/launcher-icon-2x.png +0 -0
  78. data/{public → lib/ditty/templates/public}/images/launcher-icon-4x.png +0 -0
  79. data/{public → lib/ditty/templates/public}/images/mstile-150x150.png +0 -0
  80. data/{public → lib/ditty/templates/public}/images/safari-pinned-tab.svg +0 -0
  81. data/lib/ditty/templates/public/js/sb-admin-2.min.js +7 -0
  82. data/lib/ditty/templates/public/js/scripts.js +1 -0
  83. data/{public/manifest.json → lib/ditty/templates/public/manifest.json.erb} +2 -2
  84. data/lib/ditty/templates/settings.yml.erb +29 -0
  85. data/lib/ditty/templates/sidekiq.rb +18 -0
  86. data/lib/ditty/templates/sidekiq.yml +9 -0
  87. data/lib/ditty/templates/spec_helper.rb +43 -0
  88. data/lib/ditty/templates/type.rb.erb +21 -0
  89. data/lib/ditty/templates/views/display.haml.tt +20 -0
  90. data/lib/ditty/templates/views/edit.haml.tt +10 -0
  91. data/lib/ditty/templates/views/form.haml.tt +11 -0
  92. data/lib/ditty/templates/views/index.haml.tt +29 -0
  93. data/lib/ditty/templates/views/new.haml.tt +10 -0
  94. data/lib/ditty/version.rb +1 -1
  95. data/lib/ditty.rb +6 -4
  96. data/lib/rubocop/cop/ditty/call_services_directly.rb +2 -2
  97. data/migrate/20181209_add_user_login_traits.rb +4 -4
  98. data/migrate/20190220_add_parent_id_to_roles.rb +9 -0
  99. data/spec/ditty/api_spec.rb +51 -0
  100. data/spec/ditty/controllers/roles_spec.rb +67 -0
  101. data/spec/ditty/controllers/user_login_traits_spec.rb +72 -0
  102. data/spec/ditty/controllers/users_spec.rb +72 -0
  103. data/spec/ditty/emails/base_spec.rb +76 -0
  104. data/spec/ditty/emails/forgot_password_spec.rb +20 -0
  105. data/spec/ditty/helpers/component_spec.rb +85 -0
  106. data/spec/ditty/models/user_spec.rb +36 -0
  107. data/spec/ditty/services/email_spec.rb +36 -0
  108. data/spec/ditty/services/logger_spec.rb +68 -0
  109. data/spec/ditty/services/settings_spec.rb +63 -0
  110. data/spec/ditty_spec.rb +9 -0
  111. data/spec/factories.rb +46 -0
  112. data/spec/fixtures/logger.yml +17 -0
  113. data/spec/fixtures/section.yml +3 -0
  114. data/spec/fixtures/settings.yml +8 -0
  115. data/spec/spec_helper.rb +51 -0
  116. data/spec/support/api_shared_examples.rb +250 -0
  117. data/spec/support/crud_shared_examples.rb +145 -0
  118. data/views/403.haml +1 -1
  119. data/views/404.haml +2 -4
  120. data/views/500.haml +11 -0
  121. data/views/audit_logs/index.haml +32 -33
  122. data/views/auth/forgot_password.haml +32 -16
  123. data/views/auth/identity.haml +14 -13
  124. data/views/auth/ldap.haml +2 -2
  125. data/views/auth/login.haml +23 -17
  126. data/views/auth/register.haml +20 -18
  127. data/views/auth/register_identity.haml +27 -12
  128. data/views/auth/reset_password.haml +36 -19
  129. data/views/blank.haml +43 -0
  130. data/views/embedded.haml +17 -11
  131. data/views/index.haml +1 -1
  132. data/views/layout.haml +45 -30
  133. data/views/partials/actions.haml +15 -14
  134. data/views/partials/content_tag.haml +0 -0
  135. data/views/partials/delete_form.haml +1 -1
  136. data/views/partials/filter_control.haml +2 -2
  137. data/views/partials/footer.haml +6 -5
  138. data/views/partials/form_control.haml +19 -12
  139. data/views/partials/form_tag.haml +1 -1
  140. data/views/partials/navitems.haml +42 -0
  141. data/views/partials/notifications.haml +12 -8
  142. data/views/partials/pager.haml +44 -25
  143. data/views/partials/search.haml +15 -11
  144. data/views/partials/sidebar.haml +15 -37
  145. data/views/partials/sort_ui.haml +2 -0
  146. data/views/partials/topbar.haml +53 -0
  147. data/views/partials/user_associations.haml +32 -0
  148. data/views/quick_start.haml +23 -0
  149. data/views/roles/display.haml +27 -6
  150. data/views/roles/edit.haml +3 -3
  151. data/views/roles/form.haml +1 -0
  152. data/views/roles/index.haml +23 -16
  153. data/views/roles/new.haml +2 -2
  154. data/views/user_login_traits/display.haml +4 -4
  155. data/views/user_login_traits/edit.haml +3 -3
  156. data/views/user_login_traits/index.haml +23 -25
  157. data/views/user_login_traits/new.haml +2 -2
  158. data/views/users/display.haml +14 -15
  159. data/views/users/edit.haml +3 -3
  160. data/views/users/form.haml +0 -0
  161. data/views/users/index.haml +31 -24
  162. data/views/users/login_traits.haml +6 -8
  163. data/views/users/new.haml +2 -2
  164. data/views/users/profile.haml +15 -15
  165. data/views/users/user.haml +1 -1
  166. metadata +271 -63
  167. data/lib/ditty/controllers/roles.rb +0 -13
  168. data/lib/ditty/controllers/user_login_traits.rb +0 -18
  169. data/views/partials/navbar.haml +0 -22
@@ -1,14 +1,15 @@
1
- - if actions.count > 1
2
- - link, text = actions.shift
3
- .btn-group.text-right
4
- %a.btn.btn-primary{ href: link }= text
5
- %button.btn.btn-primary.dropdown-toggle{ type: 'button', id: 'actions-toggle', data: { toggle: 'dropdown' } }
6
- %span.caret
7
- %span.sr-only Toggle Dropdown
8
- %ul.dropdown-menu{ 'aria-labelledby': 'actions-toggle' }
9
- -actions.each do |k, v|
10
- %li
11
- %a{ href: k }= v
12
- - elsif actions.count > 0
13
- -actions.each do |k, v|
14
- %a.btn.btn-primary{ href: k }= v
1
+ - if defined?(actions)
2
+ - if actions.count > 1
3
+ - link, text = actions.shift
4
+ .btn-group.text-right
5
+ %a.btn.btn-primary{ href: link }= text
6
+ %button.btn.btn-primary.dropdown-toggle{ type: 'button', id: 'actions-toggle', data: { toggle: 'dropdown' } }
7
+ %span.caret
8
+ %span.sr-only Toggle Dropdown
9
+ %ul.dropdown-menu{ 'aria-labelledby': 'actions-toggle' }
10
+ -actions.each do |k, v|
11
+ %li
12
+ %a{ href: k }= v
13
+ - elsif actions.count > 0
14
+ -actions.each do |k, v|
15
+ %a.btn.btn-primary{ href: k }= v
File without changes
@@ -1,2 +1,2 @@
1
- = delete_form_tag "#{base_path}/#{entity.id}" do
1
+ = delete_form_tag "#{base_path}/#{entity.display_id}" do
2
2
  %button.btn.btn-danger{ type: 'submit' }= delete_label
@@ -1,6 +1,6 @@
1
- .form-group
1
+ .form-group{ class: total_filters.to_i > 4 ? 'col-3' : 'col-md'}
2
2
  %label{ for: "filter_#{name}" }= label
3
- %select.form-control{ name: name, id: "filter_#{name}" }
3
+ %select.form-control.select2{ style: 'width: 100%', name: name, id: "filter_#{name}" }
4
4
  %option{ value: '' } -- Select One --
5
5
  - options.each do |k,v| k ||= v; v ||= k;
6
6
  %option{ value: k, selected: (params[name].eql? k)}= v
@@ -1,5 +1,6 @@
1
- %footer.footer.text-muted.text-center
2
- %hr
3
- .copyright
4
- :plain
5
- &copy; <script>document.write(new Date().getFullYear())</script>, Ditty
1
+ / Footer
2
+ %footer.sticky-footer.bg-light
3
+ .container.my-auto
4
+ -if ENV['SKIP_BRANDING'].blank?
5
+ .copyright.text-center.my-auto.text-dark
6
+ %span Copyright &copy; Ditty.io 2019
@@ -1,24 +1,31 @@
1
1
  - type = attributes.delete(:type)
2
+ - attributes[:value] ||= model.send(field) || default
3
+ - if help_text
4
+ - attributes[:'aria-describedby'] = "#{attributes[:id]}_helptext"
2
5
  - if type == 'hidden'
3
- %input{attributes, type: type, value: model[field] || default}
6
+ %input{attributes, type: type, value: model.send(field) || default}
4
7
  - else
5
- %div{ class: "form-group#{model.errors[field] ? ' has-error' : ''}" }
8
+ .form-group
6
9
  - if type != 'file'
7
- %label.col-sm-3.control-label{ for: attributes[:id] }= label
8
- .col-sm-9
10
+ %label{ for: attributes[:id] }= label
9
11
  - if type == 'select'
10
12
  - options = attributes.delete(:options)
13
+ - value = attributes.delete(:value)
14
+ - if attributes[:multiple]
15
+ - attributes[:name] = "#{attributes[:name]}[]" unless attributes[:name][-2..-1] == '[]'
11
16
  %select{attributes}
12
17
  - if attributes[:multiple]
13
- - options.each do |k,v| k ||= v; v ||= k;
14
- %option{ value: k, selected: (model.send(field).map(&:id).include? k)}= v
18
+ - options.each do |k, v| k = v if k.nil?; v = k if v.nil?;
19
+ %option{ value: k.to_s, selected: value&.include?(k) }= v
15
20
  - else
16
- %option{ value: ""} -- Select One --
17
- - options.each do |k,v| k ||= v; v ||= k;
18
- %option{ value: k, selected: [model[field].to_s, default].include?(k.to_s)}= v
21
+ %option{ value: "" } -- Select One --
22
+ - options.each do |k, v| k = v if k.nil?; v = k if v.nil?;
23
+ %option{ value: k.to_s, selected: value == k }= v
19
24
  - elsif type == 'textarea'
20
- %textarea{attributes}= preserve(model[field] || default)
25
+ %textarea{attributes}= preserve(model.send(field) || default)
21
26
  - else
22
- %input{attributes, type: type, value: model[field] || default}
27
+ %input{ attributes, type: type }
23
28
  - if model.errors[field]
24
- %p.help-block.text-danger= model.errors[field].join(', ')
29
+ .invalid-feedback= model.errors[field].join(', ')
30
+ - if help_text
31
+ %small.form-text.text-muted{ id: "#{attributes[:id]}_helptext" }= help_text
@@ -1,5 +1,5 @@
1
1
  %form{ { method: %i[get post].include?(form_verb.to_sym) ? form_verb : :post, action: url }.merge(attributes) }
2
- = Rack::Csrf.csrf_tag(env) unless ENV['APP_ENV'] == 'test'
2
+ = Rack::Csrf.csrf_tag(env) unless form_verb.to_sym == :get || ENV['APP_ENV'] == 'test'
3
3
  - if form_verb.to_sym == :get && layout
4
4
  %input{ name: 'layout', value: layout, type: 'hidden' }
5
5
  - if %i[get post].include?(form_verb.to_sym) == false
@@ -0,0 +1,42 @@
1
+ - if authenticated?
2
+ - Ditty::Components.navigation(request).each do |item|
3
+ - if item[:type] == 'divider'
4
+ %hr.sidebar-divider.my-0
5
+ - elsif item[:target].nil? || policy(item[:target]).list?
6
+ - if item[:group]
7
+ %li.nav-item
8
+ %a.nav-link.collapsed{ href: '#', 'data-toggle': 'collapse', 'data-target': "##{item[:group].parameterize}", 'aria-expanded': 'true', 'aria-controls': item[:group].parameterize }
9
+ - if item[:icon]
10
+ %i.fas.fa-fw{ class: "fa-#{item[:icon]}" }
11
+ %span= item[:group]
12
+ .collapse{ id: item[:group].parameterize, 'data-parent': '#accordionSidebar' }
13
+ .bg-white.py-2.collapse-inner.rounded
14
+ - item[:items].each do |sub_item|
15
+ - next unless sub_item[:target] && policy(sub_item[:target]).list?
16
+ %a.collapse-item{ href: "#{settings.map_path}#{sub_item[:link]}" }
17
+ - if sub_item[:icon]
18
+ %i.fa.fa-fw{ class: "fa-#{sub_item[:icon]}" }
19
+ = sub_item[:text]
20
+ - else
21
+ %li.nav-item
22
+ %a.nav-link{ href: "#{settings.map_path}#{item[:link]}" }
23
+ - if item[:icon]
24
+ %i.fas.fa-fw{ class: "fa-#{item[:icon]}" }
25
+ %span= item[:text]
26
+ %hr.sidebar-divider.my-0
27
+ %li.nav-item
28
+ = delete_form_tag("#{settings.map_path}/auth", attributes: { id: 'logout-form' }) do
29
+ %a.nav-link{ type: 'submit', onClick: 'document.getElementById("logout-form").submit()' }
30
+ %i.fas.fa-fw.fa-sign-out-alt
31
+ %span Logout
32
+ - else
33
+ %li.nav-item
34
+ %a.nav-link{ href: "#{settings.map_path}/auth/login" }
35
+ %i.fas.fa-fw.fa-user
36
+ %span Log In
37
+ - if policy(::Ditty::User).register?
38
+ %li.nav-item
39
+ %a.nav-link{ href: "#{settings.map_path}/auth/register" }
40
+ %i.fas.fa-fw.fa-pen-square
41
+ %span Register
42
+
@@ -1,28 +1,32 @@
1
1
  - if flash[:danger]
2
2
  .alert.alert-danger.alert-dismissible{ role: "alert" }
3
- %button.close{ 'type' => 'button', 'aria-hidden' => 'true', 'area-label' => 'true', 'data-dismiss' => 'alert' } &times;
4
- %ul
3
+ %button.close{ type: 'button', 'aria-label': 'Close', 'data-dismiss': 'alert' }
4
+ %span{ 'aria-hidden': 'true' } &times;
5
+ %ul.mb-0
5
6
  - [*flash[:danger]].each do |msg|
6
7
  %li= msg
7
8
 
8
9
  - if flash[:warning]
9
10
  .alert.alert-warning.alert-dismissible{ role: "alert" }
10
- %button.close{ 'type' => 'button', 'aria-hidden' => 'true', 'area-label' => 'true', 'data-dismiss' => 'alert' } &times;
11
- %ul
11
+ %button.close{ type: 'button', 'aria-label': 'Close', 'data-dismiss': 'alert' }
12
+ %span{ 'aria-hidden': 'true' } &times;
13
+ %ul.mb-0
12
14
  - [*flash[:warning]].each do |msg|
13
15
  %li= msg
14
16
 
15
17
  - if flash[:success]
16
18
  .alert.alert-success.alert-dismissible{ role: "alert" }
17
- %button.close{ 'type' => 'button', 'aria-hidden' => 'true', 'area-label' => 'true', 'data-dismiss' => 'alert' } &times;
18
- %ul
19
+ %button.close{ type: 'button', 'aria-label': 'Close', 'data-dismiss': 'alert' }
20
+ %span{ 'aria-hidden': 'true' } &times;
21
+ %ul.mb-0
19
22
  - [*flash[:success]].each do |msg|
20
23
  %li= msg
21
24
 
22
25
 
23
26
  - if flash[:info]
24
27
  .alert.alert-info.alert-dismissible{ role: "alert" }
25
- %button.close{ 'type' => 'button', 'aria-hidden' => 'true', 'area-label' => 'true', 'data-dismiss' => 'alert' } &times;
26
- %ul
28
+ %button.close{ type: 'button', 'aria-label': 'Close', 'data-dismiss': 'alert' }
29
+ %span{ 'aria-hidden': 'true' } &times;
30
+ %ul.mb-0
27
31
  - [*flash[:info]].each do |msg|
28
32
  %li= msg
@@ -1,26 +1,45 @@
1
1
  %nav{"aria-label" => "Page navigation"}
2
- - if list.pagination_record_count > 0
3
- %p.text-center Showing #{list.current_page_record_range} of #{list.pagination_record_count} records
4
- %ul.pager
5
- - if list.first_page?
6
- %li.disabled
7
- %span First
8
- %li.disabled
9
- %span Previous
10
- - else
11
- %li
12
- %a{href: first_link} First
13
- %li
14
- %a{href: prev_link} Previous
15
- - if list.last_page?
16
- %li.disabled
17
- %span Next
18
- %li.disabled
19
- %span Last
20
- - else
21
- %li
22
- %a{href: next_link} Next
23
- %li
24
- %a{href: last_link} Last
25
- - else
26
- %p.text-center No records to show
2
+ .row
3
+ .col-sm-12.col-md-6
4
+ %p.my-2
5
+ - if list.pagination_record_count > 0
6
+ Showing #{list.current_page_record_range} of #{list.pagination_record_count} records
7
+ - else
8
+ %p.text-center No records to show
9
+ .col-sm-12.col-md-6
10
+ - if list.pagination_record_count > 0
11
+ %ul.pagination.justify-content-end
12
+ - if list.first_page?
13
+ %li.page-item.disabled
14
+ %span.page-link First
15
+ %li.page-item.disabled
16
+ %span.page-link Previous
17
+ - else
18
+ %li.page-item
19
+ %a.page-link{ href: first_link } First
20
+ %li.page-item
21
+ %a.page-link{ href: prev_link } Previous
22
+ %li.page-item
23
+ .dropdown
24
+ %button.page-link.dropdown-toggle{ type: 'button', id: 'dropdownMenuButton', 'data-toggle': 'dropdown', 'aria-haspopup': 'true', 'aria-expanded': 'false' }
25
+ = params[:count] || 10
26
+ .dropdown-menu
27
+ %a.dropdown-item{ href: "#{base_path}?#{query_string(count: 10)}" } 10
28
+ %a.dropdown-item{ href: "#{base_path}?#{query_string(count: 25)}" } 25
29
+ %a.dropdown-item{ href: "#{base_path}?#{query_string(count: 50)}" } 50
30
+ %a.dropdown-item{ href: "#{base_path}?#{query_string(count: 100)}" } 100
31
+ - if list.last_page?
32
+ %li.page-item.disabled
33
+ %span.page-link Next
34
+ %li.page-item.disabled
35
+ %span.page-link Last
36
+ - else
37
+ %li.page-item
38
+ %a.page-link{ href: next_link } Next
39
+ %li.page-item
40
+ %a.page-link{ href: last_link } Last
41
+ %li
42
+ &nbsp;
43
+ %li
44
+ %a.page-link{ href: "#{base_path}/.csv?#{URI.encode_www_form(params.merge(count: 'all'))}" }
45
+ Export
@@ -1,21 +1,25 @@
1
- - if self.class.const_defined?(:SEARCHABLE) || self.class.const_defined?(:FILTERS)
1
+ - if self.class.const_defined?(:SEARCHABLE) && SEARCHABLE.count.positive? || self.class.const_defined?(:FILTERS) && FILTERS.count.positive?
2
2
  = form_tag(base_path, form_verb: :get, attributes: { class: '' }) do
3
- - if self.class.const_defined?(:SEARCHABLE)
3
+ - if self.class.const_defined?(:SEARCHABLE) && SEARCHABLE.count.positive?
4
4
  .form-group
5
5
  .input-group
6
6
  %input.form-control{ name: 'q', type: 'text', placeholder: 'Search...', value: params[:q] }
7
7
  .input-group-btn
8
8
  %button.btn.btn-primary{ type: 'submit' }
9
9
  %span.fa.fa-search
10
- - if self.class.const_defined? :FILTERS
10
+ - if self.class.const_defined?(:FILTERS) && FILTERS.count.positive?
11
11
  .input-group-btn
12
- %button.btn.btn-default{ type: 'button', :'data-toggle' => 'collapse', :'data-target' => '#filter-form', :'aria-expanded' => 'false', :'aria-controls' => '#filter-form'}
12
+ %button.btn.btn-secondary{ type: 'button', :'data-toggle' => 'collapse', :'data-target' => '#filter-form', :'aria-expanded' => 'false', :'aria-controls' => '#filter-form'}
13
13
  %span.fa.fa-arrow-down
14
14
 
15
- - if self.class.const_defined?(:FILTERS)
16
- #filter-form{ class: self.class.const_defined?(:SEARCHABLE) ? 'collapse' : '' }
17
- .form-inline
18
- - FILTERS.each do |filter|
19
- = filter_control(filter)
20
- - unless self.class.const_defined?(:SEARCHABLE)
21
- %button.btn.btn-default{ type: 'submit'} Go
15
+ - if self.class.const_defined?(:FILTERS) && FILTERS.count.positive?
16
+ #filter-form{ class: self.class.const_defined?(:SEARCHABLE) && SEARCHABLE.count.positive? ? 'collapse' : '' }
17
+ .card.card-default.mb-2
18
+ .card-body
19
+ .row
20
+ - FILTERS.each do |filter|
21
+ = filter_control(filter, filters: FILTERS.count)
22
+ - unless self.class.const_defined?(:SEARCHABLE) && SEARCHABLE.count.positive?
23
+ .form-group
24
+ %label
25
+ %button.form-control.btn.btn-secondary{ type: 'submit'} Go
@@ -1,37 +1,15 @@
1
- .sidebar-nav.navbar-collapse
2
- %ul.nav.nav-pills.nav-stacked
3
- - if authenticated?
4
- %li
5
- %a{ href: "#{settings.map_path}/" }
6
- %i.fa.fa-home.fa-fw
7
- Home
8
- - Ditty::Components.navigation.each do |item|
9
- - if item[:target].nil? || policy(item[:target]).list?
10
- - if item[:group]
11
- %li
12
- %a{ href: '#' }
13
- %i.fa.fa-fw{ class: "fa-#{item[:icon]}" }
14
- =item[:group]
15
- %span.fa.arrow
16
- %ul.nav.nav-second-level
17
- - item[:items].each do |sub_item|
18
- - if sub_item[:target].nil? || policy(sub_item[:target]).list?
19
- %li
20
- %a{ href: "#{settings.map_path}#{sub_item[:link]}" }
21
- %i.fa.fa-fw{ class: "fa-#{sub_item[:icon]}" }
22
- = sub_item[:text]
23
- - else
24
- %li
25
- %a{ href: "#{settings.map_path}#{item[:link]}" }
26
- %i.fa.fa-fw{ class: "fa-#{item[:icon]}" }
27
- = item[:text]
28
- - else
29
- %li
30
- %a{ href: "#{settings.map_path}/auth/login" }
31
- %i.fa.fa-user.fa-fw
32
- Log In
33
- - if policy(::Ditty::User).register?
34
- %li
35
- %a{ href: "#{settings.map_path}/auth/register" }
36
- %i.fa.fa-pencil-square-o.fa-fw
37
- Register
1
+ / Sidebar
2
+ %ul#accordionSidebar.navbar-nav.bg-gradient-primary.sidebar.sidebar-dark.accordion
3
+ / Sidebar - Brand
4
+ %a.sidebar-brand.d-flex.align-items-center.justify-content-center{ href: config('ditty.home_page', settings.map_path || '/') }
5
+ .sidebar-brand-icon.rotate-n-15
6
+ %i.fas{ class: config('ditty.brand-icon', 'fa-laugh-wink') }
7
+ .sidebar-brand-text.mx-3
8
+ = config('ditty.title', 'Ditty')
9
+
10
+ %hr.sidebar-divider.my-0
11
+
12
+ = haml :'partials/navitems'
13
+
14
+ .text-center.d-none.d-md-inline
15
+ %button#sidebarToggle.rounded-circle.border-0
@@ -0,0 +1,2 @@
1
+ %a{ href: "#{base_path}?#{sort_query(field)}" }
2
+ %i.fa{ class: sort_icon(field) }
@@ -0,0 +1,53 @@
1
+ %nav.navbar.navbar-expand.navbar-light.bg-white.topbar.mb-4.static-top.shadow
2
+ / Sidebar Toggle
3
+ %button#sidebarToggleTop.btn.btn-link.d-md-none.rounded-circle.mr-3
4
+ %i.fa.fa-bars
5
+
6
+ / Topbar Search
7
+ %form.d-none.d-sm-inline-block.form-inline.mr-auto.ml-md-3.my-2.my-md-0.mw-100.navbar-search
8
+ .input-group
9
+ %input.form-control.bg-light.border-0.small{ type: 'text', placeholder: 'Search for...', 'aria-label': 'Search', 'aria-describedby': 'basic-addon2' }
10
+ .input-group-append
11
+ %button.btn.btn-primary{ type: 'button' }
12
+ %i.fas.fa-search.fa-sm
13
+
14
+ / Topbar Navbar
15
+ %ul.navbar-nav.ml-auto
16
+ / Nav Item - Search Dropdown (Visible Only XS)
17
+ %li.nav-item.dropdown.no-arrow.d-sm-none
18
+ %a#searchDropdown.nav-link.dropdown-toggle{ href: '#', role: 'button', 'data-toggle': 'dropdown', 'aria-haspopup': 'true', 'aria-expanded': 'false' }
19
+ %i.fas.fa-search.fa-fw
20
+ / Dropdown - Messages
21
+ .dropdown-menu.dropdown-menu-right.p-3.shadow.animated--grow-in{ :'aria-labelledby' => 'searchDropdown' }
22
+ %form.form-inline.mr-auto.w-100.navbar-search
23
+ .input-group
24
+ %input.form-control.bg-light.border-0.small{ type: 'text', placeholder: 'Search for...', :'aria-label' => 'Search', :'aria-describedby' => 'basic-addon2' }
25
+ .input-group-append
26
+ %button.btn.btn-primary{ type: 'button' }
27
+ %i.fas.fa-.fa-sm
28
+
29
+
30
+ .topbar-divider.d-none.d-sm-block
31
+
32
+ / Nav Item - User Information
33
+ - if authenticated?
34
+ %li.nav-item.dropdown.no-arrow
35
+ %a#userDropdown.nav-link.dropdown-toggle{ href: '#', role: 'button', 'aria-haspopup': 'true', 'area-expanded': 'false', 'data-toggle': 'dropdown' }
36
+ %span.mr-2.d-none.d-lg-inline.text-gray-600.small= current_user.display_name
37
+ %img.img-profile.rounded-circle{ src: current_user.gravatar }
38
+ / Dropdown - User Information
39
+ .dropdown-menu.dropdown-menu-right.shadow.animated--grow-in{ 'aria-labelledby': 'userDropdown' }
40
+ %a.dropdown-item{ href: "#{settings.map_path}/users/profile" }
41
+ %i.fas.fa-user.fa-sm.fa-fw.mr-2.text-gray-400
42
+ Profile
43
+ / %a.dropdown-item{ href: '#' }
44
+ / %i.fas.fa-cogs.fa-sm.fa-fw.mr-2.text-gray-400
45
+ / Settings
46
+ %a.dropdown-item{ href: "#{settings.map_path}/login-traits" }
47
+ %i.fas.fa-list.fa-sm.fa-fw.mr-2.text-gray-400
48
+ Past Logins
49
+ .dropdown-divider
50
+ %a.dropdown-item{ href: '#', data: { toggle: 'modal', target: '#logoutModal' } }
51
+ %i.fas.fa-sign-out-alt.fa-sm.fa-fw.mr-2.text-gray-400
52
+ Logout
53
+ - else
@@ -0,0 +1,32 @@
1
+ - group = entity.class.to_s.demodulize.underscore
2
+ %table.table.mb-0
3
+ %tbody
4
+ - if entity.users.count.positive?
5
+ - entity.users.each do |user|
6
+ %tr
7
+ %td
8
+ - if policy(user).read?
9
+ %a{ href: "#{settings.map_path}/users/#{user.id}" }
10
+ = user.username
11
+ - else
12
+ = user.username
13
+ %td.text-right
14
+ = delete_form_tag "#{base_path}/#{entity.display_id}/users/#{user.id}" do
15
+ %button.btn.btn-danger.btn-sm{ type: 'submit' } &times;
16
+ - else
17
+ %tr
18
+ %td{ colspan: 2 } No Users Associated
19
+ %tr
20
+ %td{ colspan: 2 }
21
+ - users = user_options.select { |k, v| entity.users.map(&:id).include?(k) == false }
22
+ - if users && users.count.positive?
23
+ = new_form_tag "#{base_path}/#{entity.display_id}/users" do
24
+ .input-group.tall-select2
25
+ %select.form-control.select2{ name: "#{group}[user_id]", id: 'user_id' }
26
+ %option{ value: '' } Select User
27
+ - users.each do |key, value|
28
+ %option{ value: key }= value
29
+ %span.input-group-append
30
+ %button.btn.btn-primary{ type: 'submit' } Add User
31
+ - else
32
+ No Users available to link