trestle 0.8.5 → 0.8.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (63) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/javascripts/trestle/admin.js +11 -10
  3. data/app/assets/javascripts/trestle/{_confirmation.js → components/_confirmation.js} +1 -1
  4. data/app/assets/javascripts/trestle/{_datepicker.js → components/_datepicker.js} +4 -4
  5. data/app/assets/javascripts/trestle/components/_dialog.js +107 -0
  6. data/app/assets/javascripts/trestle/{_errors.js → components/_errors.js} +2 -2
  7. data/app/assets/javascripts/trestle/components/_form.js +48 -0
  8. data/app/assets/javascripts/trestle/{_gallery.js → components/_gallery.js} +3 -3
  9. data/app/assets/javascripts/trestle/{_select.js → components/_select.js} +2 -2
  10. data/app/assets/javascripts/trestle/{_sidebar.js → components/_sidebar.js} +3 -1
  11. data/app/assets/javascripts/trestle/{_table.js → components/_table.js} +1 -1
  12. data/app/assets/javascripts/trestle/components/_tabs.js +24 -0
  13. data/app/assets/javascripts/trestle/components/_tooltips.js +3 -0
  14. data/app/assets/javascripts/trestle/core/_contexts.js +13 -0
  15. data/app/assets/javascripts/trestle/{_cookies.js → core/_cookies.js} +2 -1
  16. data/app/assets/javascripts/trestle/core/_events.js +39 -0
  17. data/app/assets/javascripts/trestle/core/_visit.js +10 -0
  18. data/app/assets/stylesheets/trestle/components/_buttons.scss +9 -0
  19. data/app/assets/stylesheets/trestle/components/_modal.scss +92 -0
  20. data/app/assets/stylesheets/trestle/components/_navigation.scss +47 -12
  21. data/app/assets/stylesheets/trestle/components/_sidebar.scss +1 -0
  22. data/app/assets/stylesheets/trestle/core/_defaults.scss +5 -1
  23. data/app/controllers/trestle/application_controller.rb +5 -1
  24. data/app/helpers/trestle/dialog_helper.rb +7 -0
  25. data/app/helpers/trestle/form_helper.rb +7 -0
  26. data/app/helpers/trestle/url_helper.rb +34 -6
  27. data/app/views/layouts/trestle/admin.html.erb +1 -1
  28. data/app/views/trestle/application/_dialog.html.erb +36 -0
  29. data/app/views/trestle/application/_tabs.html.erb +7 -1
  30. data/app/views/trestle/resource/edit.html.erb +5 -5
  31. data/app/views/trestle/resource/index.html.erb +2 -2
  32. data/app/views/trestle/resource/new.html.erb +2 -2
  33. data/app/views/trestle/resource/show.html.erb +5 -5
  34. data/bower.json +1 -1
  35. data/config/locales/en.yml +25 -21
  36. data/config/locales/fr.rb +18 -0
  37. data/config/locales/fr.yml +69 -0
  38. data/config/locales/nl.yml +14 -14
  39. data/config/locales/pl.rb +18 -0
  40. data/config/locales/pl.yml +70 -0
  41. data/config/locales/pt-BR.yml +22 -22
  42. data/lib/generators/trestle/resource/templates/admin.rb.erb +1 -1
  43. data/lib/trestle/admin.rb +14 -1
  44. data/lib/trestle/admin/builder.rb +10 -2
  45. data/lib/trestle/breadcrumb.rb +13 -0
  46. data/lib/trestle/configuration.rb +6 -1
  47. data/lib/trestle/form.rb +7 -3
  48. data/lib/trestle/form/automatic.rb +1 -1
  49. data/lib/trestle/reloader.rb +1 -1
  50. data/lib/trestle/resource.rb +20 -5
  51. data/lib/trestle/resource/builder.rb +15 -0
  52. data/lib/trestle/resource/controller.rb +19 -6
  53. data/lib/trestle/table.rb +4 -0
  54. data/lib/trestle/table/actions_column.rb +9 -7
  55. data/lib/trestle/table/column.rb +3 -2
  56. data/lib/trestle/table/row.rb +7 -1
  57. data/lib/trestle/version.rb +1 -1
  58. data/trestle.gemspec +3 -3
  59. data/vendor/assets/bower_components/trestle/select2/dist/js/select2.full.js +90 -69
  60. metadata +30 -19
  61. data/app/assets/javascripts/trestle/_form.js +0 -6
  62. data/app/assets/javascripts/trestle/_tabs.js +0 -13
  63. data/app/assets/javascripts/trestle/_tooltips.js +0 -3
