opale 0.1.4 → 0.1.31

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ad137f79771c5abae1292ae9e03ad44e0f1523b7fd16650fe40ab9fe6319bfbe
4
- data.tar.gz: da3c86fdb9d7caa0b5d310140a905472c3190583538a955a5be8b327e0f7b232
3
+ metadata.gz: 23355a3649ae3815009a2517aa90c3bfb8c11e8660955b795ea15abf53dace18
4
+ data.tar.gz: 485e4e8d946f6163371c14d4194c5143e9fd74156e997a854ccedd287c3d1370
5
5
  SHA512:
6
- metadata.gz: be8415431a2ad71dd829547582ce846c89a943cec8ae8b4eabde59e535752f4a3f7badf1a326780c2338f8888f206f1ef0cfe7002262050573c9576b8e340a27
7
- data.tar.gz: 6d53e0c79a0b8ce92c6cce957be92054d082835d5fe6bae4bc550ad8f95f2b24a210e8a1aaeeb6b290ec796d39dfee66872c8e07e9960d4c6d8de506d416f4f1
6
+ metadata.gz: '09c08b11c4c9d1e6e0b87ff09b321778a3f5d93865f79711293edcf2ee59c235b6081ec4ef92d60e41143598e8e9e3fd3ec43e8f23736fbee7f819bf09dea92b'
7
+ data.tar.gz: '029385960ecd71a6cedc421cdfd92396e77ad97cf845a817e11b3345250e47ff468472ae8d5d23673d88662046b9f8fde81c025ffabf4884adab71d19b256211'
Binary file
@@ -1,5 +1,5 @@
1
1
  # Concern for sorting models
2
- module Sort
2
+ module Sortable
3
3
  extend ActiveSupport::Concern
4
4
 
5
5
  included do
@@ -12,7 +12,7 @@ module Sort
12
12
  return if params['searching'].nil?
13
13
 
14
14
  @search_hash = Array.new
15
- objects = Array.new
15
+ objects = Array.new
16
16
 
17
17
  params.each do |k, v|
18
18
  unless v.class.eql? String
@@ -21,6 +21,10 @@ module Sort
21
21
  end
22
22
  end
23
23
 
24
+ puts objects.inspect
25
+
26
+ return if objects.nil? || objects.empty?
27
+
24
28
  # If the object is inside a namespace
25
29
  if objects[0].include? '::'
26
30
  to_capitalize = objects[0].split('::')
@@ -0,0 +1,8 @@
1
+ module Opale
2
+ class Error < StandardError; end
3
+ # Your code goes here...
4
+ end
5
+
6
+ require 'opale/railtie' if defined?(Rails)
7
+ require "opale/version"
8
+ require "opale/script_inserter"
Binary file
@@ -1,9 +1,15 @@
1
- require 'helpers/sortable_helper'
1
+ require 'helpers/sortables_helper'
2
+ require 'controllers/concerns/sortable'
2
3
 
3
4
  module Opale
4
5
  class Railtie < Rails::Railtie
5
- initializer 'helpers.sortable_helper' do
6
+ initializer 'helpers.sortables_helper' do
6
7
  ActionView::Base.send :include, SortableHelper
7
8
  end
9
+
10
+ initializer "opalejs-rails" do |app|
11
+ ActionController::Base.send :include, Opale::ScriptInserter
12
+ ActionController::Base.after_action :insert_opalejs
13
+ end
8
14
  end
9
15
  end
@@ -0,0 +1,30 @@
1
+ module Opale
2
+ module ScriptInserter
3
+ BODY_TAG = %r{</body>}
4
+
5
+ JS_SCRIPT = %q(
6
+ <script>
7
+ function sortable(event, column) {
8
+ console.log("sortable");
9
+ var direction = $("#direction").val();
10
+
11
+ $("#sort").val(column);
12
+ $("#direction").val(direction == "desc" ? "asc" : "desc");
13
+
14
+ $('#direction').parent().submit();
15
+
16
+ //event.preventDefault();
17
+ }
18
+ </script>
19
+ )
20
+
21
+ def insert_opalejs
22
+ if (
23
+ response.content_type == 'text/html' &&
24
+ response.body.match(BODY_TAG)
25
+ )
26
+ response.body = response.body.gsub(BODY_TAG, JS_SCRIPT + '\\0')
27
+ end
28
+ end
29
+ end
30
+ end
@@ -1,3 +1,3 @@
1
1
  module Opale
2
- VERSION = '0.1.4'
2
+ VERSION = '0.1.31'
3
3
  end
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: opale
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.31
5
5
  platform: ruby
6
6
  authors:
7
7
  - Poulpy
@@ -82,14 +82,22 @@ files:
82
82
  - assets/javascripts/sortable.js
83
83
  - bin/console
84
84
  - bin/setup
85
+ - lib/.DS_Store
85
86
  - lib/controllers/concerns/sortable.rb
86
87
  - lib/helpers/sortables_helper.rb
88
+ - lib/opale.rb
89
+ - lib/opale/.DS_Store
87
90
  - lib/opale/railtie.rb
91
+ - lib/opale/script_inserter.rb
88
92
  - lib/opale/version.rb
89
- - opale-0.1.0.gem
90
- - opale-0.1.1.gem
91
- - opale-0.1.2.gem
92
- - opale-0.1.3.gem
93
+ - opale-0.1.23.gem
94
+ - opale-0.1.24.gem
95
+ - opale-0.1.25.gem
96
+ - opale-0.1.26.gem
97
+ - opale-0.1.27.gem
98
+ - opale-0.1.28.gem
99
+ - opale-0.1.29.gem
100
+ - opale-0.1.30.gem
93
101
  - opale.gemspec
94
102
  - spec/opale_spec.rb
95
103
  - spec/spec_helper.rb
@@ -112,7 +120,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
112
120
  version: '0'
113
121
  requirements: []
114
122
  rubyforge_project:
115
- rubygems_version: 2.7.9
123
+ rubygems_version: 2.7.10
116
124
  signing_key:
117
125
  specification_version: 4
118
126
  summary: Summary
Binary file
Binary file
Binary file
Binary file