uvdesk / core-framework

UVDesk Community Helpdesk Core Framework Bundle providing the core essential functionalities and integration tools to easily integrate any other community helpdesk packages.
https://www.uvdesk.com
MIT License
60 stars 50 forks source link

Saved Replies Not Showing in Backend #567

Open acceleratemedia opened 2 years ago

acceleratemedia commented 2 years ago

Description
When visiting the route '/member/saved-replies' to the backend application, I am not seeing any saved replies showing in the list. There are 22 in my database.

How to reproduce
I am not exactly sure the steps to reproduce this. But, I think it has something to do with the fact that on my installation the saved replies being shared with a group that my user is in. I would try to do it by adding the admin user to the default group, and having it create several saved replies, some in shared with the default group and some not. It might also require creating other admin users and adding them to the default group.

Possible Solution
The issue is right here (https://github.com/uvdesk/core-framework/blob/master/Controller/SavedReplies.php#L34)

The list generated for my user has some duplicates in it. I think this is a result of some replies being owned by the user AND those same replies being shared with a group the user is in. Using array_unique creates an array where the keys are no longer sequential. Then, since the array keys are no longer sequential, the twig template converts that array of keys into a JSON object here (https://github.com/uvdesk/core-framework/blob/master/Resources/views/savedRepliesList.html.twig#L200). That JSON object lacks a length property which causes the for loop to not proceed.

The problem is solved for me by changing line 34 in SavedReplies.php to the following:

            'savedReplyReferenceIds' => array_values(array_unique($savedReplyReferenceIds))
komal-sh-27 commented 2 years ago

@acceleratemedia

Can you please brief your query so we can understand what is the issue? Please let us know if your issue is solved or not?

acceleratemedia commented 2 years ago

@Komal-sharma-2712 I apologize but I'm not sure what 'brief your query' means. If you can explain a bit more I can respond to that.

I can confirm on my copy that changing (https://github.com/uvdesk/core-framework/blob/master/Controller/SavedReplies.php#L34) from:

            'savedReplyReferenceIds' => array_unique($savedReplyReferenceIds),

to:

            'savedReplyReferenceIds' => array_values(array_unique($savedReplyReferenceIds))

fixes the issue for me.

komal-sh-27 commented 2 years ago

@acceleratemedia

What steps are you follow for this issue? If you are not facing this issue so we are closing this issue.

Thank you

acceleratemedia commented 2 years ago

I don't understand - you're closing the issue without making the necessary changes to the code that fix the issue?

To fix the issue, I had to hack the file I mentioned above in the /vendor/ folder. This means if/when I update via composer I'm going to have to re-hack the file to solve the problem again.

If you don't change this line where I pointed out above (https://github.com/uvdesk/core-framework/blob/master/Controller/SavedReplies.php#L34) the issue is not fixed.

papnoisanjeev commented 2 years ago

@acceleratemedia

Please mention all steps you have done so far as normally agents and admin able to see listing of saved replies (individual saved replies and based on group as well) with latest release of project.

Please let us know all the steps you have done so that we can reproduce and fix the issue soon.