People: Fix edit dialog save button in people/dialog/edit.vue #3168

Signed-off-by: Michael Mayer <michael@photoprism.app>
This commit is contained in:
Michael Mayer
2025-01-17 09:27:34 +01:00
parent aeb51eb5fa
commit a9645b532b
9 changed files with 40 additions and 54 deletions

View File

@@ -45,7 +45,7 @@ import PLabelEditDialog from "label/dialog/edit.vue";
// People. // People.
import PPeopleMergeDialog from "people/dialog/merge.vue"; import PPeopleMergeDialog from "people/dialog/merge.vue";
import PPeopleEditDialog from "people/dialog/edit.vue"; import PPeopleEditDialog from "people/dialog/edit.vue";
import PSubjectClipboard from "subject/clipboard.vue"; import PPeopleClipboard from "component/people/clipboard.vue";
// Photos. // Photos.
import PPhotoCards from "photo/view/cards.vue"; import PPhotoCards from "photo/view/cards.vue";
@@ -105,7 +105,7 @@ export function install(app) {
app.component("PPeopleMergeDialog", PPeopleMergeDialog); app.component("PPeopleMergeDialog", PPeopleMergeDialog);
app.component("PPeopleEditDialog", PPeopleEditDialog); app.component("PPeopleEditDialog", PPeopleEditDialog);
app.component("PSubjectClipboard", PSubjectClipboard); app.component("PPeopleClipboard", PPeopleClipboard);
app.component("PPhotoCards", PPhotoCards); app.component("PPhotoCards", PPhotoCards);
app.component("PPhotoMosaic", PPhotoMosaic); app.component("PPhotoMosaic", PPhotoMosaic);

View File

@@ -4,7 +4,7 @@
<v-speed-dial <v-speed-dial
id="t-clipboard" id="t-clipboard"
v-model="expanded" v-model="expanded"
:class="`p-clipboard p-subject-clipboard`" :class="`p-clipboard p-people-clipboard`"
:end="!rtl" :end="!rtl"
:start="rtl" :start="rtl"
:attach="true" :attach="true"
@@ -32,7 +32,7 @@ import Notify from "common/notify";
import download from "common/download"; import download from "common/download";
export default { export default {
name: "PSubjectClipboard", name: "PPeopleClipboard",
props: { props: {
selection: { selection: {
type: Array, type: Array,

View File

@@ -66,6 +66,7 @@ export default {
this.close(); this.close();
return; return;
} }
this.$emit("confirm", this.model); this.$emit("confirm", this.model);
}, },
}, },

View File

@@ -155,7 +155,7 @@ export class Subject extends RestModel {
} }
static getModelName() { static getModelName() {
return $gettext("Subject"); return $gettext("Person");
} }
} }

View File

@@ -52,7 +52,7 @@
<v-progress-linear :indeterminate="true"></v-progress-linear> <v-progress-linear :indeterminate="true"></v-progress-linear>
</div> </div>
<div v-else style="min-height: 100vh"> <div v-else style="min-height: 100vh">
<p-subject-clipboard :refresh="refresh" :selection="selection" :clear-selection="clearSelection"></p-subject-clipboard> <p-people-clipboard :refresh="refresh" :selection="selection" :clear-selection="clearSelection"></p-people-clipboard>
<p-scroll :load-more="loadMore" :load-disabled="scrollDisabled" :load-distance="scrollDistance" :loading="loading"></p-scroll> <p-scroll :load-more="loadMore" :load-disabled="scrollDisabled" :load-distance="scrollDistance" :loading="loading"></p-scroll>
@@ -253,8 +253,7 @@ export default {
} }
const existing = this.$config.getPerson(m.Name); const existing = this.$config.getPerson(m.Name);
if (!existing || existing.UID === m.UID) {
if (!existing) {
this.busy = true; this.busy = true;
m.update() m.update()
.then((m) => { .then((m) => {
@@ -263,10 +262,12 @@ export default {
}) })
.finally(() => { .finally(() => {
this.busy = false; this.busy = false;
this.dialog.edit = false;
}); });
} else if (existing.UID !== m.UID) { } else {
this.merge.subj1 = m; this.merge.subj1 = m;
this.merge.subj2 = existing; this.merge.subj2 = existing;
this.dialog.edit = false;
this.merge.show = true; this.merge.show = true;
} }
}, },

View File

