trestle 0.9.3 → 0.9.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (117) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +1 -0
  3. data/Gemfile +2 -2
  4. data/app/assets/bundle/trestle/bundle.css +0 -0
  5. data/app/assets/bundle/trestle/bundle.js +0 -0
  6. data/app/assets/bundle/trestle/fa-brands-400.eot +0 -0
  7. data/app/assets/bundle/trestle/fa-brands-400.svg +0 -0
  8. data/app/assets/bundle/trestle/fa-brands-400.ttf +0 -0
  9. data/app/assets/bundle/trestle/fa-brands-400.woff +0 -0
  10. data/app/assets/bundle/trestle/fa-brands-400.woff2 +0 -0
  11. data/app/assets/bundle/trestle/fa-regular-400.eot +0 -0
  12. data/app/assets/bundle/trestle/fa-regular-400.svg +0 -0
  13. data/app/assets/bundle/trestle/fa-regular-400.ttf +0 -0
  14. data/app/assets/bundle/trestle/fa-regular-400.woff +0 -0
  15. data/app/assets/bundle/trestle/fa-regular-400.woff2 +0 -0
  16. data/app/assets/bundle/trestle/fa-solid-900.eot +0 -0
  17. data/app/assets/bundle/trestle/fa-solid-900.svg +0 -0
  18. data/app/assets/bundle/trestle/fa-solid-900.ttf +0 -0
  19. data/app/assets/bundle/trestle/fa-solid-900.woff +0 -0
  20. data/app/assets/bundle/trestle/fa-solid-900.woff2 +0 -0
  21. data/app/assets/bundle/trestle/flatpickr/ar.js +0 -0
  22. data/app/assets/bundle/trestle/flatpickr/at.js +0 -0
  23. data/app/assets/bundle/trestle/flatpickr/az.js +0 -0
  24. data/app/assets/bundle/trestle/flatpickr/be.js +0 -0
  25. data/app/assets/bundle/trestle/flatpickr/bg.js +0 -0
  26. data/app/assets/bundle/trestle/flatpickr/bn.js +0 -0
  27. data/app/assets/bundle/trestle/flatpickr/bs.js +0 -0
  28. data/app/assets/bundle/trestle/flatpickr/cat.js +0 -0
  29. data/app/assets/bundle/trestle/flatpickr/cs.js +0 -0
  30. data/app/assets/bundle/trestle/flatpickr/cy.js +0 -0
  31. data/app/assets/bundle/trestle/flatpickr/da.js +0 -0
  32. data/app/assets/bundle/trestle/flatpickr/de.js +0 -0
  33. data/app/assets/bundle/trestle/flatpickr/default.js +0 -0
  34. data/app/assets/bundle/trestle/flatpickr/eo.js +0 -0
  35. data/app/assets/bundle/trestle/flatpickr/es.js +0 -0
  36. data/app/assets/bundle/trestle/flatpickr/et.js +0 -0
  37. data/app/assets/bundle/trestle/flatpickr/fa.js +0 -0
  38. data/app/assets/bundle/trestle/flatpickr/fi.js +0 -0
  39. data/app/assets/bundle/trestle/flatpickr/fo.js +0 -0
  40. data/app/assets/bundle/trestle/flatpickr/fr.js +0 -0
  41. data/app/assets/bundle/trestle/flatpickr/ga.js +0 -0
  42. data/app/assets/bundle/trestle/flatpickr/gr.js +0 -0
  43. data/app/assets/bundle/trestle/flatpickr/he.js +0 -0
  44. data/app/assets/bundle/trestle/flatpickr/hi.js +0 -0
  45. data/app/assets/bundle/trestle/flatpickr/hr.js +0 -0
  46. data/app/assets/bundle/trestle/flatpickr/hu.js +0 -0
  47. data/app/assets/bundle/trestle/flatpickr/id.js +0 -0
  48. data/app/assets/bundle/trestle/flatpickr/is.js +0 -0
  49. data/app/assets/bundle/trestle/flatpickr/it.js +0 -0
  50. data/app/assets/bundle/trestle/flatpickr/ja.js +0 -0
  51. data/app/assets/bundle/trestle/flatpickr/ka.js +0 -0
  52. data/app/assets/bundle/trestle/flatpickr/km.js +0 -0
  53. data/app/assets/bundle/trestle/flatpickr/ko.js +0 -0
  54. data/app/assets/bundle/trestle/flatpickr/kz.js +0 -0
  55. data/app/assets/bundle/trestle/flatpickr/lt.js +0 -0
  56. data/app/assets/bundle/trestle/flatpickr/lv.js +0 -0
  57. data/app/assets/bundle/trestle/flatpickr/mk.js +0 -0
  58. data/app/assets/bundle/trestle/flatpickr/mn.js +0 -0
  59. data/app/assets/bundle/trestle/flatpickr/my.js +0 -0
  60. data/app/assets/bundle/trestle/flatpickr/nl.js +0 -0
  61. data/app/assets/bundle/trestle/flatpickr/no.js +0 -0
  62. data/app/assets/bundle/trestle/flatpickr/pa.js +0 -0
  63. data/app/assets/bundle/trestle/flatpickr/pl.js +0 -0
  64. data/app/assets/bundle/trestle/flatpickr/pt.js +0 -0
  65. data/app/assets/bundle/trestle/flatpickr/ro.js +0 -0
  66. data/app/assets/bundle/trestle/flatpickr/ru.js +0 -0
  67. data/app/assets/bundle/trestle/flatpickr/si.js +0 -0
  68. data/app/assets/bundle/trestle/flatpickr/sk.js +0 -0
  69. data/app/assets/bundle/trestle/flatpickr/sl.js +0 -0
  70. data/app/assets/bundle/trestle/flatpickr/sq.js +0 -0
  71. data/app/assets/bundle/trestle/flatpickr/sr-cyr.js +0 -0
  72. data/app/assets/bundle/trestle/flatpickr/sr.js +0 -0
  73. data/app/assets/bundle/trestle/flatpickr/sv.js +0 -0
  74. data/app/assets/bundle/trestle/flatpickr/th.js +0 -0
  75. data/app/assets/bundle/trestle/flatpickr/tr.js +0 -0
  76. data/app/assets/bundle/trestle/flatpickr/uk.js +0 -0
  77. data/app/assets/bundle/trestle/flatpickr/uz.js +0 -0
  78. data/app/assets/bundle/trestle/flatpickr/uz_latn.js +0 -0
  79. data/app/assets/bundle/trestle/flatpickr/vn.js +0 -0
  80. data/app/assets/bundle/trestle/flatpickr/zh-tw.js +0 -0
  81. data/app/assets/bundle/trestle/flatpickr/zh.js +0 -0
  82. data/app/helpers/trestle/hook_helper.rb +1 -27
  83. data/app/helpers/trestle/table_helper.rb +15 -0
  84. data/app/views/trestle/resource/index.html.erb +1 -1
  85. data/app/views/trestle/table/_pagination.html.erb +1 -1
  86. data/config/locales/vi.rb +18 -0
  87. data/config/locales/vi.yml +101 -0
  88. data/frontend/css/components/_scopes.scss +2 -0
  89. data/frontend/css/components/_table.scss +4 -0
  90. data/frontend/js/components/pagination.js +51 -0
  91. data/frontend/js/index.js +1 -0
  92. data/lib/trestle/admin.rb +12 -2
  93. data/lib/trestle/engine.rb +3 -6
  94. data/lib/trestle/form/field.rb +19 -12
  95. data/lib/trestle/form/fields/collection_select.rb +1 -1
  96. data/lib/trestle/form/fields/date_picker.rb +9 -3
  97. data/lib/trestle/form/fields/file_field.rb +1 -1
  98. data/lib/trestle/form/fields/form_group.rb +13 -2
  99. data/lib/trestle/form/fields/grouped_collection_select.rb +1 -1
  100. data/lib/trestle/form/fields/range_field.rb +2 -4
  101. data/lib/trestle/form/fields/select.rb +2 -3
  102. data/lib/trestle/form/fields/static_field.rb +2 -2
  103. data/lib/trestle/form/fields/tag_select.rb +1 -1
  104. data/lib/trestle/form/fields/time_zone_select.rb +1 -1
  105. data/lib/trestle/form/renderer.rb +5 -3
  106. data/lib/trestle/hook.rb +3 -29
  107. data/lib/trestle/hook/helpers.rb +33 -0
  108. data/lib/trestle/hook/set.rb +32 -0
  109. data/lib/trestle/reloader.rb +25 -5
  110. data/lib/trestle/resource.rb +4 -3
  111. data/lib/trestle/scopes.rb +5 -4
  112. data/lib/trestle/scopes/block.rb +9 -8
  113. data/lib/trestle/scopes/scope.rb +1 -1
  114. data/lib/trestle/version.rb +1 -1
  115. data/package.json +8 -8
  116. data/yarn.lock +1360 -1452
  117. metadata +12 -5
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1a0e145542ea21344ab56ce456f98a2eab365820c9cb65da1a2c64e57b7041e1
4
- data.tar.gz: 9957f9704925389b5adf30d148dee1f41843fd450bd1d5442b40a296b6daf21f
3
+ metadata.gz: c79f7b5d12b485966fe7c165b5481e00f9e411e353a74818d91dc9d17c4dd6f2
4
+ data.tar.gz: 8502c2dee447e7ad01ccb3df23d3b17dc1e02db3e8f1de5049cbb3a245655a43
5
5
  SHA512:
