Skip to content

Implement Reset Hits feature to Weblinks#590

Merged
joomdonation merged 8 commits intojoomla-extensions:5.x-devfrom
mahmoudmagdy1-1:reset_counter
Apr 12, 2025
Merged

Implement Reset Hits feature to Weblinks#590
joomdonation merged 8 commits intojoomla-extensions:5.x-devfrom
mahmoudmagdy1-1:reset_counter

Conversation

@mahmoudmagdy1-1
Copy link
Copy Markdown
Contributor

Pull Request for Issue #475 .

Summary of Changes

This pull request adds a "Reset Hits" feature to the Joomla Weblinks admin interface when editing a weblink. It adds a new button in the Publishing tab to reset a weblink’s hit counter to zero.

Screencast.from.03-25-2025.03.14.31.PM.webm

Testing Instructions

  1. Login as Administrator
  2. Turn on counter clicks from the global configuration for weblinks extension
  3. Create a test weblink as an admin
  4. Increment the counter from visiting the links in the frontend
  5. Edit the test weblink as an admin and hit the "Reset Hits"

Expected result

Clicking "Reset Hits" when editing a weblink in the 'Publishing' tab sets the weblink’s hit count to 0.

Actual result

There was no option to reset the hits counter.

Documentation Changes Required

@alikon
Copy link
Copy Markdown
Collaborator

alikon commented Mar 26, 2025

@mahmoudmagdy1-1
please move this pr on the new branch 5.x-dev cause is a new feature

thanks in advance

@mahmoudmagdy1-1 mahmoudmagdy1-1 changed the base branch from 4.0-dev to 5.x-dev March 26, 2025 07:58
@alikon
Copy link
Copy Markdown
Collaborator

alikon commented Mar 26, 2025

i don't like where the button reset hit it is placed, it should be on the toolbar

@mahmoudmagdy1-1
Copy link
Copy Markdown
Contributor Author

i don't like where the button reset hit it is placed, it should be on the toolbar

Screenshot from 2025-03-26 18-56-49
you mean right here maybe?

@alikon
Copy link
Copy Markdown
Collaborator

alikon commented Mar 26, 2025

yes exaclty, cause i think it's much more "family feeling"

@suhaib-ilahi suhaib-ilahi mentioned this pull request Mar 28, 2025
@mahmoudmagdy1-1 mahmoudmagdy1-1 force-pushed the reset_counter branch 2 times, most recently from bffe665 to a0b3984 Compare March 28, 2025 22:53
@mahmoudmagdy1-1
Copy link
Copy Markdown
Contributor Author

mahmoudmagdy1-1 commented Mar 28, 2025

The latest changes I've made changes the button position and it handles the cases that if the weblinks user have set their Count Clicks in the Global Configuation for Weblinks to Off or if the user is making a new weblink, they wouldn't see the button, this is the final result on the front end

image

The build kept failing so I fixed it and force pushed the commits back to keep the commit history clean, is there an issue with that or that is fine?

@alikon
Copy link
Copy Markdown
Collaborator

alikon commented Mar 29, 2025

you can override the setting of Global Configuration for Weblinks in the weblink item options

image

so we should not show the reset button if is set to NO in the weblink item options, like is done for the Global Configuration

and in the other way around

@mahmoudmagdy1-1
Copy link
Copy Markdown
Contributor Author

so we should not show the reset button if is set to NO in the weblink item options, like is done for the Global Configuration

and in the other way around

It should be able to handle this case now

Copy link
Copy Markdown
Contributor

@joomdonation joomdonation left a comment

Choose a reason for hiding this comment

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

Thanks for working on this. There are some changes needed. See below:

@mahmoudmagdy1-1
Copy link
Copy Markdown
Contributor Author

Thanks for the feedback I really appreciate it, I just addressed the issues you mentioned,
Should I add comments inside those functions? or just stick with the docblock only?

@alikon
Copy link
Copy Markdown
Collaborator

alikon commented Apr 6, 2025

