Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 0567d9817f |
+3
-3
@@ -4,9 +4,9 @@
|
|||||||
|
|
||||||
### Bug Fixes
|
### Bug Fixes
|
||||||
|
|
||||||
- **Fixed previously added set being re-added when adding an individual minifigure** (Issue #150, branch `bugfix/issue-150`): After adding a set, entering a `fig-` ID and confirming would add the previous set again instead of the minifigure, if user did not reload inbetween.
|
- **Fixed "Reset to Defaults" blanking all settings instead of restoring them** (Issue #149a, branch `bugfix/issue-149a`): "Reset to Defaults" was clearing all fields to empty/false instead of populating them with their actual default values
|
||||||
- `add.js` was creating a second `BrickMinifigureSocket` with its own listeners on the same button and input as `BrickSetSocket`, causing duplicate socket events and cross-socket state confusion
|
- `resetToDefaults()` now reads from `window.DEFAULT_CONFIG` and restores each field to its proper default, matching the same logic used on initial page load
|
||||||
- **Fixed deleting a wish with an owner assigned** (Issue #152): Resolved foreign key constraint error when removing a set from the wishlist that had an owner assigned
|
- **Fixed deleting a wish with an owner assigned** (Issue #152, branch `bugfix/issue-152`): Resolved foreign key constraint error when removing a set from the wishlist that had an owner assigned
|
||||||
- Wish owners are now deleted before the wish itself, respecting the FK constraint
|
- Wish owners are now deleted before the wish itself, respecting the FK constraint
|
||||||
|
|
||||||
## 1.4
|
## 1.4
|
||||||
|
|||||||
+64
-6
@@ -1,6 +1,6 @@
|
|||||||
// Add page - handles both sets and individual minifigures
|
// Add page - handles both sets and individual minifigures
|
||||||
// Server auto-routes fig- numbers to IndividualMinifigure via LOAD_SET / IMPORT_SET
|
|
||||||
document.addEventListener("DOMContentLoaded", () => {
|
document.addEventListener("DOMContentLoaded", () => {
|
||||||
|
// Initialize date pickers
|
||||||
document.querySelectorAll('[data-add-date="true"]').forEach(el => {
|
document.querySelectorAll('[data-add-date="true"]').forEach(el => {
|
||||||
new Datepicker(el, {
|
new Datepicker(el, {
|
||||||
buttonClass: 'btn',
|
buttonClass: 'btn',
|
||||||
@@ -8,23 +8,81 @@ document.addEventListener("DOMContentLoaded", () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Get template data from data attributes
|
||||||
const addContainer = document.getElementById('add-set');
|
const addContainer = document.getElementById('add-set');
|
||||||
if (!addContainer) return;
|
if (!addContainer) return;
|
||||||
|
|
||||||
new BrickSetSocket(
|
// Read data from data attributes
|
||||||
'add',
|
const templateData = {
|
||||||
addContainer.dataset.path,
|
path: addContainer.dataset.path,
|
||||||
addContainer.dataset.namespace,
|
namespace: addContainer.dataset.namespace,
|
||||||
{
|
messages: {
|
||||||
COMPLETE: addContainer.dataset.msgComplete,
|
COMPLETE: addContainer.dataset.msgComplete,
|
||||||
FAIL: addContainer.dataset.msgFail,
|
FAIL: addContainer.dataset.msgFail,
|
||||||
IMPORT_SET: addContainer.dataset.msgImportSet,
|
IMPORT_SET: addContainer.dataset.msgImportSet,
|
||||||
LOAD_SET: addContainer.dataset.msgLoadSet,
|
LOAD_SET: addContainer.dataset.msgLoadSet,
|
||||||
PROGRESS: addContainer.dataset.msgProgress,
|
PROGRESS: addContainer.dataset.msgProgress,
|
||||||
SET_LOADED: addContainer.dataset.msgSetLoaded,
|
SET_LOADED: addContainer.dataset.msgSetLoaded,
|
||||||
|
IMPORT_MINIFIGURE: addContainer.dataset.msgImportMinifigure,
|
||||||
|
LOAD_MINIFIGURE: addContainer.dataset.msgLoadMinifigure,
|
||||||
MINIFIGURE_LOADED: addContainer.dataset.msgMinifigureLoaded,
|
MINIFIGURE_LOADED: addContainer.dataset.msgMinifigureLoaded,
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// Default: create set socket
|
||||||
|
const setSocket = new BrickSetSocket(
|
||||||
|
'add',
|
||||||
|
templateData.path,
|
||||||
|
templateData.namespace,
|
||||||
|
{
|
||||||
|
COMPLETE: templateData.messages.COMPLETE,
|
||||||
|
FAIL: templateData.messages.FAIL,
|
||||||
|
IMPORT_SET: templateData.messages.IMPORT_SET,
|
||||||
|
LOAD_SET: templateData.messages.LOAD_SET,
|
||||||
|
PROGRESS: templateData.messages.PROGRESS,
|
||||||
|
SET_LOADED: templateData.messages.SET_LOADED,
|
||||||
},
|
},
|
||||||
false,
|
false,
|
||||||
false
|
false
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// Override the execute method to check for minifigures
|
||||||
|
const originalExecute = setSocket.execute.bind(setSocket);
|
||||||
|
let minifigSocket = null;
|
||||||
|
|
||||||
|
setSocket.execute = function() {
|
||||||
|
const inputValue = document.getElementById('add-set').value.trim();
|
||||||
|
|
||||||
|
if (inputValue.startsWith('fig-') || inputValue.match(/^fig\d/i)) {
|
||||||
|
// It's a minifigure - create minifig socket if needed and execute when ready
|
||||||
|
if (!minifigSocket) {
|
||||||
|
minifigSocket = new BrickMinifigureSocket(
|
||||||
|
'add',
|
||||||
|
templateData.path,
|
||||||
|
templateData.namespace,
|
||||||
|
{
|
||||||
|
COMPLETE: templateData.messages.COMPLETE,
|
||||||
|
FAIL: templateData.messages.FAIL,
|
||||||
|
IMPORT_MINIFIGURE: templateData.messages.IMPORT_MINIFIGURE,
|
||||||
|
LOAD_MINIFIGURE: templateData.messages.LOAD_MINIFIGURE,
|
||||||
|
MINIFIGURE_LOADED: templateData.messages.MINIFIGURE_LOADED,
|
||||||
|
PROGRESS: templateData.messages.PROGRESS,
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
// Wait for socket to connect before executing
|
||||||
|
const checkConnection = setInterval(() => {
|
||||||
|
if (minifigSocket.socket && minifigSocket.socket.connected) {
|
||||||
|
clearInterval(checkConnection);
|
||||||
|
minifigSocket.execute();
|
||||||
|
}
|
||||||
|
}, 100);
|
||||||
|
} else {
|
||||||
|
minifigSocket.execute();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// It's a set - use original execute
|
||||||
|
originalExecute();
|
||||||
|
}
|
||||||
|
};
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -285,18 +285,21 @@ function saveLiveConfiguration() {
|
|||||||
function resetToDefaults() {
|
function resetToDefaults() {
|
||||||
console.log('Resetting to defaults');
|
console.log('Resetting to defaults');
|
||||||
|
|
||||||
// Reset all form inputs
|
Object.keys(window.DEFAULT_CONFIG).forEach(varName => {
|
||||||
document.querySelectorAll('.config-toggle, .config-number, .config-text').forEach(input => {
|
const defaultValue = window.DEFAULT_CONFIG[varName];
|
||||||
if (input.type === 'checkbox') {
|
|
||||||
input.checked = false;
|
|
||||||
} else {
|
|
||||||
input.value = '';
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// Update badges
|
const toggle = document.getElementById(varName);
|
||||||
Object.keys(window.CURRENT_CONFIG).forEach(varName => {
|
if (toggle && toggle.type === 'checkbox') {
|
||||||
updateConfigBadge(varName, null);
|
toggle.checked = defaultValue === true;
|
||||||
|
}
|
||||||
|
|
||||||
|
document.querySelectorAll(`input[data-var="${varName}"]:not(.config-static)`).forEach(input => {
|
||||||
|
if (input.type !== 'checkbox') {
|
||||||
|
input.value = defaultValue !== null && defaultValue !== undefined ? defaultValue : '';
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
updateConfigBadge(varName, defaultValue);
|
||||||
});
|
});
|
||||||
|
|
||||||
// Show status message
|
// Show status message
|
||||||
|
|||||||
Reference in New Issue
Block a user