Compare commits
2
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
665441c5ac | ||
|
|
d751a3d0af |
+2
-3
@@ -4,9 +4,8 @@
|
|||||||
|
|
||||||
### Bug Fixes
|
### Bug Fixes
|
||||||
|
|
||||||
- **Fixed purchase date, price, and notes not being saved when adding an individual minifigure** (Issue #151, branch `bugfix/issue-151`): Filling in purchase date, price, or notes before clicking Add had no effect, only purchase location was saved
|
- **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.
|
||||||
- `BrickMinifigureSocket` was missing references to `#add-purchase-date`, `#add-purchase-price`, and `#add-description`, so those fields were never read or included in the socket emit
|
- `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
|
||||||
- The backend already supported all three fields. This was just a frontend error
|
|
||||||
- **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): 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
|
||||||
|
|
||||||
|
|||||||
+6
-64
@@ -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,81 +8,23 @@ 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;
|
||||||
|
|
||||||
// Read data from data attributes
|
new BrickSetSocket(
|
||||||
const templateData = {
|
'add',
|
||||||
path: addContainer.dataset.path,
|
addContainer.dataset.path,
|
||||||
namespace: addContainer.dataset.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();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -13,12 +13,9 @@ class BrickMinifigureSocket extends BrickSocket {
|
|||||||
this.html_input = document.getElementById(`${id}-set`);
|
this.html_input = document.getElementById(`${id}-set`);
|
||||||
this.html_no_confim = document.getElementById(`${id}-no-confirm`);
|
this.html_no_confim = document.getElementById(`${id}-no-confirm`);
|
||||||
this.html_owners = document.getElementById(`${id}-owners`);
|
this.html_owners = document.getElementById(`${id}-owners`);
|
||||||
this.html_purchase_date = document.getElementById(`${id}-purchase-date`);
|
|
||||||
this.html_purchase_price = document.getElementById(`${id}-purchase-price`);
|
|
||||||
this.html_purchase_location = document.getElementById(`${id}-purchase-location`);
|
this.html_purchase_location = document.getElementById(`${id}-purchase-location`);
|
||||||
this.html_storage = document.getElementById(`${id}-storage`);
|
this.html_storage = document.getElementById(`${id}-storage`);
|
||||||
this.html_tags = document.getElementById(`${id}-tags`);
|
this.html_tags = document.getElementById(`${id}-tags`);
|
||||||
this.html_description = document.getElementById(`${id}-description`);
|
|
||||||
|
|
||||||
// Card elements
|
// Card elements
|
||||||
this.html_card = document.getElementById(`${id}-card`);
|
this.html_card = document.getElementById(`${id}-card`);
|
||||||
@@ -101,28 +98,12 @@ class BrickMinifigureSocket extends BrickSocket {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// Grab the purchase info
|
// Grab the purchase location
|
||||||
let purchase_date = null;
|
|
||||||
if (this.html_purchase_date) {
|
|
||||||
purchase_date = this.html_purchase_date.value || null;
|
|
||||||
}
|
|
||||||
|
|
||||||
let purchase_price = null;
|
|
||||||
if (this.html_purchase_price) {
|
|
||||||
purchase_price = this.html_purchase_price.value || null;
|
|
||||||
}
|
|
||||||
|
|
||||||
let purchase_location = null;
|
let purchase_location = null;
|
||||||
if (this.html_purchase_location) {
|
if (this.html_purchase_location) {
|
||||||
purchase_location = this.html_purchase_location.value;
|
purchase_location = this.html_purchase_location.value;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Grab the description (notes)
|
|
||||||
let description = '';
|
|
||||||
if (this.html_description) {
|
|
||||||
description = this.html_description.value || '';
|
|
||||||
}
|
|
||||||
|
|
||||||
// Grab the storage
|
// Grab the storage
|
||||||
let storage = null;
|
let storage = null;
|
||||||
if (this.html_storage) {
|
if (this.html_storage) {
|
||||||
@@ -148,12 +129,9 @@ class BrickMinifigureSocket extends BrickSocket {
|
|||||||
this.socket.emit(this.messages.IMPORT_MINIFIGURE, {
|
this.socket.emit(this.messages.IMPORT_MINIFIGURE, {
|
||||||
figure: (figure !== undefined) ? figure : this.html_input.value,
|
figure: (figure !== undefined) ? figure : this.html_input.value,
|
||||||
owners: owners,
|
owners: owners,
|
||||||
purchase_date: purchase_date,
|
|
||||||
purchase_price: purchase_price,
|
|
||||||
purchase_location: purchase_location,
|
purchase_location: purchase_location,
|
||||||
storage: storage,
|
storage: storage,
|
||||||
tags: tags,
|
tags: tags,
|
||||||
description: description,
|
|
||||||
quantity: 1
|
quantity: 1
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
@@ -257,22 +235,10 @@ class BrickMinifigureSocket extends BrickSocket {
|
|||||||
this.html_owners.querySelectorAll('input').forEach(input => input.disabled = !enabled);
|
this.html_owners.querySelectorAll('input').forEach(input => input.disabled = !enabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.html_purchase_date) {
|
|
||||||
this.html_purchase_date.disabled = !enabled;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.html_purchase_price) {
|
|
||||||
this.html_purchase_price.disabled = !enabled;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.html_purchase_location) {
|
if (this.html_purchase_location) {
|
||||||
this.html_purchase_location.disabled = !enabled;
|
this.html_purchase_location.disabled = !enabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.html_description) {
|
|
||||||
this.html_description.disabled = !enabled;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.html_storage) {
|
if (this.html_storage) {
|
||||||
this.html_storage.disabled = !enabled;
|
this.html_storage.disabled = !enabled;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user