me and @joomdonation have had a discussion about this pull request, and we come to the conclusion that it would better, to put the reset hit button like it has been done for the banners component, sorry for my previuos comment to move the button on the toolbar i've forgot about banners

image

@joomdonation
Copy link
Copy Markdown
Contributor

Also, you made too many unnecessary docblock changes in the PR. Please revert all the changes you made to docblock in this PR. For example, for @param spaces, we use the following rules:

  • Between tag and type: 3 spaces
  • Between type and name: 2 spaces
  • Between name and description: 2 space

@alikon alikon added this to the Weblinks 5.0.0 milestone Apr 6, 2025
@mahmoudmagdy1-1
Copy link
Copy Markdown
Contributor Author

me and @joomdonation have had a discussion about this pull request, and we come to the conclusion that it would better, to put the reset hit button like it has been done for the banners component

I didn't know about this, thanks for mentioning it, now after the latest changes I changed the implementation to match the banners component's reset

Also, you made too many unnecessary docblock changes in the PR. Please revert all the changes you made to docblock in this PR. For example, for @param spaces, we use the following rules:

Sorry, I just reverted those changes, thanks for letting me know.

@alikon
Copy link
Copy Markdown
Collaborator

alikon commented Apr 7, 2025

i'm afraid you have removed too much needed files, please check

@mahmoudmagdy1-1
Copy link
Copy Markdown
Contributor Author

i'm afraid you have removed too much needed files, please check

Screencast.from.04-07-2025.09.54.15.AM.webm

It works for me, can you tell me what exactly is not working for you?

@joomdonation
Copy link
Copy Markdown
Contributor

Guess it is because you have old modified files left in your installation. Please check the modified files for your PR https://github.com/joomla-extensions/weblinks/pull/590/files , you removed the changes you made in model, controller classes, so the change was lost and won't work anymore.

@mahmoudmagdy1-1
Copy link
Copy Markdown
Contributor Author

mahmoudmagdy1-1 commented Apr 7, 2025

you removed the changes you made in model, controller classes, so the change was lost and won't work anymore.

The old changes are no longer needed

After debugging now from a fresh install I see why it doesn't work for you, The issue lies within the com_patchtester (it's the same issue i made this pr for joomla-extensions/patchtester#376), The issue is caused because the changes I made contain another "src"
pic
so that's why it doesn't actually apply that change in the joomla-cms, hence why you aren't seeing the changes

@alikon
Copy link
Copy Markdown
Collaborator

alikon commented Apr 7, 2025

i can confirm it works fine
for those want to test the pr with com_patchtester this pr joomla-extensions/patchtester#376 must be applied before

@mahmoudmagdy1-1
Copy link
Copy Markdown
Contributor Author

@joomdonation please take a look when you have time

@joomdonation joomdonation merged commit 2c61880 into joomla-extensions:5.x-dev Apr 12, 2025
1 check passed
@joomdonation
Copy link
Copy Markdown
Contributor

Thanks @mahmoudmagdy1-1 for your work. I expected to have server side code to reset hits of weblink item, not just a litle javascript code to reset value of hits input. By removing unset filter for the field, it opens the door to allow admin to manual adjust the value of Hits (for example, inspect element and change the value manually)

But maybe it is not that important to prevent that behavior, so we will accept this change for now.

Thanks again and sorry for slow getting back to you, I'm quite busy these days. Looking forward to seeing other improvements from you.

@mahmoudmagdy1-1
Copy link
Copy Markdown
Contributor Author

Thanks @mahmoudmagdy1-1 for your work. I expected to have server side code to reset hits of weblink item
But maybe it is not that important to prevent that behavior, so we will accept this change for now.

No problem, Yes I've noticed that but that's how is the reset button is implemented in other components, maybe we will fix this behavior in the future,

Thanks again and sorry for slow getting back to you, I'm quite busy these days. Looking forward to seeing other improvements from you.

It's Okay, Thanks for taking the time to review and giving me feedback :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants