diff --git a/ayanova/devdocs/todo.txt b/ayanova/devdocs/todo.txt index 89e9c71a..199160f9 100644 --- a/ayanova/devdocs/todo.txt +++ b/ayanova/devdocs/todo.txt @@ -25,6 +25,45 @@ todo: deleting HeadOffice does it delete all contacts too? todo: seeded user names look stupid with the numbers in them, change that so unique is done but without that nonsense +todo: How to handle delete of customer with records?? + Completely seperate process "purge" or extension or something? + mass delete extension maybe, can pick items to delete, i.e. "Delete all workorders for this Customer" + +todo: delete error with connected records should display a really clear error at the client, right now it just says server internal error and this is at the server: +2020-12-03 14:57:04.6421|ERROR|SERVER|Error=>Microsoft.EntityFrameworkCore.DbUpdateException: An error occurred while updating the entries. See the inner exception for details. + ---> Npgsql.PostgresException (0x80004005): 23503: update or delete on table "acustomer" violates foreign key constraint "auser_customerid_fkey" on table "auser" + at Npgsql.NpgsqlConnector.g__ReadMessageLong|194_0(NpgsqlConnector connector, Boolean async, DataRowLoadingMode dataRowLoadingMode, Boolean readingNotifications, Boolean isReadingPrependedMessage) + at Npgsql.NpgsqlDataReader.NextResult(Boolean async, Boolean isConsuming, CancellationToken cancellationToken) + at Npgsql.NpgsqlCommand.ExecuteReader(CommandBehavior behavior, Boolean async, CancellationToken cancellationToken) + at Npgsql.NpgsqlCommand.ExecuteReader(CommandBehavior behavior, Boolean async, CancellationToken cancellationToken) + at Npgsql.NpgsqlCommand.ExecuteDbDataReaderAsync(CommandBehavior behavior, CancellationToken cancellationToken) + at Microsoft.EntityFrameworkCore.Storage.RelationalCommand.ExecuteReaderAsync(RelationalCommandParameterObject parameterObject, CancellationToken cancellationToken) + at Microsoft.EntityFrameworkCore.Storage.RelationalCommand.ExecuteReaderAsync(RelationalCommandParameterObject parameterObject, CancellationToken cancellationToken) + at Microsoft.EntityFrameworkCore.Update.ReaderModificationCommandBatch.ExecuteAsync(IRelationalConnection connection, CancellationToken cancellationToken) + Exception data: + Severity: ERROR + SqlState: 23503 + MessageText: update or delete on table "acustomer" violates foreign key constraint "auser_customerid_fkey" on table "auser" + Detail: Detail redacted as it may contain sensitive data. Specify 'Include Error Detail' in the connection string to include this information. + SchemaName: public + TableName: auser + ConstraintName: auser_customerid_fkey + File: d:\pginstaller_13.auto\postgres.windows-x64\src\backend\utils\adt\ri_triggers.c + Line: 2493 + Routine: ri_ReportViolation + --- End of inner exception stack trace --- + at Microsoft.EntityFrameworkCore.Update.ReaderModificationCommandBatch.ExecuteAsync(IRelationalConnection connection, CancellationToken cancellationToken) + at Microsoft.EntityFrameworkCore.Update.Internal.BatchExecutor.ExecuteAsync(IEnumerable`1 commandBatches, IRelationalConnection connection, CancellationToken cancellationToken) + at Microsoft.EntityFrameworkCore.Update.Internal.BatchExecutor.ExecuteAsync(IEnumerable`1 commandBatches, IRelationalConnection connection, CancellationToken cancellationToken) + at Microsoft.EntityFrameworkCore.Update.Internal.BatchExecutor.ExecuteAsync(IEnumerable`1 commandBatches, IRelationalConnection connection, CancellationToken cancellationToken) + at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.StateManager.SaveChangesAsync(IList`1 entriesToSave, CancellationToken cancellationToken) + at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.StateManager.SaveChangesAsync(DbContext _, Boolean acceptAllChangesOnSuccess, CancellationToken cancellationToken) + at Npgsql.EntityFrameworkCore.PostgreSQL.Storage.Internal.NpgsqlExecutionStrategy.ExecuteAsync[TState,TResult](TState state, Func`4 operation, Func`4 verifySucceeded, CancellationToken cancellationToken) + at Microsoft.EntityFrameworkCore.DbContext.SaveChangesAsync(Boolean acceptAllChangesOnSuccess, CancellationToken cancellationToken) + at Microsoft.EntityFrameworkCore.DbContext.SaveChangesAsync(Boolean acceptAllChangesOnSuccess, CancellationToken cancellationToken) + at AyaNova.Biz.CustomerBiz.DeleteAsync(Int64 id) in C:\data\code\raven\server\AyaNova\biz\CustomerBiz.cs:line 160 + at AyaNova.Api.Controllers.CustomerController.DeleteCustomer(Int64 id) in C:\data\code\raven\server\AyaNova\Controllers\CustomerController.cs:line 146 + ............................................................ diff --git a/ayanova/src/api/gzform.js b/ayanova/src/api/gzform.js index 510fcd12..29136a2e 100644 --- a/ayanova/src/api/gzform.js +++ b/ayanova/src/api/gzform.js @@ -86,26 +86,10 @@ function getControlLabel(ctrl) { function getErrorsForField(vm, ref) { let ret = []; if (ref == "errorbox") { - //de-lodash - // ret = window.$gz. _.filter(vm.formState.serverError.details, function(o) { - // return !o.target; - // }); - - ret = vm.formState.serverError.details.filter(z => z.target == false); + ret = vm.formState.serverError.details.filter( + z => z.target == false || z.target == "errorbox" + ); } else { - //de-lodash - // ret = window.$gz. _.filter(vm.formState.serverError.details, function(o) { - // if (!o.target) { - // return false; - // } - // //server error fields are capitalized - // //client field names are generally lower case except for custom fields - // //so we need to normalize them all to lower case to match - // //they will always differ by more than case so this is fine - - // return o.target.toLowerCase() == ref.toLowerCase(); - // }); - ret = vm.formState.serverError.details.filter(function(o) { if (!o.target) { return false; @@ -652,11 +636,13 @@ export default { API_CLOSED = 2000, API_OPS_ONLY = 2001, API_SERVER_ERROR = 2002, + VALIDATION_REFERENTIAL_INTEGRITY = 2208 */ switch (apiErrorCode) { case 2000: case 2001: case 2002: + case 2208: formValid = true; //we came here because the user saved because the form was valid so it's safe to set that the same again break; default: