Ticket.bjs
[gitlive] / Ticket.vala
index 3a81d2a..744b1fb 100644 (file)
@@ -67,7 +67,20 @@ public class Ticket : Object
                        return;
                }
                 
-               return; 
+                
+               var tid = RooTicket.singleton().createTicket(
+               
+                       _this.project_id.selectProjectId(),
+               
+                       _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 
+               );
+               
+               
                 
                 
         
@@ -858,16 +871,7 @@ public class Ticket : Object
             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 severity --");
-           // if (id == "") {
-                   _this.severity_id.el.set_active_iter(iter);
-           // }
-           
+             
             var projects = rt.serverities;
             foreach(var project in projects) {
             
@@ -875,9 +879,9 @@ public class Ticket : Object
                 
                 el.set_value(iter, 0, project.id);
                 el.set_value(iter, 1,  project.display_name );
-                //if (id == project.id) {
-                       //   _this.severity_id.el.set_active_iter(iter);
-                   //}   
+                if ("normal" == project.name) {
+                          _this.severity_id.el.set_active_iter(iter);
+                   }   
                 
             }
            
@@ -941,13 +945,13 @@ public class Ticket : Object
         }
 
         // user defined functions
-        public string selectedProjectId () {
+        public string selectedClassificationId () {
                Gtk.TreeIter iter;
                Value val1;
          
          
                this.el.get_active_iter (out iter);
-               _this.prmodel.el.get_value (iter, 0, out val1);
+               _this.clmodel.el.get_value (iter, 0, out val1);
          
         
                return  (string) val1;
@@ -991,13 +995,7 @@ public class Ticket : Object
             
             el.append(out iter);
         
-            
-            el.set_value(iter, 0, "");
-            el.set_value(iter, 1, "-- select classification --");
-          //  if (id == "") {
-                   _this.classification_id.el.set_active_iter(iter);
-        //    }
-            
+             
             var projects = rt.classifications;
             foreach(var project in projects) {
             
@@ -1005,9 +1003,9 @@ public class Ticket : Object
                 
                 el.set_value(iter, 0, project.id);
                 el.set_value(iter, 1,  project.display_name );
-            //    if (id == project.id) {
-               //         _this.classification_id.el.set_active_iter(iter);
-               //    }   
+                if ("bug" == project.name) {
+                          _this.classification_id.el.set_active_iter(iter);
+                   }   
                 
             }
             
@@ -1123,7 +1121,7 @@ public class Ticket : Object
         
             
             el.set_value(iter, 0, "");
-            el.set_value(iter, 1, "-- select a project --");
+            el.set_value(iter, 1, "-- select a developer --");
           //  if (id == "") {
                    _this.developer_id.el.set_active_iter(iter);
            // }
@@ -1176,6 +1174,59 @@ public class Ticket : Object
             //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);
             });
         }