From 424eebf8a96c11d28b3da871c3e1560638d3511f Mon Sep 17 00:00:00 2001 From: Alan Knowles Date: Mon, 17 Dec 2018 15:51:40 +0800 Subject: [PATCH] Partial Fix #5560 - Gitlive - branching wip --- Clones.bjs | 27 +- Clones.vala | 6 + Makefile.am | 1 + NewBranch.bjs | 20 +- NewBranch.vala | 15 +- RepoStatusPopover.bjs | 16 +- RepoStatusPopover.vala | 3 +- RooTicket.vala | 166 +++++- StatusIcon.vala | 25 + Ticket.bjs | 277 +++++++++ Ticket.vala | 1240 ++++++++++++++++++++++++++++++++++++++++ config1.builder | 3 +- 12 files changed, 1757 insertions(+), 42 deletions(-) create mode 100644 Ticket.bjs create mode 100644 Ticket.vala diff --git a/Clones.bjs b/Clones.bjs index 66620121..a2107e4b 100644 --- a/Clones.bjs +++ b/Clones.bjs @@ -30,8 +30,8 @@ "items" : [ { "bool homogeneous" : true, - "* pack" : "pack_start,false,false,0", "xtype" : "Box", + "* pack" : "pack_start,false,false,0", "$ xns" : "Gtk", "Gtk.Orientation orientation" : "Gtk.Orientation.HORIZONTAL", "items" : [ @@ -40,16 +40,17 @@ "clicked" : "() => {\n\t\tClone.singleton().show(this.el);\n \n \n \n}" }, "label" : "Add Repository", - "* pack" : "add", + "* init" : "{\n this.el.get_style_context().add_class(\"suggested-action\");\n}\n", "xtype" : "Button", + "* pack" : "add", "$ xns" : "Gtk" } ] }, { "* init" : " {\n \n this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);\n}\n", - "bool hexpand" : true, "bool expand" : true, + "bool hexpand" : true, "xtype" : "ScrolledWindow", "* pack" : "pack_end,true,true,0", "Gtk.ShadowType shadow_type" : "Gtk.ShadowType.IN", @@ -61,8 +62,8 @@ "cursor_changed" : "() => {\n // SEE SELECTION.CHANGED\n /*\n \n return;\n \n if (this.el.get_selection().count_selected_rows() < 1) {\n //nothing? - clea it?\n return;\n }\n var ret = {}; \n var model = this.get('/changedFilesStore');\n\n var s = this.el.get_selection();\n var files = [];\n s.selected_foreach(function(model,p,iter) {\n \n files.push( model.get_value(iter, 0).value.get_string());\n \n });\n this.get('/patchview').showDiff(files); \n //var value = ''+ ret.model.get_value(ret.iter, 1).value.get_string();\n //print(\"OUT?\" + value);// id..\n // load the list in the right grid..\n \n return true;\n*/\n}" }, "id" : "reposView", - "bool activate_on_single_click" : true, "* init" : " \n{\n var selection = this.el.get_selection();\n selection.set_mode( Gtk.SelectionMode.SINGLE);\n\n\n var description = new Pango.FontDescription();\n description.set_size(10000);\n this.el.override_font(description);\n \n}\n", + "bool activate_on_single_click" : true, "xtype" : "TreeView", "* pack" : "add", "int search_column" : 0, @@ -93,8 +94,8 @@ "toggled" : " (self, path) => {\n \n \tGtk.TreeIter iter;\n \t_this.reposStore.el.get_iter_from_string(out iter, path);\n \t\n \tGLib.Value val;\n \tGLib.Value rval;\n \t_this.reposStore.el.get_value(iter, 4, out val);\n \t_this.reposStore.el.get_value(iter, 6, out rval);\n \t\n \tvar repopath = (string)rval;\n \tvar bval = (bool)val;\n \t_this.reposStore.el.set_value(iter, 4, !bval);\n \tGLib.debug(\"got repopath? %s\", repopath);\n \t\n \tvar repo = GitRepo.get(repopath);\n \trepo.set_autocommit(!bval);\n \t\n \t\n \t\n \n}" }, "id" : "cr_autocommit", - "* pack" : "pack_start,false", "xtype" : "CellRendererToggle", + "* pack" : "pack_start,false", "$ xns" : "Gtk", "$ mode" : "Gtk.CellRendererMode.ACTIVATABLE" } @@ -114,8 +115,8 @@ "toggled" : " (self, path) => {\n \n \tGtk.TreeIter iter;\n \t_this.reposStore.el.get_iter_from_string(out iter, path);\n \t\n \tGLib.Value val;\n \tGLib.Value rval;\n \t_this.reposStore.el.get_value(iter, 5, out val);\n \t_this.reposStore.el.get_value(iter, 6, out rval);\n \t\n \tvar repopath = (string)rval;\n \tvar bval = (bool)val;\n \t_this.reposStore.el.set_value(iter, 5, !bval);\n \tvar repo = GitRepo.get(repopath);\n \trepo.set_autopush(!bval);\n \t\n \t\n \t\n \n}" }, "id" : "cr_autopush", - "* pack" : "pack_start,false", "xtype" : "CellRendererToggle", + "* pack" : "pack_start,false", "$ xns" : "Gtk", "$ mode" : "Gtk.CellRendererMode.ACTIVATABLE" } @@ -135,8 +136,8 @@ "toggled" : " (self, path) => {\n \n \tGtk.TreeIter iter;\n \t_this.reposStore.el.get_iter_from_string(out iter, path);\n \t\n \tGLib.Value val;\n \tGLib.Value rval;\n \t_this.reposStore.el.get_value(iter, 8, out val);\n \t_this.reposStore.el.get_value(iter, 6, out rval);\n \t\n \tvar repopath = (string)rval;\n \tvar bval = (bool)val;\n \t_this.reposStore.el.set_value(iter, 8, !bval);\n \tvar repo = GitRepo.get(repopath);\n \trepo.set_auto_branch(!bval);\n \t\n \t\n \t\n \n}" }, "id" : "cr_autobranch", - "xtype" : "CellRendererToggle", "* pack" : "pack_start,false", + "xtype" : "CellRendererToggle", "$ xns" : "Gtk", "$ mode" : "Gtk.CellRendererMode.ACTIVATABLE" } @@ -144,8 +145,8 @@ }, { "id" : "tv_repo", - "* init" : "\n this.el.add_attribute(_this.cr_repo.el , \"markup\", 0 );\n", "Gtk.SortType sort_order" : "Gtk.SortType.ASCENDING", + "* init" : "\n this.el.add_attribute(_this.cr_repo.el , \"markup\", 0 );\n", "title" : "Repo", "* pack" : "append_column", "xtype" : "TreeViewColumn", @@ -156,8 +157,8 @@ "items" : [ { "id" : "cr_repo", - "* pack" : "pack_start,false", "xtype" : "CellRendererText", + "* pack" : "pack_start,false", "$ xns" : "Gtk" } ] @@ -173,8 +174,8 @@ "items" : [ { "id" : "cr_active_ticket", - "xtype" : "CellRendererText", "* pack" : "pack_start,false", + "xtype" : "CellRendererText", "$ xns" : "Gtk" } ] @@ -190,8 +191,8 @@ "items" : [ { "id" : "cr_current_branch", - "* pack" : "pack_start,false", "xtype" : "CellRendererText", + "* pack" : "pack_start,false", "$ xns" : "Gtk" } ] @@ -207,8 +208,8 @@ "items" : [ { "id" : "cr_last_updated", - "* pack" : "pack_start,false", "xtype" : "CellRendererText", + "* pack" : "pack_start,false", "$ xns" : "Gtk" } ] @@ -225,8 +226,8 @@ "items" : [ { "id" : "cr_all_branches", - "* pack" : "pack_start,false", "xtype" : "CellRendererText", + "* pack" : "pack_start,false", "$ xns" : "Gtk" } ] diff --git a/Clones.vala b/Clones.vala index befa7f30..8b0da799 100644 --- a/Clones.vala +++ b/Clones.vala @@ -169,6 +169,12 @@ public class Clones : Object // set gobject values this.el.label = "Add Repository"; + // init method + + { + this.el.get_style_context().add_class("suggested-action"); + } + //listeners this.el.clicked.connect( () => { Clone.singleton().show(this.el); diff --git a/Makefile.am b/Makefile.am index 731bbd4f..3556ac92 100644 --- a/Makefile.am +++ b/Makefile.am @@ -32,6 +32,7 @@ Gitlive_SOURCES = \ WindowLog.vala \ Clones.vala \ Clone.vala \ + Ticket.vala \ NewBranch.vala \ MergeBranch.vala \ RepoStatusPopover.vala diff --git a/NewBranch.bjs b/NewBranch.bjs index 040ffc1d..a218c914 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 ) \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 \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);\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 \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 \tthis.el.run();\n\n}", "default_height" : 200, "$ xns" : "Gtk", "# bool running" : false, @@ -65,8 +65,8 @@ "changed" : "() => {\n\tif (this.loading) {\n\t\treturn;\n\t}\n\tvar project_id = this.selectedProjectId();\n\t_this.dbmodel.loadTickets(project_id);\n\t\n\t\n\t/*if (this.loading) {\n\t\treturn;\n\t}\n\tvar ticket_id = this.selectedTicketId();\n\t\n\tvar name = RooTicket.singleton().usernameLocal();\n\t\n\tif (ticket_id == \"\" || ticket_id == null) {\n\t\n\t\tvar dt = new DateTime.now_local();\n\t\t_this.name.el.set_text(\"wip_%s_%s\".printf(name,dt.format(\"%Y_%b_%d\")));\n\t\treturn;\n\t}\n\t\n\t\n\tvar ticket = RooTicket.singleton().getById(ticket_id);\n \n\t_this.name.el.set_text(\"wip_%s_T%s_%s\".printf(name,ticket.id, ticket.summaryToBranchName()));\n\t\n\t//GLib.debug (//\"Selection: %s, %s\\n\", (string) val1, (string) val2);\n\t*/\n}" }, "* ctor" : "new Gtk.ComboBox.with_entry()", - "id" : "projectsel", "| string selectedProjectId" : "() {\n\tGtk.TreeIter iter;\n\tValue val1;\n \n \n\tthis.el.get_active_iter (out iter);\n\t_this.prmodel.el.get_value (iter, 0, out val1);\n \n\n\treturn (string) val1;\n\t\n\t\n\t\n\t\n}\n", + "id" : "projectsel", "* init" : "this.el.set_entry_text_column(1);", "* pack" : "attach_defaults,0,1,1,2", "xtype" : "ComboBox", @@ -75,8 +75,8 @@ "items" : [ { "id" : "prcellrenderer", - "xtype" : "CellRendererText", "* pack" : "pack_start,true", + "xtype" : "CellRendererText", "$ xns" : "Gtk" }, { @@ -105,15 +105,15 @@ "items" : [ { "id" : "dbcellrenderer", - "* pack" : "pack_start,true", "xtype" : "CellRendererText", + "* pack" : "pack_start,true", "$ xns" : "Gtk" }, { "id" : "dbmodel", - "* pack" : "set_model", "xtype" : "ListStore", - "| void loadTickets" : "(string project_id) {\n\n\n \n // fixme .. get project id from selection..\n \n RooTicket.singleton().loadTickets(\n \t\t\tproject_id,\n \t\t\t_this.btn_not_me.el.active ? RooTicket.NotMe.TRUE : RooTicket.NotMe.FALSE,\n \t\t\t _this.btn_closed.el.active ? RooTicket.Closed.TRUE : RooTicket.Closed.FALSE\n\t\t );\n \n _this.ticketsel.loading = true;\n\n this.el.clear(); \n Gtk.TreeIter iter;\n var el = this.el;\n \n el.append(out iter);\n\n \n el.set_value(iter, 0, \"\");\n el.set_value(iter, 1, \"-- select a ticket --\");\n \n _this.ticketsel.el.set_active_iter(iter);\n var tickets = RooTicket.singleton().tickets;\n foreach(var ticket in tickets) {\n \n el.append(out iter);\n \n el.set_value(iter, 0, ticket.id);\n el.set_value(iter, 1, \"#%s [%s] %s\".printf( ticket.id, ticket.project_id_name , ticket.summary));\n \n //if (data.get(i) == cur) {\n // _this.build_module.el.set_active_iter(iter);\n // }\n \n }\n \n _this.ticketsel.loading = false;\n //this.el.set_sort_column_id(0, Gtk.SortType.ASCENDING); \n \n}\n", + "* pack" : "set_model", + "| void loadTickets" : "(string project_id , string tid = \"\") {\n\n\n \n // fixme .. get project id from selection..\n \n RooTicket.singleton().loadTickets(\n \t\t\tproject_id,\n \t\t\t_this.btn_not_me.el.active ? RooTicket.NotMe.TRUE : RooTicket.NotMe.FALSE,\n \t\t\t _this.btn_closed.el.active ? RooTicket.Closed.TRUE : RooTicket.Closed.FALSE\n\t\t );\n \n _this.ticketsel.loading = true;\n\n this.el.clear(); \n Gtk.TreeIter iter;\n var el = this.el;\n \n el.append(out iter);\n\n \n el.set_value(iter, 0, \"\");\n el.set_value(iter, 1, \"-- select a ticket --\");\n \n _this.ticketsel.el.set_active_iter(iter);\n var tickets = RooTicket.singleton().tickets;\n foreach(var ticket in tickets) {\n \n el.append(out iter);\n \n el.set_value(iter, 0, ticket.id);\n el.set_value(iter, 1, \"#%s [%s] %s\".printf( ticket.id, ticket.project_id_name , ticket.summary));\n \n if (ticket.id == tid) {\n\t\t _this.ticketsel.el.set_active_iter(iter);\n }\n \n }\n \n _this.ticketsel.loading = false;\n //this.el.set_sort_column_id(0, Gtk.SortType.ASCENDING); \n \n}\n", "$ columns" : "typeof(string),typeof(string)", "n_columns" : 2, "$ xns" : "Gtk" @@ -122,8 +122,8 @@ }, { "bool expand" : false, - "xtype" : "Button", "* pack" : "attach_defaults,4,5,1,2", + "xtype" : "Button", "string label" : "New Ticket", "$ xns" : "Gtk" }, @@ -146,7 +146,7 @@ }, { "listeners" : { - "activate" : "() => {\n\t_this.el.response(1);\n}\n" + "clicked" : "() => {\n\tGLib.debug(\"fire response = 1\");\n\t_this.el.response(1);\n}" }, "label" : "Create Branch", "* init" : "{\n this.el.get_style_context().add_class(\"suggested-action\");\n}\n", @@ -165,8 +165,8 @@ "toggled" : "() => {\n\tvar project_id = _this.projectsel.selectedProjectId();\n\t_this.dbmodel.loadTickets(project_id);\t\n}" }, "id" : "btn_not_me", - "string label" : "Show tickets not assigned to me", "* pack" : "add", + "string label" : "Show tickets not assigned to me", "xtype" : "CheckButton", "$ xns" : "Gtk" }, @@ -175,8 +175,8 @@ "toggled" : "() => {\n \tvar project_id = _this.projectsel.selectedProjectId();\n\t_this.dbmodel.loadTickets(project_id);\t\n\t \n}" }, "id" : "btn_closed", - "xtype" : "CheckButton", "string label" : "Show closed Tickets", + "xtype" : "CheckButton", "* pack" : "add", "$ xns" : "Gtk" }, diff --git a/NewBranch.vala b/NewBranch.vala index 34662cd4..643489b2 100644 --- a/NewBranch.vala +++ b/NewBranch.vala @@ -97,7 +97,7 @@ public class NewBranch : Object } // user defined functions - public void show ( GitRepo repo, Gee.ArrayList queue ) + public void show ( GitRepo repo, Gee.ArrayList queue, string tid = "" ) { // this.el.set_gravity(Gdk.Gravity.NORTH); if (this.running) { // should not happen!! @@ -125,7 +125,7 @@ public class NewBranch : Object var curproj = RooTicket.singleton().getProjectByRepo(this.repo); _this.prmodel.loadProjects(curproj == null ? "" : curproj.id); - _this.dbmodel.loadTickets(curproj == null ? "": curproj.id); + _this.dbmodel.loadTickets(curproj == null ? "": curproj.id, tid); this.el.run(); } @@ -536,7 +536,7 @@ public class NewBranch : Object } // user defined functions - public void loadTickets (string project_id) { + public void loadTickets (string project_id , string tid = "") { @@ -569,9 +569,9 @@ public class NewBranch : Object el.set_value(iter, 0, ticket.id); el.set_value(iter, 1, "#%s [%s] %s".printf( ticket.id, ticket.project_id_name , ticket.summary)); - //if (data.get(i) == cur) { - // _this.build_module.el.set_active_iter(iter); - // } + if (ticket.id == tid) { + _this.ticketsel.el.set_active_iter(iter); + } } @@ -681,7 +681,8 @@ public class NewBranch : Object } //listeners - this.el.activate.connect( () => { + this.el.clicked.connect( () => { + GLib.debug("fire response = 1"); _this.el.response(1); }); } diff --git a/RepoStatusPopover.bjs b/RepoStatusPopover.bjs index 9cc00e91..5952a648 100644 --- a/RepoStatusPopover.bjs +++ b/RepoStatusPopover.bjs @@ -31,15 +31,15 @@ "items" : [ { "id" : "label_status", - "xtype" : "Label", "* pack" : false, + "xtype" : "Label", "$ xns" : "Gtk", "utf8 label" : "Status" }, { "id" : "label_diff", - "* pack" : false, "xtype" : "Label", + "* pack" : false, "$ xns" : "Gtk", "utf8 label" : "Diff" }, @@ -75,8 +75,8 @@ "items" : [ { "int height_request" : 400, - "xtype" : "ScrolledWindow", "* pack" : "pack_start,true,true,0", + "xtype" : "ScrolledWindow", "$ xns" : "Gtk", "items" : [ { @@ -106,8 +106,8 @@ "button_press_event" : "() => {\n \n \n GitMonitor.gitmonitor.stop();\n _this.repo.git({ \"stash\" , \"--all\" });\n _this.repo.loadStatus();\n GitMonitor.gitmonitor.start();\n _this.diff_view.el.get_buffer().set_text(_this.repo.git_diff);\n _this.status_view.el.get_buffer().set_text(_this.repo.git_status);\n Clones.singleton().reposStore.load();\n \n _this.el.hide();\n return false;\n}" }, "label" : "Stash Changes", - "* pack" : "add", "xtype" : "Button", + "* pack" : "add", "$ xns" : "Gtk" }, { @@ -115,17 +115,17 @@ "button_press_event" : "() => {\n _this.repo.git({ \"commit\" , \"-a\" ,\"-m\", \"Uncommited changes synced\" });\n _this.repo.push();\n _this.repo.loadStatus();\n \n _this.diff_view.el.get_buffer().set_text(_this.repo.git_diff);\n _this.status_view.el.get_buffer().set_text(_this.repo.git_status);\n \n _this.el.hide();\n Clones.singleton().reposStore.load();\n \n return false;\n}" }, "label" : "Commit Changes", - "* pack" : "add", "xtype" : "Button", + "* pack" : "add", "$ xns" : "Gtk" }, { "listeners" : { - "button_press_event" : "() => {\n var oldq = new Gee.ArrayList(); \n\t \n\tNewBranch.singleton().show(_this.repo, oldq);\n\n return false;\n}" + "button_press_event" : "() => {\n var oldq = new Gee.ArrayList(); \n\t_this.el.hide();\n\tClones.singleton().el.hide();\n\tNewBranch.singleton().show(_this.repo, oldq);\n\n return false;\n}" }, "label" : "Create Branch", - "xtype" : "Button", "* pack" : "add", + "xtype" : "Button", "$ xns" : "Gtk" }, { @@ -133,8 +133,8 @@ "button_press_event" : "() => {\n _this.el.hide();\n return false;\n}" }, "label" : "Ignore for now", - "xtype" : "Button", "* pack" : "add", + "xtype" : "Button", "$ xns" : "Gtk" } ] diff --git a/RepoStatusPopover.vala b/RepoStatusPopover.vala index 3fc1a6be..d9e384ea 100644 --- a/RepoStatusPopover.vala +++ b/RepoStatusPopover.vala @@ -466,7 +466,8 @@ public class RepoStatusPopover : Object //listeners this.el.button_press_event.connect( () => { var oldq = new Gee.ArrayList(); - + _this.el.hide(); + Clones.singleton().el.hide(); NewBranch.singleton().show(_this.repo, oldq); return false; diff --git a/RooTicket.vala b/RooTicket.vala index d675621c..5d3c357c 100644 --- a/RooTicket.vala +++ b/RooTicket.vala @@ -1,4 +1,4 @@ -/** +/** code to fetch ticket info... @@ -13,10 +13,27 @@ public class RooRepo : Object public string project_id; public string description; public string shortname; + +} + +public class RooOption : Object +{ + + public string id; // not really important that they are numbers.. + public string name; + public string display_name; + + public RooOption (string id, string name, string display_name) + { + this.id = id; + this.name = name; + this.display_name = name; + } } + public class RooProject : Object { public string id; // not really important that they are numbers.. @@ -58,6 +75,14 @@ public class RooTicket : Object public Gee.ArrayList tickets; // only available for singletonn. public Gee.ArrayList projects; // only available for singletonn. public Gee.ArrayList repos; // only available for singletonn. + + public Gee.ArrayList milestones; + public Gee.ArrayList priorities; + public Gee.ArrayList serverities; + public Gee.ArrayList classifications; + public Gee.ArrayList developers; + + public string username = ""; // only available for singletonn. public string password = ""; // only available for singletonn. @@ -89,6 +114,20 @@ public class RooTicket : Object } + public Gee.ArrayList readJsonArray(Json.Array a) + { + var ret = new Gee.ArrayList(); + for(var i = 0; i < a.get_length(); i++) { + var t = a.get_object_element(i); + ret.add(new RooOption( + t.get_string_member("id"), + t.get_string_member("name"), + t.get_string_member("display_name") + )); + } + return ret; + + } public RooTicket addTicket(Json.Object t) { @@ -412,7 +451,73 @@ public class RooTicket : Object } } - + public void loadProjectOptions(string pid) + { + var rt = RooTicket.singleton(); + rt.milestones = new Gee.ArrayList(); + rt.priorities = new Gee.ArrayList(); + rt.serverities = new Gee.ArrayList(); + rt.classifications = new Gee.ArrayList(); + rt.developers = new Gee.ArrayList(); + + if (pid == "") { + return; + } + + + + var table = new GLib.HashTable(str_hash, str_equal); + + table.insert("_options_for",pid); + + var params = Soup.Form.encode_hash(table); + + var url = "%s/%s?%s" . printf(roourl, "mtrack_ticket", params); + + GLib.debug("request %s", url); + + var session = new Soup.Session (); + session.timeout = 0; + var message = new Soup.Message ("GET", url); + + + RooTicket.setAuth(message); + + session.send_message (message); + + var data = (string) message.response_body.flatten().data; + //GLib.debug("got %s", data); + try { + var parser = new Json.Parser (); + parser.load_from_data (data, -1); + + var response = parser.get_root().get_object(); + var status = response.get_boolean_member("success"); + + if(!status){ + GLib.error(response.get_string_member("errorMsg")); + return; + } + var rd = response.get_object_member ("data"); + + rt.milestones = this.readJsonArray( rd.get_array_member("milestone")); + rt.priorities = this.readJsonArray( rd.get_array_member("priority")); + rt.serverities = this.readJsonArray( rd.get_array_member("severity")); + rt.classifications = this.readJsonArray( rd.get_array_member("classification")); + rt.developers = this.readJsonArray( rd.get_array_member("developer")); + + + + + // got a valid result... + + + } catch (Error e) { + GLib.error(e.message); + return; + } + + } public static void setAuth(Soup.Message message) { @@ -490,7 +595,64 @@ public class RooTicket : Object } } + public string createTicket( + string project_id, + string milestone_id, + string priority_id, + string classification_id, + string developer_id, + string summary, + string description + ) + { + + var table = new GLib.HashTable(str_hash, str_equal); + + table.insert("project_id", project_id); + table.insert("milestone_id", milestone_id); + table.insert("priority_id", priority_id); + table.insert("classification_id", classification_id); + table.insert("developer_id", developer_id); + table.insert("summary", summary); + table.insert("description", description); + + var params = Soup.Form.encode_hash(table); + + GLib.debug("request POST %s / %s", roourl, id); + + var session = new Soup.Session (); + session.timeout = 0; + var message = new Soup.Message ("POST", roourl + "/mtrack_ticket"); + RooTicket.setAuth(message); + message.set_request ("application/x-www-form-urlencoded", Soup.MemoryUse.STATIC, params.data); + session.send_message (message); + + + var data = (string) message.response_body.flatten().data; + GLib.debug("got %s", data); + try { + var parser = new Json.Parser (); + parser.load_from_data (data, -1); + + var response = parser.get_root().get_object(); + var status = response.get_boolean_member("success"); + + if(!status){ + GLib.error(response.get_string_member("errorMsg")); + return "" ; + } + var rd = response.get_object_member ("data"); + return rd.get_string_member("id"); + + + + } catch (Error e) { + GLib.error(e.message); + return ""; + } + + } } diff --git a/StatusIcon.vala b/StatusIcon.vala index efedebaa..d2154e0c 100644 --- a/StatusIcon.vala +++ b/StatusIcon.vala @@ -180,6 +180,7 @@ public class StatusIconA : StatusIcon { this.append(this.after_seperator); //this.append(new MenuItemUpdateTimesheet()); this.append(new MenuItemManageClones()); + this.append(new MenuItemNewTicket()); this.append(new MenuItemAbout()); this.append(new MenuItemQuit()); this.merge_items = new Gee.ArrayList(); @@ -468,6 +469,30 @@ public class StatusIconA : StatusIcon { } + class MenuItemNewTicket : ImageMenuItem { + + public MenuItemNewTicket() + { + + var image = new Gtk.Image(); + image.set_from_stock(Gtk.Stock.FULLSCREEN,Gtk.IconSize.MENU ); + this.set_image (image); + this.label= "New Ticket"; + this.always_show_image = true; + this.accel_group = null; + + this.activate.connect( () => { + Ticket.singleton().show(null); + + + // Clones.singleton().show(); + }); + } + + + } + + class MenuItemAbout : ImageMenuItem { public MenuItemAbout() diff --git a/Ticket.bjs b/Ticket.bjs new file mode 100644 index 00000000..d2c8a699 --- /dev/null +++ b/Ticket.bjs @@ -0,0 +1,277 @@ +{ + "name" : "Ticket", + "parent" : "", + "title" : "", + "path" : "/home/alan/gitlive/gitlive/Ticket.bjs", + "permname" : "", + "modOrder" : "", + "build_module" : "gitlive", + "items" : [ + { + "listeners" : { + "delete_event" : "(self, event) => {\n this.el.hide();\n return true; \n //test \n}\n ", + "response" : " (self, response_id) => { \n \n\tGLib.debug(\"got %d\", (int) response_id);\n\tif (response_id < 1) {\n\t _this.el.hide();\t\n\t this.running = false; \n\t \treturn;\n\t}\n\t \n\t \n\tvar tid = RooTicket.singleton().createTicket(\n\t\n\t\t_this.project_id.selectedProjectId(),\n\t\n\t\t_this.milestone_id.selectedMilestoneId(),\n\t\t_this.priority_id.selectedPriorityId() ,\n\t\t_this.classification_id.selectedClassificationId() ,\n\t\t_this.developer_id.selectedDeveloperId(),\n\t\t_this.summary.el.get_text() ,\n\t\t_this.description.el.buffer.text \n\t);\n\t\n\tif (this.repo != null) {\n\t \tNewBranch.singleton().show(this.repo, new Gee.ArrayList(), tid);\n \t}\n\t \n\n\t \n}" + }, + "default_width" : 500, + "$ deletable" : true, + "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 \n \n \tthis.el.run();\n\n}", + "default_height" : 200, + "$ xns" : "Gtk", + "# bool running" : false, + "bool modal" : true, + "items" : [ + { + "xtype" : "VBox", + "$ pack" : "get_content_area().add", + "$ xns" : "Gtk", + "items" : [ + { + "bool homogeneous" : true, + "bool expand" : false, + "xtype" : "Table", + "* pack" : "pack_start,false,false,0", + "uint column_spacing" : 4, + "n_columns" : 4, + "$ xns" : "Gtk", + "n_rows" : 14, + "bool vexpand" : false, + "int margin" : 2, + "items" : [ + { + "label" : "Project", + "$ visible" : true, + "Gtk.Align halign" : "Gtk.Align.START", + "* pack" : "attach_defaults,0,1,0,1", + "xtype" : "Label", + "$ xns" : "Gtk" + }, + { + "label" : "Summary", + "$ visible" : true, + "Gtk.Align halign" : "Gtk.Align.START", + "* pack" : "attach_defaults,1,2,0,1", + "xtype" : "Label", + "x_options" : 4, + "$ xns" : "Gtk" + }, + { + "listeners" : { + "changed" : "() => {\n\tif (this.loading) {\n\t\treturn;\n\t}\n\tvar project_id = this.selectedProjectId();\n\t\n\tvar rt = RooTicket.singleton();\n\trt.loadProjectOptions(project_id);\n\t\n\t_this.msmodel.loadMilestones();\n\t_this.primodel.loadPriorities();\n\t_this.sevmodel.loadSeverities();\n\t_this.clmodel.loadClassifications();\t\n\t_this.devmodel.loadDevelopers();\t\n\t\n\t// affects projects and milestones..\n\t\n\t\n\t/*if (this.loading) {\n\t\treturn;\n\t}\n\tvar ticket_id = this.selectedTicketId();\n\t\n\tvar name = RooTicket.singleton().usernameLocal();\n\t\n\tif (ticket_id == \"\" || ticket_id == null) {\n\t\n\t\tvar dt = new DateTime.now_local();\n\t\t_this.name.el.set_text(\"wip_%s_%s\".printf(name,dt.format(\"%Y_%b_%d\")));\n\t\treturn;\n\t}\n\t\n\t\n\tvar ticket = RooTicket.singleton().getById(ticket_id);\n \n\t_this.name.el.set_text(\"wip_%s_T%s_%s\".printf(name,ticket.id, ticket.summaryToBranchName()));\n\t\n\t//GLib.debug (//\"Selection: %s, %s\\n\", (string) val1, (string) val2);\n\t*/\n}" + }, + "* ctor" : "new Gtk.ComboBox.with_entry()", + "id" : "project_id", + "| string selectedProjectId" : "() {\n\tGtk.TreeIter iter;\n\tValue val1;\n \n \n\tthis.el.get_active_iter (out iter);\n\t_this.prmodel.el.get_value (iter, 0, out val1);\n \n\n\treturn (string) val1;\n\t\n\t\n\t\n\t\n}\n", + "* init" : "this.el.set_entry_text_column(1);", + "* pack" : "attach_defaults,0,1,1,2", + "xtype" : "ComboBox", + "# bool loading" : false, + "$ xns" : "Gtk", + "items" : [ + { + "id" : "prcellrenderer", + "xtype" : "CellRendererText", + "* pack" : "pack_start,true", + "$ xns" : "Gtk" + }, + { + "| void loadProjects" : " (string id) {\n\n var rt = RooTicket.singleton();\n rt.loadProjects();\n \n _this.project_id.loading = true;\n\n this.el.clear(); \n Gtk.TreeIter iter;\n var el = this.el;\n \n el.append(out iter);\n\n \n el.set_value(iter, 0, \"\");\n el.set_value(iter, 1, \"-- select a project --\");\n if (id == \"\") {\n\t _this.project_id.el.set_active_iter(iter);\n }\n var projects = rt.projects;\n foreach(var project in projects) {\n \n el.append(out iter);\n \n el.set_value(iter, 0, project.id);\n el.set_value(iter, 1, project.name );\n if (id == project.id) {\n\t \t _this.project_id.el.set_active_iter(iter);\n\t } \n \n }\n \n _this.project_id.loading = false;\n //this.el.set_sort_column_id(0, Gtk.SortType.ASCENDING); \n \n}\n", + "id" : "prmodel", + "* pack" : "set_model", + "xtype" : "ListStore", + "$ columns" : "typeof(string),typeof(string)", + "n_columns" : 2, + "$ xns" : "Gtk" + } + ] + }, + { + "id" : "summary", + "$ visible" : true, + "xtype" : "Entry", + "* pack" : "attach_defaults,1,4,1,2", + "$ xns" : "Gtk" + }, + { + "label" : "Milestone", + "Gtk.Align halign" : "Gtk.Align.START", + "xalign" : 0.90000000000000002, + "* pack" : "attach_defaults,0,1,2,3", + "xtype" : "Label", + "$ justify" : "Gtk.Justification.RIGHT", + "x_options" : 4, + "$ xns" : "Gtk" + }, + { + "* ctor" : "new Gtk.ComboBox.with_entry()", + "id" : "milestone_id", + "* init" : "this.el.set_entry_text_column(1);", + "* pack" : "attach_defaults,0,1,3,4", + "xtype" : "ComboBox", + "# bool loading" : false, + "$ xns" : "Gtk", + "| string selectedMilestoneId" : "() {\n\tGtk.TreeIter iter;\n\tValue val1;\n \n \n\tthis.el.get_active_iter (out iter);\n\t_this.msmodel.el.get_value (iter, 0, out val1);\n \n\n\treturn (string) val1;\n\t\n\t\n\t\n\t\n}\n", + "items" : [ + { + "id" : "msmodel", + "* pack" : "set_model", + "xtype" : "ListStore", + "| void loadMilestones" : " ( ) {\n\n var rt = RooTicket.singleton();\n // rt.loadProjects();\n \n _this.milestone_id.loading = true;\n\n this.el.clear(); \n Gtk.TreeIter iter;\n var el = this.el;\n \n el.append(out iter);\n\n \n el.set_value(iter, 0, \"\");\n el.set_value(iter, 1, \"-- select a milestone --\");\n _this.milestone_id.el.set_active_iter(iter); \n \n var projects = rt.milestones;\n foreach(var project in projects) {\n \n el.append(out iter);\n \n el.set_value(iter, 0, project.id);\n el.set_value(iter, 1, project.display_name );\n // if (id == project.id) {\n\t //\t _this.milestone.el.set_active_iter(iter);\n\t // } \n \n }\n \n \n _this.milestone_id.loading = false;\n //this.el.set_sort_column_id(0, Gtk.SortType.ASCENDING); \n \n}\n", + "$ columns" : "typeof(string),typeof(string)", + "n_columns" : 2, + "$ xns" : "Gtk" + } + ] + }, + { + "label" : "Description", + "Gtk.Align halign" : "Gtk.Align.START", + "* pack" : "attach_defaults,1,4,2,3", + "xtype" : "Label", + "x_options" : 4, + "$ xns" : "Gtk" + }, + { + "id" : "description", + "* pack" : "attach_defaults,1,4,3,12", + "xtype" : "TextView", + "$ xns" : "Gtk", + "uint border_width" : 1 + }, + { + "label" : "Priority", + "Gtk.Align halign" : "Gtk.Align.START", + "xalign" : 0.90000000000000002, + "* pack" : "attach_defaults,0,1,4,5", + "xtype" : "Label", + "x_options" : 4, + "$ xns" : "Gtk" + }, + { + "* ctor" : "new Gtk.ComboBox.with_entry()", + "id" : "priority_id", + "* init" : "this.el.set_entry_text_column(1);", + "* pack" : "attach_defaults,0,1,5,6", + "xtype" : "ComboBox", + "# bool loading" : false, + "$ xns" : "Gtk", + "| string selectedPriorityId" : "() {\n\tGtk.TreeIter iter;\n\tValue val1;\n \n \n\tthis.el.get_active_iter (out iter);\n\t_this.primodel.el.get_value (iter, 0, out val1);\n \n\n\treturn (string) val1;\n\t\n\t\n\t\n\t\n}\n", + "items" : [ + { + "id" : "primodel", + "| void loadPriorities" : " ( ) {\n\n var rt = RooTicket.singleton();\n // rt.loadProjects();\n \n _this.priority_id.loading = true;\n\n this.el.clear(); \n Gtk.TreeIter iter;\n var el = this.el;\n \n \n var projects = rt.priorities;\n foreach(var project in projects) {\n \n el.append(out iter);\n \n el.set_value(iter, 0, project.id);\n el.set_value(iter, 1, project.display_name );\n if (\"normal\" == project.name) {\n\t \t _this.priority_id.el.set_active_iter(iter);\n\t } \n \n }\n \n _this.priority_id.loading = false;\n \n \n}\n", + "* pack" : "set_model", + "xtype" : "ListStore", + "$ columns" : "typeof(string),typeof(string)", + "n_columns" : 2, + "$ xns" : "Gtk" + } + ] + }, + { + "label" : "Severity", + "Gtk.Align halign" : "Gtk.Align.START", + "* pack" : "attach_defaults,0,1,6,7", + "xtype" : "Label", + "x_options" : 4, + "$ xns" : "Gtk" + }, + { + "* ctor" : "new Gtk.ComboBox.with_entry()", + "id" : "severity_id", + "* init" : "this.el.set_entry_text_column(1);", + "* pack" : "attach_defaults,0,1,7,8", + "xtype" : "ComboBox", + "# bool loading" : false, + "$ xns" : "Gtk", + "| string selectedSeverityId" : "() {\n\tGtk.TreeIter iter;\n\tValue val1;\n \n \n\tthis.el.get_active_iter (out iter);\n\t_this.sevmodel.el.get_value (iter, 0, out val1);\n \n\n\treturn (string) val1;\n\t\n\t\n\t\n\t\n}\n", + "items" : [ + { + "| void loadSeverities" : " () {\n\n var rt = RooTicket.singleton();\n //rt.loadProjects();\n \n _this.severity_id.loading = true;\n\n this.el.clear(); \n Gtk.TreeIter iter;\n var el = this.el;\n \n var projects = rt.serverities;\n foreach(var project in projects) {\n \n el.append(out iter);\n \n el.set_value(iter, 0, project.id);\n el.set_value(iter, 1, project.display_name );\n if (\"normal\" == project.name) {\n\t \t _this.severity_id.el.set_active_iter(iter);\n\t } \n \n }\n \n _this.severity_id.loading = false;\n //this.el.set_sort_column_id(0, Gtk.SortType.ASCENDING); \n \n}\n", + "id" : "sevmodel", + "* pack" : "set_model", + "xtype" : "ListStore", + "$ columns" : "typeof(string),typeof(string)", + "n_columns" : 2, + "$ xns" : "Gtk" + } + ] + }, + { + "label" : "Classification", + "Gtk.Align halign" : "Gtk.Align.START", + "* pack" : "attach_defaults,0,1,8,9", + "xtype" : "Label", + "x_options" : 4, + "$ xns" : "Gtk" + }, + { + "* ctor" : "new Gtk.ComboBox.with_entry()", + "id" : "classification_id", + "* init" : "this.el.set_entry_text_column(1);", + "* pack" : "attach_defaults,0,1,9,10", + "xtype" : "ComboBox", + "# bool loading" : false, + "$ xns" : "Gtk", + "| string selectedClassificationId" : "() {\n\tGtk.TreeIter iter;\n\tValue val1;\n \n \n\tthis.el.get_active_iter (out iter);\n\t_this.clmodel.el.get_value (iter, 0, out val1);\n \n\n\treturn (string) val1;\n\t\n\t\n\t\n\t\n}\n", + "items" : [ + { + "id" : "clmodel", + "| void loadClassifications" : " ( ) {\n\n var rt = RooTicket.singleton();\n // rt.loadProjects();\n \n _this.classification_id.loading = true;\n\n this.el.clear(); \n Gtk.TreeIter iter;\n var el = this.el;\n \n el.append(out iter);\n\n \n var projects = rt.classifications;\n foreach(var project in projects) {\n \n el.append(out iter);\n \n el.set_value(iter, 0, project.id);\n el.set_value(iter, 1, project.display_name );\n if (\"bug\" == project.name) {\n\t \t _this.classification_id.el.set_active_iter(iter);\n\t } \n \n }\n \n _this.classification_id.loading = false;\n //this.el.set_sort_column_id(0, Gtk.SortType.ASCENDING); \n \n}\n", + "* pack" : "set_model", + "xtype" : "ListStore", + "$ columns" : "typeof(string),typeof(string)", + "n_columns" : 2, + "$ xns" : "Gtk" + } + ] + }, + { + "label" : "Assign to", + "Gtk.Align halign" : "Gtk.Align.START", + "* pack" : "attach_defaults,0,1,10,11", + "xtype" : "Label", + "x_options" : 4, + "$ xns" : "Gtk" + }, + { + "* ctor" : "new Gtk.ComboBox.with_entry()", + "id" : "developer_id", + "* init" : "this.el.set_entry_text_column(1);", + "* pack" : "attach_defaults,0,1,11,12", + "xtype" : "ComboBox", + "# bool loading" : false, + "| string selectedDeveloperId" : "() {\n\tGtk.TreeIter iter;\n\tValue val1;\n \n \n\tthis.el.get_active_iter (out iter);\n\t_this.devmodel.el.get_value (iter, 0, out val1);\n \n\n\treturn (string) val1;\n\t\n\t\n\t\n\t\n}\n", + "$ xns" : "Gtk", + "items" : [ + { + "id" : "devmodel", + "* pack" : "set_model", + "xtype" : "ListStore", + "$ columns" : "typeof(string),typeof(string)", + "n_columns" : 2, + "$ xns" : "Gtk", + "| void loadDevelopers" : " ( ) {\n\n var rt = RooTicket.singleton();\n //rt.loadProjects();\n \n _this.developer_id.loading = true;\n\n this.el.clear(); \n Gtk.TreeIter iter;\n var el = this.el;\n \n el.append(out iter);\n\n \n el.set_value(iter, 0, \"\");\n el.set_value(iter, 1, \"-- select a developer --\");\n // if (id == \"\") {\n\t _this.developer_id.el.set_active_iter(iter);\n // }\n \n var projects = rt.developers;\n foreach(var project in projects) {\n \n el.append(out iter);\n \n el.set_value(iter, 0, project.id);\n el.set_value(iter, 1, project.display_name );\n// if (id == project.id) {\n\t// \t _this.projectsel.el.set_active_iter(iter);\n//\t } \n \n }\n \n _this.developer_id.loading = false;\n //this.el.set_sort_column_id(0, Gtk.SortType.ASCENDING); \n \n}\n" + } + ] + }, + { + "listeners" : { + "clicked" : "() => {\n\tGLib.debug(\"fire response = 1\");\n\t\n\t\n\tvar invalid = false;\n\t\n\t// validate first...\n\t_this.project_id.el.get_child().get_style_context().remove_class(\"warning\");\t\n\tif (_this.project_id.selectedProjectId() == \"\") {\n\t\t_this.project_id.el.get_child().get_style_context().add_class(\"warning\");\n\t\tinvalid = true;\n\t}\n\t\n\t_this.milestone_id.el.get_child().get_style_context().remove_class(\"warning\");\t\n\tif (_this.milestone_id.selectedMilestoneId() == \"\") {\n\t\t_this.milestone_id.el.get_child().get_style_context().add_class(\"warning\");\n\t\tinvalid = true;\n\t}\n\n\t_this.priority_id.el.get_child().get_style_context().remove_class(\"warning\");\t\n\tif (_this.priority_id.selectedPriorityId() == \"\") {\n\t\t_this.priority_id.el.get_child().get_style_context().add_class(\"warning\");\n\t\tinvalid = true;\n\t}\n\t\n\t_this.classification_id.el.get_child().get_style_context().remove_class(\"warning\");\t\n\tif (_this.classification_id.selectedClassificationId() == \"\") {\n\t\t_this.classification_id.el.get_child().get_style_context().add_class(\"warning\");\n\t\tinvalid = true;\n\t}\n\t\n\t_this.developer_id.el.get_child().get_style_context().remove_class(\"warning\");\t\n\tif (_this.developer_id.selectedDeveloperId() == \"\") {\n\t\t_this.developer_id.el.get_child().get_style_context().add_class(\"warning\");\n\t\tinvalid = true;\n\t}\n\t\n\t_this.summary.el.get_style_context().remove_class(\"warning\");\t\n\tif (_this.summary.el.get_text() == \"\") {\n\t\t_this.summary.el.get_style_context().add_class(\"warning\");\n\t\tinvalid = true;\n\t}\n\t\n\t_this.description.el.get_style_context().remove_class(\"warning\");\t\n\tif (_this.description.el.buffer.text == \"\") {\n\t\t_this.description.el.get_style_context().add_class(\"warning\");\n\t\tinvalid = true;\n\t}\n\t\n\t\n\tif (invalid) {\n\t\treturn;\n\t}\n\tGLib.debug(\"for is valid\");\n\t\n\t_this.el.response(1);\n}" + }, + "label" : "Create Ticket", + "* init" : "{\n this.el.get_style_context().add_class(\"suggested-action\");\n}\n", + "xtype" : "Button", + "* pack" : "attach_defaults,0,4,13,14", + "$ xns" : "Gtk" + } + ] + } + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/Ticket.vala b/Ticket.vala new file mode 100644 index 00000000..9857b7ff --- /dev/null +++ b/Ticket.vala @@ -0,0 +1,1240 @@ +static Ticket _Ticket; + +public class Ticket : Object +{ + public Gtk.Dialog el; + private Ticket _this; + + public static Ticket singleton() + { + if (_Ticket == null) { + _Ticket= new Ticket(); + } + return _Ticket; + } + public Xcls_project_id project_id; + public Xcls_prcellrenderer prcellrenderer; + public Xcls_prmodel prmodel; + public Xcls_summary summary; + public Xcls_milestone_id milestone_id; + public Xcls_msmodel msmodel; + public Xcls_description description; + public Xcls_priority_id priority_id; + public Xcls_primodel primodel; + public Xcls_severity_id severity_id; + public Xcls_sevmodel sevmodel; + public Xcls_classification_id classification_id; + public Xcls_clmodel clmodel; + public Xcls_developer_id developer_id; + public Xcls_devmodel devmodel; + + // my vars (def) + public GitRepo? repo; + public bool running; + + // ctor + public Ticket() + { + _this = this; + this.el = new Gtk.Dialog(); + + // my vars (dec) + this.repo = null; + this.running = false; + + // set gobject values + this.el.title = "Create a Ticket"; + this.el.default_height = 200; + this.el.default_width = 500; + this.el.deletable = true; + this.el.modal = true; + var child_0 = new Xcls_VBox2( _this ); + child_0.ref(); + this.el.get_content_area().add ( child_0.el ); + + //listeners + this.el.delete_event.connect( (self, event) => { + this.el.hide(); + return true; + //test + }); + this.el.response.connect( (self, response_id) => { + + GLib.debug("got %d", (int) response_id); + if (response_id < 1) { + _this.el.hide(); + this.running = false; + return; + } + + + var tid = RooTicket.singleton().createTicket( + + _this.project_id.selectedProjectId(), + + _this.milestone_id.selectedMilestoneId(), + _this.priority_id.selectedPriorityId() , + _this.classification_id.selectedClassificationId() , + _this.developer_id.selectedDeveloperId(), + _this.summary.el.get_text() , + _this.description.el.buffer.text + ); + + if (this.repo != null) { + NewBranch.singleton().show(this.repo, new Gee.ArrayList(), tid); + } + + + + }); + } + + // user defined functions + public void show ( GitRepo? repo ) + { + // this.el.set_gravity(Gdk.Gravity.NORTH); + if (this.running) { // should not happen!! + GLib.error("new branch show called, when already being displayed?"); + } + + + this.running = true; + //GitMonitor.gitmonitor.stop(); + + this.repo = repo; + + + + + this.el.move((Gdk.Screen.width() / 2)- 250 ,0); + this.el.set_default_size( 500,200); // not sure why it grows.. + GLib.debug("Loading tickets"); + + + this.el.show_all(); + this.el.set_keep_above(true); + + + RooProject? curproj = null; + if (this.repo != null) { + curproj = RooTicket.singleton().getProjectByRepo(this.repo); + } + _this.prmodel.loadProjects(curproj == null ? "" : curproj.id); + + + this.el.run(); + + } + public class Xcls_VBox2 : Object + { + public Gtk.VBox el; + private Ticket _this; + + + // my vars (def) + + // ctor + public Xcls_VBox2(Ticket _owner ) + { + _this = _owner; + this.el = new Gtk.VBox( true, 0 ); + + // my vars (dec) + + // set gobject values + var child_0 = new Xcls_Table3( _this ); + child_0.ref(); + this.el.pack_start ( child_0.el , false,false,0 ); + } + + // user defined functions + } + public class Xcls_Table3 : Object + { + public Gtk.Table el; + private Ticket _this; + + + // my vars (def) + + // ctor + public Xcls_Table3(Ticket _owner ) + { + _this = _owner; + this.el = new Gtk.Table( 14, 4, true ); + + // my vars (dec) + + // set gobject values + this.el.expand = false; + this.el.margin = 2; + this.el.column_spacing = 4; + this.el.vexpand = false; + var child_0 = new Xcls_Label4( _this ); + child_0.ref(); + this.el.attach_defaults ( child_0.el , 0,1,0,1 ); + var child_1 = new Xcls_Label5( _this ); + child_1.ref(); + this.el.attach_defaults ( child_1.el , 1,2,0,1 ); + var child_2 = new Xcls_project_id( _this ); + child_2.ref(); + this.el.attach_defaults ( child_2.el , 0,1,1,2 ); + var child_3 = new Xcls_summary( _this ); + child_3.ref(); + this.el.attach_defaults ( child_3.el , 1,4,1,2 ); + var child_4 = new Xcls_Label10( _this ); + child_4.ref(); + this.el.attach_defaults ( child_4.el , 0,1,2,3 ); + var child_5 = new Xcls_milestone_id( _this ); + child_5.ref(); + this.el.attach_defaults ( child_5.el , 0,1,3,4 ); + var child_6 = new Xcls_Label13( _this ); + child_6.ref(); + this.el.attach_defaults ( child_6.el , 1,4,2,3 ); + var child_7 = new Xcls_description( _this ); + child_7.ref(); + this.el.attach_defaults ( child_7.el , 1,4,3,12 ); + var child_8 = new Xcls_Label15( _this ); + child_8.ref(); + this.el.attach_defaults ( child_8.el , 0,1,4,5 ); + var child_9 = new Xcls_priority_id( _this ); + child_9.ref(); + this.el.attach_defaults ( child_9.el , 0,1,5,6 ); + var child_10 = new Xcls_Label18( _this ); + child_10.ref(); + this.el.attach_defaults ( child_10.el , 0,1,6,7 ); + var child_11 = new Xcls_severity_id( _this ); + child_11.ref(); + this.el.attach_defaults ( child_11.el , 0,1,7,8 ); + var child_12 = new Xcls_Label21( _this ); + child_12.ref(); + this.el.attach_defaults ( child_12.el , 0,1,8,9 ); + var child_13 = new Xcls_classification_id( _this ); + child_13.ref(); + this.el.attach_defaults ( child_13.el , 0,1,9,10 ); + var child_14 = new Xcls_Label24( _this ); + child_14.ref(); + this.el.attach_defaults ( child_14.el , 0,1,10,11 ); + var child_15 = new Xcls_developer_id( _this ); + child_15.ref(); + this.el.attach_defaults ( child_15.el , 0,1,11,12 ); + var child_16 = new Xcls_Button27( _this ); + child_16.ref(); + this.el.attach_defaults ( child_16.el , 0,4,13,14 ); + } + + // user defined functions + } + public class Xcls_Label4 : Object + { + public Gtk.Label el; + private Ticket _this; + + + // my vars (def) + + // ctor + public Xcls_Label4(Ticket _owner ) + { + _this = _owner; + this.el = new Gtk.Label( "Project" ); + + // my vars (dec) + + // set gobject values + this.el.halign = Gtk.Align.START; + this.el.visible = true; + } + + // user defined functions + } + + public class Xcls_Label5 : Object + { + public Gtk.Label el; + private Ticket _this; + + + // my vars (def) + + // ctor + public Xcls_Label5(Ticket _owner ) + { + _this = _owner; + this.el = new Gtk.Label( "Summary" ); + + // my vars (dec) + + // set gobject values + this.el.halign = Gtk.Align.START; + this.el.visible = true; + } + + // user defined functions + } + + public class Xcls_project_id : Object + { + public Gtk.ComboBox el; + private Ticket _this; + + + // my vars (def) + public bool loading; + + // ctor + public Xcls_project_id(Ticket _owner ) + { + _this = _owner; + _this.project_id = this; + this.el = new Gtk.ComboBox.with_entry(); + + // my vars (dec) + this.loading = false; + + // set gobject values + var child_0 = new Xcls_prcellrenderer( _this ); + child_0.ref(); + this.el.pack_start ( child_0.el , true ); + var child_1 = new Xcls_prmodel( _this ); + child_1.ref(); + this.el.set_model ( child_1.el ); + + // init method + + this.el.set_entry_text_column(1); + + //listeners + this.el.changed.connect( () => { + if (this.loading) { + return; + } + var project_id = this.selectedProjectId(); + + var rt = RooTicket.singleton(); + rt.loadProjectOptions(project_id); + + _this.msmodel.loadMilestones(); + _this.primodel.loadPriorities(); + _this.sevmodel.loadSeverities(); + _this.clmodel.loadClassifications(); + _this.devmodel.loadDevelopers(); + + // affects projects and milestones.. + + + /*if (this.loading) { + return; + } + var ticket_id = this.selectedTicketId(); + + var name = RooTicket.singleton().usernameLocal(); + + if (ticket_id == "" || ticket_id == null) { + + var dt = new DateTime.now_local(); + _this.name.el.set_text("wip_%s_%s".printf(name,dt.format("%Y_%b_%d"))); + return; + } + + + var ticket = RooTicket.singleton().getById(ticket_id); + + _this.name.el.set_text("wip_%s_T%s_%s".printf(name,ticket.id, ticket.summaryToBranchName())); + + //GLib.debug (//"Selection: %s, %s\n", (string) val1, (string) val2); + */ + }); + } + + // user defined functions + public string selectedProjectId () { + Gtk.TreeIter iter; + Value val1; + + + this.el.get_active_iter (out iter); + _this.prmodel.el.get_value (iter, 0, out val1); + + + return (string) val1; + + + + + } + } + public class Xcls_prcellrenderer : Object + { + public Gtk.CellRendererText el; + private Ticket _this; + + + // my vars (def) + + // ctor + public Xcls_prcellrenderer(Ticket _owner ) + { + _this = _owner; + _this.prcellrenderer = this; + this.el = new Gtk.CellRendererText(); + + // my vars (dec) + + // set gobject values + } + + // user defined functions + } + + public class Xcls_prmodel : Object + { + public Gtk.ListStore el; + private Ticket _this; + + + // my vars (def) + + // ctor + public Xcls_prmodel(Ticket _owner ) + { + _this = _owner; + _this.prmodel = this; + this.el = new Gtk.ListStore( 2, typeof(string),typeof(string) ); + + // my vars (dec) + + // set gobject values + } + + // user defined functions + public void loadProjects (string id) { + + var rt = RooTicket.singleton(); + rt.loadProjects(); + + _this.project_id.loading = true; + + this.el.clear(); + Gtk.TreeIter iter; + var el = this.el; + + el.append(out iter); + + + el.set_value(iter, 0, ""); + el.set_value(iter, 1, "-- select a project --"); + if (id == "") { + _this.project_id.el.set_active_iter(iter); + } + var projects = rt.projects; + foreach(var project in projects) { + + el.append(out iter); + + el.set_value(iter, 0, project.id); + el.set_value(iter, 1, project.name ); + if (id == project.id) { + _this.project_id.el.set_active_iter(iter); + } + + } + + _this.project_id.loading = false; + //this.el.set_sort_column_id(0, Gtk.SortType.ASCENDING); + + } + } + + + public class Xcls_summary : Object + { + public Gtk.Entry el; + private Ticket _this; + + + // my vars (def) + + // ctor + public Xcls_summary(Ticket _owner ) + { + _this = _owner; + _this.summary = this; + this.el = new Gtk.Entry(); + + // my vars (dec) + + // set gobject values + this.el.visible = true; + } + + // user defined functions + } + + public class Xcls_Label10 : Object + { + public Gtk.Label el; + private Ticket _this; + + + // my vars (def) + + // ctor + public Xcls_Label10(Ticket _owner ) + { + _this = _owner; + this.el = new Gtk.Label( "Milestone" ); + + // my vars (dec) + + // set gobject values + this.el.halign = Gtk.Align.START; + this.el.justify = Gtk.Justification.RIGHT; + this.el.xalign = 0.900000f; + } + + // user defined functions + } + + public class Xcls_milestone_id : Object + { + public Gtk.ComboBox el; + private Ticket _this; + + + // my vars (def) + public bool loading; + + // ctor + public Xcls_milestone_id(Ticket _owner ) + { + _this = _owner; + _this.milestone_id = this; + this.el = new Gtk.ComboBox.with_entry(); + + // my vars (dec) + this.loading = false; + + // set gobject values + var child_0 = new Xcls_msmodel( _this ); + child_0.ref(); + this.el.set_model ( child_0.el ); + + // init method + + this.el.set_entry_text_column(1); + } + + // user defined functions + public string selectedMilestoneId () { + Gtk.TreeIter iter; + Value val1; + + + this.el.get_active_iter (out iter); + _this.msmodel.el.get_value (iter, 0, out val1); + + + return (string) val1; + + + + + } + } + public class Xcls_msmodel : Object + { + public Gtk.ListStore el; + private Ticket _this; + + + // my vars (def) + + // ctor + public Xcls_msmodel(Ticket _owner ) + { + _this = _owner; + _this.msmodel = this; + this.el = new Gtk.ListStore( 2, typeof(string),typeof(string) ); + + // my vars (dec) + + // set gobject values + } + + // user defined functions + public void loadMilestones ( ) { + + var rt = RooTicket.singleton(); + // rt.loadProjects(); + + _this.milestone_id.loading = true; + + this.el.clear(); + Gtk.TreeIter iter; + var el = this.el; + + el.append(out iter); + + + el.set_value(iter, 0, ""); + el.set_value(iter, 1, "-- select a milestone --"); + _this.milestone_id.el.set_active_iter(iter); + + var projects = rt.milestones; + foreach(var project in projects) { + + el.append(out iter); + + el.set_value(iter, 0, project.id); + el.set_value(iter, 1, project.display_name ); + // if (id == project.id) { + // _this.milestone.el.set_active_iter(iter); + // } + + } + + + _this.milestone_id.loading = false; + //this.el.set_sort_column_id(0, Gtk.SortType.ASCENDING); + + } + } + + + public class Xcls_Label13 : Object + { + public Gtk.Label el; + private Ticket _this; + + + // my vars (def) + + // ctor + public Xcls_Label13(Ticket _owner ) + { + _this = _owner; + this.el = new Gtk.Label( "Description" ); + + // my vars (dec) + + // set gobject values + this.el.halign = Gtk.Align.START; + } + + // user defined functions + } + + public class Xcls_description : Object + { + public Gtk.TextView el; + private Ticket _this; + + + // my vars (def) + + // ctor + public Xcls_description(Ticket _owner ) + { + _this = _owner; + _this.description = this; + this.el = new Gtk.TextView(); + + // my vars (dec) + + // set gobject values + this.el.border_width = 1; + } + + // user defined functions + } + + public class Xcls_Label15 : Object + { + public Gtk.Label el; + private Ticket _this; + + + // my vars (def) + + // ctor + public Xcls_Label15(Ticket _owner ) + { + _this = _owner; + this.el = new Gtk.Label( "Priority" ); + + // my vars (dec) + + // set gobject values + this.el.halign = Gtk.Align.START; + this.el.xalign = 0.900000f; + } + + // user defined functions + } + + public class Xcls_priority_id : Object + { + public Gtk.ComboBox el; + private Ticket _this; + + + // my vars (def) + public bool loading; + + // ctor + public Xcls_priority_id(Ticket _owner ) + { + _this = _owner; + _this.priority_id = this; + this.el = new Gtk.ComboBox.with_entry(); + + // my vars (dec) + this.loading = false; + + // set gobject values + var child_0 = new Xcls_primodel( _this ); + child_0.ref(); + this.el.set_model ( child_0.el ); + + // init method + + this.el.set_entry_text_column(1); + } + + // user defined functions + public string selectedPriorityId () { + Gtk.TreeIter iter; + Value val1; + + + this.el.get_active_iter (out iter); + _this.primodel.el.get_value (iter, 0, out val1); + + + return (string) val1; + + + + + } + } + public class Xcls_primodel : Object + { + public Gtk.ListStore el; + private Ticket _this; + + + // my vars (def) + + // ctor + public Xcls_primodel(Ticket _owner ) + { + _this = _owner; + _this.primodel = this; + this.el = new Gtk.ListStore( 2, typeof(string),typeof(string) ); + + // my vars (dec) + + // set gobject values + } + + // user defined functions + public void loadPriorities ( ) { + + var rt = RooTicket.singleton(); + // rt.loadProjects(); + + _this.priority_id.loading = true; + + this.el.clear(); + Gtk.TreeIter iter; + var el = this.el; + + + var projects = rt.priorities; + foreach(var project in projects) { + + el.append(out iter); + + el.set_value(iter, 0, project.id); + el.set_value(iter, 1, project.display_name ); + if ("normal" == project.name) { + _this.priority_id.el.set_active_iter(iter); + } + + } + + _this.priority_id.loading = false; + + + } + } + + + public class Xcls_Label18 : Object + { + public Gtk.Label el; + private Ticket _this; + + + // my vars (def) + + // ctor + public Xcls_Label18(Ticket _owner ) + { + _this = _owner; + this.el = new Gtk.Label( "Severity" ); + + // my vars (dec) + + // set gobject values + this.el.halign = Gtk.Align.START; + } + + // user defined functions + } + + public class Xcls_severity_id : Object + { + public Gtk.ComboBox el; + private Ticket _this; + + + // my vars (def) + public bool loading; + + // ctor + public Xcls_severity_id(Ticket _owner ) + { + _this = _owner; + _this.severity_id = this; + this.el = new Gtk.ComboBox.with_entry(); + + // my vars (dec) + this.loading = false; + + // set gobject values + var child_0 = new Xcls_sevmodel( _this ); + child_0.ref(); + this.el.set_model ( child_0.el ); + + // init method + + this.el.set_entry_text_column(1); + } + + // user defined functions + public string selectedSeverityId () { + Gtk.TreeIter iter; + Value val1; + + + this.el.get_active_iter (out iter); + _this.sevmodel.el.get_value (iter, 0, out val1); + + + return (string) val1; + + + + + } + } + public class Xcls_sevmodel : Object + { + public Gtk.ListStore el; + private Ticket _this; + + + // my vars (def) + + // ctor + public Xcls_sevmodel(Ticket _owner ) + { + _this = _owner; + _this.sevmodel = this; + this.el = new Gtk.ListStore( 2, typeof(string),typeof(string) ); + + // my vars (dec) + + // set gobject values + } + + // user defined functions + public void loadSeverities () { + + var rt = RooTicket.singleton(); + //rt.loadProjects(); + + _this.severity_id.loading = true; + + this.el.clear(); + Gtk.TreeIter iter; + var el = this.el; + + var projects = rt.serverities; + foreach(var project in projects) { + + el.append(out iter); + + el.set_value(iter, 0, project.id); + el.set_value(iter, 1, project.display_name ); + if ("normal" == project.name) { + _this.severity_id.el.set_active_iter(iter); + } + + } + + _this.severity_id.loading = false; + //this.el.set_sort_column_id(0, Gtk.SortType.ASCENDING); + + } + } + + + public class Xcls_Label21 : Object + { + public Gtk.Label el; + private Ticket _this; + + + // my vars (def) + + // ctor + public Xcls_Label21(Ticket _owner ) + { + _this = _owner; + this.el = new Gtk.Label( "Classification" ); + + // my vars (dec) + + // set gobject values + this.el.halign = Gtk.Align.START; + } + + // user defined functions + } + + public class Xcls_classification_id : Object + { + public Gtk.ComboBox el; + private Ticket _this; + + + // my vars (def) + public bool loading; + + // ctor + public Xcls_classification_id(Ticket _owner ) + { + _this = _owner; + _this.classification_id = this; + this.el = new Gtk.ComboBox.with_entry(); + + // my vars (dec) + this.loading = false; + + // set gobject values + var child_0 = new Xcls_clmodel( _this ); + child_0.ref(); + this.el.set_model ( child_0.el ); + + // init method + + this.el.set_entry_text_column(1); + } + + // user defined functions + public string selectedClassificationId () { + Gtk.TreeIter iter; + Value val1; + + + this.el.get_active_iter (out iter); + _this.clmodel.el.get_value (iter, 0, out val1); + + + return (string) val1; + + + + + } + } + public class Xcls_clmodel : Object + { + public Gtk.ListStore el; + private Ticket _this; + + + // my vars (def) + + // ctor + public Xcls_clmodel(Ticket _owner ) + { + _this = _owner; + _this.clmodel = this; + this.el = new Gtk.ListStore( 2, typeof(string),typeof(string) ); + + // my vars (dec) + + // set gobject values + } + + // user defined functions + public void loadClassifications ( ) { + + var rt = RooTicket.singleton(); + // rt.loadProjects(); + + _this.classification_id.loading = true; + + this.el.clear(); + Gtk.TreeIter iter; + var el = this.el; + + el.append(out iter); + + + var projects = rt.classifications; + foreach(var project in projects) { + + el.append(out iter); + + el.set_value(iter, 0, project.id); + el.set_value(iter, 1, project.display_name ); + if ("bug" == project.name) { + _this.classification_id.el.set_active_iter(iter); + } + + } + + _this.classification_id.loading = false; + //this.el.set_sort_column_id(0, Gtk.SortType.ASCENDING); + + } + } + + + public class Xcls_Label24 : Object + { + public Gtk.Label el; + private Ticket _this; + + + // my vars (def) + + // ctor + public Xcls_Label24(Ticket _owner ) + { + _this = _owner; + this.el = new Gtk.Label( "Assign to" ); + + // my vars (dec) + + // set gobject values + this.el.halign = Gtk.Align.START; + } + + // user defined functions + } + + public class Xcls_developer_id : Object + { + public Gtk.ComboBox el; + private Ticket _this; + + + // my vars (def) + public bool loading; + + // ctor + public Xcls_developer_id(Ticket _owner ) + { + _this = _owner; + _this.developer_id = this; + this.el = new Gtk.ComboBox.with_entry(); + + // my vars (dec) + this.loading = false; + + // set gobject values + var child_0 = new Xcls_devmodel( _this ); + child_0.ref(); + this.el.set_model ( child_0.el ); + + // init method + + this.el.set_entry_text_column(1); + } + + // user defined functions + public string selectedDeveloperId () { + Gtk.TreeIter iter; + Value val1; + + + this.el.get_active_iter (out iter); + _this.devmodel.el.get_value (iter, 0, out val1); + + + return (string) val1; + + + + + } + } + public class Xcls_devmodel : Object + { + public Gtk.ListStore el; + private Ticket _this; + + + // my vars (def) + + // ctor + public Xcls_devmodel(Ticket _owner ) + { + _this = _owner; + _this.devmodel = this; + this.el = new Gtk.ListStore( 2, typeof(string),typeof(string) ); + + // my vars (dec) + + // set gobject values + } + + // user defined functions + public void loadDevelopers ( ) { + + var rt = RooTicket.singleton(); + //rt.loadProjects(); + + _this.developer_id.loading = true; + + this.el.clear(); + Gtk.TreeIter iter; + var el = this.el; + + el.append(out iter); + + + el.set_value(iter, 0, ""); + el.set_value(iter, 1, "-- select a developer --"); + // if (id == "") { + _this.developer_id.el.set_active_iter(iter); + // } + + var projects = rt.developers; + foreach(var project in projects) { + + el.append(out iter); + + el.set_value(iter, 0, project.id); + el.set_value(iter, 1, project.display_name ); + // if (id == project.id) { + // _this.projectsel.el.set_active_iter(iter); + // } + + } + + _this.developer_id.loading = false; + //this.el.set_sort_column_id(0, Gtk.SortType.ASCENDING); + + } + } + + + public class Xcls_Button27 : Object + { + public Gtk.Button el; + private Ticket _this; + + + // my vars (def) + + // ctor + public Xcls_Button27(Ticket _owner ) + { + _this = _owner; + this.el = new Gtk.Button(); + + // my vars (dec) + + // set gobject values + this.el.label = "Create Ticket"; + + // init method + + { + this.el.get_style_context().add_class("suggested-action"); + } + + //listeners + this.el.clicked.connect( () => { + GLib.debug("fire response = 1"); + + + var invalid = false; + + // validate first... + _this.project_id.el.get_child().get_style_context().remove_class("warning"); + if (_this.project_id.selectedProjectId() == "") { + _this.project_id.el.get_child().get_style_context().add_class("warning"); + invalid = true; + } + + _this.milestone_id.el.get_child().get_style_context().remove_class("warning"); + if (_this.milestone_id.selectedMilestoneId() == "") { + _this.milestone_id.el.get_child().get_style_context().add_class("warning"); + invalid = true; + } + + _this.priority_id.el.get_child().get_style_context().remove_class("warning"); + if (_this.priority_id.selectedPriorityId() == "") { + _this.priority_id.el.get_child().get_style_context().add_class("warning"); + invalid = true; + } + + _this.classification_id.el.get_child().get_style_context().remove_class("warning"); + if (_this.classification_id.selectedClassificationId() == "") { + _this.classification_id.el.get_child().get_style_context().add_class("warning"); + invalid = true; + } + + _this.developer_id.el.get_child().get_style_context().remove_class("warning"); + if (_this.developer_id.selectedDeveloperId() == "") { + _this.developer_id.el.get_child().get_style_context().add_class("warning"); + invalid = true; + } + + _this.summary.el.get_style_context().remove_class("warning"); + if (_this.summary.el.get_text() == "") { + _this.summary.el.get_style_context().add_class("warning"); + invalid = true; + } + + _this.description.el.get_style_context().remove_class("warning"); + if (_this.description.el.buffer.text == "") { + _this.description.el.get_style_context().add_class("warning"); + invalid = true; + } + + + if (invalid) { + return; + } + GLib.debug("for is valid"); + + _this.el.response(1); + }); + } + + // user defined functions + } + + + +} diff --git a/config1.builder b/config1.builder index 88c1719a..572b90f0 100644 --- a/config1.builder +++ b/config1.builder @@ -20,7 +20,8 @@ "..//gitlive/RooTicket.vala", "..//gitlive/MergeBranch.vala", "..//gitlive/RepoStatusPopover.vala", - "..//gitlive/Clone.vala" + "..//gitlive/Clone.vala", + "..//gitlive/Ticket.vala" ], "packages" : [ ] -- 2.39.2