@@ -0,0 +1,18 @@
1
+ {
2
+ fr: {
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: "%Hh%M",
14
+ trestle_time_with_seconds: '%Hh %M\' %S"'
15
+ }
16
+ }
17
+ }
18
+ }
@@ -0,0 +1,69 @@
1
+ fr:
2
+ trestle:
3
+ title: "Trestle Admin"
4
+ footer: "Fourni par Trestle"
5
+ version: "Version"
6
+
7
+ flash:
8
+ success:
9
+ title: "Opération réussie"
10
+ create: "%{model_name} créé(e)."
11
+ update: "%{model_name} mis(e) à jour."
12
+ destroy: "%{model_name} supprimé(e)."
13
+
14
+ failure:
15
+ title: "Attention!"
16
+ create: "Veuillez corriger les erreurs ci-après."
17
+ update: "Veuillez corriger les erreurs ci-après."
18
+ destroy: "Suppression impossible."
19
+
20
+ helpers:
21
+ page_entries_info:
22
+ one_page:
23
+ display_entries:
24
+ zero: "Aucun(e) '%{entry_name}'"
25
+ one: "<strong>1</strong> %{entry_name}"
26
+ other: "<strong>%{count}</strong> %{entry_name}"
27
+
28
+ more_pages:
29
+ display_entries: "%{entry_name} <strong>%{first}&nbsp;-&nbsp;%{last}</strong> sur <b>%{total}</b>"
30
+
31
+ onboarding:
32
+ welcome: "Bienvenue sur Trestle"
33
+ no_admins: "Pour commencer, créez le répertoire <code>app/admin</code>."
34
+ no_template: "Pour personnaliser ce modèle, veuillez créer <code>%{path}</code>."
35
+ no_form: "Veuillez déclarer un block 'form' ou créer un modèle partiel <code>_form.html</code>."
36
+
37
+ admin:
38
+ titles:
39
+ index: "Liste des %{pluralized_model_name}"
40
+ new: "%{model_name} (ajout)"
41
+ edit: "%{model_name} (modification)"
42
+
43
+ buttons:
44
+ new: "Nouveau"
45
+ save: "Enregistrer"
46
+ delete: "Supprimer"
47
+
48
+ breadcrumbs:
49
+ home: "Acceuil"
50
+
51
+ table:
52
+ headers:
53
+ id: "ID"
54
+
55
+ form:
56
+ select:
57
+ prompt: "- Choisir le/la %{attribute_name} -"
58
+
59
+ confirmation:
60
+ title: "Voulez-vous supprimer?"
61
+ delete: "Oui"
62
+ cancel: "Non"
63
+
64
+ ui:
65
+ toggle_navigation: "Basculer navigation"
66
+ toggle_sidebar: "Basculer vue latérale"
67
+
68
+ format:
69
+ blank: "Aucun"
@@ -1,8 +1,8 @@
1
1
  nl:
2
2
  trestle:
3
- title: Trestle Admin
4
- footer: Powered by Trestle
5
- version: Versie
3
+ title: "Trestle Admin"
4
+ footer: "Powered by Trestle"
5
+ version: "Versie"
6
6
 
7
7
  flash:
8
8
  success:
@@ -29,14 +29,14 @@ nl:
29
29
  display_entries: "%{entry_name} <strong>%{first}&nbsp;-&nbsp;%{last}</strong> van de <b>%{total}</b> worden weergeven"
30
30
 
31
31
  onboarding:
