rails_modal_manager 1.0.14 → 1.0.16
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/javascript/rails_modal_manager/controllers/rmm_modal_controller.js +35 -0
- data/app/javascript/rails_modal_manager/controllers/rmm_sidebar_controller.js +24 -0
- data/app/javascript/rails_modal_manager/controllers/rmm_submenu_controller.js +28 -0
- data/lib/rails_modal_manager/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 9ddfd329fb8f4ef8eff88d5d5d3284dcf02c9739d153252c0647e118433bb446
|
|
4
|
+
data.tar.gz: 37ae27aab69556b2d49037873677753002898892fad7ec3aec7671b1d08a25fa
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 2871ebeb6b3dc8ff22beef165fb488b0c4acd8cb674faa8167c6b41d464cbd121ddb2ab17b811e28faf893a10b19f34a918139369eb4ab88f5346931bcb41c94
|
|
7
|
+
data.tar.gz: 10008b13adf85eea1729b346e228059ada4a849958dc08ea8f04c787f4cd4d930bcf938e5323fdc57ae55d5f9e2795bd5ed98436b5c267d89b7280ce24423db9
|
|
@@ -345,6 +345,9 @@ export default class extends Controller {
|
|
|
345
345
|
const modal = this.element
|
|
346
346
|
const overlay = this.getOverlay()
|
|
347
347
|
|
|
348
|
+
// Reset sidebar and submenu to first item before hiding
|
|
349
|
+
this.resetSidebarAndSubmenu()
|
|
350
|
+
|
|
348
351
|
modal.classList.remove('rmm-active')
|
|
349
352
|
if (overlay) overlay.classList.remove('rmm-active')
|
|
350
353
|
|
|
@@ -359,6 +362,38 @@ export default class extends Controller {
|
|
|
359
362
|
}, this.animationDurationValue)
|
|
360
363
|
}
|
|
361
364
|
|
|
365
|
+
/**
|
|
366
|
+
* Reset sidebar and submenu controllers to first item
|
|
367
|
+
* Called when modal is closed to ensure clean state on next open
|
|
368
|
+
*/
|
|
369
|
+
resetSidebarAndSubmenu() {
|
|
370
|
+
const modal = this.element
|
|
371
|
+
|
|
372
|
+
// Reset sidebar controller
|
|
373
|
+
const sidebarElement = modal.querySelector('[data-controller*="rmm-sidebar"]')
|
|
374
|
+
if (sidebarElement) {
|
|
375
|
+
const sidebarController = this.application.getControllerForElementAndIdentifier(
|
|
376
|
+
sidebarElement,
|
|
377
|
+
'rmm-sidebar'
|
|
378
|
+
)
|
|
379
|
+
if (sidebarController && typeof sidebarController.resetToFirst === 'function') {
|
|
380
|
+
sidebarController.resetToFirst()
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
// Reset all submenu controllers
|
|
385
|
+
const submenuElements = modal.querySelectorAll('[data-controller*="rmm-submenu"]')
|
|
386
|
+
submenuElements.forEach(submenuElement => {
|
|
387
|
+
const submenuController = this.application.getControllerForElementAndIdentifier(
|
|
388
|
+
submenuElement,
|
|
389
|
+
'rmm-submenu'
|
|
390
|
+
)
|
|
391
|
+
if (submenuController && typeof submenuController.resetToFirst === 'function') {
|
|
392
|
+
submenuController.resetToFirst()
|
|
393
|
+
}
|
|
394
|
+
})
|
|
395
|
+
}
|
|
396
|
+
|
|
362
397
|
// ============================================
|
|
363
398
|
// Styles
|
|
364
399
|
// ============================================
|
|
@@ -201,4 +201,28 @@ export default class extends Controller {
|
|
|
201
201
|
this.collapsedValue = true
|
|
202
202
|
this.element.classList.add('rmm-sidebar-collapsed')
|
|
203
203
|
}
|
|
204
|
+
|
|
205
|
+
/**
|
|
206
|
+
* Reset sidebar to first item
|
|
207
|
+
* Called by modal controller when modal is closed
|
|
208
|
+
*/
|
|
209
|
+
resetToFirst() {
|
|
210
|
+
const firstItem = this.element.querySelector('.rmm-sidebar-item')
|
|
211
|
+
if (!firstItem) return
|
|
212
|
+
|
|
213
|
+
// Remove active from all items
|
|
214
|
+
this.element.querySelectorAll('.rmm-sidebar-item').forEach(el => {
|
|
215
|
+
el.classList.remove('rmm-active')
|
|
216
|
+
})
|
|
217
|
+
|
|
218
|
+
// Add active to first item
|
|
219
|
+
firstItem.classList.add('rmm-active')
|
|
220
|
+
this.currentItemId = firstItem.dataset.itemId
|
|
221
|
+
|
|
222
|
+
// Switch content panel
|
|
223
|
+
this.switchPanel(firstItem)
|
|
224
|
+
|
|
225
|
+
// Switch submenu group
|
|
226
|
+
this.switchSubmenuGroup(firstItem)
|
|
227
|
+
}
|
|
204
228
|
}
|
|
@@ -228,4 +228,32 @@ export default class extends Controller {
|
|
|
228
228
|
}
|
|
229
229
|
}
|
|
230
230
|
}
|
|
231
|
+
|
|
232
|
+
/**
|
|
233
|
+
* Reset submenu to first item
|
|
234
|
+
* Called by modal controller when modal is closed
|
|
235
|
+
*/
|
|
236
|
+
resetToFirst() {
|
|
237
|
+
const firstItem = this.element.querySelector('.rmm-submenu-item')
|
|
238
|
+
if (!firstItem) return
|
|
239
|
+
|
|
240
|
+
// Remove active from all items
|
|
241
|
+
this.element.querySelectorAll('.rmm-submenu-item').forEach(el => {
|
|
242
|
+
el.classList.remove('rmm-active')
|
|
243
|
+
})
|
|
244
|
+
|
|
245
|
+
// Add active to first item
|
|
246
|
+
firstItem.classList.add('rmm-active')
|
|
247
|
+
this.currentItemId = firstItem.dataset.itemId
|
|
248
|
+
|
|
249
|
+
// Switch panel
|
|
250
|
+
if (this.loadModeValue === 'ajax') {
|
|
251
|
+
this.loadAjaxContent(firstItem)
|
|
252
|
+
} else {
|
|
253
|
+
this.switchPanel(firstItem)
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
// Clear AJAX cache
|
|
257
|
+
this.ajaxCache.clear()
|
|
258
|
+
}
|
|
231
259
|
}
|