plutonium 0.15.19 → 0.15.20

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2597e1a3e20c5c758cd45e5a321f0936d952e0199b31358af89744a2e9834044
4
- data.tar.gz: 04edfbeb6a3a35ba542aba1c84f0e44f0e6f78e84d621abd80196ac48d09f369
3
+ metadata.gz: 5630875ec6ddc198a720bed518f95ccc137da33384bd7676ff552588397bec09
4
+ data.tar.gz: f2f18c6a3e9607eaf984e42cc817a2760f66f05c5a470cf64087100ec7699c42
5
5
  SHA512:
6
- metadata.gz: ee8a6e93a4d1b41ac05cdb073a779da98ee19ecaff321be36eae78590625fa74ac8c62e50d024a53e1dc1e98b7e9f0dd7cd481edf2fe2ff335e38202df986e06
7
- data.tar.gz: dd22ea7eea8750454724f13e25730a3744c0e5795f9915e8ef4d3fef69e15894a80098c796f29213c1eeacb1ab2e13cb6839581915c8e1fc3747d4b3849f48cf
6
+ metadata.gz: a1000adb19a64a243302ee953c74fcf693d190025b738b884dc13c3e2431bd93ce31767d0b6f1295a433a9456fd9932c7ecfd7bfc72ff65395bdc1fb7d477704
7
+ data.tar.gz: b086a809086dd47b3b3811433a592ee3e608d5d6a22e4e2599f52add01584b078895aa2dccfcdc49172808da42e853e68ba843682b5f6891de456d4d44649643
@@ -108,7 +108,7 @@ module PlutoniumUi
108
108
  label = column.label
109
109
  search_object = column.search_object
110
110
 
111
- if (sort_params = search_object.sort_params_for(name))
111
+ if (sort_params = search_object.sort_params_for(name, request:))
112
112
  tag.div class: "inline-flex" do
113
113
  concat begin
114
114
  link_to(sort_params[:url], class: "flex", title: sort_params[:direction] || "Sort") do
@@ -51,7 +51,7 @@ module Pu
51
51
 
52
52
  def import_styles
53
53
  prepend_to_file "app/assets/stylesheets/application.tailwind.css",
54
- "@import \"gem:plutonium/src/css/plutonium.css\";\n"
54
+ "@import \"gem:plutonium/src/css/plutonium.css\";\n\n"
55
55
  end
56
56
  end
57
57
  end
@@ -62,7 +62,7 @@ module Plutonium
62
62
  #
63
63
  # @param options [Hash] The options for building the URL.
64
64
  # @return [String] The constructed URL with query parameters.
65
- def build_url(**options)
65
+ def build_url(request:, **options)
66
66
  q = {}
67
67
 
68
68
  q[:search] = options.key?(:search) ? options[:search].presence : search_query
@@ -74,7 +74,7 @@ module Plutonium
74
74
 
75
75
  q.merge! params.slice(*filter_definitions.keys)
76
76
  query_params = deep_compact({q: q}).to_param
77
- "?#{query_params}"
77
+ "#{request.path}?#{query_params}"
78
78
  end
79
79
 
80
80
  # Applies the defined filters and sorts to the given scope.
@@ -99,12 +99,12 @@ module Plutonium
99
99
  #
100
100
  # @param name [Symbol, String] The name of the field to sort.
101
101
  # @return [Hash, nil] The sorting parameters including URL and direction.
102
- def sort_params_for(name)
102
+ def sort_params_for(name, request:)
103
103
  return unless sort_definitions[name]
104
104
 
105
105
  {
106
- url: build_url(sort: name),
107
- reset_url: build_url(sort: name, reset: true),
106
+ url: build_url(request:, sort: name),
107
+ reset_url: build_url(request:, sort: name, reset: true),
108
108
  position: selected_sort_fields.index(name.to_s),
109
109
  direction: selected_sort_directions[name]
110
110
  }
@@ -18,14 +18,14 @@ module Plutonium
18
18
  if current_scope.blank?
19
19
  a(
20
20
  id: "#{name}-scope",
21
- href: current_query_object.build_url(scope: nil),
21
+ href: current_query_object.build_url(request:, scope: nil),
22
22
  class:
23
23
  "px-4 py-2 text-sm font-medium text-white bg-primary-700 border border-primary-700 rounded-lg hover:bg-primary-800 focus:z-10 focus:ring-2 focus:ring-primary-700 focus:text-white dark:bg-primary-600 dark:border-primary-600 dark:hover:bg-primary-700 dark:focus:ring-primary-800"
24
24
  ) { name.humanize }
25
25
  else
26
26
  a(
27
27
  id: "#{name}-scope",
28
- href: current_query_object.build_url(scope: nil),
28
+ href: current_query_object.build_url(request:, scope: nil),
29
29
  class:
30
30
  "px-4 py-2 text-sm font-medium text-gray-500 bg-white border border-gray-300 rounded-lg hover:bg-gray-100 hover:text-gray-700 focus:z-10 focus:ring-2 focus:ring-gray-300 focus:text-gray-700 dark:bg-gray-800 dark:text-gray-400 dark:border-gray-600 dark:hover:text-white dark:hover:bg-gray-700 dark:focus:ring-gray-700 dark:focus:text-white"
31
31
  ) { name.humanize }
@@ -35,14 +35,14 @@ module Plutonium
35
35
  if name == current_scope
36
36
  a(
37
37
  id: "#{name}-scope",
38
- href: current_query_object.build_url(scope: name),
38
+ href: current_query_object.build_url(request:, scope: name),
39
39
  class:
40
40
  "px-4 py-2 text-sm font-medium text-white bg-primary-700 border border-primary-700 rounded-lg hover:bg-primary-800 focus:z-10 focus:ring-2 focus:ring-primary-700 focus:text-white dark:bg-primary-600 dark:border-primary-600 dark:hover:bg-primary-700 dark:focus:ring-primary-800"
41
41
  ) { name.humanize }
42
42
  else
43
43
  a(
44
44
  id: "#{name}-scope",
45
- href: current_query_object.build_url(scope: name),
45
+ href: current_query_object.build_url(request:, scope: name),
46
46
  class:
47
47
  "px-4 py-2 text-sm font-medium text-gray-500 bg-white border border-gray-300 rounded-lg hover:bg-gray-100 hover:text-gray-700 focus:z-10 focus:ring-2 focus:ring-gray-300 focus:text-gray-700 dark:bg-gray-800 dark:text-gray-400 dark:border-gray-600 dark:hover:text-white dark:hover:bg-gray-700 dark:focus:ring-gray-700 dark:focus:text-white"
48
48
  ) { name.humanize }
@@ -66,7 +66,10 @@ module Plutonium
66
66
  field_options = resource_definition.defined_fields[name] ? resource_definition.defined_fields[name][:options].dup : {}
67
67
  field_options = field_options.merge(**column_display_options.slice(:align))
68
68
  # field_options[:align] = align_field_to if align_field_to
69
- table.column name, **field_options, sort_params: current_query_object.sort_params_for(name), &display_tag_block
69
+ table.column name,
70
+ **field_options,
71
+ sort_params: current_query_object.sort_params_for(name, request:),
72
+ &display_tag_block
70
73
  end
71
74
 
72
75
  table.actions do |wrapped_object|
@@ -1,5 +1,5 @@
1
1
  module Plutonium
2
- VERSION = "0.15.19"
2
+ VERSION = "0.15.20"
3
3
  NEXT_MAJOR_VERSION = VERSION.split(".").tap { |v|
4
4
  v[1] = v[1].to_i + 1
5
5
  v[2] = 0
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: plutonium
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.15.19
4
+ version: 0.15.20
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stefan Froelich