Skip to content
This repository has been archived by the owner on Apr 6, 2021. It is now read-only.

Pressing space in textbox submits form. #72

Open
steve-van-de-heuvel opened this issue Apr 20, 2015 · 5 comments
Open

Pressing space in textbox submits form. #72

steve-van-de-heuvel opened this issue Apr 20, 2015 · 5 comments
Labels

Comments

@steve-van-de-heuvel
Copy link

I cannot input a space into a textbox in a form that is within a dialog. It triggers the onclick event of dialog button.

@nightwing
Copy link
Contributor

Could you please tell us more details, where is this dialog or how do you create it?

@steve-van-de-heuvel
Copy link
Author

          formLogTime: new Form({
                colwidth: '33%',
                edge: "0 0 0 0",
                form: [
                    {
                        name: "summary",
                        title: 'Summary',
                        type: "textbox",
                    },
                    {
                        name: "value",
                        title: 'Hours (eg: 3.5 or 3:30)',
                        type: "textbox",
                        defaultValue: 0.5,
                        width: 70

                    }
                ]

            }),

@steve-van-de-heuvel
Copy link
Author

        dialogLogTime: new Dialog('Log Time', main.consumes, {
            title: "Log Time for Project:",
            modal: true,
            allowClose : true,
            elements : [
                {
                    type: "button",
                    id: "ok",
                    color: "green",
                    caption: "OK",
                    "default": true,
                    onclick: function(){
                        var params = Project.formLogTime.toJson();
                        params.method = 'POST';
                        params.pathInfo = 'projects/'+Project.data.id+'/tracking/time/add';
                        var currentTime = new Date();
                        var recordDate = currentTime.getFullYear() + '-' + (currentTime.getMonth()+1) + '-' + currentTime.getDate();
                        params.body = {
                            "time_record[user_id]": activeCollab.user.id,
                            "time_record[value]": params.value,
                            "time_record[record_date]": recordDate,
                            "time_record[job_type_id]": params.jobTypes,
                            "time_record[summary]": params.summary,
                            "time_record[billable_status]": 1,

                            "submitted": "submitted"
                        }
                        queryApi(params, function(json) {
                            Project.dialogLogTime.hide();
                            var bubble = imports["notification.bubble"];
                            bubble.popup("Time logged successfully.", false, function(){
                            });
                        });

                    }

                }
            ]
        })
    }
    ui.addElement(Project.contextMenu);
    ui.addElement(Project.dialogLogTime);
    ui.addElement(Project.formLogTime);

    Project.dialogLogTime.on('draw', function(e){
        Project.formLogTime.attachTo(e.html);
    });

@nightwing
Copy link
Contributor

Indeed there is a bug in focus handling
Here's a code snippet for testing easily from browser console

Form = app.Form
f = new Form({
    colwidth: '33%',
    edge: "0 0 0 0",
    form: [{
        name: "summary",
        title: 'Summary',
        type: "textbox",
    }, {
        name: "value",
        title: 'Hours (eg: 3.5 or 3:30)',
        type: "textbox",
        defaultValue: 0.5,
        width: 70

    }]

})
Dialog = app.Dialog
d = new Dialog('Log Time', [], {
    title: "Log Time for Project:",
    modal: true,
    allowClose: true,
    elements: [{
        type: "button",
        id: "ok",
        color: "green",
        caption: "OK",
        "default": true,
        onclick: function() {
            debugger
        }
    }]
})
d.on('draw', function(e) {
    f.attachTo(e.html);
});
d.show()

@nightwing nightwing added the bug label Apr 20, 2015
@steve-van-de-heuvel
Copy link
Author

Thanks for confirming. Will just use form submit button for now.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants