trestle 0.9.3 → 0.9.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +1 -0
- data/Gemfile +2 -2
- data/app/assets/bundle/trestle/bundle.css +0 -0
- data/app/assets/bundle/trestle/bundle.js +0 -0
- data/app/assets/bundle/trestle/fa-brands-400.eot +0 -0
- data/app/assets/bundle/trestle/fa-brands-400.svg +0 -0
- data/app/assets/bundle/trestle/fa-brands-400.ttf +0 -0
- data/app/assets/bundle/trestle/fa-brands-400.woff +0 -0
- data/app/assets/bundle/trestle/fa-brands-400.woff2 +0 -0
- data/app/assets/bundle/trestle/fa-regular-400.eot +0 -0
- data/app/assets/bundle/trestle/fa-regular-400.svg +0 -0
- data/app/assets/bundle/trestle/fa-regular-400.ttf +0 -0
- data/app/assets/bundle/trestle/fa-regular-400.woff +0 -0
- data/app/assets/bundle/trestle/fa-regular-400.woff2 +0 -0
- data/app/assets/bundle/trestle/fa-solid-900.eot +0 -0
- data/app/assets/bundle/trestle/fa-solid-900.svg +0 -0
- data/app/assets/bundle/trestle/fa-solid-900.ttf +0 -0
- data/app/assets/bundle/trestle/fa-solid-900.woff +0 -0
- data/app/assets/bundle/trestle/fa-solid-900.woff2 +0 -0
- data/app/assets/bundle/trestle/flatpickr/ar.js +0 -0
- data/app/assets/bundle/trestle/flatpickr/at.js +0 -0
- data/app/assets/bundle/trestle/flatpickr/az.js +0 -0
- data/app/assets/bundle/trestle/flatpickr/be.js +0 -0
- data/app/assets/bundle/trestle/flatpickr/bg.js +0 -0
- data/app/assets/bundle/trestle/flatpickr/bn.js +0 -0
- data/app/assets/bundle/trestle/flatpickr/bs.js +0 -0
- data/app/assets/bundle/trestle/flatpickr/cat.js +0 -0
- data/app/assets/bundle/trestle/flatpickr/cs.js +0 -0
- data/app/assets/bundle/trestle/flatpickr/cy.js +0 -0
- data/app/assets/bundle/trestle/flatpickr/da.js +0 -0
- data/app/assets/bundle/trestle/flatpickr/de.js +0 -0
- data/app/assets/bundle/trestle/flatpickr/default.js +0 -0
- data/app/assets/bundle/trestle/flatpickr/eo.js +0 -0
- data/app/assets/bundle/trestle/flatpickr/es.js +0 -0
- data/app/assets/bundle/trestle/flatpickr/et.js +0 -0
- data/app/assets/bundle/trestle/flatpickr/fa.js +0 -0
- data/app/assets/bundle/trestle/flatpickr/fi.js +0 -0
- data/app/assets/bundle/trestle/flatpickr/fo.js +0 -0
- data/app/assets/bundle/trestle/flatpickr/fr.js +0 -0
- data/app/assets/bundle/trestle/flatpickr/ga.js +0 -0
- data/app/assets/bundle/trestle/flatpickr/gr.js +0 -0
- data/app/assets/bundle/trestle/flatpickr/he.js +0 -0
- data/app/assets/bundle/trestle/flatpickr/hi.js +0 -0
- data/app/assets/bundle/trestle/flatpickr/hr.js +0 -0
- data/app/assets/bundle/trestle/flatpickr/hu.js +0 -0
- data/app/assets/bundle/trestle/flatpickr/id.js +0 -0
- data/app/assets/bundle/trestle/flatpickr/is.js +0 -0
- data/app/assets/bundle/trestle/flatpickr/it.js +0 -0
- data/app/assets/bundle/trestle/flatpickr/ja.js +0 -0
- data/app/assets/bundle/trestle/flatpickr/ka.js +0 -0
- data/app/assets/bundle/trestle/flatpickr/km.js +0 -0
- data/app/assets/bundle/trestle/flatpickr/ko.js +0 -0
- data/app/assets/bundle/trestle/flatpickr/kz.js +0 -0
- data/app/assets/bundle/trestle/flatpickr/lt.js +0 -0
- data/app/assets/bundle/trestle/flatpickr/lv.js +0 -0
- data/app/assets/bundle/trestle/flatpickr/mk.js +0 -0
- data/app/assets/bundle/trestle/flatpickr/mn.js +0 -0
- data/app/assets/bundle/trestle/flatpickr/my.js +0 -0
- data/app/assets/bundle/trestle/flatpickr/nl.js +0 -0
- data/app/assets/bundle/trestle/flatpickr/no.js +0 -0
- data/app/assets/bundle/trestle/flatpickr/pa.js +0 -0
- data/app/assets/bundle/trestle/flatpickr/pl.js +0 -0
- data/app/assets/bundle/trestle/flatpickr/pt.js +0 -0
- data/app/assets/bundle/trestle/flatpickr/ro.js +0 -0
- data/app/assets/bundle/trestle/flatpickr/ru.js +0 -0
- data/app/assets/bundle/trestle/flatpickr/si.js +0 -0
- data/app/assets/bundle/trestle/flatpickr/sk.js +0 -0
- data/app/assets/bundle/trestle/flatpickr/sl.js +0 -0
- data/app/assets/bundle/trestle/flatpickr/sq.js +0 -0
- data/app/assets/bundle/trestle/flatpickr/sr-cyr.js +0 -0
- data/app/assets/bundle/trestle/flatpickr/sr.js +0 -0
- data/app/assets/bundle/trestle/flatpickr/sv.js +0 -0
- data/app/assets/bundle/trestle/flatpickr/th.js +0 -0
- data/app/assets/bundle/trestle/flatpickr/tr.js +0 -0
- data/app/assets/bundle/trestle/flatpickr/uk.js +0 -0
- data/app/assets/bundle/trestle/flatpickr/uz.js +0 -0
- data/app/assets/bundle/trestle/flatpickr/uz_latn.js +0 -0
- data/app/assets/bundle/trestle/flatpickr/vn.js +0 -0
- data/app/assets/bundle/trestle/flatpickr/zh-tw.js +0 -0
- data/app/assets/bundle/trestle/flatpickr/zh.js +0 -0
- data/app/helpers/trestle/hook_helper.rb +1 -27
- data/app/helpers/trestle/table_helper.rb +15 -0
- data/app/views/trestle/resource/index.html.erb +1 -1
- data/app/views/trestle/table/_pagination.html.erb +1 -1
- data/config/locales/vi.rb +18 -0
- data/config/locales/vi.yml +101 -0
- data/frontend/css/components/_scopes.scss +2 -0
- data/frontend/css/components/_table.scss +4 -0
- data/frontend/js/components/pagination.js +51 -0
- data/frontend/js/index.js +1 -0
- data/lib/trestle/admin.rb +12 -2
- data/lib/trestle/engine.rb +3 -6
- data/lib/trestle/form/field.rb +19 -12
- data/lib/trestle/form/fields/collection_select.rb +1 -1
- data/lib/trestle/form/fields/date_picker.rb +9 -3
- data/lib/trestle/form/fields/file_field.rb +1 -1
- data/lib/trestle/form/fields/form_group.rb +13 -2
- data/lib/trestle/form/fields/grouped_collection_select.rb +1 -1
- data/lib/trestle/form/fields/range_field.rb +2 -4
- data/lib/trestle/form/fields/select.rb +2 -3
- data/lib/trestle/form/fields/static_field.rb +2 -2
- data/lib/trestle/form/fields/tag_select.rb +1 -1
- data/lib/trestle/form/fields/time_zone_select.rb +1 -1
- data/lib/trestle/form/renderer.rb +5 -3
- data/lib/trestle/hook.rb +3 -29
- data/lib/trestle/hook/helpers.rb +33 -0
- data/lib/trestle/hook/set.rb +32 -0
- data/lib/trestle/reloader.rb +25 -5
- data/lib/trestle/resource.rb +4 -3
- data/lib/trestle/scopes.rb +5 -4
- data/lib/trestle/scopes/block.rb +9 -8
- data/lib/trestle/scopes/scope.rb +1 -1
- data/lib/trestle/version.rb +1 -1
- data/package.json +8 -8
- data/yarn.lock +1360 -1452
- metadata +12 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c79f7b5d12b485966fe7c165b5481e00f9e411e353a74818d91dc9d17c4dd6f2
|
4
|
+
data.tar.gz: 8502c2dee447e7ad01ccb3df23d3b17dc1e02db3e8f1de5049cbb3a245655a43
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8c86b38910a39e0c8cc45625db9b34860074491b4f6b8033c7ac54d17706ca2efae535d9657efb6725b744adcb5c91b4854e84c6e58ff34a79f8648328dc36be
|
7
|
+
data.tar.gz: e597539d8dc3285a710da28be1b935d2c0c0ef2d555d193dd03d402f109929a93c63db9b3e5d518846e33a69ad4e52be712b5a7f3aefb9bc02d3cd2ae5303a0d
|
data/.travis.yml
CHANGED
data/Gemfile
CHANGED
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
@@ -1,31 +1,5 @@
|
|
1
1
|
module Trestle
|
2
2
|
module HookHelper
|
3
|
-
|
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
|
-
<%=
|
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} - %{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"
|
@@ -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
|
+
})
|