6
- metadata.gz: c43a3a0a73533519d3fcaac45788fb1bb41c1bf746d5d0b2c4516c172f90f73cf51a1cc88560f0e546e76b3b0d269550ee91e39a5176ec63ba9933fc1f33e6c5
7
- data.tar.gz: c415ad3ce71f604c39af7dd052556b1b53da73b5c4214ae60802f7024edc38cb761548ee78373f780987a95c8fdb9b753fc7dbfff1b270c400515f6454151f9d
6
+ metadata.gz: 8c86b38910a39e0c8cc45625db9b34860074491b4f6b8033c7ac54d17706ca2efae535d9657efb6725b744adcb5c91b4854e84c6e58ff34a79f8648328dc36be
7
+ data.tar.gz: e597539d8dc3285a710da28be1b935d2c0c0ef2d555d193dd03d402f109929a93c63db9b3e5d518846e33a69ad4e52be712b5a7f3aefb9bc02d3cd2ae5303a0d
@@ -8,6 +8,7 @@ before_install:
8
8
 
9
9
  rvm:
10
10
  - 2.6.5
11
+ - 2.7.1
11
12
 
12
13
  gemfile:
13
14
  - gemfiles/rails-5.0.gemfile
data/Gemfile CHANGED
@@ -4,8 +4,8 @@ source 'https://rubygems.org'
4
4
  gemspec
