snaptable 2.2.4 → 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/app/assets/javascripts/snaptable.js +0 -2
- data/app/assets/javascripts/snaptable/table.js +38 -31
- data/app/views/snaptable/_search_field.html.erb +1 -1
- data/lib/snaptable/constructor/renderer.rb +0 -3
- data/lib/snaptable/constructor/sortable.rb +1 -1
- data/lib/snaptable/engine.rb +0 -1
- data/lib/snaptable/version.rb +1 -1
- metadata +4 -20
- data/app/views/snaptable/sort.js.erb +0 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 277fe830bde38834c01c0cedf76baf9fdfd1f884823c052cbe480bf840a982c6
|
4
|
+
data.tar.gz: 955421611309c919843daf076892f086baf25a09ccbe3b8f0eab4df78fba33ed
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d06b3919053af0a68e8c825238d4e9d72ca08a6e8da650528ecbfd30d447f0ef304575f0b97f35143f5fa748e719ea64dfe899f1a42a658d717a6ac2b64bbdc0
|
7
|
+
data.tar.gz: b5ceb7fdf56348f5346fcd288c419d4cc6475ca9ae55b877006cac052143fdd768eeb4cb9e9a32ecaa4d2a21dd5e5037ea9124661daec20df2da45bbcc2e6ab7
|
data/README.md
CHANGED
@@ -3,43 +3,53 @@
|
|
3
3
|
|
4
4
|
/* Admin table */
|
5
5
|
|
6
|
+
/* Admin table */
|
7
|
+
|
6
8
|
function snapifyTable(snaptable) {
|
7
9
|
|
8
|
-
var tableButtons = snaptable.
|
9
|
-
editButton = tableButtons.
|
10
|
-
deleteButton = tableButtons.
|
11
|
-
showButton = tableButtons.
|
10
|
+
var tableButtons = snaptable.querySelector(".table_buttons"),
|
11
|
+
editButton = tableButtons.querySelector("a.edit"),
|
12
|
+
deleteButton = tableButtons.querySelector("a.delete"),
|
13
|
+
showButton = tableButtons.querySelector("a.show"),
|
12
14
|
path = window.location.pathname + "/",
|
13
15
|
urlParams = new URLSearchParams(location.search),
|
14
16
|
token = urlParams.get('token');
|
15
17
|
|
16
18
|
var paramsStr = (token ? ("?token=" + token) : "")
|
17
19
|
|
18
|
-
// add ajax to the pagination
|
19
|
-
snaptable.on("click", ".pagination a", function() {
|
20
|
-
$.getScript(this.href);
|
21
|
-
return false;
|
22
|
-
});
|
23
|
-
|
24
20
|
// line clickable
|
25
|
-
snaptable.
|
26
|
-
var
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
21
|
+
snaptable.querySelector("tbody").addEventListener("click", function(e) {
|
22
|
+
var target = e.target.parentElement; // td is clicked, tr is the direct parent
|
23
|
+
var id = target.dataset.url;
|
24
|
+
if (typeof id !== "undefined" && !target.classList.contains("selected")) {
|
25
|
+
// change selected row
|
26
|
+
var selected = snaptable.querySelector("tr.selected");
|
27
|
+
if (selected) {
|
28
|
+
snaptable.querySelector("tr.selected").classList.remove("selected");
|
29
|
+
}
|
30
|
+
target.classList.add("selected");
|
31
|
+
// update the buttons
|
32
|
+
if (showButton) {
|
33
|
+
showButton.classList.add("on");
|
34
|
+
showButton.setAttribute("href", path + id + paramsStr);
|
35
|
+
}
|
36
|
+
if (editButton) {
|
37
|
+
editButton.classList.add("on");
|
38
|
+
editButton.setAttribute("href", path + id + "/edit" + paramsStr);
|
39
|
+
}
|
40
|
+
if (deleteButton) {
|
41
|
+
deleteButton.classList.add("on");
|
42
|
+
deleteButton.setAttribute("href", path + id + paramsStr);
|
43
|
+
}
|
34
44
|
}
|
35
45
|
});
|
36
46
|
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
var id =
|
47
|
+
if(editButton) {
|
48
|
+
snaptable.querySelector("tbody").addEventListener("dblclick", function(e) {
|
49
|
+
var target = e.target.parentElement; // td is clicked, tr is the direct parent
|
50
|
+
var id = target.dataset.url;
|
41
51
|
if ( typeof id !== "undefined" ) {
|
42
|
-
window.location = path + id + "/edit";
|
52
|
+
window.location = path + id + "/edit" + paramsStr;
|
43
53
|
}
|
44
54
|
});
|
45
55
|
}
|
@@ -48,14 +58,11 @@ function snapifyTable(snaptable) {
|
|
48
58
|
|
49
59
|
function snapifyTables() {
|
50
60
|
|
51
|
-
|
52
|
-
snapifyTable(
|
61
|
+
document.querySelectorAll(".snaptable").forEach(function(table) {
|
62
|
+
snapifyTable(table);
|
53
63
|
})
|
54
64
|
|
55
65
|
}
|
56
66
|
|
57
|
-
|
58
|
-
|
59
|
-
snapifyTables();
|
60
|
-
|
61
|
-
});
|
67
|
+
document.addEventListener("ready", snapifyTables);
|
68
|
+
document.addEventListener("turbolinks:load", snapifyTables);
|
@@ -1,6 +1,6 @@
|
|
1
1
|
<div class="search">
|
2
2
|
<p><%= t("table.search.title") %></p>
|
3
|
-
<%= form_tag request.fullpath, method: :get
|
3
|
+
<%= form_tag request.fullpath, method: :get do %>
|
4
4
|
<%= hidden_field_tag :table, presenter.table_name %>
|
5
5
|
<%= hidden_field_tag :buttons, presenter.instance_variable_get(:@buttons) %>
|
6
6
|
<%= search_field_tag :query, params[:query] %>
|
@@ -4,7 +4,7 @@ module Snaptable
|
|
4
4
|
|
5
5
|
def sortable(column)
|
6
6
|
if model.reflect_on_association(column.gsub /_id/, '').nil?
|
7
|
-
view_context.link_to({sort: column, direction: direction(column), query: params[:query], paginate_key => page, table: table_name, buttons: @buttons}, {
|
7
|
+
view_context.link_to({sort: column, direction: direction(column), query: params[:query], paginate_key => page, table: table_name, buttons: @buttons}, {class: css_class(column)}) do
|
8
8
|
model.human_attribute_name(column)
|
9
9
|
end
|
10
10
|
else
|
data/lib/snaptable/engine.rb
CHANGED
data/lib/snaptable/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: snaptable
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 3.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- khcr
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-02-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -39,21 +39,7 @@ dependencies:
|
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
|
-
name:
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
44
|
-
requirements:
|
45
|
-
- - ">="
|
46
|
-
- !ruby/object:Gem::Version
|
47
|
-
version: '0'
|
48
|
-
type: :runtime
|
49
|
-
prerelease: false
|
50
|
-
version_requirements: !ruby/object:Gem::Requirement
|
51
|
-
requirements:
|
52
|
-
- - ">="
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
version: '0'
|
55
|
-
- !ruby/object:Gem::Dependency
|
56
|
-
name: jquery-rails
|
42
|
+
name: sassc-rails
|
57
43
|
requirement: !ruby/object:Gem::Requirement
|
58
44
|
requirements:
|
59
45
|
- - ">="
|
@@ -98,7 +84,6 @@ files:
|
|
98
84
|
- app/views/snaptable/_buttons.html.erb
|
99
85
|
- app/views/snaptable/_search_field.html.erb
|
100
86
|
- app/views/snaptable/base.html.erb
|
101
|
-
- app/views/snaptable/sort.js.erb
|
102
87
|
- config/locales/en.yml
|
103
88
|
- config/locales/fr.yml
|
104
89
|
- lib/snaptable.rb
|
@@ -129,8 +114,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
129
114
|
- !ruby/object:Gem::Version
|
130
115
|
version: '0'
|
131
116
|
requirements: []
|
132
|
-
|
133
|
-
rubygems_version: 2.7.7
|
117
|
+
rubygems_version: 3.0.3
|
134
118
|
signing_key:
|
135
119
|
specification_version: 4
|
136
120
|
summary: A gem that generate HTML tables from your models in order to display them
|