Edit photo: Improve add and remove labels

Signed-off-by: Michael Mayer <michael@liquidbytes.net>
This commit is contained in:
Michael Mayer 2020-01-29 16:49:42 +01:00
parent bdf976abd7
commit 91beb766fa
3 changed files with 11 additions and 6 deletions

View file

@ -172,12 +172,16 @@ div.v-dialog table.v-table tfoot td {
}
table.v-table tbody td,
table.v-table tbody td input,
table.v-table tbody td label.v-label,
table.v-table tfoot td,
table.v-table tfoot td input
table.v-table tfoot td input,
table.v-table tfoot td label.v-label
{
font-weight: 400;
font-size: 13px;
}
table.v-table tbody td div.v-input__slot,
table.v-table tfoot td div.v-input__slot {
padding: 0 !important;

View file

@ -14,7 +14,6 @@
<td>{{ props.item.Label.LabelName }}</td>
<td class="text-xs-left">{{ props.item.LabelSource }}</td>
<td class="text-xs-center">{{ 100 - props.item.LabelUncertainty }}%</td>
<td class="text-xs-center">{{ props.item.Label.LabelPriority }}</td>
<td class="text-xs-center"><v-btn icon small flat :ripple="false"
class="p-photo-label-remove"
@click.stop.prevent="removeLabel(props.item.Label)">
@ -27,6 +26,7 @@
v-model="newLabel"
:rules="[nameRule]"
color="secondary-dark"
:label="labels.addLabel"
single-line
flat solo hide-details
autofocus
@ -34,7 +34,6 @@
</td>
<td class="text-xs-left">manual</td>
<td class="text-xs-center">100%</td>
<td class="text-xs-center"></td>
<td class="text-xs-center"><v-btn icon small flat :ripple="false"
class="p-photo-label-remove"
@click.stop.prevent="addLabel">
@ -63,11 +62,10 @@
{text: this.$gettext('Label'), value: '', sortable: false, align: 'left'},
{text: this.$gettext('Source'), value: 'LabelSource', sortable: false, align: 'left'},
{text: this.$gettext('Confidence'), value: 'LabelUncertainty', sortable: false, align: 'center'},
{text: this.$gettext('Priority'), value: 'LabelPriority', sortable: false, align: 'center'},
{text: this.$gettext('Action'), value: '', sortable: false, align: 'center'},
],
labels: {
labelName: this.$gettext("Label Name"),
addLabel: "",
},
nameRule: v => v.length <= 25 || this.$gettext("Name too long"),
};

View file

@ -6,6 +6,7 @@ import (
"time"
"github.com/gosimple/slug"
"github.com/jinzhu/gorm"
"github.com/photoprism/photoprism/internal/entity"
"github.com/photoprism/photoprism/internal/form"
"github.com/photoprism/photoprism/pkg/capture"
@ -353,7 +354,9 @@ func (s *Repo) FindPhotoByUUID(photoUUID string) (photo entity.Photo, err error)
// PreloadPhotoByUUID returns a Photo based on the UUID with all dependencies preloaded.
func (s *Repo) PreloadPhotoByUUID(photoUUID string) (photo entity.Photo, err error) {
if err := s.db.Where("photo_uuid = ?", photoUUID).
Preload("Labels").
Preload("Labels", func(db *gorm.DB) *gorm.DB {
return db.Order("photos_labels.label_uncertainty ASC, photos_labels.label_id")
}).
Preload("Labels.Label").
Preload("Camera").
Preload("Lens").