Albums: Improve sorting options in extended search form #353

Signed-off-by: Michael Mayer <michael@photoprism.app>
This commit is contained in:
Michael Mayer 2023-01-04 14:15:07 +01:00
parent 09b6dedb9d
commit 843155ef60
9 changed files with 37 additions and 10 deletions

View file

@ -160,7 +160,7 @@ export default [
path: "/albums",
component: Albums,
meta: { title: $gettext("Albums"), auth: true },
props: { view: "album", defaultOrder: "name", staticFilter: { type: "album" } },
props: { view: "album", defaultOrder: "favorites", staticFilter: { type: "album" } },
},
{
name: "album",

View file

@ -52,6 +52,7 @@
<v-flex xs12 sm6 md3 pa-2 class="p-countries-select">
<v-select :value="filter.country"
:label="$gettext('Country')"
:menu-props="{'maxHeight':346}"
flat solo hide-details
color="secondary-dark"
item-value="ID"
@ -65,6 +66,7 @@
<v-flex xs12 sm6 md3 pa-2 class="p-camera-select">
<v-select :value="filter.camera"
:label="$gettext('Camera')"
:menu-props="{'maxHeight':346}"
flat solo hide-details
color="secondary-dark"
item-value="ID"
@ -76,8 +78,8 @@
<v-flex xs12 sm6 md3 pa-2 class="p-view-select">
<v-select id="viewSelect"
:value="settings.view"
:label="$gettext('View')" flat solo
hide-details
:label="$gettext('View')"
flat solo hide-details
color="secondary-dark"
:items="options.views"
@change="(v) => {setView(v)}">
@ -86,6 +88,7 @@
<v-flex xs12 sm6 md3 pa-2 class="p-time-select">
<v-select :value="filter.order"
:label="$gettext('Sort Order')"
:menu-props="{'maxHeight':400}"
flat solo hide-details
color="secondary-dark"
:items="options.sorting"
@ -95,6 +98,7 @@
<v-flex xs12 sm6 md3 pa-2 class="p-year-select">
<v-select :value="filter.year"
:label="$gettext('Year')"
:menu-props="{'maxHeight':346}"
flat solo hide-details
color="secondary-dark"
item-value="value"
@ -106,6 +110,7 @@
<v-flex xs12 sm6 md3 pa-2 class="p-month-select">
<v-select :value="filter.month"
:label="$gettext('Month')"
:menu-props="{'maxHeight':346}"
flat solo hide-details
color="secondary-dark"
item-value="value"
@ -128,6 +133,7 @@
<v-flex xs12 sm6 md3 pa-2 class="p-color-select">
<v-select :value="filter.color"
:label="$gettext('Color')"
:menu-props="{'maxHeight':346}"
flat solo hide-details
color="secondary-dark"
item-value="Slug"
@ -139,6 +145,7 @@
<v-flex xs12 sm6 md3 pa-2 class="p-category-select">
<v-select :value="filter.label"
:label="$gettext('Category')"
:menu-props="{'maxHeight':346}"
flat solo hide-details
color="secondary-dark"
item-value="Slug"

View file

@ -67,6 +67,7 @@
<v-select
v-model="model.Order"
:label="$gettext('Sort Order')"
:menu-props="{'maxHeight':400}"
hide-details box flat
:items="sorting"
:disabled="disabled"

View file

@ -187,6 +187,7 @@
:append-icon="model.CameraSrc === 'manual' ? 'check' : ''"
:disabled="disabled"
:label="$gettext('Camera')"
:menu-props="{'maxHeight':346}"
browser-autocomplete="off"
hide-details box flat
color="secondary-dark"
@ -233,6 +234,7 @@
:append-icon="model.CameraSrc === 'manual' ? 'check' : ''"
:disabled="disabled"
:label="$gettext('Lens')"
:menu-props="{'maxHeight':346}"
browser-autocomplete="off"
hide-details box flat
color="secondary-dark"

File diff suppressed because one or more lines are too long

View file

@ -48,6 +48,7 @@
<v-select :value="filter.year"
:label="$gettext('Year')"
:disabled="context === 'state'"
:menu-props="{'maxHeight':346}"
flat solo hide-details
color="secondary-dark"
item-value="value"
@ -59,6 +60,7 @@
<v-flex xs12 sm4 pa-2 class="p-category-select">
<v-select :value="filter.category"
:label="$gettext('Category')"
:menu-props="{'maxHeight':346}"
flat solo hide-details
color="secondary-dark"
:items="categories"
@ -68,6 +70,7 @@
<v-flex xs12 sm4 pa-2 class="p-sort-select">
<v-select :value="filter.order"
:label="$gettext('Sort Order')"
:menu-props="{'maxHeight':400}"
flat solo hide-details
color="secondary-dark"
:items="options.sorting"
@ -321,13 +324,14 @@ export default {
},
options: {
'sorting': [
{value: 'newest', text: this.$gettext('Newest First')},
{value: 'oldest', text: this.$gettext('Oldest First')},
{value: 'added', text: this.$gettext('Recently Added')},
{value: 'favorites', text: this.$gettext('Favorites')},
{value: 'name', text: this.$gettext('Name')},
{value: 'place', text: this.$gettext('Location')},
{value: 'moment', text: this.$gettext('Place & Time')},
{value: 'relevance', text: this.$gettext('Most Relevant')},
{value: 'newest', text: this.$gettext('Newest First')},
{value: 'oldest', text: this.$gettext('Oldest First')},
{value: 'added', text: this.$gettext('Recently Added')},
{value: 'edited', text: this.$gettext('Recently Edited')},
],
},
};

