question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

What's the suggested way of providing parameters for bulk actions?

See original GitHub issue

Let’s say I have an integer column and would like to use @action to change all the values to a new one, i.e. I need a intermediate page to be able the type in the new value. Any hints on how this can be done easiest?

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
daimon99commented, Dec 31, 2015

I do it this way, using js.

{% extends 'admin/model/list.html' %}
{% block list_row_actions %}
    {{ super() }}
{% endblock %}

{% block model_menu_bar_before_filters %}
    <li id="here" class="form-row">
        <input name="pay_batch" class="form-control" placeholder="金额批量录入" aria-describedby="basic-addon1"/>
        <input name="memo_batch" class="form-control" placeholder="备注批量录入" aria-describedby="basic-addon1"/>
    </li>
{% endblock %}

{% block tail %}
    {{ super() }}
    <script type="application/javascript">
        $("input[name='memo_batch']").appendTo($("#action_form"))
        $("input[name='pay_batch']").appendTo($("#action_form"))
        $("#action_form").appendTo($("#here"))
        $("#action_form").attr("style", "")
    </script>
{% endblock %}

Then in coding file:

@action('batch_memo', '修改备注', )
    def action_batch_memo(self, ids):
        try:
            memo_batch = request.form['memo_batch']
            pay_batch = request.form['pay_batch']

            query = BankPay.query.filter(BankPay.id.in_(ids))

0reactions
michaeltoohigcommented, Jun 3, 2019

@daimon99 Thank you, this method saved me.

For others using the method here which requires a redirect 307 I hope they also find this comment. The method above does work and would be great for those who need to attach a large form to an action but it didn’t work in my production environment.

I’d like to append my version which places the inputs at the top of the block body. Which may be more versatile for others.

{% block body %}
  <div id="here">
    <div id="bank-reference" class="input-group" style="margin-bottom: 20px;">
      <span class="input-group-addon">
        <i class="glyphicon glyphicon-check"></i>
      </span>
      <input name="bank_ref" placeholder="Bank Reference" class="form-control">
    </div>
    <div id="bank-date" class="input-group" style="margin-bottom: 20px;">
      <span class="input-group-addon">
        <i class="glyphicon glyphicon-calendar"></i>
      </span>
      <input name="bank_date" class="form-control" type="date">
    </div>
  </div>
  {{ super() }}
{% endblock body %}

{% block tail %}
  {{ super() }}
  <script type="application/javascript">
    $("#bank-reference").appendTo($("#action_form"))
    $("#bank-date").appendTo($("#action_form"))
    $("#action_form").appendTo($("#here"))
    $("#action_form").attr("style", "")
  </script>
{% endblock tail %}

image

Read more comments on GitHub >

github_iconTop Results From Across the Web

Using bulk actions in your Shopify admin
Select the list items that you want to perform a bulk action on. Select the bulk action in one of the following ways:...
Read more >
What is a Bulk Action? - Helpshift Support
A common use of Bulk Actions is to identify and select multiple Issues in a search and assign them to a particular Agent,...
Read more >
Use bulk actions to create or edit campaigns - LinkedIn
Edit existing campaign settings – Select existing campaigns to include in the template and edit the relevant fields. Who can use this feature?...
Read more >
Perform Bulk Actions on Multiple Salesforce Records from ...
Sometimes, you need to perform the same action on a group of records. With CRM Analytics bulk actions, you can perform an action...
Read more >
Bulk Action Framework - Nuxeo Documentation
The Bulk Action Framework provides a service to be able to run resilient bulk actions on a possibly large set of documents.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found