svn: /pear2/BugManager/trunk/www/pearworm/source/class/pearworm/ BugController.js HistoryController.js MainWindow.js model/Issue.js

[email protected] (Greg Beaver) Fri, 10 Sep 2010 01:31:48 +0000
Newsgroups php.pear.cvs,php.pear.core
Message-ID <[email protected]>
cellog                                   Fri, 10 Sep 2010 01:31:48 +0000

Revision: http://svn.php.net/viewvc?view=revision&revision=303247

Log:
add full support for remembering history of which bugs are open plus which tabs were clicked.  Very simple: edit|1*bug|2 will display bug #1 with an edit form and bug #2 with the comments view

Bugs: http://pear.php.net/bugs/1 (unknown) 
      http://pear.php.net/bugs/2 (unknown) 
      
Changed paths:
    U   pear2/BugManager/trunk/www/pearworm/source/class/pearworm/BugController.js
    U   pear2/BugManager/trunk/www/pearworm/source/class/pearworm/HistoryController.js
    U   pear2/BugManager/trunk/www/pearworm/source/class/pearworm/MainWindow.js
    U   pear2/BugManager/trunk/www/pearworm/source/class/pearworm/model/Issue.js
svn-diffs-303247.txt (text/x-diff, 9.9 KB)
Modified: pear2/BugManager/trunk/www/pearworm/source/class/pearworm/BugController.js
===================================================================
--- pear2/BugManager/trunk/www/pearworm/source/class/pearworm/BugController.js	2010-09-10 00:40:27 UTC (rev 303246)
+++ pear2/BugManager/trunk/www/pearworm/source/class/pearworm/BugController.js	2010-09-10 01:31:48 UTC (rev 303247)
@@ -21,46 +21,69 @@
 {
   extend : qx.core.Object,

+  events: {
+    "buglistUpdated" : "qx.event.type.Data"
+  },
+
   members : {
     _pane: null,
     _pages: null,
-    display: function(id, addtohistory, data)
+    _bugs: null,
+    _views: null,
+    _pending: null,
+    display: function(id, data, view)
     {
+      if (!view) {
+        if (this._views[id]) {
+          view = this._views[id];
+        } else {
+          view = "bug";
+        }
+      }
       if (this._pages[id]) {
         this._pane.resetSelection();
         this._pane.setSelection([this._pages[id]]);
+        if (view != this._views[id]) {
+          this._bugs[id].selectView(view);
+          this._views[id] = view;
+          this.fireDataEvent("buglistUpdated", null);
+        }
         return;
       }
-      if (addtohistory) {
-        qx.bom.History.getInstance().addToHistory("bug|" + id);
-      }
-      if (undefined !== data) {
+      if (data) {
+        this._views[id] = view;
         this.handleSuccess({getData: function(){return {result: data};}});
         return;
       }
       var remote = new pearworm.Remote();
+      this._views[id] = view;
+      this._pending = id;
       remote.callRemoteContext(this, this.handleSuccess, this.handleFail, "PEAR2\\BugManager\\Issue", "toJson",
                                id);
     },
     handleFail: function(result)
     {
+      delete this._views[this._pending];
       alert("Could not load bug: " + result.getData().message);
     },
     handleSuccess: function(result)
     {
+      this._pending = null;
       var data = result.getData().result;
+      var save = this._views[data.id];

       var page = new qx.ui.tabview.Page(data.type + " " + data.id);
       var issue = new pearworm.model.Issue();
       issue.fromTableData(data);
       page.setLayout(new qx.ui.layout.Grow());
-      page.add(issue.getIssueForm());
+      page.add(issue.getIssueForm(save));
       issue.addListener("dirty", function () {
         page.setLabel(data.type + " " + data.id + " *");
       })
       issue.addListener("clean", function () {
         page.setLabel(data.type + " " + data.id);
       });
+      issue.addListener("chosetab", this.updateBuglist, this);
       page.setShowCloseButton(true);
       page.addListener("close", function() {
         this.fireDataEvent("closing", this.getId());
@@ -68,15 +91,37 @@
       issue.addListener("closing", this.removePage, this);
       this._pane.add(page);
       this._pages[data.id] = page;
+      this._bugs[data.id] = issue;
     },
     removePage: function(e)
     {
       delete this._pages[e.getData()];
+      delete this._views[e.getData()];
+      this.fireDataEvent("buglistUpdated", null);
+    },
+    updateBuglist: function(e)
+    {
+      var info = e.getData();
+      var id = info.issue.getId();
+      var view = info.page;
+
+      this._views[id] = view;
+      this.fireDataEvent("buglistUpdated", null);
+    },
+    getState: function()
+    {
+      var ret = [], i = 0;
+      for (var id in this._pages) {
+        ret[i++] = this._views[id] + "|"+id;
+      }
+      return ret.join("*");
     }
   },
   construct: function(pane)
   {
     this._pane = pane;
     this._pages = {};
+    this._bugs = {};
+    this._views = {};
   }
 });

Modified: pear2/BugManager/trunk/www/pearworm/source/class/pearworm/HistoryController.js
===================================================================
--- pear2/BugManager/trunk/www/pearworm/source/class/pearworm/HistoryController.js	2010-09-10 00:40:27 UTC (rev 303246)
+++ pear2/BugManager/trunk/www/pearworm/source/class/pearworm/HistoryController.js	2010-09-10 01:31:48 UTC (rev 303247)
@@ -34,12 +34,17 @@
       return states;
     },

-    mapState: function(state, value, addtohistory)
+    mapState: function(state, value)
     {
       switch (state) {
         case "bug" :
-          this._bugcontroller.display(Number(value), addtohistory);
+          this._bugcontroller.display(Number(value));
           break;
+        case "patches" :
+        case "edit" :
+        case "add" :
+          this._bugcontroller.display(Number(value), undefined, state);
+          break;
       }
     },

@@ -47,12 +52,19 @@
     {
       states = this.parseState(state);
       for (var i = 0; i < states.length; i++) {
-        this.mapState(states[i][0], states[i][1], false);
+        this.mapState(states[i][0], states[i][1]);
       }
     },
-    getBugController: function()
+
+    saveState: function()
     {
-      return this._bugcontroller;
+      qx.bom.History.getInstance().addToHistory(this._bugcontroller.getState());
+    },
+
+    displayBug: function(id, data)
+    {
+      this._bugcontroller.display(Number(id), data);
+      qx.bom.History.getInstance().addToHistory(this._bugcontroller.getState());
     }
   },
   construct : function(leftpane, rightpane)
