##// END OF EJS Templates
pull-requests: added filters to my account pull requests page.
ergo -
r4318:635c5bc5 default
parent child Browse files
Show More
@@ -723,12 +723,12 b' class MyAccountView(BaseAppView, DataGri'
723
723
724 pull_requests = PullRequestModel().get_im_participating_in(
724 pull_requests = PullRequestModel().get_im_participating_in(
725 user_id=self._rhodecode_user.user_id,
725 user_id=self._rhodecode_user.user_id,
726 statuses=statuses,
726 statuses=statuses, query=search_q,
727 offset=start, length=limit, order_by=order_by,
727 offset=start, length=limit, order_by=order_by,
728 order_dir=order_dir)
728 order_dir=order_dir)
729
729
730 pull_requests_total_count = PullRequestModel().count_im_participating_in(
730 pull_requests_total_count = PullRequestModel().count_im_participating_in(
731 user_id=self._rhodecode_user.user_id, statuses=statuses)
731 user_id=self._rhodecode_user.user_id, statuses=statuses, query=search_q)
732
732
733 data = []
733 data = []
734 comments_model = CommentsModel()
734 comments_model = CommentsModel()
@@ -355,7 +355,7 b' class PullRequestModel(BaseModel):'
355 PullRequestReviewers.user_id == user_id).all()
355 PullRequestReviewers.user_id == user_id).all()
356 ]
356 ]
357
357
358 def _prepare_participating_query(self, user_id=None, statuses=None,
358 def _prepare_participating_query(self, user_id=None, statuses=None, query='',
359 order_by=None, order_dir='desc'):
359 order_by=None, order_dir='desc'):
360 q = PullRequest.query()
360 q = PullRequest.query()
361 if user_id:
361 if user_id:
@@ -372,6 +372,13 b' class PullRequestModel(BaseModel):'
372 if statuses:
372 if statuses:
373 q = q.filter(PullRequest.status.in_(statuses))
373 q = q.filter(PullRequest.status.in_(statuses))
374
374
375 if query:
376 like_expression = u'%{}%'.format(safe_unicode(query))
377 q = q.filter(or_(
378 cast(PullRequest.pull_request_id, String).ilike(like_expression),
379 PullRequest.title.ilike(like_expression),
380 PullRequest.description.ilike(like_expression),
381 ))
375 if order_by:
382 if order_by:
376 order_map = {
383 order_map = {
377 'name_raw': PullRequest.pull_request_id,
384 'name_raw': PullRequest.pull_request_id,
@@ -386,19 +393,19 b' class PullRequestModel(BaseModel):'
386
393
387 return q
394 return q
388
395
389 def count_im_participating_in(self, user_id=None, statuses=None):
396 def count_im_participating_in(self, user_id=None, statuses=None, query=''):
390 q = self._prepare_participating_query(user_id, statuses=statuses)
397 q = self._prepare_participating_query(user_id, statuses=statuses, query=query)
391 return q.count()
398 return q.count()
392
399
393 def get_im_participating_in(
400 def get_im_participating_in(
394 self, user_id=None, statuses=None, offset=0,
401 self, user_id=None, statuses=None, query='', offset=0,
395 length=None, order_by=None, order_dir='desc'):
402 length=None, order_by=None, order_dir='desc'):
396 """
403 """
397 Get all Pull requests that i'm participating in, or i have opened
404 Get all Pull requests that i'm participating in, or i have opened
398 """
405 """
399
406
400 q = self._prepare_participating_query(
407 q = self._prepare_participating_query(
401 user_id, statuses=statuses, order_by=order_by,
408 user_id, statuses=statuses, query=query, order_by=order_by,
402 order_dir=order_dir)
409 order_dir=order_dir)
403
410
404 if length:
411 if length:
@@ -2,11 +2,29 b''
2
2
3 <div class="panel panel-default">
3 <div class="panel panel-default">
4 <div class="panel-body">
4 <div class="panel-body">
5 %if c.closed:
5 <div style="height: 35px">
6 ${h.checkbox('show_closed',checked="checked", label=_('Show Closed Pull Requests'))}
6 <%
7 %else:
7 selected_filter = 'all'
8 ${h.checkbox('show_closed',label=_('Show Closed Pull Requests'))}
8 if c.closed:
9 %endif
9 selected_filter = 'all_closed'
10 %>
11
12 <ul class="button-links">
13 <li class="btn ${h.is_active('all', selected_filter)}"><a href="${h.route_path('my_account_pullrequests')}">${_('All')}</a></li>
14 <li class="btn ${h.is_active('all_closed', selected_filter)}"><a href="${h.route_path('my_account_pullrequests', _query={'pr_show_closed':1})}">${_('All + Closed')}</a></li>
15 </ul>
16
17 <div class="grid-quick-filter">
18 <ul class="grid-filter-box">
19 <li class="grid-filter-box-icon">
20 <i class="icon-search"></i>
21 </li>
22 <li class="grid-filter-box-input">
23 <input class="q_filter_box" id="q_filter" size="15" type="text" name="filter" placeholder="${_('quick filter...')}" value=""/>
24 </li>
25 </ul>
26 </div>
27 </div>
10 </div>
28 </div>
11 </div>
29 </div>
12
30
@@ -20,72 +38,107 b''
20 </div>
38 </div>
21
39
22 <script type="text/javascript">
40 <script type="text/javascript">
23 $(document).ready(function() {
41 $(document).ready(function () {
24
42
25 $('#show_closed').on('click', function(e){
43 var $pullRequestListTable = $('#pull_request_list_table');
26 if($(this).is(":checked")){
27 window.location = "${h.route_path('my_account_pullrequests', _query={'pr_show_closed':1})}";
28 }
29 else{
30 window.location = "${h.route_path('my_account_pullrequests')}";
31 }
32 });
33
34 var $pullRequestListTable = $('#pull_request_list_table');
35
44
36 // participating object list
45 // participating object list
37 $pullRequestListTable.DataTable({
46 $pullRequestListTable.DataTable({
38 processing: true,
47 processing: true,
39 serverSide: true,
48 serverSide: true,
40 ajax: {
49 ajax: {
41 "url": "${h.route_path('my_account_pullrequests_data')}",
50 "url": "${h.route_path('my_account_pullrequests_data')}",
42 "data": function (d) {
51 "data": function (d) {
43 d.closed = "${c.closed}";
52 d.closed = "${c.closed}";
44 }
53 },
45 },
54 "dataSrc": function (json) {
46 dom: 'rtp',
55 return json.data;
47 pageLength: ${c.visual.dashboard_items},
56 }
48 order: [[ 2, "desc" ]],
57 },
49 columns: [
58
50 { data: {"_": "target_repo",
59 dom: 'rtp',
51 "sort": "target_repo"}, title: "${_('Target Repo')}", className: "td-targetrepo", orderable: false},
60 pageLength: ${c.visual.dashboard_items},
52 { data: {"_": "status",
61 order: [[2, "desc"]],
53 "sort": "status"}, title: "", className: "td-status", orderable: false},
62 columns: [
54 { data: {"_": "name",
63 {
55 "sort": "name_raw"}, title: "${_('Id')}", className: "td-componentname", "type": "num" },
64 data: {
56 { data: {"_": "title",
65 "_": "target_repo",
57 "sort": "title"}, title: "${_('Title')}", className: "td-description" },
66 "sort": "target_repo"
58 { data: {"_": "author",
67 }, title: "${_('Target Repo')}", className: "td-targetrepo", orderable: false
59 "sort": "author_raw"}, title: "${_('Author')}", className: "td-user", orderable: false },
68 },
60 { data: {"_": "comments",
69 {
61 "sort": "comments_raw"}, title: "", className: "td-comments", orderable: false},
70 data: {
62 { data: {"_": "updated_on",
71 "_": "status",
63 "sort": "updated_on_raw"}, title: "${_('Last Update')}", className: "td-time" }
72 "sort": "status"
64 ],
73 }, title: "", className: "td-status", orderable: false
65 language: {
74 },
75 {
76 data: {
77 "_": "name",
78 "sort": "name_raw"
79 }, title: "${_('Id')}", className: "td-componentname", "type": "num"
80 },
81 {
82 data: {
83 "_": "title",
84 "sort": "title"
85 }, title: "${_('Title')}", className: "td-description"
86 },
87 {
88 data: {
89 "_": "author",
90 "sort": "author_raw"
91 }, title: "${_('Author')}", className: "td-user", orderable: false
92 },
93 {
94 data: {
95 "_": "comments",
96 "sort": "comments_raw"
97 }, title: "", className: "td-comments", orderable: false
98 },
99 {
100 data: {
101 "_": "updated_on",
102 "sort": "updated_on_raw"
103 }, title: "${_('Last Update')}", className: "td-time"
104 }
105 ],
106 language: {
66 paginate: DEFAULT_GRID_PAGINATION,
107 paginate: DEFAULT_GRID_PAGINATION,
67 sProcessing: _gettext('loading...'),
108 sProcessing: _gettext('loading...'),
68 emptyTable: _gettext("There are currently no open pull requests requiring your participation.")
109 emptyTable: _gettext("There are currently no open pull requests requiring your participation.")
69 },
110 },
70 "drawCallback": function( settings, json ) {
111 "drawCallback": function (settings, json) {
71 timeagoActivate();
112 timeagoActivate();
72 tooltipActivate();
113 tooltipActivate();
73 },
114 },
74 "createdRow": function ( row, data, index ) {
115 "createdRow": function (row, data, index) {
75 if (data['closed']) {
116 if (data['closed']) {
76 $(row).addClass('closed');
117 $(row).addClass('closed');
77 }
118 }
78 if (data['owned']) {
119 if (data['owned']) {
79 $(row).addClass('owned');
120 $(row).addClass('owned');
80 }
121 }
81 }
122 }
82 });
123 });
83 $pullRequestListTable.on('xhr.dt', function(e, settings, json, xhr){
124 $pullRequestListTable.on('xhr.dt', function (e, settings, json, xhr) {
84 $pullRequestListTable.css('opacity', 1);
125 $pullRequestListTable.css('opacity', 1);
85 });
126 });
86
127
87 $pullRequestListTable.on('preXhr.dt', function(e, settings, data){
128 $pullRequestListTable.on('preXhr.dt', function (e, settings, data) {
88 $pullRequestListTable.css('opacity', 0.3);
129 $pullRequestListTable.css('opacity', 0.3);
89 });
130 });
131
132 // filter
133 $('#q_filter').on('keyup',
134 $.debounce(250, function () {
135 $pullRequestListTable.DataTable().search(
136 $('#q_filter').val()
137 ).draw();
138 })
139 );
140
90 });
141 });
142
143
91 </script>
144 </script>
General Comments 0
You need to be logged in to leave comments. Login now