Fix #5724 - force ticket selection for branches...
authorAlan Knowles <alan@roojs.com>
Wed, 13 Feb 2019 06:02:04 +0000 (14:02 +0800)
committerAlan Knowles <alan@roojs.com>
Wed, 13 Feb 2019 06:02:04 +0000 (14:02 +0800)
NewBranch.bjs
NewBranch.vala
Ticket.bjs
Ticket.vala

index 07d7b0d..efee1cb 100644 (file)
   {
    "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// have they selected a ticket..\n\t// make that the current active ticket?\n\t// we really need to store locally what ticket is being worked on..\n\t// in theory we could be working on multiple project and not merging..\n\t// -- each repo would have their active ticket (only one per repo)\n\t// -- so we could just store that in there\n\t// -- initial load can check the contents of the ticket files on first scan.\n\tvar ticket_id = _this.ticketsel.selectedTicketId();\n\t\n    if (this.repo != null) {\n    \tvar bn = _this.name.el.get_text();\n\n\t\tvar res = this.repo.setActiveTicket(\t\t\t\n\t\t\t RooTicket.singleton().getById(ticket_id != \"\" ? ticket_id : \"-1\"), bn\n\t\t );\n\t\t if (res) {\n\t\t \t// start the monitoring..\n\t\t \t GitMonitor.gitmonitor.start();\n\t\t \t \n\t\t }\n    }\n    \n\n    this.running = false; \n\n\tthis.el.hide();\n\t \n\t \n\n\t \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\t\n\t\n\t \n\t// have they selected a ticket..\n\t// make that the current active ticket?\n\t// we really need to store locally what ticket is being worked on..\n\t// in theory we could be working on multiple project and not merging..\n\t// -- each repo would have their active ticket (only one per repo)\n\t// -- so we could just store that in there\n\t// -- initial load can check the contents of the ticket files on first scan.\n\tvar ticket_id = _this.ticketsel.selectedTicketId();\n\t\n\tif (ticket_id == \"\") {\n\t\t_this.ticketsel.el.get_child().get_style_context().add_class(\"warning\");\n\t\treturn;\n\t}\n\t\n    if (this.repo != null) {\n    \tvar bn = _this.name.el.get_text();\n\n\t\tvar res = this.repo.setActiveTicket(\t\t\t\n\t\t\t RooTicket.singleton().getById(ticket_id != \"\" ? ticket_id : \"-1\"), bn\n\t\t );\n\t\t if (res) {\n\t\t \t// start the monitoring..\n\t\t \t GitMonitor.gitmonitor.start();\n\t\t \t \n\t\t }\n    }\n    \n\n    this.running = false; \n\n\tthis.el.hide();\n\t \n\t \n\n\t \n}"
    },
    "default_width" : 500,
    "$ deletable" : true,
    "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 = 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}",
+   "|   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\t_this.ticketsel.el.get_child().get_style_context().remove_class(\"warning\");\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\t} else {\n\t\t_this.ticketsel.el.get_child().get_style_context().add_class(\"warning\");\n\t}\n    _this.view.loadTicket(tid);\n \tthis.el.run();\n\n}",
    "default_height" : 500,
    "$ xns" : "Gtk",
-   "# bool running" : false,
+   "# bool running" : true,
    "# Gee.ArrayList<GitMonitorQueue> queue" : "null",
    "bool modal" : true,
    "items" : [
@@ -93,7 +93,7 @@
         },
         {
          "listeners" : {
-          "changed" : "() => {\n\tif (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\t_this.view.loadTicket(\"\");\t\t\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_this.scrolled_window.el.show();\n\t \n\t_this.view.loadTicket(ticket.id);\n\t//GLib.debug (//\"Selection: %s, %s\\n\", (string) val1, (string) val2);\n}"
+          "changed" : "() => {\n\tif (this.loading) {\n\t\treturn;\n\t}\n\tvar ticket_id = this.selectedTicketId();\n\t\n\tvar name = RooTicket.singleton().usernameLocal();\n\t\n\tthis.el.get_child().get_style_context().remove_class(\"warning\");\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\t_this.view.loadTicket(\"\");\t\t\n\t\t\n\t\tthis.el.get_child().get_style_context().add_class(\"warning\");\n\t\t\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_this.scrolled_window.el.show();\n\t \n\t_this.view.loadTicket(ticket.id);\n\t//GLib.debug (//\"Selection: %s, %s\\n\", (string) val1, (string) val2);\n}"
          },
          "* ctor" : "new Gtk.ComboBox.with_entry()",
          "id" : "ticketsel",
index c2800e8..1a3a079 100644 (file)
@@ -37,7 +37,7 @@ public class NewBranch : Object
 
         // my vars (dec)
         this.repo = null;
-        this.running = false;
+        this.running = true;
         this.queue = null;
 
         // set gobject values
@@ -64,6 +64,10 @@ public class NewBranch : Object
                    this.running = false; 
                        return;
                }
+               
+               
+               
+               
                 
                // have they selected a ticket..
                // make that the current active ticket?
@@ -74,6 +78,11 @@ public class NewBranch : Object
                // -- initial load can check the contents of the ticket files on first scan.
                var ticket_id = _this.ticketsel.selectedTicketId();
                