@@ -62,6 +74,7 @@
     this._right = rightpane;

     this._bugcontroller = new pearworm.BugController(this._right);
+    this._bugcontroller.addListener("buglistUpdated", this.saveState, this);

     // initial state retrieval
     var state = qx.bom.History.getInstance().getState();

Modified: pear2/BugManager/trunk/www/pearworm/source/class/pearworm/MainWindow.js
===================================================================
--- pear2/BugManager/trunk/www/pearworm/source/class/pearworm/MainWindow.js	2010-09-10 00:40:27 UTC (rev 303246)
+++ pear2/BugManager/trunk/www/pearworm/source/class/pearworm/MainWindow.js	2010-09-10 01:31:48 UTC (rev 303247)
@@ -21,6 +21,9 @@
 {
   extend : qx.ui.splitpane.Pane,

+  statics: {
+    HISTORY: null,
+  },
   construct : function()
   {
     this.base(arguments, "vertical");
@@ -36,6 +39,7 @@
         detail = new qx.ui.tabview.TabView("top"),
         columns = table.getTableColumnModel(),
         historymanager = new pearworm.HistoryController(table, detail);
+    pearworm.MainWindow.HISTORY = historymanager;

     tablemodel.setColumns(["Id", "Date", "Last Modified", "Type", "Summary", "Site", "Reporter", "Assigned"],
                           ["id", "createtimestamp", "modifiedtimestamp", "type", "summary", "primarycategory",
@@ -59,7 +63,7 @@
     table.addListener("cellDblclick", function(e) {
       this.getSelectionModel().iterateSelection(function(index) {
         var data = this.getTableModel().getRowData(index);
-        historymanager.getBugController().display(data.id, true, data);
+        historymanager.displayBug(data.id, data);
       }, this);
     }, table);
   }

Modified: pear2/BugManager/trunk/www/pearworm/source/class/pearworm/model/Issue.js
===================================================================
--- pear2/BugManager/trunk/www/pearworm/source/class/pearworm/model/Issue.js	2010-09-10 00:40:27 UTC (rev 303246)
+++ pear2/BugManager/trunk/www/pearworm/source/class/pearworm/model/Issue.js	2010-09-10 01:31:48 UTC (rev 303247)
@@ -24,7 +24,8 @@
   events: {
     "dirty" : "qx.event.type.Data",
     "clean" : "qx.event.type.Data",
-    "closing" : "qx.event.type.Data"
+    "closing" : "qx.event.type.Data",
+    "chosetab" : "qx.event.type.Data"
   },

   properties: {
@@ -196,7 +197,7 @@
     {
       this.fireDataEvent("dirty", this);
     },
-    getIssueForm: function()
+    getIssueForm: function(view)
     {
       var form = new qx.ui.form.Form();
       var manager = form.getValidationManager();
@@ -210,6 +211,10 @@
           {value : "Doc", name : "Documentation Problem"}
       ], 1);

+      if (!view) {
+        view = "bug";
+      }
+
       formcontroller.addBindingOptions("status", {converter:
           function(data) {
             if (data == null) {
@@ -474,13 +479,61 @@

       editpage.add(renderer);

-      choices.add(commentspage);
-      choices.add(patchespage);
-      choices.add(editpage);
-      choices.add(addpatchpage);
+      choices.add(this._commentspage = commentspage);
+      choices.add(this._patchespage = patchespage);
+      if (view == "patches") {
+        choices.setSelection([patchespage]);
+      }
+      choices.add(this._editpage = editpage);
+      if (view == "edit") {
+        choices.setSelection([editpage]);
+      }
+      choices.add(this._addpatchpage = addpatchpage);
+      if (view == "add") {
+        choices.setSelection([addpatchpage]);
+      }
+
+      choices.addListener("changeSelection", this.tabListener, this);
+      this._choices = choices;
+
       content.add(choices, {flex: 5});
       return content;
-    }
+    },
+    tabListener: function(e) {
+      if (!e.getData()) return;
+      var sel = e.getData()[0];
+      if (sel == this._commentspage) {
+        this.fireDataEvent("chosetab", {issue: this, page: "bug"});
+      } else if (sel == this._patchespage) {
+        this.fireDataEvent("chosetab", {issue: this, page: "patches"});
+      } else if (sel == this._editpage) {
+        this.fireDataEvent("chosetab", {issue: this, page: "edit"});
+      } else if (sel == this._addpatchpage) {
+        this.fireDataEvent("chosetab", {issue: this, page: "add"});
+      }
+    },
+    selectView: function(view) {
+      this._choices.resetSelection();
+      switch (view) {
+        case "bug" :
+          this._choices.setSelection([this._commentspage]);
+          break;
+        case "patches" :
+          this._choices.setSelection([this._patchespage]);
+          break;
+        case "edit" :
+          this._choices.setSelection([this._editpage]);
+          break;
+        case "add" :
+          this._choices.setSelection([this._addpatchpage]);
+          break;
+      }
+    },
+    _choices: null,
+    _commentspage: null,
+    _patchespage: null,
+    _editpage: null,
+    _addpatchpage: null
   },
   construct : function() {
     this.base(arguments);