trestle 0.8.9 → 0.8.10

Sign up to get free protection for your applications and to get access to all the features.
Files changed (49) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/javascripts/trestle/components/_confirmation.js +31 -14
  3. data/app/assets/javascripts/trestle/components/_form.js +19 -15
  4. data/app/assets/javascripts/trestle/components/_tabs.js +1 -1
  5. data/app/assets/stylesheets/trestle/components/_breadcrumbs.scss +12 -0
  6. data/app/assets/stylesheets/trestle/components/_buttons.scss +102 -1
  7. data/app/assets/stylesheets/trestle/components/_content.scss +41 -21
  8. data/app/assets/stylesheets/trestle/components/_input-group.scss +8 -1
  9. data/app/assets/stylesheets/trestle/components/_modal.scss +3 -0
  10. data/app/assets/stylesheets/trestle/components/_pagination.scss +0 -3
  11. data/app/assets/stylesheets/trestle/components/_scopes.scss +11 -2
  12. data/app/assets/stylesheets/trestle/components/_table.scss +34 -10
  13. data/app/assets/stylesheets/trestle/components/_timestamp.scss +4 -1
  14. data/app/assets/stylesheets/trestle/components/_toolbars.scss +55 -0
  15. data/app/assets/stylesheets/trestle/core/_defaults.scss +13 -2
  16. data/app/assets/stylesheets/trestle/core/_mixins.scss +11 -0
  17. data/app/helpers/trestle/form_helper.rb +1 -5
  18. data/app/helpers/trestle/hook_helper.rb +10 -6
  19. data/app/helpers/trestle/timestamp_helper.rb +49 -7
  20. data/app/helpers/trestle/toolbars_helper.rb +34 -0
  21. data/app/views/layouts/trestle/admin.html.erb +2 -2
  22. data/app/views/trestle/application/_dialog.html.erb +8 -10
  23. data/app/views/trestle/application/_header.html.erb +22 -20
  24. data/app/views/trestle/resource/edit.html.erb +4 -6
  25. data/app/views/trestle/resource/index.html.erb +15 -6
  26. data/app/views/trestle/resource/new.html.erb +2 -2
  27. data/app/views/trestle/resource/show.html.erb +4 -6
  28. data/app/views/trestle/shared/_sidebar.html.erb +3 -1
  29. data/app/views/trestle/shared/_title.html.erb +14 -0
  30. data/config/locales/en.yml +2 -0
  31. data/config/locales/es-MX.yml +94 -0
  32. data/config/locales/es.yml +94 -0
  33. data/config/locales/lv.rb +18 -0
  34. data/config/locales/lv.yml +94 -0
  35. data/lib/generators/trestle/install/templates/trestle.rb.erb +12 -2
  36. data/lib/trestle.rb +2 -0
  37. data/lib/trestle/configuration.rb +9 -3
  38. data/lib/trestle/engine.rb +5 -3
  39. data/lib/trestle/form/fields/form_control.rb +14 -4
  40. data/lib/trestle/form/renderer.rb +2 -2
  41. data/lib/trestle/hook.rb +27 -0
  42. data/lib/trestle/table/actions_column.rb +31 -26
  43. data/lib/trestle/table/column.rb +1 -0
  44. data/lib/trestle/toolbar.rb +43 -0
  45. data/lib/trestle/toolbar/builder.rb +52 -0
  46. data/lib/trestle/toolbar/context.rb +39 -0
  47. data/lib/trestle/version.rb +1 -1
  48. metadata +13 -3
  49. data/app/helpers/trestle/title_helper.rb +0 -26
@@ -1,10 +1,7 @@
1
1
  <% content_for(:title, admin.t("titles.index", default: "Listing %{pluralized_model_name}")) %>
2
2
 
3
- <% content_for(:primary_toolbar) do %>
4
- <%= admin_link_to action: :new, class: "btn btn-default btn-lg" do %>
5
- <%= icon("fa fa-plus") %>
6
- <span class="sr-only"><%= admin.t("buttons.new", default: "New %{model_name}") %></span>
7
- <% end if admin.actions.include?(:new) %>
3
+ <% toolbar(:primary) do |t| %>
4
+ <%= t.link admin.t("buttons.new", default: "New %{model_name}"), action: :new, icon: "fa fa-plus", class: "btn-new-resource" if admin.actions.include?(:new) %>
8
5
  <% end %>
9
6
 
10
7
  <% content_for(:utilities) do %>
@@ -12,5 +9,17 @@
12
9
  <% end if admin.scopes.any? %>
13
10
 
14
11
  <%= render layout: "layout" do %>
15
- <%= render "table" %>
12
+ <% if hook?("resource.index.header") %>
13
+ <header class="main-content-header">
14
+ <%= hook("resource.index.header") %>
15
+ </header>
16
+ <% end %>
17
+
18
+ <%= render "trestle/table/table", table: admin.table, collection: collection %>
19
+
20
+ <footer class="main-content-footer">
21
+ <%= hook("resource.index.footer") %>
22
+
23
+ <%= render "trestle/table/pagination", collection: collection, entry_name: admin.model_name %>
24
+ </footer>
16
25
  <% end %>
@@ -3,8 +3,8 @@
3
3
  <% content_for(:title, title) %>
4
4
  <% breadcrumb(title) %>
5
5
 
6
- <% content_for(:primary_toolbar) do %>
7
- <%= button_tag admin.t("buttons.save", default: "Save %{model_name}"), class: "btn btn-success btn-lg" if admin.actions.include?(:create) %>
6
+ <% toolbar(:primary) do |t| %>
7
+ <%= t.button admin.t("buttons.save", default: "Save %{model_name}"), style: :success if admin.actions.include?(:create) %>
8
8
  <% end %>
9
9
 
10
10
  <%= trestle_form_for instance, url: admin.path(:create), method: :post do |f| %>
@@ -3,14 +3,12 @@
3
3
  <% content_for(:title, title) %>
4
4
  <% breadcrumb(title) unless admin.singular? %>
5
5
 
6
- <% content_for(:primary_toolbar) do %>
7
- <%= button_tag admin.t("buttons.save", default: "Save %{model_name}"), class: "btn btn-success btn-lg" if admin.actions.include?(:update) %>
6
+ <% toolbar(:primary) do |t| %>
7
+ <%= t.button admin.t("buttons.save", default: "Save %{model_name}"), style: :success if admin.actions.include?(:update) %>
8
8
  <% end %>
9
9
 
10
- <% content_for(:secondary_toolbar) do %>
11
- <%= admin_link_to instance, action: :destroy, method: :delete, class: "btn btn-danger", data: { toggle: "confirm-delete", placement: "bottom" } do %>
12
- <%= icon("fa fa-trash") %> <%= admin.t("buttons.delete", default: "Delete %{model_name}") %>
13
- <% end if admin.actions.include?(:destroy) %>
10
+ <% toolbar(:secondary) do |t| %>
11
+ <%= t.link admin.t("buttons.delete", default: "Delete %{model_name}"), instance, action: :destroy, method: :delete, style: :danger, icon: "fa fa-trash", data: { toggle: "confirm-delete", placement: "bottom" } if admin.actions.include?(:destroy) %>
14
12
  <% end %>
15
13
 
16
14
  <%= trestle_form_for instance, url: admin.actions.include?(:update) ? admin.instance_path(instance, action: :update) : "#", method: :patch do |f| %>
@@ -7,7 +7,9 @@
7
7
  <span class="icon-bar"></span>
8
8
  </button>
9
9
 
10
- <%= link_to trestle_title, Trestle.config.path, class: "navbar-brand" %>
10
+ <%= link_to Trestle.config.root, class: "navbar-brand" do %>
11
+ <%= hook("view.title") { render "trestle/shared/title" } %>
12
+ <% end %>
11
13
  </header>
12
14
 
13
15
  <div class="app-sidebar-inner">
@@ -0,0 +1,14 @@
1
+ <% if Trestle.config.site_logo %>
2
+ <% if Trestle.config.site_logo_small %>
3
+ <%= image_tag(Trestle.config.site_logo, class: "visible-xs-inline visible-lg-inline", alt: Trestle.config.site_title) %>
4
+ <%= image_tag(Trestle.config.site_logo_small, class: "visible-sm-inline visible-md-inline", alt: Trestle.config.site_title) %>
5
+ <% else %>
6
+ <%= image_tag(Trestle.config.site_logo) %>
7
+ <% end %>
8
+ <% elsif Trestle.config.site_logo_small %>
9
+ <%= image_tag(Trestle.config.site_logo_small, alt: "") %>
10
+ <span class="visible-xs-inline visible-lg-inline"><%= Trestle.config.site_title %></span>
11
+ <% else %>
12
+ <span class="visible-xs-inline visible-lg-inline"><%= Trestle.config.site_title %></span>
13
+ <span class="visible-sm-inline visible-md-inline"><%= Trestle.config.site_title.split(/ /).map(&:first).first(3).join %></span>
14
+ <% end %>
@@ -43,6 +43,8 @@ en:
43
43
  new: "New %{model_name}"
