Skip to content

Commit

Permalink
## 14.34.0 - 2024-09-04
Browse files Browse the repository at this point in the history
  • Loading branch information
tabuna committed Sep 4, 2024
1 parent 35efd7a commit 3ccd82f
Show file tree
Hide file tree
Showing 8 changed files with 50 additions and 7 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

## 14.34.0 - 2024-09-04

### Changed
- Adding state to the form when Turbo is disabled

## 14.33.1 - 2024-09-04

### Fixed
Expand Down
2 changes: 1 addition & 1 deletion public/css/orchid.rtl.css.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion public/js/orchid.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion public/js/orchid.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion public/js/vendor.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion public/mix-manifest.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

40 changes: 39 additions & 1 deletion resources/js/controllers/form_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,10 @@ export default class extends ApplicationController {
* @returns {boolean}
*/
submit(event) {
// disable
// When Turbo disable
if (this.getActiveElementAttr('data-turbo') === 'false') {
this.addReserveState(event.target);

return true;
}

Expand Down Expand Up @@ -215,4 +217,40 @@ export default class extends ApplicationController {
}
}
}

/**
* Adds or updates a hidden input field with name="_state" and id="reserve_state" in the form.
* Used in case Turbo is disabled.
* @param {HTMLFormElement} form - The form to which the field is added
*/
addReserveState(form) {
// Get the state value
const stateValue = this.getState();

// Find the input element with id 'reserve_state'
const existingInput = form.querySelector('#reserve_state');

// If the element already exists, update its value
if (existingInput) {
existingInput.value = stateValue;
return;
}

// If the element does not exist, create a new one
const newInput = document.createElement('input');

// Set its attributes
newInput.type = 'hidden';
newInput.id = 'reserve_state';
newInput.name = '_state';
newInput.value = stateValue;

// Add the new element to the form
form.appendChild(newInput);
}

// Implement this method to return the state value
getState() {
return document.getElementById('screen-state')?.value || '';
}
}
2 changes: 1 addition & 1 deletion src/Platform/Dashboard.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class Dashboard
*
* @deprecated Use `Dashboard::version()` instead.
*/
public const VERSION = '14.33.1';
public const VERSION = '14.34.0';

/**
* @deprecated
Expand Down

0 comments on commit 3ccd82f

Please sign in to comment.