cuba-platform / cuba

CUBA Platform is a high level framework for enterprise applications development
https://www.cuba-platform.com
Apache License 2.0
1.34k stars 219 forks source link

The icon is not shown in the search field for SuggestionPickerField #3242

Closed imorenov94 closed 3 years ago

imorenov94 commented 3 years ago

Environment

Description of the bug or enhancement

Steps:

  1. Create a new project
  2. Create a new screen
  3. Add to screen SuggestionPickerField (can use code example from below)

    @Inject
    private SuggestionPickerField<NewEntity> suggest;
    @Inject
    private Metadata metadata;
    
    @Subscribe
    public void onInit(InitEvent event) {
        NewEntity entity1 = metadata.create(NewEntity.class);
        entity1.setName("entity1");
        NewEntity entity2 = metadata.create(NewEntity.class);
        entity2.setName("entity2");
        List<NewEntity> entityList = Arrays.asList(entity1,entity2);
        suggest.setSearchExecutor((searchString, searchParams) -> {
            return entityList.stream().filter(entity -> entity.getName().contains(searchString)).collect(Collectors.toList());
        });
    }
    
    @Install(to = "suggest", subject = "optionIconProvider")
    private String suggestOptionIconProvider(NewEntity newEntity) {
        if (newEntity == null) {
            return null;
        }
        if ("entity1".equals(newEntity.getName())) {
            return CubaIcon.ADDRESS_BOOK.source();
        } else if ("entity2".equals(newEntity.getName())) {
            return CubaIcon.BLACK_TIE.source();
        }
        return null;
    }
  4. Run the app
  5. Open created screen
  6. Pass entity name in SugestionPickerField and pick it

ER:

AR: Icons haven't been installed in the search field and don't show in the dropdown list

Flaurite commented 3 years ago

@imorenov94

Icons should be shown for suggestions in the dropdown list

After investigation it turns out that SuggestionField has custom popup widget and it does not provide the ability to set icons by design.