sync
[web.mtrack] / MTrackWeb / templates / images / MTrackWeb / MTrackWeb.Layout.js
index a0fa89b..1040e9c 100644 (file)
@@ -3,18 +3,32 @@
 // Auto generated file - created by app.Builder.js- do not edit directly (at present!)
 
 MTrackWeb.Layout = new Roo.XComponent({
+    part     :  ["MTrackWeb","Layout"],
     order    : '001-MTrackWeb.Layout',
     region   : 'center',
     parent   : false,
     name     : "unnamed module",
     disabled : false, 
-    tree : function()
+    permname : '', 
+    _tree : function()
     {
         var _this = this;
         var MODULE = this;
         return {
             xtype: 'NestedLayoutPanel',
             xns: Roo,
+            listeners : {
+                activate : function (_self)
+                {
+                      
+                }
+            },
+            getProjectName : function() {
+                return MTrack.projectCombo.el.dom.value;
+            },
+            getProjectId : function() {
+                return  MTrack.projectCombo.getValue();
+            },
             layout : {
                 xtype: 'BorderLayout',
                 xns: Roo,
@@ -25,16 +39,22 @@ MTrackWeb.Layout = new Roo.XComponent({
                         region : 'north',
                         content : '<div class="banner-username"></div>' + 
                                 '<div id="banner">' +
-                                    '<a href="' + rootURL + '"><img style="float: left;margin-right: 10px;" src="' +
-                                        rootURL + '/Roojscom/templates/images/roojsorg_logo-55.png" width="150" height="55"></a>' +
+                                    '<a href="' + baseURL + '"><img style="float: left;margin-right: 10px;" src="' +
+                                         '/Roojscom/templates/images/roojsorg_logo-55.png" width="150" height="55"></a>' +
                                     '<div class="banner-title">Project Tracker</div>'+
                                 '</div>'
                     },
                     {
                         xtype: 'ContentPanel',
                         xns: Roo,
-                        region : 'center',
-                        title : "test"
+                        region : 'south',
+                        content : ' <div id="footer">' +
+                                '<div class="navfoot">' +
+                                   'Powered by <a href="http://www.roojs.com/mtrack/index.php/Browse/default/web.mtrack">web.mtrack</a>' +
+                                   ' based on Wez\'s ' +
+                                    '<a href="http://bitbucket.org/wez/mtrack/">mtrack</a>' +
+                                '</div>' +
+                            '</div>'
                     }
                 ],
                 north : {
@@ -64,42 +84,68 @@ MTrackWeb.Layout = new Roo.XComponent({
                             {
                                 xtype: 'ComboBox',
                                 xns: Roo.form,
-                                allowBlank : 'false',
-                                editable : 'false',
-                                emptyText : "Select Projects",
+                                listeners : {
+                                    beforeselect : function (combo, rec, index)
+                                    {
+                                      // this should post to the system, - to register active Project..
+                                                            // it's not really needed in new version... but done for compat.
+                                                            // at present..
+                                            Roo.Ajax.request( {
+                                                method: 'POST',
+                                                url : baseURL + '/Projects/' + rec.data.id,
+                                                success : function (data) {
+                                                    // then, it should refresh the current active tab..
+                                                    MTrack.ajaxLoad( MTrack.currentURL);
+                                                }
+                                            }); 
+                                        
+                                    },
+                                    render : function (_self)
+                                    {
+                                        
+                                        _this.projectCombo = _self;
+                                        // BC..
+                                       MTrack.projectCombo = _self;
+                                        
+                                        // set the default value to our current project..
+                                        this.setFromData({
+                                            id : project_id,
+                                            name : project_name
+                                        });
+                                    }
+                                },
+                                allowBlank : false,
+                                alwaysQuery : true,
+                                displayField : 'name',
+                                editable : false,
+                                emptyText : "Select Project",
                                 forceSelection : true,
                                 listWidth : 400,
                                 loadingText : "Searching...",
-                                minChars : 2,
-                                pageSize : 20,
-                                qtip : "Select Projects",
+                                pageSize : 40,
+                                qtip : "Select Project",
                                 selectOnFocus : true,
+                                tpl : '<div class="x-grid-cell-text x-btn">{name} -  <b>{code}</b> </div>',
                                 triggerAction : 'all',
                                 typeAhead : true,
-                                width : 300,
-                                tpl : '<div class="x-grid-cell-text x-btn button"><b>{name}</b> </div>',
-                                queryParam : '',
-                                fieldLabel : 'Projects',
                                 valueField : 'id',
-                                displayField : '',
-                                hiddenName : '',
-                                name : '',
+                                width : 150,
                                 store : {
                                     xtype: 'Store',
                                     xns: Roo.data,
-                                    remoteSort : true,
-                                    sortInfo : { direction : 'ASC', field: 'id' },
                                     listeners : {
                                         beforeload : function (_self, o){
                                             o.params = o.params || {};
                                             // set more here
                                         }
                                     },
+                                    remoteSort : true,
+                                    sortInfo : { direction : 'ASC', field: 'name' },
                                     proxy : {
                                         xtype: 'HttpProxy',
                                         xns: Roo.data,
                                         method : 'GET',
-                                        url : baseURL + '/Roo/Projects.php'
+                                        url : baseURL + '/Roo/core_project.php'
                                     },
                                     reader : {
                                         xtype: 'JsonReader',
@@ -107,14 +153,136 @@ MTrackWeb.Layout = new Roo.XComponent({
                                         id : 'id',
                                         root : 'data',
                                         totalProperty : 'total',
-                                        fields : [{"name":"id","type":"int"},{"name":"name","type":"string"}]
+                                        fields : [{"name":"id","type":"int"},"name","code"]
                                     }
                                 }
                             },
+                            {
+                                xtype: 'Separator',
+                                xns: Roo.Toolbar
+                            },
+                            {
+                                xtype: 'TextField',
+                                xns: Roo.form,
+                                listeners : {
+                                    specialkey : function (_self, e)
+                                    {
+                                       if (e.getKey() == 13) {
+                                            // search!
+                                       }
+                                    }
+                                },
+                                emptyText : "Search (to be done..)",
+                                width : 100
+                            },
                             {
                                 xtype: 'Button',
                                 xns: Roo.Toolbar,
-                                text : "test"
+                                cls : 'x-btn-icon',
+                                icon : rootURL + '/Pman/templates/images/search.gif'
+                            },
+                            {
+                                xtype: 'Separator',
+                                xns: Roo.Toolbar
+                            },
+                            {
+                                xtype: 'SplitButton',
+                                xns: Roo.Toolbar,
+                                listeners : {
+                                    click : function (_self, e)
+                                    {
+                                        var bt = this;
+                                        if (!Pman.Login.authUser.id) { 
+                                            Pman.Login.show(false, function() {
+                                                bt.setText('Logout');
+                                                Roo.select('.banner-username').first().update(
+                                                    String.format('You are logged in as {0} &lt;{1}&gt;',
+                                                        Pman.Login.authUser.name,
+                                                        Pman.Login.authUser.email));
+                                                
+                                                 
+                                                // set the default value to our current project..
+                                                MTrack.projectCombo.setFromData({
+                                                    id : Pman.Login.authUser.project.id,
+                                                    name : Pman.Login.authUser.project.name
+                                                });
+                                                
+                                                MTrack.ajaxLoad( MTrack.currentURL);
+                                                //document.location = baseURL + '/Report/1?ts=' + Math.random();
+                                                // reload the project list!??
+                                                // reload the active page
+                                            });
+                                        } else {
+                                            Roo.MessageBox.confirm("Logout", 
+                                                "Are you sure you want to Log out?",
+                                                function(r) {
+                                                    if (r!='yes') {
+                                                        return;
+                                                    }
+                                            
+                                                    Pman.Login.logout();
+                                                }
+                                            );
+                                            // should for a reload..
+                                        }
+                                    },
+                                    render : function (_self)
+                                    {
+                                        if (typeof(Pman) == 'undefined') {
+                                            return;
+                                        }
+                                        
+                                        // if we are logged in.. change stuff..
+                                        if (!Pman.Login.authUser.id) {
+                                            // not logged in..
+                                            return;
+                                        }
+                                        // logged in..
+                                        this.el.child("button:first").setStyle(
+                                                'background-image', 'url(' + rootURL + '/Pman/templates/images/logout.gif)');
+                                        this.setText('Logout');
+                                        Roo.select('.banner-username').first().update(
+                                             String.format('You are logged in as {0} &lt;{1}&gt;',
+                                                Pman.Login.authUser.name,
+                                                Pman.Login.authUser.email));
+                                        // change the icon..
+                                         
+                                    }
+                                },
+                                cls : 'x-btn-text-icon',
+                                text : "Login",
+                                icon : rootURL + '/Pman/templates/images/lock.gif',
+                                menu : {
+                                    xtype: 'Menu',
+                                    xns: Roo.menu,
+                                    items : [
+                                        {
+                                            xtype: 'Item',
+                                            xns: Roo.menu,
+                                            text : "Request Account"
+                                        },
+                                        {
+                                            xtype: 'Item',
+                                            xns: Roo.menu,
+                                            text : "Send Invite to a Friend"
+                                        },
+                                        {
+                                            xtype: 'Separator',
+                                            xns: Roo.menu
+                                        },
+                                        {
+                                            xtype: 'Item',
+                                            xns: Roo.menu,
+                                            listeners : {
+                                                render : function (_self)
+                                                {
+                                                    _this.changePassword = _self;
+                                                }
+                                            },
+                                            text : "Change Password"
+                                        }
+                                    ]
+                                }
                             }
                         ]
                     }