-
Notifications
You must be signed in to change notification settings - Fork 18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added a new datatype named as "profile photo" as field type in Admin UI. #2546
Conversation
Deployed to https://pr-2546.aam-digital.net/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good and works well!
Two more related changes I would like to implement together with this:
- in the
config-fix.ts
file, change the "photo" attribute there to use the new dataType - in the
ConfigService
add an automatic migration for existing config
For the migration, have a look at how the other migration functions (e.g. the one for migrateEntityArrayDatatype
, which is similar). I have written a short unit test for this. Copy the code below into the config-service spec file and see if you can write a migration so that it passes?
it("should migrate to new photo dataType", fakeAsync(() => {
const config = new Config();
const oldFormat = {
attributes: {
myPhoto: {
dataType: "photo",
editComponent: "EditPhoto",
label: "My Photo",
},
},
};
const newFormat: EntityConfig = {
attributes: {
myPhoto: {
dataType: "file",
label: "My Photo",
},
},
};
config.data = { "entity:X": oldFormat };
updateSubject.next({ entity: config, type: "update" });
tick();
const actualFromOld = service.getConfig<EntityConfig>("entity:X");
expect(actualFromOld).toEqual(newFormat);
config.data = { "entity:X": newFormat };
updateSubject.next({ entity: config, type: "update" });
tick();
const actualFromNew = service.getConfig<EntityConfig>("entity:X");
expect(actualFromNew).toEqual(newFormat);
}));
2)Add an automatic migration for photodata type in config service.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So sorry, @sadaf895, I actually posted a wrong unit test for you to implement 🙄
The old (current) format and the new (to be migrated to) format were mixed up. I commented in the code now. Let me know if you have questions about it!
Your code and approach generally looks good, however.
Co-authored-by: Sebastian <sebastian@aam-digital.com>
Co-authored-by: Sebastian <sebastian@aam-digital.com>
Co-authored-by: Sebastian <sebastian@aam-digital.com>
Co-authored-by: Sebastian <sebastian@aam-digital.com>
Co-authored-by: Sebastian <sebastian@aam-digital.com>
src/app/core/basic-datatypes/number/display-percentage/percentage.datatype.ts
Outdated
Show resolved
Hide resolved
…age.datatype.ts Co-authored-by: Sebastian <sebastian@aam-digital.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good but the registration of percentage-datatype is missing (if you run the app you'll see errors).
src/app/core/basic-datatypes/number/display-percentage/percentage.datatype.ts
Outdated
Show resolved
Hide resolved
Co-authored-by: Sebastian <sebastian@aam-digital.com>
Co-authored-by: Sebastian <sebastian@aam-digital.com>
Co-authored-by: Sebastian <sebastian@aam-digital.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work! :-)
🎉 This PR is included in version 3.41.2-master.2 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
🎉 This PR is included in version 3.41.2 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
closes: #2503