5
5
 
6
6
  group :test do
7
- gem 'coveralls', require: false
8
- gem 'guard-rspec', require: false
7
+ gem 'coveralls_reborn', require: false
8
+ gem 'guard-rspec', require: false
9
9
 
10
10
  gem 'capybara'
11
11
  gem 'capybara-selenium'
@@ -1,31 +1,5 @@
1
1
  module Trestle
2
2
  module HookHelper
3
- def hook(name, *args)
4
- hooks = hooks(name)
5
-
6
- if hooks.any?
7
- safe_join(hooks.map { |hook|
8
- hook.evaluate(self, *args)
9
- }, "\n")
10
- elsif block_given?
11
- capture(*args, &Proc.new)
12
- end
13
- end
14
-
15
- def hook?(name)
16
- hooks(name).any?
17
- end
18
-
19
- protected
20
- def hooks(name)
21
- hook_sets.map { |set| set.for(name) }.inject(&:+).select { |h| h.visible?(self) }
22
- end
23
-
24
- def hook_sets
25
- @_hook_sets ||= [
26
- (admin.hooks if defined?(admin) && admin),
27
- Trestle.config.hooks
28
- ].compact
29
- end
3
+ include Trestle::Hook::Helpers
30
4
  end
31
5
  end
@@ -47,5 +47,20 @@ module Trestle
47
47
 
48
48
  render "trestle/table/table", table: table, collection: collection
