Frontend: Enable search for 2 character words #773 #746

This commit is contained in:
Michael Mayer 2020-12-30 13:59:27 +01:00
parent f7e7073f35
commit 4614cbe4ea
12 changed files with 48 additions and 62 deletions

View file

@ -282,12 +282,6 @@ export default {
},
updateQuery() {
this.filter.q = this.filter.q.trim();
const len = this.filter.q.length;
if (len > 1 && len < 3) {
this.$notify.error(this.$gettext("Search term too short"));
return;
}
const query = {
view: this.settings.view
@ -302,7 +296,7 @@ export default {
}
if (JSON.stringify(this.$route.query) === JSON.stringify(query)) {
return
return;
}
this.$router.replace({query: query});

View file

@ -417,12 +417,6 @@ export default {
},
updateQuery() {
this.filter.q = this.filter.q.trim();
const len = this.filter.q.length;
if (len > 1 && len < 3) {
this.$notify.error(this.$gettext("Search term too short"));
return;
}
const query = {
view: this.settings.view
@ -437,7 +431,7 @@ export default {
}
if (JSON.stringify(this.$route.query) === JSON.stringify(query)) {
return
return;
}
this.$router.replace({query: query});

View file

@ -369,12 +369,6 @@ export default {
},
updateQuery() {
this.filter.q = this.filter.q.trim();
const len = this.filter.q.length;
if (len > 1 && len < 3) {
this.$notify.error(this.$gettext("Search term too short"));
return;
}
const query = {
view: this.settings.view
@ -389,7 +383,7 @@ export default {
}
if (JSON.stringify(this.$route.query) === JSON.stringify(query)) {
return
return;
}
this.$router.replace({query: query});

View file

@ -118,12 +118,6 @@ export default {
methods: {
updateQuery() {
this.filter.q = this.filter.q.trim();
const len = this.filter.q.length;
if (len > 1 && len < 3) {
this.$notify.error(this.$gettext("Search term too short"));
return;
}
const query = {};
@ -136,7 +130,7 @@ export default {
}
if (JSON.stringify(this.$route.query) === JSON.stringify(query)) {
return
return;
}
this.$router.replace({query});

View file

@ -332,12 +332,6 @@ export default {
},
updateQuery() {
this.filter.q = this.filter.q.trim();
const len = this.filter.q.length;
if (len > 1 && len < 3) {
this.$notify.error(this.$gettext("Search term too short"));
return;
}
const query = {
view: this.settings.view
@ -352,7 +346,7 @@ export default {
}
if (JSON.stringify(this.$route.query) === JSON.stringify(query)) {
return
return;
}
this.$router.replace({query: query});

View file

@ -333,12 +333,6 @@ export default {
},
updateQuery() {
this.filter.q = this.filter.q.trim();
const len = this.filter.q.length;
if (len > 1 && len < 3) {
this.$notify.error(this.$gettext("Search term too short"));
return;
}
const query = {
view: this.settings.view

View file

@ -211,12 +211,6 @@ export default {
},
updateQuery() {
this.filter.q = this.filter.q.trim();
const len = this.filter.q.length;
if (len > 1 && len < 3) {
this.$notify.error(this.$gettext("Search term too short"));
return;
}
if (this.query() !== this.filter.q) {
if (this.filter.q) {

View file

@ -289,12 +289,6 @@ export default {
},
updateQuery() {
this.filter.q = this.filter.q.trim();
const len = this.filter.q.length;
if (len > 1 && len < 3) {
this.$notify.error(this.$gettext("Search term too short"));
return;
}
const query = {
view: this.settings.view
@ -309,7 +303,7 @@ export default {
}
if (JSON.stringify(this.$route.query) === JSON.stringify(query)) {
return
return;
}
this.$router.replace({query: query});

View file

@ -322,12 +322,6 @@ export default {
},
updateQuery() {
this.filter.q = this.filter.q.trim();
const len = this.filter.q.length;
if (len > 1 && len < 3) {
this.$notify.error(this.$gettext("Search term too short"));
return;
}
const query = {
view: this.settings.view
@ -342,7 +336,7 @@ export default {
}
if (JSON.stringify(this.$route.query) === JSON.stringify(query)) {
return
return;
}
this.$router.replace({query: query});

View file

@ -7,7 +7,7 @@ import (
"github.com/photoprism/photoprism/pkg/fs"
)
var FileTitleRegexp = regexp.MustCompile("[\\p{L}\\-,':&+!?]{1,}|( [&+] )?")
var FileTitleRegexp = regexp.MustCompile("[\\p{L}\\-,':&+!?]{1,}|( [&+] )?")
// FileTitle returns the string with the first characters of each word converted to uppercase.
func FileTitle(s string) string {

View file

@ -10,6 +10,18 @@ func TestFileTitle(t *testing.T) {
t.Run("桥", func(t *testing.T) {
assert.Equal(t, "桥", FileTitle("桥"))
})
t.Run("桥船", func(t *testing.T) {
result := FileTitle("桥船")
assert.Equal(t, "桥船", result)
})
t.Run("桥船猫", func(t *testing.T) {
result := FileTitle("桥船猫")
assert.Equal(t, "桥船猫", result)
})
t.Run("谢谢!", func(t *testing.T) {
result := FileTitle("谢谢!")
assert.Equal(t, "谢谢!", result)
})
t.Run("i_love_you!", func(t *testing.T) {
assert.Equal(t, "Love You!", FileTitle("i_love_you!"))
})

View file

@ -11,6 +11,18 @@ func TestWords(t *testing.T) {
result := Words("桥")
assert.Equal(t, []string{"桥"}, result)
})
t.Run("桥船", func(t *testing.T) {
result := Words("桥船")
assert.Equal(t, []string{"桥船"}, result)
})
t.Run("桥船猫", func(t *testing.T) {
result := Words("桥船猫")
assert.Equal(t, []string{"桥船猫"}, result)
})
t.Run("谢谢!", func(t *testing.T) {
result := Words("谢谢!")
assert.Equal(t, []string{"谢谢"}, result)
})
t.Run("I'm a lazy-brown fox!", func(t *testing.T) {
result := Words("I'm a lazy-BRoWN fox!")
assert.Equal(t, []string{"lazy-BRoWN", "fox"}, result)
@ -91,6 +103,22 @@ func TestFilenameKeywords(t *testing.T) {
}
func TestKeywords(t *testing.T) {
t.Run("桥", func(t *testing.T) {
result := Keywords("桥")
assert.Equal(t, []string{"桥"}, result)
})
t.Run("桥船", func(t *testing.T) {
result := Keywords("桥船")
assert.Equal(t, []string{"桥船"}, result)
})
t.Run("桥船猫", func(t *testing.T) {
result := Keywords("桥船猫")
assert.Equal(t, []string{"桥船猫"}, result)
})
t.Run("谢谢!", func(t *testing.T) {
result := Keywords("谢谢!")
assert.Equal(t, []string{"谢谢"}, result)
})
t.Run("I'm a lazy brown fox!", func(t *testing.T) {
result := Keywords("I'm a lazy BRoWN img!")
assert.Equal(t, []string{"lazy", "brown"}, result)