From 68644a3a958874b1bac939cde6f09b2a238406bf Mon Sep 17 00:00:00 2001 From: ThorstenSuckow Date: Sat, 11 Jun 2022 18:47:49 +0200 Subject: [PATCH] refactor: responses for GET MailAccounts consider updated rest-api-email refs conjoon/php-lib-conjoon#8 --- src/model/mail/account/MailAccount.js | 7 ++++++- tests/src/model/mail/account/MailAccountTest.js | 12 +++++++++++- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/src/model/mail/account/MailAccount.js b/src/model/mail/account/MailAccount.js index 9b7420fc..b03ea74d 100644 --- a/src/model/mail/account/MailAccount.js +++ b/src/model/mail/account/MailAccount.js @@ -93,7 +93,12 @@ Ext.define("conjoon.cn_mail.model.mail.account.MailAccount", { }, { name: "outbox_secure", type: "string" - }], + }].map(field => { + if (!["id", "type"].includes(field.name)) { + field.mapping = `attributes.${field.name}`; + } + return field; + }), /** * Overriden to make sure we can specify class statics for values of diff --git a/tests/src/model/mail/account/MailAccountTest.js b/tests/src/model/mail/account/MailAccountTest.js index a23e5cd3..b956d1df 100644 --- a/tests/src/model/mail/account/MailAccountTest.js +++ b/tests/src/model/mail/account/MailAccountTest.js @@ -1,7 +1,7 @@ /** * conjoon * extjs-app-webmail - * Copyright (C) 2017-2021 Thorsten Suckow-Homberg https://github.com/conjoon/extjs-app-webmail + * Copyright (C) 2017-2022 Thorsten Suckow-Homberg https://github.com/conjoon/extjs-app-webmail * * Permission is hereby granted, free of charge, to any person * obtaining a copy of this software and associated documentation @@ -91,4 +91,14 @@ StartTest(t => { }); + t.it("test mappings php-lib-conjoon#8", t => { + + model.fields.forEach(field => { + if (field.getName() !== "id" && Object.prototype.hasOwnProperty.call(field, "definedBy")) { + t.expect(field.getMapping()).toBe(`attributes.${field.getName()}`); + } + }); + + }); + });