49
49
  end
50
+
51
+ # Renders the pagination controls for a collection.
52
+ #
53
+ # collection - The paginated Kaminari collection to render controls for (required).
54
+ # options - Hash of options that will be passed to the Kaminari #paginate method (default: {}):
55
+ #
56
+ # Examples
57
+ #
58
+ # <%= pagination collection: Account.page(params[:page]), remote: true %>
59
+ #
60
+ # Returns the HTML representation of the pagination controls as a HTML-safe String.
61
+ def pagination(collection:, entry_name: nil, **options)
62
+ collection = collection.call if collection.respond_to?(:call)
63
+ render "trestle/table/pagination", collection: collection, entry_name: entry_name, options: options
64
+ end
50
65
  end
51
66
  end
@@ -20,6 +20,6 @@
20
20
  <footer class="main-content-footer">
21
21
  <%= hook("resource.index.footer") %>
22
22
 
23
- <%= render "trestle/table/pagination", collection: collection, entry_name: admin.model_name %>
23
+ <%= pagination collection: collection, entry_name: admin.model_name, remote: admin.pagination_options[:ajax] %>
24
24
  </footer>
25
25
  <% end %>
@@ -1,5 +1,5 @@
1
1
  <nav class="pagination-container">
2
2
  <p><%= page_entries_info(collection, entry_name: (entry_name if local_assigns.has_key?(:entry_name))) %>
3
3
 
4
- <%= paginate(collection, theme: "trestle") %>
4
+ <%= paginate(collection, **{ theme: "trestle" }.reverse_merge(local_assigns.has_key?(:options) ? options : {})) %>
5
5
  </nav>
@@ -0,0 +1,18 @@
1
+ {
2
+ vi: {
3
+ date: {
4
+ formats: {
5
+ trestle_date: proc { |date| "%d/%m/%Y" },
6
+ trestle_calendar: "%d/%m/%Y"
7
+ }
8
+ },
9
+
10
+ time: {
11
+ formats: {
12
+ trestle_date: proc { |time| "%d/%m/%Y" },
13
+ trestle_time: "%H:%M",
14
+ trestle_time_with_seconds: "%H:%M:%S"
15
+ }
16
+ }
17
+ }
18
+ }
@@ -0,0 +1,101 @@
1
+ vi:
2
+ trestle:
3
+ title: "Trestle Admin"
4
+ footer: "Powered by Trestle"
5
+ version: "Version"
6
+
7
+ helpers:
8
+ page_entries_info:
9
+ one_page:
10
+ display_entries:
11
+ zero: "Không có %{entry_name} được tìm thấy"
12
+ one: "Hiển thị <strong>1</strong> %{entry_name}"
13
+ other: "Hiển thị <strong>tất cả %{count}</strong> %{entry_name}"
14
+
15
+ more_pages:
16
+ display_entries: "Hiển thị %{entry_name} <strong>%{first}&nbsp;-&nbsp;%{last}</strong> của <b>%{total}</b>"
17
+
18
+ onboarding:
19
+ welcome: "Welcome to Trestle"
20
+ no_admins: "To begin, please create an admin within <code>app/admin</code>."
21
+ no_template: "To customize this template, please create <code>%{path}</code>."
22
+ no_form: "Please define a form block or create a <code>_form.html</code> partial."
23
+
24
+ ui:
25
+ toggle_navigation: "Toggle navigation"
26
+ toggle_sidebar: "Toggle sidebar"
27
+ toggle_dropdown: "Toggle dropdown"
28
+
29
+ dialog:
30
+ error: "Yêu cầu chưa hoàn thành."
31
+
32
+ confirmation:
33
+ title: "Bạn có chắc?"
34
+ delete: "Xoá"
35
+ cancel: "Huỷ"
36
+
37
+ file:
38
+ choose_file: "Chọn tập tin..."
39
+ browse: "Tải lên"
40
+
41
+ admin:
42
+ titles:
43
+ index: "Danh sách %{pluralized_model_name}"
44
+ new: "Tạo mới %{model_name}"
45
+ edit: Chỉnh sửa %{model_name}"
46
+
47
+ buttons:
48
+ new: "Tạo mới %{model_name}"
49
+ save: "Lưu %{model_name}"
50
+ delete: "Xoá %{model_name}"
51
+ show: "Xem %{model_name}"
52
+ edit: "Chỉnh sửa %{model_name}"
53
+ ok: "Đồng ý"
54
+
55
+ breadcrumbs:
56
+ home: "Trang Chủ"
57
+
58
+ flash:
59
+ create:
60
+ success:
61
+ title: "Thành công!"
62
+ message: "%{lowercase_model_name} được tạo mới thành công!"
63
+
64
+ failure:
65
+ title: "Cảnh báo!"
66
+ message: "Vui lòng chính xác các thông tin bên dưới!"
67
+
68
+ update:
69
+ success:
70
+ title: "Thành công!"
71
+ message: "%{lowercase_model_name} đã được cập nhật thành công!"
72
+
73
+ failure:
74
+ title: "Cảnh báo!"
75
+ message: "Vui lòng chính xác các thông tin bên dưới!."
76
+
77
+ destroy:
78
+ success:
79
+ title: "Thành công!"
80
+ message: "%{lowercase_model_name} đã được xoá thành công!"
81
+
82
+ failure:
83
+ title: "Cảnh báo!"
84
+ message: "Không thể xoá %{lowercase_model_name}."
85
+
86
+ table:
87
+ headers:
88
+ id: "ID"
89
+
90
+ form:
91
+ select:
92
+ prompt: "- Chọn %{attribute_name} -"
93
+
94
+ format:
95
+ blank: "Chưa có"
96
+
97
+ datepicker:
98
+ formats:
99
+ date: "m/d/Y"
100
+ datetime: "m/d/Y h:i K"
101
+ time: "h:i K"
@@ -19,6 +19,8 @@
19
19
  }
