Skip to content
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

Merged
merged 26 commits into from
Sep 4, 2024

Conversation

sadaf895
Copy link
Contributor

@sadaf895 sadaf895 commented Aug 28, 2024

closes: #2503

Copy link

Deployed to https://pr-2546.aam-digital.net/

Copy link
Member

@sleidig sleidig left a 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);
  }));

@sleidig sleidig linked an issue Aug 29, 2024 that may be closed by this pull request
3 tasks
2)Add an automatic migration for photodata type in config service.
Copy link
Member

@sleidig sleidig left a 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.

src/app/core/config/config-fix.ts Outdated Show resolved Hide resolved
src/app/core/config/config.service.spec.ts Outdated Show resolved Hide resolved
src/app/core/config/config.service.spec.ts Outdated Show resolved Hide resolved
src/app/core/config/config.service.spec.ts Outdated Show resolved Hide resolved
src/app/core/config/config.service.ts Outdated Show resolved Hide resolved
sadaf895 and others added 8 commits September 2, 2024 19:46
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>
Copy link
Member

@sleidig sleidig left a 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/config/config-fix.ts Outdated Show resolved Hide resolved
src/app/core/config/config-fix.ts Outdated Show resolved Hide resolved
src/app/core/config/config.service.spec.ts Outdated Show resolved Hide resolved
src/app/core/config/config.service.spec.ts Outdated Show resolved Hide resolved
src/app/features/file/file.module.ts Show resolved Hide resolved
sadaf895 and others added 4 commits September 4, 2024 17:45
Co-authored-by: Sebastian <sebastian@aam-digital.com>
Co-authored-by: Sebastian <sebastian@aam-digital.com>
Co-authored-by: Sebastian <sebastian@aam-digital.com>
@sleidig sleidig marked this pull request as ready for review September 4, 2024 13:37
Copy link
Member

@sleidig sleidig left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work! :-)

@sleidig sleidig merged commit 482feae into master Sep 4, 2024
13 checks passed
@sleidig sleidig deleted the Setup_Wizard branch September 4, 2024 14:27
@aam-digital-ci
Copy link
Collaborator

🎉 This PR is included in version 3.41.2-master.2 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

@aam-digital-ci aam-digital-ci added the released on @master managed by CI (semantic-release) label Sep 4, 2024
@aam-digital-ci
Copy link
Collaborator

🎉 This PR is included in version 3.41.2 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

@aam-digital-ci aam-digital-ci added the released managed by CI (semantic-release) label Sep 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
released on @master managed by CI (semantic-release) released managed by CI (semantic-release)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

"photo" datatype not available as field type in Admin UI yet
4 participants