Fixing #10155 - some options errors were being swallowed and in general it was never considered to be an error state due to the 'handled' flag being consistently sent, changed the logic a bit here.
This commit is contained in:
parent
b1325e4742
commit
373952a59b
|
@ -42,7 +42,7 @@
|
|||
</script>
|
||||
|
||||
{#if type === "options" && meta.constraints.inclusion.length !== 0}
|
||||
<Select {label} bind:value options={meta.constraints.inclusion} sort />
|
||||
<Select {label} bind:value options={meta.constraints.inclusion} sort {error} />
|
||||
{:else if type === "datetime"}
|
||||
<DatePicker
|
||||
{error}
|
||||
|
|
|
@ -27,11 +27,12 @@
|
|||
notifications.success("Row saved successfully")
|
||||
dispatch("updaterows")
|
||||
} catch (error) {
|
||||
if (error.handled) {
|
||||
const response = error.json
|
||||
if (response?.errors) {
|
||||
if (error.handled && response?.errors) {
|
||||
console.error("FIRST")
|
||||
errors = response.errors
|
||||
} else if (response?.validationErrors) {
|
||||
} else if (error.handled && response?.validationErrors) {
|
||||
console.error(response.validationErrors)
|
||||
const mappedErrors = {}
|
||||
for (let field in response.validationErrors) {
|
||||
mappedErrors[
|
||||
|
@ -39,9 +40,9 @@
|
|||
] = `${field} ${response.validationErrors[field][0]}`
|
||||
}
|
||||
errors = mappedErrors
|
||||
}
|
||||
console.log(errors)
|
||||
} else {
|
||||
notifications.error("Failed to save row")
|
||||
notifications.error(`Failed to save row - ${error.message}`)
|
||||
}
|
||||
// Prevent modal closing if there were errors
|
||||
return false
|
||||
|
|
|
@ -7,6 +7,7 @@ CREATE TABLE Persons (
|
|||
LastName varchar(255),
|
||||
FirstName varchar(255),
|
||||
Address varchar(255),
|
||||
Age INT NOT NULL,
|
||||
City varchar(255) DEFAULT 'Belfast',
|
||||
Type person_job
|
||||
);
|
||||
|
@ -42,8 +43,8 @@ CREATE TABLE test.table1 (
|
|||
id SERIAL PRIMARY KEY,
|
||||
Name varchar(255)
|
||||
);
|
||||
INSERT INTO Persons (FirstName, LastName, Address, City, Type) VALUES ('Mike', 'Hughes', '123 Fake Street', 'Belfast', 'qa');
|
||||
INSERT INTO Persons (FirstName, LastName, Address, City, Type) VALUES ('John', 'Smith', '64 Updown Road', 'Dublin', 'programmer');
|
||||
INSERT INTO Persons (FirstName, LastName, Address, City, Type, Age) VALUES ('Mike', 'Hughes', '123 Fake Street', 'Belfast', 'qa', 20);
|
||||
INSERT INTO Persons (FirstName, LastName, Address, City, Type, Age) VALUES ('John', 'Smith', '64 Updown Road', 'Dublin', 'programmer', 30);
|
||||
INSERT INTO Tasks (ExecutorID, QaID, TaskName, Completed) VALUES (1, 2, 'assembling', TRUE);
|
||||
INSERT INTO Tasks (ExecutorID, QaID, TaskName, Completed) VALUES (2, 1, 'processing', FALSE);
|
||||
INSERT INTO Products (ProductName) VALUES ('Computers');
|
||||
|
|
Loading…
Reference in New Issue