@@ -36,11 +36,7 @@ const putEntityResponse = {
}; };
const deleteEntityResponse = null; const deleteEntityResponse = null;
Mock.onPost("api/v1/users/urii20d30w2wqzjf/profile").reply( Mock.onPost("api/v1/users/urii20d30w2wqzjf/profile").reply(200, { DisplayName: "Max New" }, mockHeaders);
200,
{ DisplayName: "Max New" },
mockHeaders
);
Mock.onPost("api/v1/users/52/avatar").reply(200, { Thumb: "abc", ThumbSrc: "manual" }, mockHeaders); Mock.onPost("api/v1/users/52/avatar").reply(200, { Thumb: "abc", ThumbSrc: "manual" }, mockHeaders);
Mock.onGet("api/v1/foo").reply(200, getCollectionResponse, mockHeaders); Mock.onGet("api/v1/foo").reply(200, getCollectionResponse, mockHeaders);
Mock.onGet("api/v1/foo/123").reply(200, getEntityResponse, mockHeaders); Mock.onGet("api/v1/foo/123").reply(200, getEntityResponse, mockHeaders);
@@ -124,11 +120,7 @@ Mock.onPut("api/v1/photos/pqbemz8276mhtobh/label/12345", { Label: { Name: "Somme
}, },
mockHeaders mockHeaders
); );
Mock.onDelete("api/v1/photos/pqbemz8276mhtobh/label/12345").reply( Mock.onDelete("api/v1/photos/pqbemz8276mhtobh/label/12345").reply(200, { success: "ok" }, mockHeaders);
200,
{ success: "ok" },
mockHeaders
);
Mock.onPost("api/v1/session").reply( Mock.onPost("api/v1/session").reply(
200, 200,
@@ -169,13 +161,9 @@ Mock.onGet("api/v1/session/5aa770f2a1ef431628d9f17bdf82a0d16865e99d4a1ddd9356e1a
mockHeaders mockHeaders
); );
Mock.onDelete( Mock.onDelete("api/v1/session/5aa770f2a1ef431628d9f17bdf82a0d16865e99d4a1ddd9356e1aabfe6464683").reply(200);
"api/v1/session/5aa770f2a1ef431628d9f17bdf82a0d16865e99d4a1ddd9356e1aabfe6464683"
).reply(200);
Mock.onDelete( Mock.onDelete("api/v1/session/a9b8ff820bf40ab451910f8bbfe401b2432446693aa539538fbd2399560a722f").reply(200);
"api/v1/session/a9b8ff820bf40ab451910f8bbfe401b2432446693aa539538fbd2399560a722f"
).reply(200);
Mock.onGet("api/v1/settings").reply(200, { download: true, language: "de" }, mockHeaders); Mock.onGet("api/v1/settings").reply(200, { download: true, language: "de" }, mockHeaders);
Mock.onPost("api/v1/settings").reply(200, { download: true, language: "en" }, mockHeaders); Mock.onPost("api/v1/settings").reply(200, { download: true, language: "en" }, mockHeaders);
@@ -312,11 +300,7 @@ Mock.onAny("api/v1/users/52/register").reply(200, { foo: "register" }, mockHeade
Mock.onAny("api/v1/users/53/profile").reply(200, { foo: "profile" }, mockHeaders); Mock.onAny("api/v1/users/53/profile").reply(200, { foo: "profile" }, mockHeaders);
Mock.onPut("api/v1/users/54/password").reply( Mock.onPut("api/v1/users/54/password").reply(200, { password: "old", new_password: "new" }, mockHeaders);
200,
{ password: "old", new_password: "new" },
mockHeaders
);
Mock.onGet("api/v1/link/5").reply(200, "get success", mockHeaders); Mock.onGet("api/v1/link/5").reply(200, "get success", mockHeaders);
Mock.onPut("api/v1/link/5").reply(200, "put success", mockHeaders); Mock.onPut("api/v1/link/5").reply(200, "put success", mockHeaders);

View File

@@ -1200,7 +1200,7 @@ describe("model/photo", () => {
Name: "_MG_9509", Name: "_MG_9509",
OriginalName: "", OriginalName: "",
Title: "Unknown / 2018", Title: "Unknown / 2018",
Description: "", Caption: "",
Year: 2018, Year: 2018,
Month: 10, Month: 10,
Day: 5, Day: 5,
@@ -1451,7 +1451,7 @@ describe("model/photo", () => {
Lng: 3.3, Lng: 3.3,
CameraID: 123, CameraID: 123,
Title: "Test Titel", Title: "Test Titel",
Description: "Super nice video", Caption: "Super nice video",
Day: 10, Day: 10,
Country: "es", Country: "es",
Files: [ Files: [
@@ -1477,7 +1477,7 @@ describe("model/photo", () => {
const photo = new Photo(values); const photo = new Photo(values);
photo.Title = "New Title"; photo.Title = "New Title";
photo.Type = "newtype"; photo.Type = "newtype";
photo.Description = "New description"; photo.Caption = "New description";
photo.Day = 21; photo.Day = 21;
photo.Country = "de"; photo.Country = "de";
photo.CameraID = "newcameraid"; photo.CameraID = "newcameraid";
@@ -1498,7 +1498,7 @@ describe("model/photo", () => {
}); });
assert.equal(photo.Title, "New Title"); assert.equal(photo.Title, "New Title");
assert.equal(photo.Type, "newtype"); assert.equal(photo.Type, "newtype");
assert.equal(photo.Description, "New description"); assert.equal(photo.Caption, "New description");
assert.equal(photo.Day, 21); assert.equal(photo.Day, 21);
assert.equal(photo.Country, "de"); assert.equal(photo.Country, "de");
assert.equal(photo.CameraID, "newcameraid"); assert.equal(photo.CameraID, "newcameraid");
@@ -1518,7 +1518,7 @@ describe("model/photo", () => {
Lng: 3.3, Lng: 3.3,
CameraID: 123, CameraID: 123,
Title: "Test Titel", Title: "Test Titel",
Description: "Super nice video", Caption: "Super nice video",
Files: [ Files: [
{ {
UID: "fqbfk181n4ca5sud", UID: "fqbfk181n4ca5sud",
@@ -1539,7 +1539,7 @@ describe("model/photo", () => {
Lng: 3.3, Lng: 3.3,
CameraID: 123, CameraID: 123,
Title: "Test Titel", Title: "Test Titel",
Description: "Super nice video", Caption: "Super nice video",
Files: [ Files: [
{ {
UID: "fqbfk181n4ca5sud", UID: "fqbfk181n4ca5sud",

View File

@@ -250,6 +250,6 @@ describe("model/subject", () => {
it("should get model name", () => { it("should get model name", () => {
const result = Subject.getModelName(); const result = Subject.getModelName();
assert.equal(result, "Subject"); assert.equal(result, "Person");
}); });
}); });

View File

@@ -12,7 +12,7 @@ describe("model/thumb", () => {
UID: "55", UID: "55",
Title: "", Title: "",
TakenAtLocal: "", TakenAtLocal: "",
Description: "", Caption: "",
Favorite: false, Favorite: false,
Playable: false, Playable: false,
Width: 0, Width: 0,
@@ -51,7 +51,7 @@ describe("model/thumb", () => {
UID: "55", UID: "55",
Title: "", Title: "",
TakenAtLocal: "", TakenAtLocal: "",
Description: "", Caption: "",
Favorite: true, Favorite: true,
Playable: false, Playable: false,
Width: 0, Width: 0,
@@ -88,13 +88,13 @@ describe("model/thumb", () => {
Title: "Crazy Cat", Title: "Crazy Cat",
TakenAt: "2012-07-08T14:45:39Z", TakenAt: "2012-07-08T14:45:39Z",
TakenAtLocal: "2012-07-08T14:45:39Z", TakenAtLocal: "2012-07-08T14:45:39Z",
Description: "Nice description", Caption: "Nice description",
Favorite: true, Favorite: true,
}; };
const photo = new Photo(values2); const photo = new Photo(values2);
const result = Thumb.fromFile(photo, file); const result = Thumb.fromFile(photo, file);
assert.equal(result.UID, "5"); assert.equal(result.UID, "5");
assert.equal(result.Description, "Nice description"); assert.equal(result.Caption, "Nice description");
assert.equal(result.Width, 500); assert.equal(result.Width, 500);
const result2 = Thumb.fromFile(); const result2 = Thumb.fromFile();
assert.equal(result2.UID, ""); assert.equal(result2.UID, "");
@@ -106,7 +106,7 @@ describe("model/thumb", () => {
Title: "Crazy Cat", Title: "Crazy Cat",
TakenAt: "2012-07-08T14:45:39Z", TakenAt: "2012-07-08T14:45:39Z",
TakenAtLocal: "2012-07-08T14:45:39Z", TakenAtLocal: "2012-07-08T14:45:39Z",
Description: "Nice description", Caption: "Nice description",
Favorite: true, Favorite: true,
}; };
const photo = new Photo(values2); const photo = new Photo(values2);
@@ -116,7 +116,7 @@ describe("model/thumb", () => {
Title: "Crazy Cat", Title: "Crazy Cat",
TakenAt: "2012-07-08T14:45:39Z", TakenAt: "2012-07-08T14:45:39Z",
TakenAtLocal: "2012-07-08T14:45:39Z", TakenAtLocal: "2012-07-08T14:45:39Z",
Description: "Nice description", Caption: "Nice description",
Favorite: true, Favorite: true,
}; };
const photo2 = new Photo(values3); const photo2 = new Photo(values3);
@@ -126,7 +126,7 @@ describe("model/thumb", () => {
const values4 = { const values4 = {
ID: 8, ID: 8,
UID: "ABC123", UID: "ABC123",
Description: "Nice description 2", Caption: "Nice description 2",
Hash: "abc345", Hash: "abc345",
Files: [ Files: [
{ {
@@ -144,13 +144,13 @@ describe("model/thumb", () => {
const Photos2 = [photo, photo2, photo3]; const Photos2 = [photo, photo2, photo3];
const result2 = Thumb.fromFiles(Photos2); const result2 = Thumb.fromFiles(Photos2);
assert.equal(result2[0].UID, "ABC123"); assert.equal(result2[0].UID, "ABC123");
assert.equal(result2[0].Description, "Nice description 2"); assert.equal(result2[0].Caption, "Nice description 2");
assert.equal(result2[0].Width, 500); assert.equal(result2[0].Width, 500);
assert.equal(result2.length, 1); assert.equal(result2.length, 1);
const values5 = { const values5 = {
ID: 8, ID: 8,
UID: "ABC123", UID: "ABC123",
Description: "Nice description 2", Caption: "Nice description 2",
Hash: "abc345", Hash: "abc345",
Files: [ Files: [
{ {
@@ -169,7 +169,7 @@ describe("model/thumb", () => {
const result3 = Thumb.fromFiles(Photos3); const result3 = Thumb.fromFiles(Photos3);
assert.equal(result3.length, 1); assert.equal(result3.length, 1);
assert.equal(result3[0].UID, "ABC123"); assert.equal(result3[0].UID, "ABC123");
assert.equal(result3[0].Description, "Nice description 2"); assert.equal(result3[0].Caption, "Nice description 2");
assert.equal(result3[0].Width, 500); assert.equal(result3[0].Width, 500);
}); });
@@ -183,7 +183,7 @@ describe("model/thumb", () => {
const values = { const values = {
ID: 8, ID: 8,
UID: "ABC123", UID: "ABC123",
Description: "Nice description 3", Caption: "Nice description 3",
Hash: "345ggh", Hash: "345ggh",
Files: [ Files: [
{ {
@@ -200,12 +200,12 @@ describe("model/thumb", () => {
const photo = new Photo(values); const photo = new Photo(values);
const result = Thumb.fromPhoto(photo); const result = Thumb.fromPhoto(photo);
assert.equal(result.UID, "ABC123"); assert.equal(result.UID, "ABC123");
assert.equal(result.Description, "Nice description 3"); assert.equal(result.Caption, "Nice description 3");
assert.equal(result.Width, 500); assert.equal(result.Width, 500);
const values3 = { const values3 = {
ID: 8, ID: 8,
UID: "ABC124", UID: "ABC124",
Description: "Nice description 3", Caption: "Nice description 3",
}; };
const photo3 = new Photo(values3); const photo3 = new Photo(values3);
const result2 = Thumb.fromPhoto(photo3); const result2 = Thumb.fromPhoto(photo3);
@@ -216,7 +216,7 @@ describe("model/thumb", () => {
Title: "Crazy Cat", Title: "Crazy Cat",
TakenAt: "2012-07-08T14:45:39Z", TakenAt: "2012-07-08T14:45:39Z",
TakenAtLocal: "2012-07-08T14:45:39Z", TakenAtLocal: "2012-07-08T14:45:39Z",
Description: "Nice description", Caption: "Nice description",
Favorite: true, Favorite: true,
Hash: "xdf45m", Hash: "xdf45m",
}; };
@@ -224,14 +224,14 @@ describe("model/thumb", () => {
const result3 = Thumb.fromPhoto(photo2); const result3 = Thumb.fromPhoto(photo2);
assert.equal(result3.UID, "ABC123"); assert.equal(result3.UID, "ABC123");
assert.equal(result3.Title, "Crazy Cat"); assert.equal(result3.Title, "Crazy Cat");
assert.equal(result3.Description, "Nice description"); assert.equal(result3.Caption, "Nice description");
}); });
it("should test from photos", () => { it("should test from photos", () => {
const values = { const values = {
ID: 8, ID: 8,
UID: "ABC123", UID: "ABC123",
Description: "Nice description 3", Caption: "Nice description 3",
Hash: "345ggh", Hash: "345ggh",
Files: [ Files: [
{ {
@@ -249,7 +249,7 @@ describe("model/thumb", () => {
const Photos = [photo]; const Photos = [photo];
const result = Thumb.fromPhotos(Photos); const result = Thumb.fromPhotos(Photos);
assert.equal(result[0].UID, "ABC123"); assert.equal(result[0].UID, "ABC123");
assert.equal(result[0].Description, "Nice description 3"); assert.equal(result[0].Caption, "Nice description 3");
assert.equal(result[0].Width, 500); assert.equal(result[0].Width, 500);
}); });