SpringBot Release 2.4.1.0

Noteworthy changes

  • Added the option to create and edit multiple entities within a single CRUD edit component.
    • This feature can be enabled for any entity relation in any CRUD edit page, and can be used to add a new related entity, or to modify an existing related entity.

    • See the documentation for the Multi-Entity CRUD feature for details.

Improvements

  • Wrapped the filterQuestions attribute declaration in list.component.ts with a single protected region to provide full control (as suggested in the forum).
  • The CORS filter used for development purposes has been replaced with the default applyPermitDefaultValues() option that is supplied by Spring Security.
    • This change was made to simplify CORS handling in development and testing as it was unnecessarily complicated (as noted in this support request).
    • Details on how this works are available in the original forum post.
  • Made improvements to the flexibility of the read and request auditing functionality.
    • Result of a forum-logged feature request.
    • RequestLoggingFilter has been enclosed in a protected region to allow for it to be disabled.
    • A new security.read-audit-enabled configuration property has been added which allows for the ability to globally disable response audit logging.
    • A new protected region has been added to the EntityListener to allow for the manual control over response auditing per entity.
  • Replaced dictionary for modelRelations with an array.
    • This was done to make it possible to add additional entities to a CRUD edit page.
    • Keeping the dictionary meant that the ID’s of relations could potentially clash, so this would impact the functionality.
  • Updated prepareReferenceCollections in CRUD edit pages to use a forEach method to perform the necessary logic to create collections for model relations.
    • The previous implementation did this separately for every relation of an entity, so this change will significantly reduce the length of CRUD edit page files for entities which have a lot of relations.
    • This change also ensures that any additional relations you have added to the relations list will be handled by this method without any additional custom code!
  • Added validation for the unique constraint to allow for better responses from the server when uniqueness is violated
  • Forms reference names are now unique and based on the form entity.

Bug fixes

  • Fixed an issue with CSV export tests and the UUID attribute type.
    • Attributes with the data type UUID caused tested errors, this has now been resolved.
  • Fixed the issue that prevented multiple constraint violation errors from showing if they exist.

Migration path

  • The protected region called Modify the existing config for the dropdown filter question for enum ref [Enum ref name] to [Enum] here has been expanded to encompass the entire filter config for the enum dropdown filter in the crud-list.component.ts files.

    • The protected region originally called Add any additional config for the dropdown filter question for enum ref [Enum ref name] to [Enum] here has been replaced with this new expanded protected region.
  • The corsFilter method has been removed and replaced with the applyPermitDefaultValues() (which has similar behaviour). If you made customisations to this method that you wish to retain, you will need to re-create it inside the protected region called Add any additional class methods here as shown below.

    // % protected region % [Add any additional class methods here] on begin
    @Bean
    @Profile("dev")
    public CorsFilter corsFilter() {
        UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
        CorsConfiguration config = new CorsConfiguration();
        config.setAllowCredentials(true);
        config.addAllowedOrigin("http://localhost:4200");
        config.addAllowedOrigin("http://localhost:8000");
        config.addAllowedHeader("*");
        config.addAllowedMethod("OPTIONS");
        config.addAllowedMethod("GET");
        config.addAllowedMethod("POST");
        config.addAllowedMethod("PUT");
        config.addAllowedMethod("DELETE");
        source.registerCorsConfiguration("/**", config);
    
        return new CorsFilter(source);
    }
    // % protected region % [Add any additional class methods here] end
    

    Alternatively, any custom CORS configuration can be added to the new configuration location, the protected region called Override the CORS configuration here for test and development.

    // % protected region % [Override the CORS configuration here for test and development] off begin
    var corsConfiguration = new CorsConfiguration().applyPermitDefaultValues();
    corsConfiguration.setAllowedOrigins(Arrays.asList("http://localhost:4200", "http://localhost:8000"));
    corsConfiguration.addAllowedMethod(HttpMethod.OPTIONS);
    corsConfiguration.setAllowCredentials(true);
    // % protected region % [Override the CORS configuration here for test and development] end
    

ModelRelations

If any of your custom code relates to the ModelRelations attributes in your CRUD tiles, you may need to make some modifications to restore the functionality.

Prior to this version of SpringBot, accessing a specific relation from the dictionary of relations for an entity would have required one of the following methods (Using a relation called ‘articles’ as an example):

this.modelRelations.articles
this.modelRelations['articles']

If you have accessed elements from the modelRelations dictionary using one of these methods, then you will need to update your custom code to access the elements from modelRelations using the following snippet instead:

this.modelRelations.find(relation => {
	return relation.id === 'articles';
})

Any situation where you are iterating through the relations using Object.values(this.modelRelations).forEach(…) will need to be replaced as well. This can be done by just removing the Object.values call with a call to this.modelRelations, as it is now an array and can be accessed using this method.

PrepareReferenceCollections

If you have previously added custom code for adding additional relations to a CRUD edit page (through adding additional entities or otherwise) it is likely that you will have made changes to the prepareReferenceCollections method. This method is used to sequentially process any relations which it expects to find, but additional relations are ignored so for additional relation drop-downs to be added to a page, this method needed to be modified.

The most recent changes have configured this method to iterate over the modelRelations array, so any changes which were previously made to prepare a specific relation can be removed, as all relations are now handled in this method.

Forms Extension

The names of forms references have been updated to be unique. This has been done by prefixing the reference with the name of the form entity. For example, the One to many reference between the form entity and the form versions entity now has the source and target reference names prefixed with the form entity name.

For example, for a form entity called Article we would have the following change.

Attribute Previous Reference Name New Reference Name
Name Versions Article Versions
Opposite Name Form Article Form

Note: A form entity is an entity with the Forms extension applied.

1 Like