snaptable 0.7.0 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/app/assets/javascripts/snaptable/table.js +20 -15
- data/app/helpers/buttons_helper.rb +27 -0
- data/app/views/snaptable/_buttons.html.erb +6 -3
- data/lib/snaptable/engine.rb +4 -0
- data/lib/snaptable/version.rb +1 -1
- data/lib/snaptable.rb +5 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1e55f9bfbf938219e391653ebc8a7f75c81fa899
|
4
|
+
data.tar.gz: e54c06773f1c757728000a32926d6bb0d378c11f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 471689c2fc415d3120de3fac9c366f2b7b6f1310e5397e607de354be14fb3aa53c96fbbeb019842df488926e75d87b74e8585a4d83cb682c1945bd3c63292a41
|
7
|
+
data.tar.gz: fb46a059da5e39b0d1330795a0af3b0a5fe5d622388ec013b6b5d8cca7bfa939519571723d91309c0e8e115122a686e815c476e1525f80422a41eda3a2a9e6ac
|
@@ -1,13 +1,17 @@
|
|
1
|
+
/* global $ */
|
2
|
+
"use strict";
|
3
|
+
|
1
4
|
/* Admin table */
|
2
5
|
|
3
6
|
function snapifyTable() {
|
4
7
|
|
5
|
-
var snaptable = $(
|
8
|
+
var snaptable = $("#snaptable");
|
6
9
|
|
7
|
-
var tableButtons = snaptable.find(
|
8
|
-
editButton = tableButtons.find(
|
9
|
-
deleteButton = tableButtons.find(
|
10
|
-
|
10
|
+
var tableButtons = snaptable.find(".table_buttons"),
|
11
|
+
editButton = tableButtons.find("a[class='edit']"),
|
12
|
+
deleteButton = tableButtons.find("a[class='delete']"),
|
13
|
+
showButton = tableButtons.find("a[class='show']"),
|
14
|
+
path = window.location.pathname + "/";
|
11
15
|
|
12
16
|
// add ajax to the pagination
|
13
17
|
snaptable.on("click", ".pagination a", function() {
|
@@ -17,21 +21,22 @@ function snapifyTable() {
|
|
17
21
|
|
18
22
|
// line clickable
|
19
23
|
snaptable.on("click", "tbody tr", function(e) {
|
20
|
-
var id = $(this).data(
|
21
|
-
if ( typeof id !==
|
22
|
-
$(
|
23
|
-
$(this).addClass(
|
24
|
-
deleteButton.add(editButton).addClass("on");
|
25
|
-
editButton.attr(
|
26
|
-
deleteButton.attr(
|
24
|
+
var id = $(this).data("url") ;
|
25
|
+
if ( typeof id !== "undefined" && !$(this).hasClass("selected") ) {
|
26
|
+
$("tr.selected").removeClass("selected");
|
27
|
+
$(this).addClass("selected");
|
28
|
+
deleteButton.add(editButton).add(showButton).addClass("on");
|
29
|
+
editButton.attr("href", path + id + "/edit");
|
30
|
+
deleteButton.attr("href", path + id);
|
31
|
+
showButton.attr("href", path + id);
|
27
32
|
}
|
28
33
|
});
|
29
34
|
|
30
35
|
// Double click
|
31
36
|
snaptable.on("dblclick", "tbody tr", function() {
|
32
|
-
var id = $(this).data(
|
33
|
-
if ( typeof id !==
|
34
|
-
window.location = path + id +
|
37
|
+
var id = $(this).data("url");
|
38
|
+
if ( typeof id !== "undefined" ) {
|
39
|
+
window.location = path + id + "/edit";
|
35
40
|
}
|
36
41
|
});
|
37
42
|
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module ButtonsHelper
|
2
|
+
|
3
|
+
def add_button?
|
4
|
+
Snaptable.add_button &&
|
5
|
+
(!Snaptable.use_permission ||
|
6
|
+
current_permission.allow_create?(params[:controller]))
|
7
|
+
end
|
8
|
+
|
9
|
+
def edit_button?
|
10
|
+
Snaptable.edit_button &&
|
11
|
+
(!Snaptable.use_permission ||
|
12
|
+
current_permission.allow_modify?(params[:controller], "update"))
|
13
|
+
end
|
14
|
+
|
15
|
+
def show_button?
|
16
|
+
Snaptable.show_button &&
|
17
|
+
(!Snaptable.use_permission ||
|
18
|
+
current_permission.allow_modify?(params[:controller], "read"))
|
19
|
+
end
|
20
|
+
|
21
|
+
def delete_button?
|
22
|
+
Snaptable.delete_button &&
|
23
|
+
(!Snaptable.use_permission ||
|
24
|
+
current_permission.allow_modify?(params[:controller], "destroy"))
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
@@ -1,13 +1,16 @@
|
|
1
1
|
<div class="table_buttons">
|
2
2
|
<p>Actions</p>
|
3
3
|
<p>
|
4
|
-
<% if
|
4
|
+
<% if add_button? %>
|
5
5
|
<%= link_to "Ajouter", request.path + "/new", class: "add" %>
|
6
6
|
<% end %>
|
7
|
-
<% if
|
7
|
+
<% if edit_button? %>
|
8
8
|
<a class="edit" href="#">Editer</a>
|
9
9
|
<% end %>
|
10
|
-
<% if
|
10
|
+
<% if show_button? %>
|
11
|
+
<a class="show" href="#">Voir</a>
|
12
|
+
<% end %>
|
13
|
+
<% if delete_button? %>
|
11
14
|
<a class="delete" href="#" data-method="delete"
|
12
15
|
rel="nofollow" data-confirm="Etes-vous sûr de vouloir supprimer cette entrée ?">
|
13
16
|
Supprimer
|
data/lib/snaptable/engine.rb
CHANGED
data/lib/snaptable/version.rb
CHANGED
data/lib/snaptable.rb
CHANGED
@@ -2,6 +2,10 @@ require 'snaptable/engine'
|
|
2
2
|
|
3
3
|
module Snaptable
|
4
4
|
@@use_permission = false
|
5
|
+
@@add_button = true
|
6
|
+
@@edit_button = true
|
7
|
+
@@delete_button = true
|
8
|
+
@@show_button = false
|
5
9
|
|
6
|
-
mattr_accessor :use_permission
|
10
|
+
mattr_accessor :use_permission, :add_button, :edit_button, :delete_button, :show_button
|
7
11
|
end
|
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: 0.
|
4
|
+
version: 0.8.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- khcr
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-09-
|
11
|
+
date: 2015-09-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -94,6 +94,7 @@ files:
|
|
94
94
|
- app/assets/javascripts/snaptable/table.js
|
95
95
|
- app/assets/stylesheets/snaptable.css
|
96
96
|
- app/assets/stylesheets/snaptable/table.css.scss
|
97
|
+
- app/helpers/buttons_helper.rb
|
97
98
|
- app/views/snaptable/_buttons.html.erb
|
98
99
|
- app/views/snaptable/_search_field.html.erb
|
99
100
|
- app/views/snaptable/base.html.erb
|