Skip to content

Commit 660bec4

Browse files
committed
Sidebar: Rename info.vue "p" computed to "photo" photoprism#5547
1 parent 6c3ac3b commit 660bec4

2 files changed

Lines changed: 77 additions & 76 deletions

File tree

frontend/src/component/sidebar/info.vue

Lines changed: 76 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
<v-list-item v-if="editingField === 'title' || model.Title || isEditable" class="metadata__item">
1111
<v-text-field
1212
v-if="editingField === 'title'"
13-
v-model="p.Title"
13+
v-model="photo.Title"
1414
:placeholder="$pgettext('Photo', 'Title')"
1515
:rules="[textRule]"
1616
variant="plain"
@@ -41,7 +41,7 @@
4141
<v-list-item v-if="editingField === 'caption' || model.Caption || isEditable" class="metadata__item">
4242
<v-textarea
4343
v-if="editingField === 'caption'"
44-
v-model="p.Caption"
44+
v-model="photo.Caption"
4545
:placeholder="$gettext('Caption')"
4646
variant="plain"
4747
density="compact"
@@ -401,7 +401,7 @@
401401
>
402402
<v-textarea
403403
v-if="editingField === 'subject'"
404-
v-model="p.Details.Subject"
404+
v-model="photo.Details.Subject"
405405
:placeholder="$gettext('Subject')"
406406
:rules="[textRule]"
407407
variant="plain"
@@ -437,7 +437,7 @@
437437
>
438438
<v-textarea
439439
v-if="editingField === 'artist'"
440-
v-model="p.Details.Artist"
440+
v-model="photo.Details.Artist"
441441
:placeholder="$gettext('Artist')"
442442
:rules="[textRule]"
443443
variant="plain"
@@ -473,7 +473,7 @@
473473
>
474474
<v-textarea
475475
v-if="editingField === 'copyright'"
476-
v-model="p.Details.Copyright"
476+
v-model="photo.Details.Copyright"
477477
:placeholder="$gettext('Copyright')"
478478
:rules="[textRule]"
479479
variant="plain"
@@ -509,7 +509,7 @@
509509
>
510510
<v-textarea
511511
v-if="editingField === 'license'"
512-
v-model="p.Details.License"
512+
v-model="photo.Details.License"
513513
:placeholder="$gettext('License')"
514514
:rules="[textRule]"
515515
variant="plain"
@@ -556,7 +556,7 @@
556556
<v-list-item class="metadata__item">
557557
<v-textarea
558558
v-if="editingField === 'keywords'"
559-
v-model="p.Details.Keywords"
559+
v-model="photo.Details.Keywords"
560560
:placeholder="$gettext('Keywords')"
561561
variant="plain"
562562
density="compact"
@@ -591,7 +591,7 @@
591591
<v-list-item class="metadata__item">
592592
<v-textarea
593593
v-if="editingField === 'notes'"
594-
v-model="p.Details.Notes"
594+
v-model="photo.Details.Notes"
595595
:placeholder="$gettext('Notes')"
596596
variant="plain"
597597
density="compact"
@@ -609,11 +609,11 @@
609609
</template>
610610
</v-list>
611611
</div>
612-
<p-date-time-dialog :visible="dateTimeDialog" :photo="p" @close="dateTimeDialog = false" @confirm="confirmDateTime"></p-date-time-dialog>
613-
<p-camera-dialog :visible="cameraDialog" :photo="p" @close="cameraDialog = false" @confirm="confirmCamera"></p-camera-dialog>
612+
<p-date-time-dialog :visible="dateTimeDialog" :photo="photo" @close="dateTimeDialog = false" @confirm="confirmDateTime"></p-date-time-dialog>
613+
<p-camera-dialog :visible="cameraDialog" :photo="photo" @close="cameraDialog = false" @confirm="confirmCamera"></p-camera-dialog>
614614
<p-location-dialog
615615
:visible="locationDialog"
616-
:latlng="[p ? Number(p.Lat) || 0 : 0, p ? Number(p.Lng) || 0 : 0]"
616+
:latlng="[photo ? Number(photo.Lat) || 0 : 0, photo ? Number(photo.Lng) || 0 : 0]"
617617
@close="locationDialog = false"
618618
@confirm="confirmLocation"
619619
></p-location-dialog>
@@ -723,13 +723,13 @@ export default {
723723
},
724724
computed: {
725725
// Aliases for parent-owned reactive state. These read through `view` so
726-
// every existing template/script reference (this.model.X, this.p.X, etc.)
726+
// every existing template/script reference (this.model.X, this.photo.X, etc.)
727727
// keeps working without churn. Mutations are explicit: write to
728-
// `this.view.photo.X` / `this.view.model.X`, never to `this.p` / `this.model`.
728+
// `this.view.photo.X` / `this.view.model.X`, never to `this.photo` / `this.model`.
729729
model() {
730730
return this.view?.model;
731731
},
732-
p() {
732+
photo() {
733733
return this.view?.photo;
734734
},
735735
canEdit() {
@@ -754,105 +754,106 @@ export default {
754754
return this.view?.pendingNameMarkerUid;
755755
},
756756
isEditable() {
757-
return this.canEdit && this.p && this.p.Details && !this.restrictedRole;
757+
return this.canEdit && this.photo && this.photo.Details && !this.restrictedRole;
758758
},
759759
restrictedRole() {
760760
return this.$session.isSidebarRestricted();
761761
},
762762
captionHtml() {
763-
const raw = this.p?.Caption ?? this.model?.Caption;
763+
const raw = this.photo?.Caption ?? this.model?.Caption;
764764
if (!raw) return "";
765765
return this.$util.sanitizeHtml(this.$util.encodeHTML(raw));
766766
},
767767
notesHtml() {
768-
if (!this.p?.Details?.Notes) return "";
769-
return this.$util.sanitizeHtml(this.$util.encodeHTML(this.p.Details.Notes));
768+
if (!this.photo?.Details?.Notes) return "";
769+
return this.$util.sanitizeHtml(this.$util.encodeHTML(this.photo.Details.Notes));
770770
},
771771
cameraInfo() {
772-
if (!this.p) return "";
772+
if (!this.photo) return "";
773773
// Backend returns the "Unknown" placeholder camera (CameraID=1,
774774
// Camera={Make:"", Model:"Unknown"}) when no EXIF camera is set, and
775775
// formatCamera() happily renders that as " Unknown". Suppress it so
776776
// the read-only sidebar doesn't surface an empty camera row.
777777
const hasRealCamera =
778-
(this.p.CameraID && this.p.CameraID > 1) ||
779-
(this.p.CameraMake && this.p.CameraMake.trim()) ||
780-
(this.p.CameraModel && this.p.CameraModel.trim() && this.p.CameraModel !== "Unknown");
778+
(this.photo.CameraID && this.photo.CameraID > 1) ||
779+
(this.photo.CameraMake && this.photo.CameraMake.trim()) ||
780+
(this.photo.CameraModel && this.photo.CameraModel.trim() && this.photo.CameraModel !== "Unknown");
781781
if (!hasRealCamera) return "";
782782
// Suppress "Unknown, ISO 100"-style rows when only ISO/exposure are set.
783-
if (!this.$util.formatCamera(this.p.Camera, this.p.CameraID, this.p.CameraMake, this.p.CameraModel, false)) return "";
784-
const info = this.p.getCameraInfo();
783+
if (!this.$util.formatCamera(this.photo.Camera, this.photo.CameraID, this.photo.CameraMake, this.photo.CameraModel, false)) return "";
784+
const info = this.photo.getCameraInfo();
785785
return info !== this.$gettext("Unknown") ? info : "";
786786
},
787787
lensInfo() {
788-
if (!this.p) return "";
789-
const hasLens = (this.p.LensID && this.p.LensID > 1) || this.p.LensMake || this.p.LensModel || this.p.Lens?.Model || this.p.Lens?.Make;
788+
if (!this.photo) return "";
789+
const hasLens =
790+
(this.photo.LensID && this.photo.LensID > 1) || this.photo.LensMake || this.photo.LensModel || this.photo.Lens?.Model || this.photo.Lens?.Make;
790791
if (!hasLens) return "";
791-
const info = this.p.getLensInfo();
792+
const info = this.photo.getLensInfo();
792793
return info !== this.$gettext("Unknown") ? info : "";
793794
},
794795
exifInfo() {
795-
if (!this.p) return "";
796-
return this.p.getExifInfo();
796+
if (!this.photo) return "";
797+
return this.photo.getExifInfo();
797798
},
798799
people() {
799-
if (!this.p) return [];
800-
return this.p.getMarkers(true);
800+
if (!this.photo) return [];
801+
return this.photo.getMarkers(true);
801802
},
802803
knownPeople() {
803804
const values = this.$config && this.$config.values;
804805
if (!values || !Array.isArray(values.people)) return [];
805806
return values.people;
806807
},
807808
labels() {
808-
if (!this.p?.Labels) return [];
809-
return this.p.Labels.filter((l) => l.Label && l.Label.Name && l.Uncertainty < 100);
809+
if (!this.photo?.Labels) return [];
810+
return this.photo.Labels.filter((l) => l.Label && l.Label.Name && l.Uncertainty < 100);
810811
},
811812
albums() {
812-
if (!this.p?.Albums) return [];
813-
return this.p.Albums.filter((a) => a.Title && !a.Private);
813+
if (!this.photo?.Albums) return [];
814+
return this.photo.Albums.filter((a) => a.Title && !a.Private);
814815
},
815816
subject() {
816-
return this.p?.Details?.Subject || "";
817+
return this.photo?.Details?.Subject || "";
817818
},
818819
artist() {
819-
return this.p?.Details?.Artist || "";
820+
return this.photo?.Details?.Artist || "";
820821
},
821822
copyright() {
822-
return this.p?.Details?.Copyright || "";
823+
return this.photo?.Details?.Copyright || "";
823824
},
824825
license() {
825-
return this.p?.Details?.License || "";
826+
return this.photo?.Details?.License || "";
826827
},
827828
keywords() {
828-
return this.p?.Details?.Keywords || "";
829+
return this.photo?.Details?.Keywords || "";
829830
},
830831
placeName() {
831-
if (!this.p) return "";
832-
return this.p.locationInfo() || "";
832+
if (!this.photo) return "";
833+
return this.photo.locationInfo() || "";
833834
},
834835
altitude() {
835-
if (!this.p || !this.p.Altitude) return "";
836-
return this.p.Altitude + " m";
836+
if (!this.photo || !this.photo.Altitude) return "";
837+
return this.photo.Altitude + " m";
837838
},
838839
fileName() {
839-
if (!this.p) return "";
840-
if (this.p.FileName) return this.p.FileName;
841-
const primary = typeof this.p.primaryFile === "function" ? this.p.primaryFile() : null;
840+
if (!this.photo) return "";
841+
if (this.photo.FileName) return this.photo.FileName;
842+
const primary = typeof this.photo.primaryFile === "function" ? this.photo.primaryFile() : null;
842843
return primary?.Name || "";
843844
},
844845
fileInfo() {
845-
if (this.p) {
846-
switch (this.p.Type) {
846+
if (this.photo) {
847+
switch (this.photo.Type) {
847848
case media.Video:
848849
case media.Live:
849850
case media.Animated:
850-
return this.p.getVideoInfo();
851+
return this.photo.getVideoInfo();
851852
case media.Vector:
852853
case media.Document:
853-
return this.p.getVectorInfo();
854+
return this.photo.getVectorInfo();
854855
default:
855-
return this.p.getImageInfo();
856+
return this.photo.getImageInfo();
856857
}
857858
}
858859
// Fallback for restricted roles: Thumb.getTypeInfo() produces
@@ -863,7 +864,7 @@ export default {
863864
return "";
864865
},
865866
fileIcon() {
866-
switch (this.p?.Type || this.model?.Type) {
867+
switch (this.photo?.Type || this.model?.Type) {
867868
case media.Raw:
868869
return "mdi-raw";
869870
case media.Video:
@@ -900,21 +901,21 @@ export default {
900901
getFieldValue(field) {
901902
switch (field) {
902903
case "title":
903-
return this.p.Title;
904+
return this.photo.Title;
904905
case "caption":
905-
return this.p.Caption;
906+
return this.photo.Caption;
906907
case "subject":
907-
return this.p.Details.Subject;
908+
return this.photo.Details.Subject;
908909
case "artist":
909-
return this.p.Details.Artist;
910+
return this.photo.Details.Artist;
910911
case "copyright":
911-
return this.p.Details.Copyright;
912+
return this.photo.Details.Copyright;
912913
case "license":
913-
return this.p.Details.License;
914+
return this.photo.Details.License;
914915
case "keywords":
915-
return this.p.Details.Keywords;
916+
return this.photo.Details.Keywords;
916917
case "notes":
917-
return this.p.Details.Notes;
918+
return this.photo.Details.Notes;
918919
default:
919920
return "";
920921
}
@@ -1159,7 +1160,7 @@ export default {
11591160
if (r) r(false);
11601161
},
11611162
confirmField() {
1162-
if (!this.p || !this.canEdit) {
1163+
if (!this.photo || !this.canEdit) {
11631164
this.editingField = null;
11641165
return;
11651166
}
@@ -1168,15 +1169,15 @@ export default {
11681169
this.editingField = null;
11691170
this.editOriginal = null;
11701171
1171-
if (!this.p.wasChanged()) {
1172+
if (!this.photo.wasChanged()) {
11721173
return;
11731174
}
11741175
1175-
// The inline-edit binding (v-model="p.X") already mutated the photo
1176+
// The inline-edit binding (v-model="photo.X") already mutated the photo
11761177
// optimistically; on success sync the matching Thumb fields, on
11771178
// failure roll back so the user sees the title/caption revert and
11781179
// gets a notification instead of a silent ghost edit.
1179-
this.p
1180+
this.photo
11801181
.update()
11811182
.then(() => {
11821183
if ((field === "title" || field === "caption") && this.view?.model) {
@@ -1185,7 +1186,7 @@ export default {
11851186
}
11861187
})
11871188
.catch(() => {
1188-
this.p.rollback();
1189+
this.photo.rollback();
11891190
this.$notify.error(this.$gettext("Failed to save changes"));
11901191
});
11911192
},
@@ -1359,7 +1360,7 @@ export default {
13591360
}
13601361
},
13611362
confirmLabels() {
1362-
if (!this.p) {
1363+
if (!this.photo) {
13631364
this.editingField = null;
13641365
return;
13651366
}
@@ -1371,8 +1372,8 @@ export default {
13711372
this.pendingLabelAdditions = [];
13721373
13731374
const promises = [];
1374-
removals.forEach((id) => promises.push(this.p.removeLabel(id)));
1375-
additions.forEach((name) => promises.push(this.p.addLabel(name)));
1375+
removals.forEach((id) => promises.push(this.photo.removeLabel(id)));
1376+
additions.forEach((name) => promises.push(this.photo.addLabel(name)));
13761377
13771378
if (promises.length) {
13781379
Promise.all(promises).catch(() => {});
@@ -1392,7 +1393,7 @@ export default {
13921393
}
13931394
},
13941395
confirmAlbums() {
1395-
if (!this.p) {
1396+
if (!this.photo) {
13961397
this.editingField = null;
13971398
return;
13981399
}
@@ -1404,17 +1405,17 @@ export default {
14041405
this.pendingAlbumAdditions = [];
14051406
14061407
const promises = [];
1407-
removals.forEach((uid) => promises.push(this.$api.delete(`albums/${uid}/photos`, { data: { photos: [this.p.UID] } })));
1408-
additions.forEach((a) => promises.push(this.$api.post(`albums/${a.UID}/photos`, { photos: [this.p.UID] })));
1408+
removals.forEach((uid) => promises.push(this.$api.delete(`albums/${uid}/photos`, { data: { photos: [this.photo.UID] } })));
1409+
additions.forEach((a) => promises.push(this.$api.post(`albums/${a.UID}/photos`, { photos: [this.photo.UID] })));
14091410
14101411
if (promises.length) {
14111412
Promise.all(promises)
14121413
.then(() => {
1413-
Photo.evictCache(this.p.UID);
1414-
return this.p.find(this.p.UID);
1414+
Photo.evictCache(this.photo.UID);
1415+
return this.photo.find(this.photo.UID);
14151416
})
14161417
.then((photo) => {
1417-
this.p.setValues(photo.getValues());
1418+
this.photo.setValues(photo.getValues());
14181419
})
14191420
.catch(() => {});
14201421
}

frontend/tests/vitest/component/sidebar/info.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2557,7 +2557,7 @@ describe("PSidebarInfo component", () => {
25572557
// Pins the template bindings on <p-date-time-dialog>, <p-camera-dialog>,
25582558
// and <p-location-dialog>. Commit 7a611b6d6 removed the legacy `photo`
25592559
// prop on PSidebarInfo and routed parent state through `$view.getData()`
2560-
// (exposed via the `p` computed). The three dialog tags in the sidebar
2560+
// (exposed via the `photo` computed). The three dialog tags in the sidebar
25612561
// template kept referencing the now-undefined `photo` identifier, so the
25622562
// dialogs received `:photo="undefined"` / `:latlng="[0, 0]"` and their
25632563
// loadFromPhoto() hooks bailed out — opening every sidebar dialog with

0 commit comments

Comments
 (0)