admin table query focus

35 views
Skip to first unread message

Dave S

unread,
Apr 23, 2024, 4:31:01 PMApr 23
to web2py-users
I've long been bugged by going through the appadmin controller to do database maintenance and not having the focus be anywhere useful.  I think I even have a comment about that somewhere in the forum.

I finally figured out a way to fix that ... the following change puts the focus on the query box of the table admin form.  Line numbers are from the 2.22.5 release, but should be close for other recent versions.

File:  .../web2py/applications/myapp/controllers/appadmin.py:
lines 226-230 before:
    form = FORM(TABLE(TR(T('Query:'), '', INPUT(_style='width:400px',
                _name='query', _value=request.vars.query or '', _class='form-control',
                requires=IS_NOT_EMPTY(
                    error_message=T('Cannot be empty')))), TR(T('Update:'),
                INPUT(_name='update_check', _type='checkbox',

lines 226-231 now:
    form = FORM(TABLE(TR(T('Query:'), '', INPUT(_style='width:400px',
                _name='query', _value=request.vars.query or '', _class='form-control',
                requires=IS_NOT_EMPTY(
                    error_message=T('Cannot be empty')), _autofocus="autofocus")),TR(T('Update:'),
                                                                                                INPUT(_name='update_check', _type='checkbox',
                value=False), INPUT(_style='width:400px',

Note that this is really one big line ... I didn't spend a lot time trying to add escapes to unwrap and reformat the long worm.

I find this little change really helps my work flow on the app where I use appadmin the most.  You may, of course, prefer to add a task-specific controller elsewhere in the app or in a script, but appadmin queries are fairly flexible, and that's often where I figure out what the task-specific details are.

Dave S
/dps

Raul Monares

unread,
May 10, 2024, 12:58:31 PMMay 10
to web2py-users
Excellent !!
Reply all
Reply to author
Forward
0 new messages