Change data from response in the Angular

54 views
Skip to first unread message

Milan Majchrak

unread,
Apr 13, 2022, 10:54:51 AM4/13/22
to DSpace Developers
Hi all,

I customize the Angular code and I'm facing to some issues, thank you for your answers,.

Problem:
For some new Items we do not know issued date and we just approximate it. If the issued  date  is approximate we store that value in the custom metadata field local.approximateDate.issued. And if the date is approximate we need to show that date in the Item view instead of issued date.
Simply said if approximate date is not null show that value instead of issued date in the Item view.

My procedure:
I was trying to modify Angular code to add decision logic there but I fear that is not right way of thinking.
I modified the class item-page.resolver.ts method resolve to catch response which has data which are showed in the Item view.
First I was trying to change RemoteData<Item> object in the map() function but it throws error that object is only readable.
Second I solved that problem by creating a copy of the response object and modified it as I need. But I fear that is not the right way too, because I modified the object which is primary readable.
Updated method resolve: mail.PNG

My questions:
- Is the right way of thinking to change Angular code when I need to add some decision logic for showing data? Or it must be done only in the BE and Angular is strictly used only for showing the data?
- If changing Angular code is not such bad idea what is the right way of changing RemoteObject<Item> or some response object? Was creating a copy of the response object a good idea?

Thank you very much!

Milan Majchrak 
dataquest s.r.o.
Reply all
Reply to author
Forward
0 new messages