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

[Bug]: Bulk action doesn't trigger a list refresh #1624

Open
bogmihut8 opened this issue Feb 12, 2024 · 1 comment
Open

[Bug]: Bulk action doesn't trigger a list refresh #1624

bogmihut8 opened this issue Feb 12, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@bogmihut8
Copy link

Contact Details

No response

What happened?

I have implemented a bulk action that should just update a flag in the db object. Everything works as expected, but after action returns the success, it doesn't trigger a list refresh. Any idea what is missing here?

Thanks!

Bug prevalence

While developing the bulk action

AdminJS dependencies version

"@adminjs/express": "^6.1.0",
"@adminjs/mongoose": "^4.0.0",
"@adminjs/themes": "^1.0.1",
"@adminjs/upload": "^4.0.1",
"adminjs": "^7.4.1",

What browsers do you see the problem on?

No response

Relevant log output

No response

Relevant code that's giving you issues

updateMultipleDiscount15: {
    actionType: 'bulk',
    method: 'post',
    icon: 'Percent',
    label: 'Set selected discount 15%',
    component: false,
    handler: async (request, response, data) => {
      const { records, currentAdmin } = data;

      try {
        await Product.updateMany(
          { _id: { $in: request.query.recordIds.split(',') } },
          { $set: { discount15: true, discount25: false, discount50: false } },
          { new: true }
        );

        return {
          records: records.map(record => record.toJSON(currentAdmin)),
          notice: {
            message: 'Discount updated successfully',
            type: 'success',
          },
          redirectUrl: '/admin/resources/Produse',
        };
      } catch (error) {
        return {
          records,
          notice: {
            message: `Error updating discount: ${error.message}`,
            type: 'error',
          },
        };
      }
    },
  },
@bogmihut8 bogmihut8 added the bug Something isn't working label Feb 12, 2024
@tamertwitter
Copy link

maybe you imagine a new idea
#1634

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants