Uncommited changes synced
authorAlan Knowles <alan@roojs.com>
Mon, 24 Dec 2018 07:16:50 +0000 (15:16 +0800)
committerAlan Knowles <alan@roojs.com>
Mon, 24 Dec 2018 07:16:50 +0000 (15:16 +0800)
NewBranch.bjs
NewBranch.vala
RooProject.vala
RooTicket.vala
Ticket.bjs
Ticket.vala

index 72818fe..02621d8 100644 (file)
@@ -17,7 +17,7 @@
    "title" : "Create a working branch ",
    "xtype" : "Dialog",
    "# GitRepo? repo" : "null",
-   "|   void show" : "( GitRepo repo, Gee.ArrayList<GitMonitorQueue> queue, string tid = \"\" ) \n{\n     // this.el.set_gravity(Gdk.Gravity.NORTH);\n    if (this.running) { // should not happen!!\n    \tGLib.error(\"new branch show called, when already being displayed?\");\n\t}\n\tthis.queue = queue;\n\t\n\tthis.running  = true;\n\tGitMonitor.gitmonitor.stop();\n\t\n    this.repo = repo;\n    \n     \n    \n\tthis.el.move((Gdk.Screen.width() / 2)- 250 ,0);\n\tthis.el.set_default_size( 500,200); // not sure why it grows..\n    GLib.debug(\"Loading tickets\"); \n     \n\n    this.el.show_all();\n    this.el.set_keep_above(true);\n   \n    \n    var curproj = RooTicket.singleton().getProjectByRepo(this.repo);\n     _this.prmodel.loadProjects(curproj == null ? \"\" : curproj.id);\n    \n \t_this.dbmodel.loadTickets(curproj == null ? \"\": curproj.id, tid);\n\n \tif (tid != \"\") {\n\t \tvar name = RooTicket.singleton().usernameLocal();\n \t\tvar ticket = RooTicket.singleton().getById(tid);\n\t\t_this.name.el.set_text(\"wip_%s_T%s_%s\".printf(name,ticket.id, ticket.summaryToBranchName()));\n\n\n\t}\n    _this.view.loadTicket(tid);\n \tthis.el.run();\n\n}",
+   "|   void show" : "( GitRepo repo, Gee.ArrayList<GitMonitorQueue> queue, string tid = \"\" ) \n{\n     // this.el.set_gravity(Gdk.Gravity.NORTH);\n    if (this.running) { // should not happen!!\n    \tGLib.error(\"new branch show called, when already being displayed?\");\n\t}\n\tthis.queue = queue;\n\t\n\tthis.running  = true;\n\tGitMonitor.gitmonitor.stop();\n\t\n    this.repo = repo;\n    \n     \n    \n\tthis.el.move((Gdk.Screen.width() / 2)- 250 ,0);\n\tthis.el.set_default_size( 500,200); // not sure why it grows..\n    GLib.debug(\"Loading tickets\"); \n     \n\n    this.el.show_all();\n    this.el.set_keep_above(true);\n   \n    \n    var curproj = RooProject.getProjectByRepo(this.repo);\n     _this.prmodel.loadProjects(curproj == null ? \"\" : curproj.id);\n    \n \t_this.dbmodel.loadTickets(curproj == null ? \"\": curproj.id, tid);\n\n \tif (tid != \"\") {\n\t \tvar name = RooTicket.singleton().usernameLocal();\n \t\tvar ticket = RooTicket.singleton().getById(tid);\n\t\t_this.name.el.set_text(\"wip_%s_T%s_%s\".printf(name,ticket.id, ticket.summaryToBranchName()));\n\n\n\t}\n    _this.view.loadTicket(tid);\n \tthis.el.run();\n\n}",
    "default_height" : 500,
    "$ xns" : "Gtk",
    "# bool running" : false,
           },
           {
            "listeners" : {
-            "activate_link" : "(uri) => {\n\tif (uri == \"refresh\") {\n\t\tvar curproj = RooTicket.singleton().getProjectByRepo(_this.repo);\n\t\t _this.prmodel.loadProjects(curproj == null ? \"\": curproj.id);\n\n\t\t_this.dbmodel.loadTickets(curproj == null ? \"\": curproj.id);\t\t\n\t}\n\treturn true;\n}"
+            "activate_link" : "(uri) => {\n\tif (uri == \"refresh\") {\n\t\tRooProject.reload();\n\t\tvar curproj = RooProject.getProjectByRepo(_this.repo);\n\t\t _this.prmodel.loadProjects(curproj == null ? \"\": curproj.id);\n\n\t\t_this.dbmodel.loadTickets(curproj == null ? \"\": curproj.id);\t\t\n\t}\n\treturn true;\n}"
            },
            "bool use_markup" : true,
            "Gtk.Align halign" : "Gtk.Align.END",
index 7746be7..6b2c345 100644 (file)
@@ -123,7 +123,7 @@ public class NewBranch : Object
         this.el.set_keep_above(true);
        
         
-        var curproj = RooTicket.singleton().getProjectByRepo(this.repo);
+        var curproj = RooProject.getProjectByRepo(this.repo);
          _this.prmodel.loadProjects(curproj == null ? "" : curproj.id);
         
        _this.dbmodel.loadTickets(curproj == null ? "": curproj.id, tid);
@@ -827,7 +827,8 @@ public class NewBranch : Object
             //listeners
             this.el.activate_link.connect( (uri) => {
                if (uri == "refresh") {
-                       var curproj = RooTicket.singleton().getProjectByRepo(_this.repo);
+                       RooProject.reload();
+                       var curproj = RooProject.getProjectByRepo(_this.repo);
                         _this.prmodel.loadProjects(curproj == null ? "": curproj.id);
             
                        _this.dbmodel.loadTickets(curproj == null ? "": curproj.id);            
index 57e1c01..448bd9a 100644 (file)
@@ -8,7 +8,7 @@ public class RooProject  : Object
        const string roourl = "https://roojs.com/admin.php/Roo";  
        
        
-       public static RooProject singleton()
+       static RooProject singleton()
     {
        if (_RooProject == null) {
             _RooProject = new RooProject();
@@ -32,6 +32,42 @@ public class RooProject  : Object
                return RooProject._projects;
        }
        
+       
+       public static  RooProject? getProjectByRepo(GitRepo repo)
+       {
+               RooProject.singleton();
+               
+               // fixme -- needs to get from rep list..
+               var rt = RooTicket.singleton();         
+               if (rt.repos.size < 1) {
+                       rt.loadRepos();
+               }
+                
+               
+               var pid = "";
+               foreach(var roo_repo in rt.repos) {
+                       if (roo_repo.shortname == repo.name) {
+                               pid = roo_repo.project_id;
+                               break;
+                       }
+               }
+               if (pid == "") {
+                       GLib.debug("getProjectByRepo: repo has no project");            
+                       return null;
+               }
+               // get project by id...
+               foreach(var roo_project in RooProject.projects()) {
+                       if (roo_project.id == pid) {
+                               GLib.debug("getProjectByRepo: project_id = %s", pid);
+                               return roo_project;
+                       }
+               }
+               GLib.debug("getProjectByRepo: can not find project");                           
+               return null;
+       
+       }
+       
+       
        public static  RooProject addProject(Json.Object t)
        {
                RooProject.singleton(); // init...
@@ -46,7 +82,7 @@ public class RooProject  : Object
                return add;
        }
 
-       static void reloadProjects()  /// has to be called on singleton..
+       public static void reload()  /// has to be called on singleton..
        {
                RooProject.loadcount = 0;
                RooProject.singleton();
index 18f5e6b..1633b76 100644 (file)
@@ -144,37 +144,7 @@ public class RooTicket : Object
                return add;
        }
        
-       public RooProject? getProjectByRepo(GitRepo repo)
-       {
-               var rt = RooTicket.singleton();
-               
-               if (rt.repos.size < 1) {
-                       rt.loadRepos();
-               }
-                
-               
-               var pid = "";
-               foreach(var roo_repo in rt.repos) {
-                       if (roo_repo.shortname == repo.name) {
-                               pid = roo_repo.project_id;
-                               break;
-                       }
-               }
-               if (pid == "") {
-                       GLib.debug("getProjectByRepo: repo has no project");            
-                       return null;
-               }
-               // get project by id...
-               foreach(var roo_project in RooProject.projects()) {
-                       if (roo_project.id == pid) {
-                               GLib.debug("getProjectByRepo: project_id = %s", pid);
-                               return roo_project;
-                       }
-               }
-               GLib.debug("getProjectByRepo: can not find project");                           
-               return null;
-       
-       }
        
        
        public static RooTicket fakeTicket()
index 6c5fa0f..ef0b04d 100644 (file)
@@ -17,7 +17,7 @@
    "title" : "Create a Ticket",
    "xtype" : "Dialog",
    "# GitRepo? repo" : "null",
-   "|   void show" : "( GitRepo? repo   ) \n{\n     // this.el.set_gravity(Gdk.Gravity.NORTH);\n    if (this.running) { // should not happen!!\n    \tGLib.error(\"new branch show called, when already being displayed?\");\n\t}\n \n\t\n\tthis.running  = true;\n\t//GitMonitor.gitmonitor.stop();\n\t\n    this.repo = repo;\n    \n    \n    \n    \n\tthis.el.move((Gdk.Screen.width() / 2)- 250 ,0);\n\tthis.el.set_default_size( 500,200); // not sure why it grows..\n    GLib.debug(\"Loading tickets\"); \n     \n\n    this.el.show_all();\n    this.el.set_keep_above(true);\n   \n\n\tRooProject? curproj = null;\n    if (this.repo != null) {\n\t    curproj = RooTicket.singleton().getProjectByRepo(this.repo);\n    }\n\t_this.prmodel.loadProjects(curproj == null ? \"\" : curproj.id);\n    if (curproj != null) {\n \n\t\t\n\t\tvar rt = RooTicket.singleton();\n\t\trt.loadProjectOptions(curproj.id);\n\t\t\n\t\t_this.msmodel.loadMilestones();\n\t\t_this.primodel.loadPriorities();\n\t\t_this.sevmodel.loadSeverities();\n\t\t_this.clmodel.loadClassifications();\t\n\t\t_this.devmodel.loadDevelopers();\t\n\t\t\n    }\n    \t_this.summary.el.set_text(\"\");\n\t\t_this.description.el.buffer.text = \"\"; \n    \n \n \tthis.el.run();\n\n}",
+   "|   void show" : "( GitRepo? repo   ) \n{\n     // this.el.set_gravity(Gdk.Gravity.NORTH);\n    if (this.running) { // should not happen!!\n    \tGLib.error(\"new branch show called, when already being displayed?\");\n\t}\n \n\t\n\tthis.running  = true;\n\t//GitMonitor.gitmonitor.stop();\n\t\n    this.repo = repo;\n    \n    \n    \n    \n\tthis.el.move((Gdk.Screen.width() / 2)- 250 ,0);\n\tthis.el.set_default_size( 500,200); // not sure why it grows..\n    GLib.debug(\"Loading tickets\"); \n     \n\n    this.el.show_all();\n    this.el.set_keep_above(true);\n   \n\n\tRooProject? curproj = null;\n    if (this.repo != null) {\n\t    curproj = RooProject.getProjectByRepo(this.repo);\n    }\n\t_this.prmodel.loadProjects(curproj == null ? \"\" : curproj.id);\n    if (curproj != null) {\n \n\t\t\n\t\tvar rt = RooTicket.singleton();\n\t\trt.loadProjectOptions(curproj.id);\n\t\t\n\t\t_this.msmodel.loadMilestones();\n\t\t_this.primodel.loadPriorities();\n\t\t_this.sevmodel.loadSeverities();\n\t\t_this.clmodel.loadClassifications();\t\n\t\t_this.devmodel.loadDevelopers();\t\n\t\t\n    }\n    \t_this.summary.el.set_text(\"\");\n\t\t_this.description.el.buffer.text = \"\"; \n    \n \n \tthis.el.run();\n\n}",
    "default_height" : 200,
    "$ xns" : "Gtk",
    "# bool running" : false,
index 992c548..cb75d9d 100644 (file)
@@ -118,7 +118,7 @@ public class Ticket : Object
     
        RooProject? curproj = null;
         if (this.repo != null) {
-           curproj = RooTicket.singleton().getProjectByRepo(this.repo);
+           curproj = RooProject.getProjectByRepo(this.repo);
         }
        _this.prmodel.loadProjects(curproj == null ? "" : curproj.id);
         if (curproj != null) {