<commit_before>
openerp.web_mobile = function(openerp) {
    
openerp.web_mobile = {};
    
openerp.web_mobile.MobileWebClient = openerp.base.Controller.extend({
    init: function(element_id) {
        var self = this;
        this._super(null, element_id);
        QWeb.add_template("xml/web_mobile.xml");
        var params = {};

        this.$element.html(QWeb.render("WebClient", {}));
        this.session = new openerp.base.Session("oe_errors");
        this.crashmanager =  new openerp.base.CrashManager(this.session);
        this.login = new openerp.web_mobile.Login(this.session, "oe_app");

        this.session.on_session_invalid.add(this.login.do_ask_login);
       
    },
    start: function() {
        this.session.start();
        this.login.start();
    }
});

openerp.web_mobile.mobilewebclient = function(element_id) {
    // TODO Helper to start mobile webclient rename it openerp.base.webclient
    var client = new openerp.web_mobile.MobileWebClient(element_id);
    client.start();
    return client;
};

openerp.web_mobile.Header =  openerp.base.Controller.extend({
    init: function(session, element_id) {
        this._super(session, element_id);
    },
    start: function() {
        this.$element.html(QWeb.render("Header", this));
        this.$element.find("a").click(this.on_clicked);
    },
    on_clicked: function(ev) {
        $opt = $(ev.currentTarget);
        current_id = $opt.attr('id');
        if (current_id == 'home') {
            this.homepage = new openerp.web_mobile.Login(this.session, "oe_app");
            this.homepage.on_login_valid();
        }
    }
    
});

openerp.web_mobile.Shortcuts =  openerp.base.Controller.extend({
    init: function(session, element_id) {
        this._super(session, element_id);
    },
    start: function() {
        var self = this;
        this.rpc('/base/session/sc_list',{} ,function(res){
            self.$element.html(QWeb.render("Shortcuts", {'sc' : res}))
            self.$element.find("a").click(self.on_clicked);
        })
    },
    on_clicked: function(ev) {
        $shortcut = $(ev.currentTarget);
        id = $shortcut.data('menu');
        res_id = $shortcut.data('res');
        jQuery("#oe_header").find("h1").html($shortcut.data('name'));
        this.listview = new openerp.web_mobile.ListView(this.session, "oe_app", res_id);
        this.listview.start();
    }
});

openerp.web_mobile.ListView = openerp.base.Controller.extend({
    init: function(session, element_id, list_id) {
        this._super(session, element_id);
        this.list_id = list_id;
    },
    start: function() {
        this.rpc('/base/menu/action', {'menu_id': this.list_id},
                    this.on_menu_action_loaded);
    },
    on_menu_action_loaded: function(data) {
        var self = this;
        if (data.action.length) {
            var action = data.action[0][2];
            self.on_action(action);
        }
    },
    on_action: function(action) {
        var self = this;
        var view_id = action.views[0][0];
        var model = action.res_model;

        self.rpc('/base/dataset/search_read', {
            model: model
            },function(result){
                this.listview = new openerp.web_mobile.ListView(this.session, "oe_app");
                self.$element.html(QWeb.render("ListView", {'records' : result}));
            });<commit_msg>[FIX] mobile so it goes through DataSetSearch instead of calling search_read directly<commit_after>
openerp.web_mobile = function(openerp) {
    
openerp.web_mobile = {};
    
openerp.web_mobile.MobileWebClient = openerp.base.Controller.extend({
    init: function(element_id) {
        var self = this;
        this._super(null, element_id);
        QWeb.add_template("xml/web_mobile.xml");
        var params = {};

        this.$element.html(QWeb.render("WebClient", {}));
        this.session = new openerp.base.Session("oe_errors");
        this.crashmanager =  new openerp.base.CrashManager(this.session);
        this.login = new openerp.web_mobile.Login(this.session, "oe_app");

        this.session.on_session_invalid.add(this.login.do_ask_login);
       
    },
    start: function() {
        this.session.start();
        this.login.start();
    }
});

openerp.web_mobile.mobilewebclient = function(element_id) {
    // TODO Helper to start mobile webclient rename it openerp.base.webclient
    var client = new openerp.web_mobile.MobileWebClient(element_id);
    client.start();
    return client;
};

openerp.web_mobile.Header =  openerp.base.Controller.extend({
    init: function(session, element_id) {
        this._super(session, element_id);
    },
    start: function() {
        this.$element.html(QWeb.render("Header", this));
        this.$element.find("a").click(this.on_clicked);
    },
    on_clicked: function(ev) {
        $opt = $(ev.currentTarget);
        current_id = $opt.attr('id');
        if (current_id == 'home') {
            this.homepage = new openerp.web_mobile.Login(this.session, "oe_app");
            this.homepage.on_login_valid();
        }
    }
    
});

openerp.web_mobile.Shortcuts =  openerp.base.Controller.extend({
    init: function(session, element_id) {
        this._super(session, element_id);
    },
    start: function() {
        var self = this;
        this.rpc('/base/session/sc_list',{} ,function(res){
            self.$element.html(QWeb.render("Shortcuts", {'sc' : res}))
            self.$element.find("a").click(self.on_clicked);
        })
    },
    on_clicked: function(ev) {
        $shortcut = $(ev.currentTarget);
        id = $shortcut.data('menu');
        res_id = $shortcut.data('res');
        jQuery("#oe_header").find("h1").html($shortcut.data('name'));
        this.listview = new openerp.web_mobile.ListView(this.session, "oe_app", res_id);
        this.listview.start();
    }
});

openerp.web_mobile.ListView = openerp.base.Controller.extend({
    init: function(session, element_id, list_id) {
        this._super(session, element_id);
        this.list_id = list_id;
    },
    start: function() {
        this.rpc('/base/menu/action', {'menu_id': this.list_id},
                    this.on_menu_action_loaded);
    },
    on_menu_action_loaded: function(data) {
        var self = this;
        if (data.action.length) {
            var action = data.action[0][2];
            self.on_action(action);
        }
    },
    on_action: function(action) {
        var self = this;
        var view_id = action.views[0][0];
        (new openerp.base.DataSetSearch(this.session, action.res_model, null, null))
            .read_slice(false, false, false, function(result){
                this.listview = new openerp.web_mobile.ListView(this.session, "oe_app");
                self.$element.html(QWeb.render("ListView", {'records' : result}));
            });
{'fraction_non_alphanumeric': 0.14979460093896713, 'fraction_numerical': 0.0014671361502347417, 'mean_word_length': 2.582238570677877, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 4}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3739201', 'n_tokens_mistral': 2201, 'n_tokens_neox': 2156, 'n_words': 329}