django-inline-actions icon indicating copy to clipboard operation
django-inline-actions copied to clipboard

support for handling additional, non-descript, attribute properties t…

Open actongorton opened this issue 7 years ago • 2 comments

…o the buttons

I needed a way to have actions take place in a new browser window, but since I may want to have other attributes in the future, seemed to me that being able to add generic attribute tags could be useful for other things.

For example, if my action is named validate_ercd, then I can now add an attribute like so:

def get_validate_ercd_attr(self, obj):
    return 'formtarget="_blank"'

This causes the record to be opened in a new browser window instead of the current browser window.

actongorton avatar Dec 03 '18 18:12 actongorton

HI @actongorton,

thanks for your contribution. I think this could be a nice addition for some special use case. But I would prefer if the method returns a dictionary of attributes instead of a single string. This ensures, that the final rendered attributes are always in the correct format and errors like missing " are prevented.

def get_validate_ercd_attrs(self, obj):
    return {
        'target': '_blank',
    }

What do you think about that? If you like the idea, could you please update your PR and add some test cases that ensure the final HTML-tag is rendered correctly?

Thanks :)

escaped avatar Dec 30 '18 12:12 escaped

Yes, good idea. Let me take another pass at it.

On Dec 30, 2018, at 6:20 AM, Alexander Frenzel [email protected] wrote:

HI @actongorton,

thanks for your contribution. I think this could be a nice addition for some special use case. But I would prefer if the method returns a dictionary of attributes instead of a single string. This ensures, that the final rendered attributes are always in the correct format and errors like missing " are prevented.

def get_validate_ercd_attrs(self, obj): return { 'target': '_blank', } What do you think about that? If you like the idea, could you please update your PR and add some test cases that ensure the final HTML-tag is rendered correctly?

Thanks :)

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or mute the thread.

actongorton avatar Jan 04 '19 00:01 actongorton