easy-admin-rails 0.2.3 → 0.2.5

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.
@@ -5757,6 +5757,11 @@ input:checked + .toggle-switch .toggle-slider:before {
5757
5757
  background-color: rgb(229 231 235 / var(--tw-bg-opacity, 1));
5758
5758
  }
5759
5759
 
5760
+ .hover\:bg-gray-300:hover {
5761
+ --tw-bg-opacity: 1;
5762
+ background-color: rgb(209 213 219 / var(--tw-bg-opacity, 1));
5763
+ }
5764
+
5760
5765
  .hover\:bg-gray-400:hover {
5761
5766
  --tw-bg-opacity: 1;
5762
5767
  background-color: rgb(156 163 175 / var(--tw-bg-opacity, 1));
@@ -101,16 +101,35 @@ module EasyAdmin
101
101
  end
102
102
 
103
103
  def render_resource_permission_group(resource)
104
- div(class: "border border-gray-200 bg-white rounded-lg p-4") do
105
- div(class: "flex items-center justify-between mb-4") do
106
- div(class: "flex items-center") do
107
- h4(class: "text-md font-medium text-gray-900 capitalize") { resource.humanize }
108
- end
109
-
110
- div(class: "flex items-center space-x-2") do
111
- span(class: "inline-flex items-center px-2 py-1 rounded-full text-xs font-medium bg-gray-100 text-gray-700") do
112
- "4 permissions"
104
+ div(
105
+ class: "border border-gray-200 bg-white rounded-lg",
106
+ data: {
107
+ controller: "collapsible-filters",
108
+ "collapsible-filters-expanded-value": "false", # Collapsed by default
109
+ "collapsible-filters-persist-state-value": "false" # Don't save/load state
110
+ }
111
+ ) do
112
+ # Collapsible header
113
+ div(
114
+ class: "px-4 py-3 border-b border-gray-200 cursor-pointer hover:bg-gray-50 transition-colors duration-150",
115
+ data: { action: "click->collapsible-filters#toggle" }
116
+ ) do
117
+ div(class: "flex items-center justify-between") do
118
+ div(class: "flex items-center space-x-3") do
119
+ # Collapse/Expand icon
120
+ div(data: { collapsible_filters_target: "icon" }) do
121
+ unsafe_raw '<svg class="w-5 h-5 text-gray-400 transform transition-transform duration-200" fill="none" stroke="currentColor" viewBox="0 0 24 24">
122
+ <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 9l-7 7-7-7"></path>
123
+ </svg>'
124
+ end
125
+
126
+ h4(class: "text-md font-medium text-gray-900 capitalize") { resource.humanize }
127
+
128
+ span(class: "inline-flex items-center px-2 py-1 rounded-full text-xs font-medium bg-gray-100 text-gray-700") do
129
+ "4 permissions"
130
+ end
113
131
  end
132
+
114
133
  # Toggle all button for this resource
115
134
  button(
116
135
  type: "button",
@@ -125,13 +144,21 @@ module EasyAdmin
125
144
  end
126
145
  end
127
146
 
128
- # Permissions grid with old card style (2 per row)
129
- div(class: "grid grid-cols-1 md:grid-cols-2 gap-3") do
130
- %w[read create update delete].each do |action|
131
- permission_name = "#{resource}:#{action}"
132
- is_granted = permission_granted?(permission_name)
133
-
134
- render_permission_toggle_card(permission_name, action, is_granted)
147
+ # Collapsible content
148
+ div(
149
+ class: "transition-all duration-300 ease-in-out overflow-hidden",
150
+ data: { collapsible_filters_target: "content" }
151
+ ) do
152
+ div(class: "p-4") do
153
+ # Permissions grid with old card style (2 per row)
154
+ div(class: "grid grid-cols-1 md:grid-cols-2 gap-3") do
155
+ %w[read create update delete].each do |action|
156
+ permission_name = "#{resource}:#{action}"
157
+ is_granted = permission_granted?(permission_name)
158
+
159
+ render_permission_toggle_card(permission_name, action, is_granted)
160
+ end
161
+ end
135
162
  end
136
163
  end
137
164
  end
@@ -4,12 +4,15 @@ import { Controller } from "@hotwired/stimulus"
4
4
  export default class extends Controller {
5
5
  static targets = ["content", "icon"]
6
6
  static values = {
7
- expanded: { type: Boolean, default: true }
7
+ expanded: { type: Boolean, default: true },
8
+ persistState: { type: Boolean, default: true }
8
9
  }
9
10
 
10
11
  connect() {
11
- // Load saved state
12
- this.loadState()
12
+ // Load saved state only if persistence is enabled
13
+ if (this.persistStateValue) {
14
+ this.loadState()
15
+ }
13
16
 
14
17
  // Set initial state
15
18
  if (this.expandedValue) {
@@ -50,8 +53,10 @@ export default class extends Controller {
50
53
  // Update icon rotation
51
54
  this.updateIconRotation()
52
55
 
53
- // Save state
54
- this.saveState(true)
56
+ // Save state only if persistence is enabled
57
+ if (this.persistStateValue) {
58
+ this.saveState(true)
59
+ }
55
60
  }
56
61
 
57
62
  collapse(animate = true) {
@@ -78,8 +83,10 @@ export default class extends Controller {
78
83
  // Update icon rotation
79
84
  this.updateIconRotation()
80
85
 
81
- // Save state
82
- this.saveState(false)
86
+ // Save state only if persistence is enabled
87
+ if (this.persistStateValue) {
88
+ this.saveState(false)
89
+ }
83
90
  }
84
91
 
85
92
  saveState(expanded) {
@@ -7,31 +7,7 @@ export default class extends Controller {
7
7
  }
8
8
 
9
9
  connect() {
10
- console.log("🎯 PermissionToggleController connected")
11
- console.log("🎯 User ID:", this.userIdValue)
12
-
13
- // Debug: Log all permission cards found
14
- const cards = this.permissionCardTargets
15
- console.log("🎯 Found", cards.length, "permission cards")
16
-
17
- cards.forEach((card, index) => {
18
- console.log(`🎯 Card ${index}:`, {
19
- permission: card.dataset.permissionName,
20
- granted: card.dataset.granted,
21
- resourceType: card.dataset.resourceType
22
- })
23
- })
24
-
25
- // Debug: Log all hidden inputs found
26
10
  const hiddenInputs = this.element.querySelectorAll('input[type="hidden"][data-permission-toggle-target="hiddenInput"]')
27
- console.log("🎯 Found", hiddenInputs.length, "hidden inputs")
28
-
29
- hiddenInputs.forEach((input, index) => {
30
- console.log(`🎯 Hidden input ${index}:`, {
31
- name: input.name,
32
- value: input.value
33
- })
34
- })
35
11
  }
36
12
 
37
13
  togglePermission(event) {
@@ -42,16 +18,8 @@ export default class extends Controller {
42
18
  const currentlyGranted = card.dataset.granted === "true"
43
19
  const newGrantedState = !currentlyGranted
44
20
 
45
- console.log("🎯 Toggling permission:", {
46
- permission: permissionName,
47
- wasGranted: currentlyGranted,
48
- nowGranted: newGrantedState
49
- })
50
-
51
- // Update the card UI immediately
52
21
  this.updateCardUI(card, newGrantedState)
53
-
54
- // Update the hidden input field for form submission
22
+
55
23
  this.updateHiddenInput(card, newGrantedState)
56
24
 
57
25
  // Show notification for feedback
@@ -63,6 +31,7 @@ export default class extends Controller {
63
31
 
64
32
  toggleAllForResource(event) {
65
33
  event.preventDefault()
34
+ event.stopPropagation() // Prevent triggering parent collapsible toggle
66
35
 
67
36
  const resourceType = event.currentTarget.dataset.resourceType
68
37
  const resourceCards = this.permissionCardTargets.filter(card =>
@@ -1,3 +1,3 @@
1
1
  module EasyAdmin
2
- VERSION = "0.2.3"
2
+ VERSION = "0.2.5"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: easy-admin-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.3
4
+ version: 0.2.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Slaurmagan
@@ -455,12 +455,12 @@ files:
455
455
  - lib/generators/easy_admin/templates/easy_admin.rb
456
456
  - lib/generators/easy_admin/templates/resource.rb
457
457
  - lib/tasks/easy_admin_tasks.rake
458
- homepage: https://github.com/yourusername/easy_admin
458
+ homepage: https://github.com/Slaurmagan/easy-admin
459
459
  licenses:
460
460
  - MIT
461
461
  metadata:
462
462
  allowed_push_host: https://rubygems.org
463
- homepage_uri: https://github.com/yourusername/easy_admin
463
+ homepage_uri: https://github.com/Slaurmagan/easy-admin
464
464
  source_code_uri: https://github.com/Slaurmagan/easy-admin
465
465
  changelog_uri: https://github.com/Slaurmagan/easy-admin/blob/main/CHANGELOG.md
466
466
  post_install_message: