NewBranch.bjs
[gitlive] / NewBranch.bjs
1 {
2  "name" : "NewBranch",
3  "parent" : "",
4  "title" : "",
5  "path" : "/home/alan/gitlive/gitlive/NewBranch.bjs",
6  "permname" : "",
7  "modOrder" : "",
8  "build_module" : "gitlive",
9  "items" : [
10   {
11    "listeners" : {
12     "delete_event" : "(self, event) => {\n    this.el.hide();\n    return true; \n    //test  \n}\n ",
13     "response" : " (self, response_id) =>  { \n  \n\tGLib.debug(\"got %d\", (int) response_id);\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\n\t \n\tif (response_id < 1) {\n\t    _this.el.hide();\t\n\t    this.running = false; \n\t \treturn;\n\t}\n\t\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}"
14    },
15    "default_width" : 500,
16    "$ deletable" : true,
17    "title" : "Create a working branch ",
18    "xtype" : "Dialog",
19    "# GitRepo? repo" : "null",
20    "|   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.createbtn.updateState();\n \t\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}",
21    "default_height" : 500,
22    "$ xns" : "Gtk",
23    "# bool running" : false,
24    "# Gee.ArrayList<GitMonitorQueue> queue" : "null",
25    "bool modal" : true,
26    "items" : [
27     {
28      "xtype" : "Box",
29      "$ pack" : "get_content_area().add",
30      "$ xns" : "Gtk",
31      "Gtk.Orientation orientation" : "Gtk.Orientation.VERTICAL"
32     },
33     {
34      "* pack" : "add",
35      "xtype" : "Notebook",
36      "$ xns" : "Gtk",
37      "bool vexpand" : true,
38      "items" : [
39       {
40        "id" : "label_select_ticket",
41        "* pack" : false,
42        "xtype" : "Label",
43        "string label" : "Select Existing Ticket to work on",
44        "$ xns" : "Gtk"
45       },
46       {
47        "id" : "label_create_ticket",
48        "xtype" : "Label",
49        "* pack" : false,
50        "string label" : "Create a new Ticket",
51        "$ xns" : "Gtk"
52       },
53       {
54        "id" : "label_quick_commit",
55        "* pack" : false,
56        "xtype" : "Label",
57        "string label" : "Quick Commit",
58        "$ xns" : "Gtk"
59       },
60       {
61        "bool homogeneous" : false,
62        "* pack" : "append_page,_this.label_select_ticket.el",
63        "xtype" : "Box",
64        "$ xns" : "Gtk",
65        "Gtk.Orientation orientation" : "Gtk.Orientation.VERTICAL",
66        "items" : [
67         {
68          "bool homogeneous" : true,
69          "bool expand" : false,
70          "xtype" : "Table",
71          "* pack" : "pack_start,false,false,0",
72          "uint column_spacing" : 4,
73          "n_columns" : 5,
74          "$ xns" : "Gtk",
75          "n_rows" : 5,
76          "bool vexpand" : false,
77          "int margin" : 2,
78          "items" : [
79           {
80            "label" : "Project",
81            "$ visible" : true,
82            "Gtk.Align halign" : "Gtk.Align.START",
83            "* pack" : "attach_defaults,0,1,0,1",
84            "xtype" : "Label",
85            "$ justify" : "Gtk.Justification.RIGHT",
86            "x_options" : 4,
87            "$ xns" : "Gtk"
88           },
89           {
90            "label" : "Ticket",
91            "$ visible" : true,
92            "Gtk.Align halign" : "Gtk.Align.START",
93            "* pack" : "attach_defaults,1,2,0,1",
94            "xtype" : "Label",
95            "x_options" : 4,
96            "$ xns" : "Gtk"
97           },
98           {
99            "listeners" : {
100             "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}"
101            },
102            "* ctor" : "new Gtk.ComboBox.with_entry()",
103            "| 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",
104            "id" : "projectsel",
105            "* init" : "this.el.set_entry_text_column(1);",
106            "* pack" : "attach_defaults,0,1,1,2",
107            "xtype" : "ComboBox",
108            "# bool loading" : false,
109            "$ xns" : "Gtk",
110            "items" : [
111             {
112              "id" : "prcellrenderer",
113              "* pack" : "pack_start,true",
114              "xtype" : "CellRendererText",
115              "$ xns" : "Gtk"
116             },
117             {
118              "| void loadProjects" : "  (string id) {\n\n\n    \n    _this.projectsel.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.projectsel.el.set_active_iter(iter);\n    }\n  \n    foreach(var project in RooProject.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.projectsel.el.set_active_iter(iter);\n\t    }   \n        \n    }\n    \n    _this.projectsel.loading = false;\n     //this.el.set_sort_column_id(0, Gtk.SortType.ASCENDING);          \n                                     \n}\n",
119              "id" : "prmodel",
120              "* pack" : "set_model",
121              "xtype" : "ListStore",
122              "$ columns" : "typeof(string),typeof(string)",
123              "n_columns" : 2,
124              "$ xns" : "Gtk"
125             }
126            ]
127           },
128           {
129            "listeners" : {
130             "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_this.createbtn.updateState();\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_this.createbtn.updateState();\n\t\n\t//GLib.debug (//\"Selection: %s, %s\\n\", (string) val1, (string) val2);\n}"
131            },
132            "* ctor" : "new Gtk.ComboBox.with_entry()",
133            "id" : "ticketsel",
134            "* init" : "//this.el.add_attribute(_this.dbcellrenderer.el , \"markup\", 1 );\nthis.el.set_entry_text_column(1);\nthis.el.get_child().set_sensitive(false); ",
135            "* pack" : "attach_defaults,1,4,1,2",
136            "xtype" : "ComboBox",
137            "# bool loading" : false,
138            "$ xns" : "Gtk",
139            "| string selectedTicketId" : "() {\nGtk.TreeIter iter;\n\tValue val1;\n \n \n\tthis.el.get_active_iter (out iter);\n\t_this.dbmodel.el.get_value (iter, 0, out val1);\n \n\n\treturn  (string) val1;\n\t\n\t\n\t\n\t\n}\n",
140            "items" : [
141             {
142              "id" : "dbcellrenderer",
143              "xtype" : "CellRendererText",
144              "* pack" : "pack_start,true",
145              "$ xns" : "Gtk"
146             },
147             {
148              "id" : "dbmodel",
149              "xtype" : "ListStore",
150              "* pack" : "set_model",
151              "| 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.Who.ANYBODY :  RooTicket.Who.ME,\n \t\t\t _this.btn_closed.el.active ? RooTicket.Status.ALL :  RooTicket.Status.ACTIVE\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\".printf( ticket.id, 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",
152              "$ columns" : "typeof(string),typeof(string)",
153              "n_columns" : 2,
154              "$ xns" : "Gtk"
155             }
156            ]
157           },
158           {
159            "listeners" : {
160             "clicked" : "() => {\n    _this.el.response(-1);\n\tTicket.singleton().show(_this.repo);\n\n}"
161            },
162            "bool expand" : false,
163            "* pack" : "attach_defaults,4,5,1,2",
164            "xtype" : "Button",
165            "string label" : "New Ticket",
166            "$ xns" : "Gtk"
167           },
168           {
169            "label" : "Use this as branch name",
170            "Gtk.Align halign" : "Gtk.Align.START",
171            "xalign" : 0.90000000000000002,
172            "* pack" : "attach_defaults,0,1,3,4",
173            "xtype" : "Label",
174            "$ justify" : "Gtk.Justification.RIGHT",
175            "x_options" : 4,
176            "$ xns" : "Gtk"
177           },
178           {
179            "id" : "name",
180            "$ visible" : true,
181            "xtype" : "Entry",
182            "* pack" : "attach_defaults,0,4,4,5",
183            "$ xns" : "Gtk"
184           },
185           {
186            "listeners" : {
187             "clicked" : "() => {\n\n\tGLib.debug(\"fire response = 1\");\n\t\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\t_this.el.response(1);\n}"
188            },
189            "label" : "Create Branch",
190            "| void updateState" : "() {\n\n\tvar ticket_id = _this.ticketsel.selectedTicketId();\n\t\n\tif (ticket_id == \"\") {\n\t\tthis.el.set_sensitive(false);\n\t\treturn;\n\t}\n \n\tthis.el.set_sensitive(true);\n \n}\n",
191            "id" : "createbtn",
192            "* init" : "{\n   this.el.get_style_context().add_class(\"suggested-action\");\n}\n",
193            "xtype" : "Button",
194            "* pack" : "attach_defaults,4,5,4,5",
195            "$ xns" : "Gtk"
196           },
197           {
198            "* pack" : "attach_defaults,0,5,2,3",
199            "xtype" : "Box",
200            "$ xns" : "Gtk",
201            "Gtk.Orientation orientation" : "Gtk.Orientation.HORIZONTAL",
202            "items" : [
203             {
204              "listeners" : {
205               "toggled" : "() => {\n\tvar project_id = _this.projectsel.selectedProjectId();\n\t_this.dbmodel.loadTickets(project_id);\t\n}"
206              },
207              "id" : "btn_not_me",
208              "* pack" : "add",
209              "string label" : "Show tickets not assigned to me",
210              "xtype" : "CheckButton",
211              "$ xns" : "Gtk"
212             },
213             {
214              "listeners" : {
215               "toggled" : "() => {\n \tvar project_id = _this.projectsel.selectedProjectId();\n\t_this.dbmodel.loadTickets(project_id);\t\n\t \n}"
216              },
217              "id" : "btn_closed",
218              "string label" : "Show closed Tickets",
219              "xtype" : "CheckButton",
220              "* pack" : "add",
221              "$ xns" : "Gtk"
222             },
223             {
224              "listeners" : {
225               "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}"
226              },
227              "bool use_markup" : true,
228              "Gtk.Align halign" : "Gtk.Align.END",
229              "bool hexpand" : true,
230              "* pack" : "add",
231              "xtype" : "Label",
232              "string label" : "<a href=\"refresh\">Refresh Ticket list</a>",
233              "$ xns" : "Gtk"
234             }
235            ]
236           }
237          ]
238         },
239         {
240          "int height_request" : 500,
241          "id" : "scrolled_window",
242          "* init" : "{\n\tthis.el.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);\n}\n",
243          "* pack" : "add",
244          "xtype" : "ScrolledWindow",
245          "$ xns" : "Gtk",
246          "bool vexpand" : true,
247          "items" : [
248           {
249            "id" : "view",
250            "* pack" : "add",
251            "xtype" : "WebView",
252            "$ xns" : "WebKit",
253            "| void loadTicket" : "(string tid) {\n\tint h,w;\n\t_this.el.get_size(out w, out h);\n\t\n\tif (tid == \"\") {\n\t\t_this.scrolled_window.el.hide();\n\t\t_this.el.resize(w, 150);\n\t} else {\n\t\t_this.scrolled_window.el.show();\n\t\t_this.el.resize(w, 800);\n\t}\n\t\n\tvar rs =  RooTicket.singleton();\t\t\n\tvar uri = new WebKit.URIRequest(\"https://roojs.com/admin.php/MTrack/View/\" + tid);\n\tvar hd = uri.get_http_headers();\n\tvar authCode = Base64.encode (\"%s:%s\".printf(rs.username, rs.password).data);\n\thd.append(\"Authorization\", \"Basic %s\".printf(authCode));\n\t\n\t this.el.load_request(uri);\n}\n"
254           }
255          ]
256         }
257        ]
258       },
259       {
260        "bool homogeneous" : false,
261        "xtype" : "Box",
262        "* pack" : "append_page,_this.label_create_ticket.el",
263        "$ xns" : "Gtk",
264        "Gtk.Orientation orientation" : "Gtk.Orientation.VERTICAL"
265       },
266       {
267        "bool homogeneous" : false,
268        "* pack" : "append_page,_this.label_quick_commit.el",
269        "xtype" : "Box",
270        "$ xns" : "Gtk",
271        "Gtk.Orientation orientation" : "Gtk.Orientation.VERTICAL"
272       }
273      ]
274     }
275    ]
276   }
277  ]
278 }