ผลต่างระหว่างรุ่นของ "Openerp/histest3"

จาก Theory Wiki
ไปยังการนำทาง ไปยังการค้นหา
แถว 65: แถว 65:
 
             'click .oe_histest_patient_new_link': 'linkClick',
 
             'click .oe_histest_patient_new_link': 'linkClick',
 
             'click .oe_histest_patient_query_link': 'patientQuery',
 
             'click .oe_histest_patient_query_link': 'patientQuery',
 +
        },
 +
 +
        start: function() {
 +
            var msgManager = new instance.histest.message.MsgManagerWidget(this);
 +
            msgManager.appendTo('.oe_application');
 
         },
 
         },
  

รุ่นแก้ไขเมื่อ 03:09, 3 เมษายน 2557

หน้านี้รวมข้อมูลสำหรับการทดสอบการพัฒนาระบบด้วย OpenERP

การแยกโค้ด javascript เป็นส่วน

ก่อนเริ่ม: ดาวน์โหลดโค้ด histest.zip จากครั้งก่อน

histest.js

openerp.histest = function(instance) {

    openerp.histest.message(instance);
    openerp.histest.patient(instance);
    
    instance.web.client_actions.add('histest.indexAction',
                                    'instance.histest.indexAction');

};

histest_message.js

openerp.histest.message = function(instance) {
    
    instance.histest.MsgManagerWidget = instance.web.Widget.extend({

        start: function() {
            var self = this;
            console.log("MsgMan started...");
            setInterval(function() {
                self.popup();
            },5000);
            this.shownMsgId = 0; 
        },

        popup: function() {
            var model = new instance.web.Model('histest.message');
            var self = this;
            model.query().filter([['id','>',this.shownMsgId]]).all().done(function(results){
                if (results.length > 0) {
                    msgId = results[results.length-1].id;
                    self.do_action({
                        type: 'ir.actions.act_window',
                        res_model: "histest.message",
                        res_id: msgId,
                        views: [[false, 'form']],
                        target: 'new',
                        context: {},
                    });
                    self.shownMsgId = msgId;
                }
            });
        }
    });
};

histest_patient.js

openerp.histest.patient = function(instance) {
    
    instance.histest.indexAction = instance.web.Widget.extend({
        template: 'histest.index',
        events: {
            'click .oe_histest_patient_new_link': 'linkClick',
            'click .oe_histest_patient_query_link': 'patientQuery',
        },

        start: function() {
            var msgManager = new instance.histest.message.MsgManagerWidget(this);
            msgManager.appendTo('.oe_application');
        },

        patientQuery: function() {
            var model = new instance.web.Model('histest.patient');
            var self = this;
            self.$(".oe_histest_patient_results").html("");
            model.query().all().done(function(results) {
                for(var i=0; i < results.length; i++) {
                    self.$(".oe_histest_patient_results")
                        .append('<li>' + results[i].first_name + '</li>');
                }
            });
        },

        linkClick: function() {
            this.do_action({
                type: 'ir.actions.act_window',
                res_model: 'histest.patient',
                views: [[false,'form']],
                target: 'current',
                context: {},
            });
        }
    });
};

Responsive CSS

เนื้อหาช่วงบ่าย

เอกสารครั้งก่อน ๆ