44
44
  save: "Save %{model_name}"
45
45
  delete: "Delete %{model_name}"
46
+ show: "Show %{model_name}"
47
+ edit: "Edit %{model_name}"
46
48
  ok: "OK"
47
49
 
48
50
  breadcrumbs:
@@ -0,0 +1,94 @@
1
+ es-MX:
2
+ trestle:
3
+ title: "Trestle Administrador"
4
+ footer: "Impulsado por Trestle"
5
+ version: "Version"
6
+
7
+ helpers:
8
+ page_entries_info:
9
+ one_page:
10
+ display_entries:
11
+ zero: "No %{entry_name} encontrado"
12
+ one: "Mostrando <strong>1</strong> %{entry_name}"
13
+ other: "Mostrando <strong>total %{count}</strong> %{entry_name}"
14
+
15
+ more_pages:
16
+ display_entries: "Mostrando %{entry_name} <strong>%{first}&nbsp;-&nbsp;%{last}</strong> of <b>%{total}</b>"
17
+
18
+ onboarding:
19
+ welcome: "Bienvenido a Trestle"
20
+ no_admins: "Para poder ingresar, por favor crea una cuenta de administrador en <code>app/admin</code>."
21
+ no_template: "Para personalizar esta plantilla, por favor crea en <code>%{path}</code>."
22
+ no_form: "Por favor define una forma de bloque o crea un parcial <code>_form.html</code>."
23
+
24
+ ui:
25
+ toggle_navigation: "Cambiar (modo de) navegación"
26
+ toggle_sidebar: "Alternar la barra lateral"
27
+
28
+ dialog:
29
+ error: "La solicitud no pudo ser completada."
30
+
31
+ confirmation:
32
+ title: "¿Estás seguro?"
33
+ delete: "Borrar"
34
+ cancel: "Cancelar"
35
+
36
+ admin:
37
+ titles:
38
+ index: "Listado de %{pluralized_model_name}"
39
+ new: "Nuevo %{model_name}"
40
+ edit: "Editando %{model_name}"
41
+
42
+ buttons:
43
+ new: "Nuevo %{model_name}"
44
+ save: "Guardar %{model_name}"
45
+ delete: "Borrar %{model_name}"
46
+ ok: "Aceptar"
47
+
48
+ breadcrumbs:
49
+ home: "Inicio"
50
+
51
+ flash:
52
+ create:
53
+ success:
54
+ title: "¡Exitosamente!"
55
+ message: "El %{lowercase_model_name} fue creado exitosamente."
56
+
57
+ failure:
58
+ title: "¡Advertencia!"
59
+ message: "Por favor corrige los siguientes errores."
60
+
61
+ update:
62
+ success:
63
+ title: "¡Exitosamente!"
64
+ message: "El %{lowercase_model_name} se actualizo exitosamente."
65
+
66
+ failure:
67
+ title: "¡Advertencia!"
68
+ message: "Por favor corrige los siguientes errores."
69
+
70
+ destroy:
71
+ success:
72
+ title: "¡Exitosamente!"
73
+ message: "El %{lowercase_model_name} fue borrado exitosamente."
74
+
75
+ failure:
76
+ title: "¡Advertencia!"
77
+ message: "%{lowercase_model_name} no pudo ser borrado."
78
+
79
+ table:
80
+ headers:
81
+ id: "ID"
82
+
83
+ form:
84
+ select:
85
+ prompt: "- Selecciona %{attribute_name} -"
86
+
87
+ format:
88
+ blank: "Ninguno"
89
+
90
+ datepicker:
91
+ formats:
92
+ date: "m/d/Y"
93
+ datetime: "m/d/Y h:i K"
94
+ time: "h:i K"
@@ -0,0 +1,94 @@
1
+ es:
2
+ trestle:
3
+ title: "Trestle Administrador"
4
+ footer: "Patrocinado por Trestle"
5
+ version: "Version"
6
+
7
+ helpers:
8
+ page_entries_info:
9
+ one_page:
10
+ display_entries:
11
+ zero: "No %{entry_name} encontrado"
12
+ one: "Mostrando <strong>1</strong> %{entry_name}"
13
+ other: "Mostrando <strong>total %{count}</strong> %{entry_name}"
14
+
15
+ more_pages:
16
+ display_entries: "Mostrando %{entry_name} <strong>%{first}&nbsp;-&nbsp;%{last}</strong> of <b>%{total}</b>"
17
+
18
+ onboarding:
19
+ welcome: "Bienvenido a Trestle"
20
+ no_admins: "Para poder ingresar, por favor crea una cuenta de administrador en <code>app/admin</code>."
21
+ no_template: "Para personalizar esta plantilla, por favor crea <code>%{path}</code>."
22
+ no_form: "Por favor define una forma de bloque o crea un parcial <code>_form.html</code>."
23
+
24
+ ui:
25
+ toggle_navigation: "Cambiar (modo de) navegación"
26
+ toggle_sidebar: "Alternar la barra lateral"
27
+
28
+ dialog:
29
+ error: "La solicitud no pudo ser completada."
30
+
31
+ confirmation:
32
+ title: "¿Estás seguro?"
33
+ delete: "Borrar"
34
+ cancel: "Cancelar"
35
+
36
+ admin:
37
+ titles:
38
+ index: "Listado de %{pluralized_model_name}"
39
+ new: "Nuevo %{model_name}"
40
+ edit: "Editando %{model_name}"
41
+
42
+ buttons:
43
+ new: "Nuevo %{model_name}"
44
+ save: "Guardar %{model_name}"
45
+ delete: "Borrar %{model_name}"
46
+ ok: "Aceptar"
47
+
48
+ breadcrumbs:
49
+ home: "Inicio"
50
+
51
+ flash:
52
+ create:
53
+ success:
54
+ title: "¡Exito!"
55
+ message: "El %{lowercase_model_name} fue creado exitosamente."
56
+
57
+ failure:
58
+ title: "¡Advertencia!"
59
+ message: "Por favor corrige los siguientes errores."
60
+
61
+ update:
62
+ success:
63
+ title: "¡Exito!"
64
+ message: "El %{lowercase_model_name} se actualizo exitosamente."
65
+
66
+ failure:
67
+ title: "¡Advertencia!"
68
+ message: "Por favor corrige los siguientes errores."
69
+
70
+ destroy:
71
+ success:
72
+ title: "¡Exito!"
73
+ message: "El %{lowercase_model_name} fue borrado exitosamente."
74
+
75
+ failure:
76
+ title: "¡Advertencia!"
77
+ message: "%{lowercase_model_name} no pudo ser borrado."
78
+
79
+ table:
80
+ headers:
81
+ id: "ID"
82
+
83
+ form:
84
+ select:
85
+ prompt: "- Selecciona %{attribute_name} -"
86
+
87
+ format:
88
+ blank: "Ninguno"
89
+
90
+ datepicker:
91
+ formats:
92
+ date: "m/d/Y"
93
+ datetime: "m/d/Y h:i K"
94
+ time: "h:i K"
@@ -0,0 +1,18 @@
1
+ {
2
+ lv: {
3
+ date: {
4
+ formats: {
5
+ trestle_date: "%e %b %Y",
6
+ trestle_calendar: "%d-%m-%Y"
7
+ }
8
+ },
9
+
10
+ time: {
11
+ formats: {
12
+ trestle_date: "%e %b %Y",
13
+ trestle_time: "%H:%M",
14
+ trestle_time_with_seconds: "%H:%M:%S"
15
+ }
16
+ }
17
+ }
18
+ }
@@ -0,0 +1,94 @@
1
+ lv:
2
+ trestle:
3
+ title: "Trestle Administrators"
4
+ footer: "Powered by Trestle"
5
+ version: "Versija"
6
+
7
+ helpers:
8
+ page_entries_info:
9
+ one_page:
10
+ display_entries:
11
+ zero: "Neviena %{entry_name} ieraksta nav atrasts"
12
+ one: "Attēlo <strong>1</strong> %{entry_name}"
13
+ other: "Attēlo <strong>%{count}</strong> %{entry_name}"
14
+
15
+ more_pages:
16
+ display_entries: "Attēlo %{entry_name} <strong>%{first}&nbsp;-&nbsp;%{last}</strong> no <b>%{total}</b>"
17
+
18
+ onboarding:
19
+ welcome: "Esi sveicināts Trestle"
20
+ no_admins: "Lai sāktu, lūdzu izveido administratoru <code>app/admin</code>."
21
+ no_template: "Lai pielāgotu šo vedni, lūdzu izveido <code>%{path}</code>."
22
+ no_form: "Lūdzu izveido formas bloku vai izveido failu <code>_form.html</code>."
23
+
24
+ ui:
25
+ toggle_navigation: "Pārslēgt navigāciju"
26
+ toggle_sidebar: "Pārslēgt malējo izvēlni"
27
+
28
+ dialog:
29
+ error: "Pieprasījumu neizdevās izpildīt."
30
+
31
+ confirmation:
32
+ title: "Vai tu esi drošs?"
33
+ delete: "Dzēst"
34
+ cancel: "Atcelt"
35
+
36
+ admin:
37
+ titles:
38
+ index: "Attēlo %{pluralized_model_name}"
39
+ new: "Jauns %{model_name}"
40
+ edit: "Labot %{model_name}"
41
+
42
+ buttons:
43
+ new: "Jauns %{model_name}"
44
+ save: "Saglabāt %{model_name}"
45
+ delete: "Dzēst %{model_name}"
46
+ ok: "Labi"
47
+
48
+ breadcrumbs:
49
+ home: "Mājas"
50
+
51
+ flash:
52
+ create:
53
+ success:
54
+ title: "Izveide veikta!"
55
+ message: "%{lowercase_model_name} tika veiksmīgi izveidots."
56
+
57
+ failure:
58
+ title: "Uzmanību!"
59
+ message: "Lūdzu labojiet zemāk atzīmētās kļūmes vai nepilnības."
60
+
61
+ update:
62
+ success:
63
+ title: "Papildināšana veikta!"
64
+ message: "%{lowercase_model_name} tika veiksmīgi papildināts."
65
+
66
+ failure:
67
+ title: "Uzmanību!"
68
+ message: "Lūdzu labojiet zemāk atzīmētās kļūmes vai nepilnības."
69
+
70
+ destroy:
71
+ success:
72
+ title: "Veiksmīgi dzēsts!"
73
+ message: "%{lowercase_model_name} tika veiksmīgi izdzēsts."
74
+
75
+ failure:
76
+ title: "Uzmanību!"
77
+ message: "%{lowercase_model_name} dzēšana neizdevās."
78
+
79
+ table:
80
+ headers:
81
+ id: "ID"
82
+
83
+ form:
84
+ select:
85
+ prompt: "- Izvēlieties %{attribute_name} -"
86
+
87
+ format:
88
+ blank: "Neviens"
89
+
90
+ datepicker:
91
+ formats:
92
+ date: "d/m/Y"
93
+ datetime: "d/m/Y H:i"
94
+ time: "H:i"
@@ -20,6 +20,11 @@ Trestle.configure do |config|
20
20
  #