View file

@ -18,6 +18,7 @@
:disabled="busy"
:items="themes"
:label="$gettext('Theme')"
:menu-props="{'maxHeight':346}"
color="secondary-dark"
background-color="secondary-light"
hide-details
@ -32,6 +33,7 @@
:disabled="busy"
:items="languages"
:label="$gettext('Language')"
:menu-props="{'maxHeight':346}"
color="secondary-dark"
background-color="secondary-light"
hide-details
@ -320,6 +322,7 @@
:disabled="busy"
:items="options.MapsStyle()"
:label="$gettext('Maps')"
:menu-props="{'maxHeight':346}"
color="secondary-dark"
background-color="secondary-light"
hide-details
@ -334,6 +337,7 @@
:disabled="busy"
:items="options.MapsAnimate()"
:label="$gettext('Animation')"
:menu-props="{'maxHeight':346}"
color="secondary-dark"
background-color="secondary-light"
hide-details

View file

@ -72,6 +72,7 @@ const (
SortOrderOldest = "oldest"
SortOrderPlace = "place"
SortOrderMoment = "moment"
SortOrderFavorites = "favorites"
SortOrderName = "name"
SortOrderPath = "path"
SortOrderSlug = "slug"

View file

@ -83,8 +83,6 @@ func UserAlbums(f form.SearchAlbums, sess *entity.Session) (results AlbumResults
switch f.Order {
case entity.SortOrderCount:
s = s.Order("photo_count DESC, albums.album_title, albums.album_uid DESC")
case entity.SortOrderRelevance:
s = s.Order("albums.album_favorite DESC, albums.updated_at DESC, albums.album_uid DESC")
case entity.SortOrderNewest:
if f.Type == entity.AlbumDefault || f.Type == entity.AlbumState {
s = s.Order("albums.album_uid DESC")
@ -99,6 +97,8 @@ func UserAlbums(f form.SearchAlbums, sess *entity.Session) (results AlbumResults
}
case entity.SortOrderAdded:
s = s.Order("albums.album_uid DESC")
case entity.SortOrderEdited:
s = s.Order("albums.updated_at DESC, albums.album_uid DESC")
case entity.SortOrderMoment:
s = s.Order("albums.album_favorite DESC, has_year, albums.album_year DESC, albums.album_month DESC, albums.album_title ASC, albums.album_uid DESC")
case entity.SortOrderPlace:
@ -109,6 +109,14 @@ func UserAlbums(f form.SearchAlbums, sess *entity.Session) (results AlbumResults
s = s.Order("albums.album_category, albums.album_title, albums.album_uid DESC")
case entity.SortOrderSlug:
s = s.Order("albums.album_slug ASC, albums.album_uid DESC")
case entity.SortOrderFavorites:
if f.Type == entity.AlbumFolder {
s = s.Order("albums.album_favorite DESC, albums.album_path ASC, albums.album_uid DESC")
} else if f.Type == entity.AlbumMonth {
s = s.Order("albums.album_favorite DESC, albums.album_year DESC, albums.album_month DESC, albums.album_day DESC, albums.album_title, albums.album_uid DESC")
} else {
s = s.Order("albums.album_favorite DESC, albums.album_title ASC, albums.album_uid DESC")
}
case entity.SortOrderName:
if f.Type == entity.AlbumFolder {
s = s.Order("albums.album_path ASC, albums.album_uid DESC")