From a9645b532b22c788a48c5da33d34b69e666309d8 Mon Sep 17 00:00:00 2001 From: Michael Mayer Date: Fri, 17 Jan 2025 09:27:34 +0100 Subject: [PATCH] People: Fix edit dialog save button in people/dialog/edit.vue #3168 Signed-off-by: Michael Mayer --- frontend/src/component/components.js | 4 +-- .../{subject => people}/clipboard.vue | 4 +-- frontend/src/component/people/dialog/edit.vue | 1 + frontend/src/model/subject.js | 2 +- frontend/src/page/people/recognized.vue | 9 ++--- frontend/tests/unit/fixtures.js | 26 +++----------- frontend/tests/unit/model/photo_test.js | 12 +++---- frontend/tests/unit/model/subject_test.js | 2 +- frontend/tests/unit/model/thumb_test.js | 34 +++++++++---------- 9 files changed, 40 insertions(+), 54 deletions(-) rename frontend/src/component/{subject => people}/clipboard.vue (97%) diff --git a/frontend/src/component/components.js b/frontend/src/component/components.js index 01368afb5..da6ad04b4 100644 --- a/frontend/src/component/components.js +++ b/frontend/src/component/components.js @@ -45,7 +45,7 @@ import PLabelEditDialog from "label/dialog/edit.vue"; // People. import PPeopleMergeDialog from "people/dialog/merge.vue"; import PPeopleEditDialog from "people/dialog/edit.vue"; -import PSubjectClipboard from "subject/clipboard.vue"; +import PPeopleClipboard from "component/people/clipboard.vue"; // Photos. import PPhotoCards from "photo/view/cards.vue"; @@ -105,7 +105,7 @@ export function install(app) { app.component("PPeopleMergeDialog", PPeopleMergeDialog); app.component("PPeopleEditDialog", PPeopleEditDialog); - app.component("PSubjectClipboard", PSubjectClipboard); + app.component("PPeopleClipboard", PPeopleClipboard); app.component("PPhotoCards", PPhotoCards); app.component("PPhotoMosaic", PPhotoMosaic); diff --git a/frontend/src/component/subject/clipboard.vue b/frontend/src/component/people/clipboard.vue similarity index 97% rename from frontend/src/component/subject/clipboard.vue rename to frontend/src/component/people/clipboard.vue index 5be00dbd6..5ac477c01 100644 --- a/frontend/src/component/subject/clipboard.vue +++ b/frontend/src/component/people/clipboard.vue @@ -4,7 +4,7 @@
- + @@ -253,8 +253,7 @@ export default { } const existing = this.$config.getPerson(m.Name); - - if (!existing) { + if (!existing || existing.UID === m.UID) { this.busy = true; m.update() .then((m) => { @@ -263,10 +262,12 @@ export default { }) .finally(() => { this.busy = false; + this.dialog.edit = false; }); - } else if (existing.UID !== m.UID) { + } else { this.merge.subj1 = m; this.merge.subj2 = existing; + this.dialog.edit = false; this.merge.show = true; } }, diff --git a/frontend/tests/unit/fixtures.js b/frontend/tests/unit/fixtures.js index fed952fdf..021ab8e30 100644 --- a/frontend/tests/unit/fixtures.js +++ b/frontend/tests/unit/fixtures.js @@ -36,11 +36,7 @@ const putEntityResponse = { }; const deleteEntityResponse = null; -Mock.onPost("api/v1/users/urii20d30w2wqzjf/profile").reply( - 200, - { DisplayName: "Max New" }, - mockHeaders -); +Mock.onPost("api/v1/users/urii20d30w2wqzjf/profile").reply(200, { DisplayName: "Max New" }, 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/123").reply(200, getEntityResponse, mockHeaders); @@ -124,11 +120,7 @@ Mock.onPut("api/v1/photos/pqbemz8276mhtobh/label/12345", { Label: { Name: "Somme }, mockHeaders ); -Mock.onDelete("api/v1/photos/pqbemz8276mhtobh/label/12345").reply( - 200, - { success: "ok" }, - mockHeaders -); +Mock.onDelete("api/v1/photos/pqbemz8276mhtobh/label/12345").reply(200, { success: "ok" }, mockHeaders); Mock.onPost("api/v1/session").reply( 200, @@ -169,13 +161,9 @@ Mock.onGet("api/v1/session/5aa770f2a1ef431628d9f17bdf82a0d16865e99d4a1ddd9356e1a mockHeaders ); -Mock.onDelete( - "api/v1/session/5aa770f2a1ef431628d9f17bdf82a0d16865e99d4a1ddd9356e1aabfe6464683" -).reply(200); +Mock.onDelete("api/v1/session/5aa770f2a1ef431628d9f17bdf82a0d16865e99d4a1ddd9356e1aabfe6464683").reply(200); -Mock.onDelete( - "api/v1/session/a9b8ff820bf40ab451910f8bbfe401b2432446693aa539538fbd2399560a722f" -).reply(200); +Mock.onDelete("api/v1/session/a9b8ff820bf40ab451910f8bbfe401b2432446693aa539538fbd2399560a722f").reply(200); Mock.onGet("api/v1/settings").reply(200, { download: true, language: "de" }, 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.onPut("api/v1/users/54/password").reply( - 200, - { password: "old", new_password: "new" }, - mockHeaders -); +Mock.onPut("api/v1/users/54/password").reply(200, { password: "old", new_password: "new" }, mockHeaders); Mock.onGet("api/v1/link/5").reply(200, "get success", mockHeaders); Mock.onPut("api/v1/link/5").reply(200, "put success", mockHeaders); diff --git a/frontend/tests/unit/model/photo_test.js b/frontend/tests/unit/model/photo_test.js index 6d987e47f..a68e1bfac 100644 --- a/frontend/tests/unit/model/photo_test.js +++ b/frontend/tests/unit/model/photo_test.js @@ -1200,7 +1200,7 @@ describe("model/photo", () => { Name: "_MG_9509", OriginalName: "", Title: "Unknown / 2018", - Description: "", + Caption: "", Year: 2018, Month: 10, Day: 5, @@ -1451,7 +1451,7 @@ describe("model/photo", () => { Lng: 3.3, CameraID: 123, Title: "Test Titel", - Description: "Super nice video", + Caption: "Super nice video", Day: 10, Country: "es", Files: [ @@ -1477,7 +1477,7 @@ describe("model/photo", () => { const photo = new Photo(values); photo.Title = "New Title"; photo.Type = "newtype"; - photo.Description = "New description"; + photo.Caption = "New description"; photo.Day = 21; photo.Country = "de"; photo.CameraID = "newcameraid"; @@ -1498,7 +1498,7 @@ describe("model/photo", () => { }); assert.equal(photo.Title, "New Title"); 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.Country, "de"); assert.equal(photo.CameraID, "newcameraid"); @@ -1518,7 +1518,7 @@ describe("model/photo", () => { Lng: 3.3, CameraID: 123, Title: "Test Titel", - Description: "Super nice video", + Caption: "Super nice video", Files: [ { UID: "fqbfk181n4ca5sud", @@ -1539,7 +1539,7 @@ describe("model/photo", () => { Lng: 3.3, CameraID: 123, Title: "Test Titel", - Description: "Super nice video", + Caption: "Super nice video", Files: [ { UID: "fqbfk181n4ca5sud", diff --git a/frontend/tests/unit/model/subject_test.js b/frontend/tests/unit/model/subject_test.js index f5eef8028..90591dfa8 100644 --- a/frontend/tests/unit/model/subject_test.js +++ b/frontend/tests/unit/model/subject_test.js @@ -250,6 +250,6 @@ describe("model/subject", () => { it("should get model name", () => { const result = Subject.getModelName(); - assert.equal(result, "Subject"); + assert.equal(result, "Person"); }); }); diff --git a/frontend/tests/unit/model/thumb_test.js b/frontend/tests/unit/model/thumb_test.js index 946789e0d..68684835f 100644 --- a/frontend/tests/unit/model/thumb_test.js +++ b/frontend/tests/unit/model/thumb_test.js @@ -12,7 +12,7 @@ describe("model/thumb", () => { UID: "55", Title: "", TakenAtLocal: "", - Description: "", + Caption: "", Favorite: false, Playable: false, Width: 0, @@ -51,7 +51,7 @@ describe("model/thumb", () => { UID: "55", Title: "", TakenAtLocal: "", - Description: "", + Caption: "", Favorite: true, Playable: false, Width: 0, @@ -88,13 +88,13 @@ describe("model/thumb", () => { Title: "Crazy Cat", TakenAt: "2012-07-08T14:45:39Z", TakenAtLocal: "2012-07-08T14:45:39Z", - Description: "Nice description", + Caption: "Nice description", Favorite: true, }; const photo = new Photo(values2); const result = Thumb.fromFile(photo, file); assert.equal(result.UID, "5"); - assert.equal(result.Description, "Nice description"); + assert.equal(result.Caption, "Nice description"); assert.equal(result.Width, 500); const result2 = Thumb.fromFile(); assert.equal(result2.UID, ""); @@ -106,7 +106,7 @@ describe("model/thumb", () => { Title: "Crazy Cat", TakenAt: "2012-07-08T14:45:39Z", TakenAtLocal: "2012-07-08T14:45:39Z", - Description: "Nice description", + Caption: "Nice description", Favorite: true, }; const photo = new Photo(values2); @@ -116,7 +116,7 @@ describe("model/thumb", () => { Title: "Crazy Cat", TakenAt: "2012-07-08T14:45:39Z", TakenAtLocal: "2012-07-08T14:45:39Z", - Description: "Nice description", + Caption: "Nice description", Favorite: true, }; const photo2 = new Photo(values3); @@ -126,7 +126,7 @@ describe("model/thumb", () => { const values4 = { ID: 8, UID: "ABC123", - Description: "Nice description 2", + Caption: "Nice description 2", Hash: "abc345", Files: [ { @@ -144,13 +144,13 @@ describe("model/thumb", () => { const Photos2 = [photo, photo2, photo3]; const result2 = Thumb.fromFiles(Photos2); 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.length, 1); const values5 = { ID: 8, UID: "ABC123", - Description: "Nice description 2", + Caption: "Nice description 2", Hash: "abc345", Files: [ { @@ -169,7 +169,7 @@ describe("model/thumb", () => { const result3 = Thumb.fromFiles(Photos3); assert.equal(result3.length, 1); 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); }); @@ -183,7 +183,7 @@ describe("model/thumb", () => { const values = { ID: 8, UID: "ABC123", - Description: "Nice description 3", + Caption: "Nice description 3", Hash: "345ggh", Files: [ { @@ -200,12 +200,12 @@ describe("model/thumb", () => { const photo = new Photo(values); const result = Thumb.fromPhoto(photo); assert.equal(result.UID, "ABC123"); - assert.equal(result.Description, "Nice description 3"); + assert.equal(result.Caption, "Nice description 3"); assert.equal(result.Width, 500); const values3 = { ID: 8, UID: "ABC124", - Description: "Nice description 3", + Caption: "Nice description 3", }; const photo3 = new Photo(values3); const result2 = Thumb.fromPhoto(photo3); @@ -216,7 +216,7 @@ describe("model/thumb", () => { Title: "Crazy Cat", TakenAt: "2012-07-08T14:45:39Z", TakenAtLocal: "2012-07-08T14:45:39Z", - Description: "Nice description", + Caption: "Nice description", Favorite: true, Hash: "xdf45m", }; @@ -224,14 +224,14 @@ describe("model/thumb", () => { const result3 = Thumb.fromPhoto(photo2); assert.equal(result3.UID, "ABC123"); assert.equal(result3.Title, "Crazy Cat"); - assert.equal(result3.Description, "Nice description"); + assert.equal(result3.Caption, "Nice description"); }); it("should test from photos", () => { const values = { ID: 8, UID: "ABC123", - Description: "Nice description 3", + Caption: "Nice description 3", Hash: "345ggh", Files: [ { @@ -249,7 +249,7 @@ describe("model/thumb", () => { const Photos = [photo]; const result = Thumb.fromPhotos(Photos); 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); });