32
- welcome: Welkom bij Trestle
33
- no_admins: Voeg een admin toe in <code>app/admin</code> om te beginnen.
34
- no_template: Maak <code>%{path}</code> aan om dit template aan te passen.
35
- no_form: Definieer een form block of maak een <code>_form.html</code> partial.
32
+ welcome: "Welkom bij Trestle"
33
+ no_admins: "Voeg een admin toe in <code>app/admin</code> om te beginnen."
34
+ no_template: "Maak <code>%{path}</code> aan om dit template aan te passen."
35
+ no_form: "Definieer een form block of maak een <code>_form.html</code> partial."
36
36
 
37
37
  admin:
38
38
  titles:
39
- index: Lijst van %{pluralized_model_name}
39
+ index: "Lijst van %{pluralized_model_name}"
40
40
  edit: "%{model_name} aanpassen"
41
41
 
42
42
  buttons:
@@ -44,24 +44,24 @@ nl:
44
44
  delete: "%{model_name} verwijderen"
45
45
 
46
46
  breadcrumbs:
47
- home: Home
47
+ home: "Home"
48
48
 
49
49
  table:
50
50
  headers:
51
- id: ID
51
+ id: "ID"
52
52
 
53
53
  form:
54
54
  select:
55
55
  prompt: "- Selecteer %{attribute_name} -"
56
56
 
57
57
  confirmation:
58
- title: Weer je het zeker?
59
- delete: Verwijderen
60
- cancel: Annuleren
58
+ title: "Weer je het zeker?"
59
+ delete: "Verwijderen"
60
+ cancel: "Annuleren"
61
61
 
62
62
  ui:
63
63
  toggle_navigation: "Navigation tonen/verbergen"
64
64
  toggle_sidebar: "Sidebar tonen/verbergen"
65
65
 
66
66
  format:
