sysadminsmedia / homebox

A continuation of HomeBox the inventory and organization system built for the Home User
https://homebox.software
GNU Affero General Public License v3.0
838 stars 47 forks source link

Locations with cyrillic charaters are not displayed in "Parent location" #164

Open mrDMG89 opened 1 month ago

mrDMG89 commented 1 month ago

First Check

Homebox Version

0.13.0

What is the issue you are experiencing?

If location's name doesn't contain Latin characters, digits or symbols, this locations won't appear in "Parent location" field. As soon as any digit or symbol added to location's name it shows up in the list.

How can the maintainer reproduce the issue?

Name location just with cyrillic letters.

Deployment

Docker (Linux)

Deployment Details

Deployed on CasaOS.

Jackxwb commented 1 week ago

This issue can also occur when using Simplified Chinese image

Jackxwb commented 3 days ago

I know why it's not showing up. The main reason is that the lunrjs (full-text search) component supports too few languages. When creating lunrFactory function, unsupported languages are ignored, and the data key for inventedIndex in lunr.Index becomes an empty string However, empty strings are ignored in the subsequent 'search' method, resulting in them not appearing in the result list image

A temporary solution:

Add a fixed field to display so that the key value pairs of inventedIndex are not empty

function lunrFactory() {
    return lunr(function () {
      this.ref("id");
      this.field("display");

      for (let i = 0; i < props.items.length; i++) {
        const item = props.items[i];
        //const display = extractDisplay(item);
        const display = "_" + extractDisplay(item);
        this.add({ id: i, display });
      }
    });
  }

image


Another solution:

const matches = index.value.search("*" + search.value + "*");

Replace with this code

let matches
    if(search.value == ""){
      //Show all Item
      matches = index.value.search("");
    }else{
      matches = index.value.search("*" + search.value + "*");
    }

This method can only achieve the use of unsupported languages for all names in the list, and cannot be used for full-text search, which still requires official support from Lunrjs. Attachment: Lunrjs supports languages