20
20
 
21
21
  a {
22
+ display: inline-block;
23
+
22
24
  background-color: $scope-bg;
23
25
 
24
26
  font-size: 0.8rem;
@@ -24,6 +24,10 @@
24
24
  .main-content-sidebar & {
25
25
  @include table-container-background($content-sidebar-bg);
26
26
  }
27
+
28
+ &.loading {
29
+ opacity: 0.5;
30
+ }
27
31
  }
28
32
 
29
33
  .trestle-table {
@@ -0,0 +1,51 @@
1
+ /* global history */
2
+
3
+ import $ from 'jquery'
4
+
5
+ import { triggerInit } from '../core/events'
6
+
7
+ const REMOTE_PAGINATION_SELECTOR = '.page-link[data-remote]'
8
+
9
+ $(document)
10
+ .on('ajax:send', function (e) {
11
+ const $context = $(e.target).closest('[data-context]')
12
+ const $table = $context.find('.table-container')
13
+ $table.addClass('loading')
14
+ })
15
+
16
+ .on('ajax:complete', function (e) {
17
+ const $context = $(e.target).closest('[data-context]')
18
+ const $table = $context.find('.table-container')
19
+ $table.removeClass('loading')
20
+ })
21
+
22
+ .on('ajax:success', REMOTE_PAGINATION_SELECTOR, function (e) {
23
+ const $link = $(e.target)
24
+ const $context = $link.closest('[data-context]')
25
+
26
+ // Update table and pagination
27
+ const $doc = $(e.detail[0])
28
+
29
+ const $table = $doc.find('.table-container')
30
+ $context.find('.table-container').replaceWith($table)
31
+
32
+ triggerInit($table)
33
+
34
+ const $pagination = $doc.find('.pagination-container')
35
+ $context.find('.pagination-container').replaceWith($pagination)
36
+
37
+ // Update the URL in the browser and context
38
+ const location = $link.attr('href')
39
+
40
+ if (location) {
41
+ // TODO: Implement URL updating with back button support
42
+ // if ($context.hasClass('app-main')) {
43
+ // history.pushState({}, '', location)
44
+ // }
45
+
46
+ $context.data('context', location)
47
+ }
48
+
49
+ // Scroll to top of table
50
+ $table[0].scrollIntoView(true)
51
+ })