21
21
  # config.footer = "Powered by Trestle"
22
22
 
23
+ # Sets the default precision for timestamps (either :minutes or :seconds).
24
+ # Defaults to :minutes.
25
+ #
26
+ # config.timestamp_precision = :minutes
27
+
23
28
  # == Mounting Options
24
29
  #
25
30
  # Set the path at which to mount the Trestle admin. Defaults to /admin.
@@ -33,10 +38,15 @@ Trestle.configure do |config|
33
38
 
34
39
  # == Navigation Options
35
40
  #
41
+ # Set the path to consider the application root (for title links and breadcrumbs).
42
+ # Defaults to the same value as `config.path`.
43
+ #
44
+ # config.root = "/"
45
+
36
46
  # Set the initial breadcrumbs to display in the breadcrumb trail.
37
- # Defaults to a breadcrumb labeled 'Home' linking to to the admin root.
47
+ # Defaults to a breadcrumb labeled 'Home' linking to to the application root.
38
48
  #
39
- # config.root_breadcrumbs = -> { [Trestle::Breadcrumb.new("Home", Trestle.config.path)] }
49
+ # config.root_breadcrumbs = -> { [Trestle::Breadcrumb.new("Home", Trestle.config.root)] }
40
50
 
41
51
  # Set the default icon class to use when it is not explicitly provided.
42
52
  # Defaults to "fa fa-arrow-circle-o-right".
@@ -18,6 +18,7 @@ module Trestle
18
18
  autoload :Configuration
19
19
  autoload :Display
20
20
  autoload :Form
21
+ autoload :Hook
21
22
  autoload :ModelName
22
23
  autoload :Navigation
23
24
  autoload :Options
@@ -26,6 +27,7 @@ module Trestle
26
27
  autoload :Scope
27
28
  autoload :Tab
28
29
  autoload :Table
30
+ autoload :Toolbar
29
31
 
30
32
  mattr_accessor :admins
31
33
  self.admins = {}