+               if (ticket_id == "") {
+                       _this.ticketsel.el.get_child().get_style_context().add_class("warning");
+                       return;
+               }
+               
             if (this.repo != null) {
                var bn = _this.name.el.get_text();
         
@@ -127,13 +136,13 @@ public class NewBranch : Object
          _this.prmodel.loadProjects(curproj == null ? "" : curproj.id);
         
        _this.dbmodel.loadTickets(curproj == null ? "": curproj.id, tid);
-    
-       if (tid != "") {
+       _this.ticketsel.el.get_child().get_style_context().remove_class("warning");
+       if (tid != "") { 
                var name = RooTicket.singleton().usernameLocal();
                var ticket = RooTicket.singleton().getById(tid);
                _this.name.el.set_text("wip_%s_T%s_%s".printf(name,ticket.id, ticket.summaryToBranchName()));
-    
-    
+       } else {
+               _this.ticketsel.el.get_child().get_style_context().add_class("warning");
        }
         _this.view.loadTicket(tid);
        this.el.run();
@@ -472,11 +481,15 @@ public class NewBranch : Object
                
                var name = RooTicket.singleton().usernameLocal();
                
+               this.el.get_child().get_style_context().remove_class("warning");
                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")));
                        _this.view.loadTicket("");              
+                       
+                       this.el.get_child().get_style_context().add_class("warning");
+                       
                        return;
                }
                
index 26a8375..ecc9654 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 \tthis.running  = true;\n \n \t_this.el.show_all();\n\t\n\t_this.table.el.hide();\n\n\t_this.spinner.el.show();\n\t_this.spinner.el.start();\t\n\tthis.el.set_keep_above(true);    \n\tthis.el.move((Gdk.Screen.width() / 2)- 250 ,0);\n\tthis.el.set_default_size( 500,200); // not sure why it grows..\n\t\n\tGLib.debug(\"Showing dialog?\"); \n    Timeout.add_seconds(1, () => {\n\t\t\n\t\t\n\t\t\n\n\t\t//GitMonitor.gitmonitor.stop();\n\t\t\n\t\tthis.repo = repo;\n\t\t\n\t\t\n\t\t\n\t\t\n\t//    GLib.debug(\"Loading tickets\"); \n\t\t \n\n\n\t\tRooProject? curproj = null;\n\t\tif (this.repo != null) {\n\t\t\tcurproj = RooProject.getProjectByRepo(this.repo);\n\t\t}\n\t\t_this.prmodel.loadProjects(curproj == null ? \"\" : curproj.id);\n\t\tif (curproj != null) {\n\t \n\t\t\t\n\t\t\tvar rt = RooTicket.singleton();\n\t\t\trt.loadProjectOptions(curproj.id);\n\t\t\t\n\t\t\t_this.msmodel.loadMilestones();\n\t\t\t_this.primodel.loadPriorities();\n\t\t\t_this.sevmodel.loadSeverities();\n\t\t\t_this.clmodel.loadClassifications();\t\n\t\t\t_this.devmodel.loadDevelopers();\t\n\t\t\t\n\t\t}\n\t\t_this.summary.el.set_text(\"\");\n\t\t_this.description.el.buffer.text = \"\"; \n\t\t_this.spinner.el.stop();\n\t\t_this.spinner.el.hide();\t\n\n\t\tthis.table.el.show();\n\t    _this.summary.el.grab_focus();\n \n\t \treturn false;\n \t});\n \tthis.el.run();\n \t\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 \tthis.running  = true;\n \n \t_this.el.show_all();\n\t\n\t_this.table.el.hide();\n\n\t_this.spinner.el.show();\n\t_this.spinner.el.start();\t\n\tthis.el.set_keep_above(true);    \n\tthis.el.move((Gdk.Screen.width() / 2)- 250 ,0);\n\tthis.el.set_default_size( 500,200); // not sure why it grows..\n\t\n\tGLib.debug(\"Showing dialog?\"); \n    Timeout.add_seconds(1, () => {\n\t\t\n\t\t \n\t\t//GitMonitor.gitmonitor.stop();\n\t\t\n\t\tthis.repo = repo;\n\t\t\n\t\t \n\t\tRooProject? curproj = null;\n\t\tif (this.repo != null) {\n\t\t\tcurproj = RooProject.getProjectByRepo(this.repo);\n\t\t}\n\t\t_this.prmodel.loadProjects(curproj == null ? \"\" : curproj.id);\n\t\tif (curproj != null) {\n\t \n\t\t\t\n\t\t\tvar rt = RooTicket.singleton();\n\t\t\trt.loadProjectOptions(curproj.id);\n\t\t\t\n\t\t\t_this.msmodel.loadMilestones();\n\t\t\t_this.primodel.loadPriorities();\n\t\t\t_this.sevmodel.loadSeverities();\n\t\t\t_this.clmodel.loadClassifications();\t\n\t\t\t_this.devmodel.loadDevelopers();\t\n\t\t\t\n\t\t}\n\t\t_this.summary.el.set_text(\"\");\n\t\t_this.description.el.buffer.text = \"\"; \n\t\t_this.spinner.el.stop();\n\t\t_this.spinner.el.hide();\t\n\n\t\tthis.table.el.show();\n\t    _this.summary.el.grab_focus();\n \n\t \treturn false;\n \t});\n \tthis.el.run();\n \t\n\n}",
    "default_height" : 200,
    "$ xns" : "Gtk",
    "# bool running" : false,
index 251da7a..04d431c 100644 (file)
@@ -115,20 +115,12 @@ public class Ticket : Object
        GLib.debug("Showing dialog?"); 
         Timeout.add_seconds(1, () => {
                
-               
-               
-    
+                
                //GitMonitor.gitmonitor.stop();
                
                this.repo = repo;
                
-               
-               
-               
-       //    GLib.debug("Loading tickets"); 
                 
-    
-    
                RooProject? curproj = null;
                if (this.repo != null) {
                        curproj = RooProject.getProjectByRepo(this.repo);