67
- blank: Geen
67
+ blank: "Geen"
@@ -0,0 +1,18 @@
1
+ {
2
+ pl: {
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,70 @@
1
+ pl:
2
+ trestle:
3
+ title: "Trestle Admin"
4
+ footer: "Powered by Trestle"
5
+ version: "Wersja"
6
+
7
+ flash:
8
+ success:
9
+ title: "Sukces!"
10
+ create: "%{lowercase_model_name} został pomyślnie utworzony."
11
+ update: "%{lowercase_model_name} został pomyślnie zaktualizowany."
12
+ destroy: "%{lowercase_model_name} został pomyślnie usunięty."
13
+
14
+ failure:
15
+ title: "Uwaga!"
16
+ create: "Popraw poniższe błędy."
17
+ update: "Popraw poniższe błędy."
18
+ destroy: "Nie można usunąć %{lowercase_model_name}."
19
+
20
+ helpers:
21
+ page_entries_info:
22
+ one_page:
23
+ display_entries:
24
+ zero: "Nie znaleziono %{entry_name}"
25
+ one: "Wyświetla <strong>1</strong> %{entry_name}"
26
+ few: "Wyświetla <strong>wszystkie %{count}</strong> %{entry_name}"
27
+ other: "Wyświetla <strong>wszystkie %{count}</strong> %{entry_name}"
28
+
29
+ more_pages:
30
+ display_entries: "Wyświetla %{entry_name} <strong>%{first}&nbsp;-&nbsp;%{last}</strong> z <b>%{total}</b> łącznie"
31
+
32
+ onboarding:
33
+ welcome: "Witamy w Trestle"
34
+ no_admins: "Aby rozpocząć, utwórz administratora w zasięgu <code>app/admin</code>."
35
+ no_template: "Aby dostosować ten szablon, utwórz <code>%{path}</code>."
36
+ no_form: "Proszę zdefiniować blok formularza lub utworzyć podszablon <code>_form.html</code>."
37
+
38
+ admin:
39
+ titles:
40
+ index: "Lista %{pluralized_model_name}"
41
+ new: "Nowy %{model_name}"
42
+ edit: "Edycja %{model_name}"
43
+
44
+ buttons:
45
+ new: "Nowy %{model_name}"
46
+ save: "Zachowaj %{model_name}"
47
+ delete: "Usuń %{model_name}"
48
+
49
+ breadcrumbs:
50
+ home: "Start"
51
+
52
+ table:
53
+ headers:
54
+ id: "ID"
55
+
56
+ form:
57
+ select:
58
+ prompt: "- Wybierz %{attribute_name} -"
59
+
60
+ confirmation:
61
+ title: "Jesteś pewny?"
62
+ delete: "Usuń"
63
+ cancel: "Anuluj"
64
+
65
+ ui:
66
+ toggle_navigation: "Przełącz nawigację"
67
+ toggle_sidebar: "Przełącz pasek boczny"
68
+
69
+ format:
70
+ blank: "Żaden"
@@ -1,8 +1,8 @@
1
1
  pt-BR:
2
2
  trestle:
3
- title: Trestle Admin
4
- footer: Powered by Trestle
5
- version: Versão
3
+ title: "Trestle Admin"
4
+ footer: "Powered by Trestle"
5
+ version: "Versão"
6
6
 
7
7
  flash:
8
8
  success:
@@ -29,41 +29,41 @@ pt-BR:
29
29
  display_entries: "Mostrando %{entry_name} <strong>%{first}&nbsp;-&nbsp;%{last}</strong> de <b>%{total}</b>"
30
30
 
31
31
  onboarding:
32
- welcome: Bem-vindo ao Trestle
33
- no_admins: Para começar, crie um admin dentro de <code>app/admin</code>.
34
- no_template: Para personalizar este template, crie <code>%{path}</code>.
35
- no_form: Defina um bloco de formulário ou crie um <code>_form.html</code> parcial.
36
-
32
+ welcome: "Bem-vindo ao Trestle"
33
+ no_admins: "Para começar, crie um admin dentro de <code>app/admin</code>."
34
+ no_template: "Para personalizar este template, crie <code>%{path}</code>."
35
+ no_form: "Defina um bloco de formulário ou crie um <code>_form.html</code> parcial."
36
+
37
37
  admin:
38
38
  titles:
39
- index: Listando %{pluralized_model_name}
40
- new: Novo %{model_name}
41
- edit: Editando %{model_name}
39
+ index: "Listando %{pluralized_model_name}"
40
+ new: "Novo %{model_name}"
41
+ edit: "Editando %{model_name}"
42
42
 
43
43
  buttons:
44
- new: Novo %{model_name}
45
- save: Salvar %{model_name}
46
- delete: Excluir %{model_name}
44
+ new: "Novo %{model_name}"
45
+ save: "Salvar %{model_name}"
46
+ delete: "Excluir %{model_name}"
47
47
 
48
48
  breadcrumbs:
49
- home: Home
49
+ home: "Home"
50
50
 
51
51
  table:
52
52
  headers:
53
- id: ID
53
+ id: "ID"
54
54
 
55
55
  form:
56
56
  select:
57
57
  prompt: "- Selecione %{attribute_name} -"
58
58
 
59
59
  confirmation:
60
- title: Você tem certeza?
61
- delete: Excluir
62
- cancel: Cancelar
60
+ title: "Você tem certeza?"
61
+ delete: "Excluir"
62
+ cancel: "Cancelar"
63
63
 
64
64
  ui:
65
- toggle_navigation: Alternar naveção
66
- toggle_sidebar: Alternar barra lateral
65
+ toggle_navigation: "Alternar naveção"
66
+ toggle_sidebar: "Alternar barra lateral"
67
67
 
68
68
  format:
69
- blank: Nenhum
69
+ blank: "Nenhum"
@@ -30,6 +30,6 @@ Trestle.resource(:<%= plural_name %><% if module? %>, scope: <%= module_name %><
30
30
  # http://guides.rubyonrails.org/action_controller_overview.html#strong-parameters
31
31
  #
32
32
  # params do |params|
33
- # params.require(:<%= singular_name %>).require(:name, ...)
33
+ # params.require(:<%= singular_name %>).permit(:name, ...)
34
34
  # end
35
35
  end
@@ -14,6 +14,7 @@ module Trestle
14
14
  attr_accessor :additional_routes
15
15
 
16
16
  attr_writer :options
17
+ attr_writer :breadcrumb
17
18
 
18
19
  def options
19
20
  @options ||= {}
@@ -24,7 +25,15 @@ module Trestle
24
25
  end
25
26
 
26
27
  def breadcrumb
27
- Breadcrumb.new(admin_name.titleize, path)
28
+ if @breadcrumb
29
+ Breadcrumb.cast(@breadcrumb.call)
30
+ else
31
+ default_breadcrumb
32
+ end
33
+ end
34
+
35
+ def default_breadcrumb
36
+ Breadcrumb.new(I18n.t("admin.breadcrumbs.#{admin_name}", default: admin_name.titleize), path)
28
37
  end
29
38
 
30
39
  def admin_name
@@ -47,6 +56,10 @@ module Trestle
47
56
  Engine.routes.url_for(options.merge(controller: controller_namespace, action: action, only_path: true))
48
57
  end
49
58
 
59
+ def actions
60
+ [:index]
61
+ end
62
+
50
63
  def routes
51
64
  admin = self
52
65
 
@@ -42,8 +42,8 @@ module Trestle
42
42
  admin.table = Table::Builder.build(options.reverse_merge(admin: admin, sortable: true), &block)
43
43
  end
44
44
 
45
- def form(&block)
46
- admin.form = Form.new(&block)
45
+ def form(options={}, &block)
46
+ admin.form = Form.new(options, &block)
47
47
  end
48
48
 
49
49
  def admin(&block)
@@ -59,6 +59,14 @@ module Trestle
59
59
  def routes(&block)
60
60
  @admin.additional_routes = block
61
61
  end
62
+
63
+ def breadcrumb(label=nil, path=nil, &block)
64
+ if block_given?
65
+ @admin.breadcrumb = block
66
+ else
67
+ @admin.breadcrumb = -> { Breadcrumb.new(label, path) }
68
+ end
69
+ end
62
70
  end
63
71
  end
64
72
  end
@@ -10,6 +10,19 @@ module Trestle
10
10
  label == other.label && path == other.path
11
11
  end
12
12
 
13
+ def self.cast(obj)
14
+ case obj
15
+ when Breadcrumb
16
+ obj
17
+ when String
18
+ new(obj)
19
+ when Array
20
+ new(*obj)
21
+ else
22
+ raise ArgumentError, "Unable to cast #{obj.inspect} to Breadcrumb"
23
+ end
24
+ end
25
+
13
26
  class Trail
14
27
  include Enumerable
15
28
 
@@ -83,7 +83,12 @@ module Trestle
83
83
  end
84
84
 
85
85
  # List of i18n keys to pass into the Trestle.i18n JavaScript object
86
- option :javascript_i18n_keys, ["admin.confirmation.title", "admin.confirmation.delete", "admin.confirmation.cancel"]
86
+ option :javascript_i18n_keys, ["admin.confirmation.title", "admin.confirmation.delete", "admin.confirmation.cancel", "trestle.dialog.error", "admin.buttons.ok"]
87
+
88
+ # List of load paths for where to find admin definitions
89
+ option :load_paths, [
90
+ -> { ActiveSupport::Dependencies.autoload_paths.grep(/\/app\/admin\Z/) }
91
+ ]
87
92
 
88
93
 
89
94
  ## Debugging
@@ -8,10 +8,14 @@ module Trestle
8
8
  autoload :Fields
9
9
  autoload :Renderer
10
10
 
11
- attr_reader :block
11
+ attr_reader :options, :block
12
12
 
13
- def initialize(&block)
14
- @block = block
13
+ def initialize(options={}, &block)
14
+ @options, @block = options, block
15
+ end
16
+
17
+ def dialog?
18
+ options[:dialog] == true
15
19
  end
16
20
 
17
21
  def render(template, instance)
@@ -2,7 +2,7 @@ module Trestle
2
2
  class Form
3
3
  class Automatic < Form
4
4
  def initialize(admin)
5
- @block = Proc.new do |instance|
5
+ super() do |instance|
6
6
  admin.default_form_attributes.each do |attribute|
7
7
  if attribute.array?
8
8
  if [:string, :text].include?(attribute.type)