Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

February Developer Challenge - CAP Plugins: Week 3

thomas_jung
Developer Advocate
Developer Advocate

If you missed week 1, you could find all the details: here
If you missed week 2, you could find all the details: here

Now that the challenge is complete: here is my sample solution: jung-thomas/dev-challenge-feb-2024: Developer Challenge February 2024 (github.com)

For this week's challenge we are going to mix things up. Week 1 and week 2 both focused on extending the protocol or version of service endpoints. This week we will use a plugin that has a completely different purpose. We are going use the Change Tracking plugin. This plugin both extends the data model and the Fiori UI automatically. It stores change history information, exposes it within our service and adds a Change History UI element to our Fiori application; all with extremely minimal effort on your part!

Your Task this week

The Change Tracking plugin provides out-of-the box support for automated capturing, storing, and viewing of the change records of modeled entities. All we need is to add @changelog annotations to your models to indicate which entities and elements should be change-tracked.

https://github.com/cap-js/change-tracking

Your task is to add change tracking to the Books entity and the Title attribute in your application.

To complete the challenge, post a screenshot of the Fiori UI for managing Books with the Change History with a change entry displayed. 

changeHistory1.png

Bonus 1: Add change tracking to the Books.Author association. However, don't display the unique ID when the association is changed. Instead, the change log should record and display the Author Name.
changeHistory2.png

39 REPLIES 39

satya-dev
Participant

here is my submission
I changed the stock and price.  

satyadev_0-1708538293400.png

 

Ruthiel
Product and Topic Expert
Product and Topic Expert

Hello!
Someone with this issue when trying to access the 'Managing Books' UI?

Ruthiel_0-1708562278546.png

 

This is because the admin service requires an admin user. 

brunonalon_0-1708566965395.png

You can just remove this or create a mock user with an admin role. 

Ruthiel
Product and Topic Expert
Product and Topic Expert

Thank you very much Bruno for your precious help!
I could complete successfully the week:

Ruthiel_0-1708596758321.png

 

0 Kudos

Or you can use the built in mock user of ‘Alice’ - no password. https://cap.cloud.sap/docs/node.js/authentication#mock-users

smok1
Explorer

Alpesa1990
Participant

ajmaradiaga
Developer Advocate
Developer Advocate

I added weights to the heights 🙂

ajmaradiaga_0-1708601076575.png

Really cool plugin!

 

qmacro
Developer Advocate
Developer Advocate

Main task: showing change tracking of the Books entity's title element:

Screenshot 2024-02-22 at 12.05.39.png

Bonus: showing change tracking of the Books entity's author element, but ensuring that the value of the name element from the Association to Authors is shown, rather than just the ID from the managed association's foreign key field (author_ID):

Screenshot 2024-02-22 at 12.09.18.png

qmacro
Developer Advocate
Developer Advocate

OK folks, so how many of you here went for the beautiful approach that CAP offers, moreover _encourages_, which is the ability to separate concerns?

In other words, who annotated the definitions in `db/schema.cds` directly, and who created a separate new CDS file and used the `annotate` directive (https://cap.cloud.sap/docs/cds/cdl#the-annotate-directive)? @thomas_jung @ajmaradiaga and I would love to know! 

100% in a separate srv/change-tracking.cds

I have annotated the definitions directly in schema.cds but I guess it is not the best practice 😂 I´m going to separte it in two files...

ajmaradiaga
Developer Advocate
Developer Advocate

I did it in a separate file 🙂 I was about to paste an image but realised that that will give away the answer haha

 

thomas_jung
Developer Advocate
Developer Advocate

I actually did it in the same file.  While I follow the concept of the separation of concerns, I don't do it as strictly has some do. I don't immediately put all annotations in a separate file. If the annotation impacts the data model; I actually like it to be as close to the data model definition as possible. Now, clearly UI annotations I always separate out. 

With one exception; the annotation for value help.  I feel like those belong in the data model although they certainly impact the UI.  It's also about reuse and inheritance.  Putting annotations like the value help into the data model ensures that they are available even if there are multiple different UIs built via annotations on that same model. This also might be my ABAP background where value help definitions are data dictionary objects and often tied in via the database table or structure.

I did have to stop and think about this particular annotation because it impacts both data model and UI. But ultimately, I thought in the future I'd more likely want to see which fields are marked for change tracking when I'm working with the data model itself. 

I love the flexibility that CAP provides to allow for these different use cases and how one development group or company might adjust their own rules for what works best for them. 

On a side note, this approach with separate files for annotations isn't just about separation of concerns of different layers but can also support reuse (as mentioned) and target platform specific logic.  For instance, when you need HANA specific features you can have build rules that include only certain folders. But perhaps that's a topic for another day or another challenge.   

SandipAgarwalla
Active Contributor

Cool plug-in. These developer challege series are always fun to do and new learnings. 

Week 3 & Bonus

SandipAgarwalla_1-1708695843104.png

I added the annotations in a separate cds file, as per the help documentation. 

Thanks

Bonus

 

 

MeriemSouissi
Participant

Hi,

 

here is my week 3 results :

MeriemSouissi_1-1708803530947.png

Bonus

MeriemSouissi_0-1708803520177.png

 

gu_marti_paulo87
Discoverer

My submission for this week's challenge and bonus

image.png

tobiasz_h
Active Participant

Hello,
Here is the task and bonus:

tobiasz_h_0-1708936074296.png

 

Cmdd
Participant

This is current week task ....

Cmdd_0-1708953117055.jpeg

...and the bonus part!

Cmdd_1-1708953146399.jpeg

 

 

NicholasB
Product and Topic Expert
Product and Topic Expert

RameshShrestha
Contributor

Finally catching up till week 3.

RameshShrestha_0-1709210266844.png

 

 

With Regards,

Ramesh Shrestha

 

Nagarajan-K
Explorer

Task & Bonus. Played around with @title and @Common.Label as well for fun.

NK2005_0-1709241422310.png

sabarna17
Contributor

The funny thing is, I have changed the description, and it's coming all over the screen. Is there any CDS UI annotate to squeeze the column height and display?

** Bonus Included

sabarna17_0-1709374463607.png

 

 

codebrokerad
Participant

spassaro
Participant

Kaustav
Discoverer