From a3718ade1e5a6386806881adfd932f3e38f9aa25 Mon Sep 17 00:00:00 2001 From: Alan Knowles Date: Mon, 24 Dec 2018 15:16:50 +0800 Subject: [PATCH] Uncommited changes synced --- NewBranch.bjs | 4 ++-- NewBranch.vala | 5 +++-- RooProject.vala | 40 ++++++++++++++++++++++++++++++++++++++-- RooTicket.vala | 32 +------------------------------- Ticket.bjs | 2 +- Ticket.vala | 2 +- 6 files changed, 46 insertions(+), 39 deletions(-) diff --git a/NewBranch.bjs b/NewBranch.bjs index 72818fe8..02621d83 100644 --- a/NewBranch.bjs +++ b/NewBranch.bjs @@ -17,7 +17,7 @@ "title" : "Create a working branch ", "xtype" : "Dialog", "# GitRepo? repo" : "null", - "| void show" : "( GitRepo repo, Gee.ArrayList 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 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, @@ -186,7 +186,7 @@ }, { "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", diff --git a/NewBranch.vala b/NewBranch.vala index 7746be7c..6b2c3455 100644 --- a/NewBranch.vala +++ b/NewBranch.vala @@ -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); diff --git a/RooProject.vala b/RooProject.vala index 57e1c016..448bd9a3 100644 --- a/RooProject.vala +++ b/RooProject.vala @@ -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(); diff --git a/RooTicket.vala b/RooTicket.vala index 18f5e6ba..1633b76f 100644 --- a/RooTicket.vala +++ b/RooTicket.vala @@ -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() diff --git a/Ticket.bjs b/Ticket.bjs index 6c5fa0f6..ef0b04d4 100644 --- a/Ticket.bjs +++ b/Ticket.bjs @@ -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, diff --git a/Ticket.vala b/Ticket.vala index 992c5485..cb75d9d8 100644 --- a/Ticket.vala +++ b/Ticket.vala @@ -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) { -- 2.39.2