##// END OF EJS Templates
pull-requests: added quick filter to grid view.
marcink -
r4055:8b8d49d6 default
parent child Browse files
Show More
@@ -76,28 +76,28 b' class RepoPullRequestsView(RepoAppView, '
76 76
77 77 if filter_type == 'awaiting_review':
78 78 pull_requests = PullRequestModel().get_awaiting_review(
79 repo_name, source=source, opened_by=opened_by,
79 repo_name, search_q=search_q, source=source, opened_by=opened_by,
80 80 statuses=statuses, offset=start, length=limit,
81 81 order_by=order_by, order_dir=order_dir)
82 82 pull_requests_total_count = PullRequestModel().count_awaiting_review(
83 repo_name, source=source, statuses=statuses,
83 repo_name, search_q=search_q, source=source, statuses=statuses,
84 84 opened_by=opened_by)
85 85 elif filter_type == 'awaiting_my_review':
86 86 pull_requests = PullRequestModel().get_awaiting_my_review(
87 repo_name, source=source, opened_by=opened_by,
87 repo_name, search_q=search_q, source=source, opened_by=opened_by,
88 88 user_id=self._rhodecode_user.user_id, statuses=statuses,
89 89 offset=start, length=limit, order_by=order_by,
90 90 order_dir=order_dir)
91 91 pull_requests_total_count = PullRequestModel().count_awaiting_my_review(
92 repo_name, source=source, user_id=self._rhodecode_user.user_id,
92 repo_name, search_q=search_q, source=source, user_id=self._rhodecode_user.user_id,
93 93 statuses=statuses, opened_by=opened_by)
94 94 else:
95 95 pull_requests = PullRequestModel().get_all(
96 repo_name, source=source, opened_by=opened_by,
96 repo_name, search_q=search_q, source=source, opened_by=opened_by,
97 97 statuses=statuses, offset=start, length=limit,
98 98 order_by=order_by, order_dir=order_dir)
99 99 pull_requests_total_count = PullRequestModel().count_all(
100 repo_name, source=source, statuses=statuses,
100 repo_name, search_q=search_q, source=source, statuses=statuses,
101 101 opened_by=opened_by)
102 102
103 103 data = []
@@ -37,7 +37,7 b' import traceback'
37 37 import collections
38 38
39 39 from sqlalchemy import (
40 or_, and_, not_, func, TypeDecorator, event,
40 or_, and_, not_, func, cast, TypeDecorator, event,
41 41 Index, Sequence, UniqueConstraint, ForeignKey, CheckConstraint, Column,
42 42 Boolean, String, Unicode, UnicodeText, DateTime, Integer, LargeBinary,
43 43 Text, Float, PickleType, BigInteger)
@@ -51,7 +51,7 b' from rhodecode.model import BaseModel'
51 51 from rhodecode.model.changeset_status import ChangesetStatusModel
52 52 from rhodecode.model.comment import CommentsModel
53 53 from rhodecode.model.db import (
54 or_, PullRequest, PullRequestReviewers, ChangesetStatus,
54 or_, String, cast, PullRequest, PullRequestReviewers, ChangesetStatus,
55 55 PullRequestVersion, ChangesetComment, Repository, RepoReviewRule)
56 56 from rhodecode.model.meta import Session
57 57 from rhodecode.model.notification import NotificationModel, \
@@ -137,8 +137,8 b' class PullRequestModel(BaseModel):'
137 137 def get(self, pull_request):
138 138 return self.__get_pull_request(pull_request)
139 139
140 def _prepare_get_all_query(self, repo_name, source=False, statuses=None,
141 opened_by=None, order_by=None,
140 def _prepare_get_all_query(self, repo_name, search_q=None, source=False,
141 statuses=None, opened_by=None, order_by=None,
142 142 order_dir='desc', only_created=False):
143 143 repo = None
144 144 if repo_name:
@@ -146,6 +146,14 b' class PullRequestModel(BaseModel):'
146 146
147 147 q = PullRequest.query()
148 148
149 if search_q:
150 like_expression = u'%{}%'.format(safe_unicode(search_q))
151 q = q.filter(or_(
152 cast(PullRequest.pull_request_id, String).ilike(like_expression),
153 PullRequest.title.ilike(like_expression),
154 PullRequest.description.ilike(like_expression),
155 ))
156
149 157 # source or target
150 158 if repo and source:
151 159 q = q.filter(PullRequest.source_repo == repo)
@@ -179,28 +187,31 b' class PullRequestModel(BaseModel):'
179 187
180 188 return q
181 189
182 def count_all(self, repo_name, source=False, statuses=None,
190 def count_all(self, repo_name, search_q=None, source=False, statuses=None,
183 191 opened_by=None):
184 192 """
185 193 Count the number of pull requests for a specific repository.
186 194
187 195 :param repo_name: target or source repo
196 :param search_q: filter by text
188 197 :param source: boolean flag to specify if repo_name refers to source
189 198 :param statuses: list of pull request statuses
190 199 :param opened_by: author user of the pull request
191 200 :returns: int number of pull requests
192 201 """
193 202 q = self._prepare_get_all_query(
194 repo_name, source=source, statuses=statuses, opened_by=opened_by)
203 repo_name, search_q=search_q, source=source, statuses=statuses,
204 opened_by=opened_by)
195 205
196 206 return q.count()
197 207
198 def get_all(self, repo_name, source=False, statuses=None, opened_by=None,
199 offset=0, length=None, order_by=None, order_dir='desc'):
208 def get_all(self, repo_name, search_q=None, source=False, statuses=None,
209 opened_by=None, offset=0, length=None, order_by=None, order_dir='desc'):
200 210 """
201 211 Get all pull requests for a specific repository.
202 212
203 213 :param repo_name: target or source repo
214 :param search_q: filter by text
204 215 :param source: boolean flag to specify if repo_name refers to source
205 216 :param statuses: list of pull request statuses
206 217 :param opened_by: author user of the pull request
@@ -211,8 +222,8 b' class PullRequestModel(BaseModel):'
211 222 :returns: list of pull requests
212 223 """
213 224 q = self._prepare_get_all_query(
214 repo_name, source=source, statuses=statuses, opened_by=opened_by,
215 order_by=order_by, order_dir=order_dir)
225 repo_name, search_q=search_q, source=source, statuses=statuses,
226 opened_by=opened_by, order_by=order_by, order_dir=order_dir)
216 227
217 228 if length:
218 229 pull_requests = q.limit(length).offset(offset).all()
@@ -221,24 +232,25 b' class PullRequestModel(BaseModel):'
221 232
222 233 return pull_requests
223 234
224 def count_awaiting_review(self, repo_name, source=False, statuses=None,
235 def count_awaiting_review(self, repo_name, search_q=None, source=False, statuses=None,
225 236 opened_by=None):
226 237 """
227 238 Count the number of pull requests for a specific repository that are
228 239 awaiting review.
229 240
230 241 :param repo_name: target or source repo
242 :param search_q: filter by text
231 243 :param source: boolean flag to specify if repo_name refers to source
232 244 :param statuses: list of pull request statuses
233 245 :param opened_by: author user of the pull request
234 246 :returns: int number of pull requests
235 247 """
236 248 pull_requests = self.get_awaiting_review(
237 repo_name, source=source, statuses=statuses, opened_by=opened_by)
249 repo_name, search_q=search_q, source=source, statuses=statuses, opened_by=opened_by)
238 250
239 251 return len(pull_requests)
240 252
241 def get_awaiting_review(self, repo_name, source=False, statuses=None,
253 def get_awaiting_review(self, repo_name, search_q=None, source=False, statuses=None,
242 254 opened_by=None, offset=0, length=None,
243 255 order_by=None, order_dir='desc'):
244 256 """
@@ -246,6 +258,7 b' class PullRequestModel(BaseModel):'
246 258 review.
247 259
248 260 :param repo_name: target or source repo
261 :param search_q: filter by text
249 262 :param source: boolean flag to specify if repo_name refers to source
250 263 :param statuses: list of pull request statuses
251 264 :param opened_by: author user of the pull request
@@ -256,8 +269,8 b' class PullRequestModel(BaseModel):'
256 269 :returns: list of pull requests
257 270 """
258 271 pull_requests = self.get_all(
259 repo_name, source=source, statuses=statuses, opened_by=opened_by,
260 order_by=order_by, order_dir=order_dir)
272 repo_name, search_q=search_q, source=source, statuses=statuses,
273 opened_by=opened_by, order_by=order_by, order_dir=order_dir)
261 274
262 275 _filtered_pull_requests = []
263 276 for pr in pull_requests:
@@ -270,13 +283,14 b' class PullRequestModel(BaseModel):'
270 283 else:
271 284 return _filtered_pull_requests
272 285
273 def count_awaiting_my_review(self, repo_name, source=False, statuses=None,
286 def count_awaiting_my_review(self, repo_name, search_q=None, source=False, statuses=None,
274 287 opened_by=None, user_id=None):
275 288 """
276 289 Count the number of pull requests for a specific repository that are
277 290 awaiting review from a specific user.
278 291
279 292 :param repo_name: target or source repo
293 :param search_q: filter by text
280 294 :param source: boolean flag to specify if repo_name refers to source
281 295 :param statuses: list of pull request statuses
282 296 :param opened_by: author user of the pull request
@@ -284,12 +298,12 b' class PullRequestModel(BaseModel):'
284 298 :returns: int number of pull requests
285 299 """
286 300 pull_requests = self.get_awaiting_my_review(
287 repo_name, source=source, statuses=statuses, opened_by=opened_by,
288 user_id=user_id)
301 repo_name, search_q=search_q, source=source, statuses=statuses,
302 opened_by=opened_by, user_id=user_id)
289 303
290 304 return len(pull_requests)
291 305
292 def get_awaiting_my_review(self, repo_name, source=False, statuses=None,
306 def get_awaiting_my_review(self, repo_name, search_q=None, source=False, statuses=None,
293 307 opened_by=None, user_id=None, offset=0,
294 308 length=None, order_by=None, order_dir='desc'):
295 309 """
@@ -297,6 +311,7 b' class PullRequestModel(BaseModel):'
297 311 review from a specific user.
298 312
299 313 :param repo_name: target or source repo
314 :param search_q: filter by text
300 315 :param source: boolean flag to specify if repo_name refers to source
301 316 :param statuses: list of pull request statuses
302 317 :param opened_by: author user of the pull request
@@ -308,8 +323,8 b' class PullRequestModel(BaseModel):'
308 323 :returns: list of pull requests
309 324 """
310 325 pull_requests = self.get_all(
311 repo_name, source=source, statuses=statuses, opened_by=opened_by,
312 order_by=order_by, order_dir=order_dir)
326 repo_name, search_q=search_q, source=source, statuses=statuses,
327 opened_by=opened_by, order_by=order_by, order_dir=order_dir)
313 328
314 329 _my = PullRequestModel().get_not_reviewed(user_id)
315 330 my_participation = []
@@ -42,6 +42,20 b''
42 42 </span>
43 43 </li>
44 44 % endif
45
46 <li>
47 <div class="grid-quick-filter">
48 <ul class="grid-filter-box">
49 <li class="grid-filter-box-icon">
50 <i class="icon-search"></i>
51 </li>
52 <li class="grid-filter-box-input">
53 <input class="q_filter_box" id="q_filter" size="15" type="text" name="filter" placeholder="${_('quick filter...')}" value=""/>
54 </li>
55 </ul>
56 </div>
57 </li>
58
45 59 </ul>
46 60
47 61 </div>
@@ -54,7 +68,6 b''
54 68
55 69 <script type="text/javascript">
56 70 $(document).ready(function() {
57
58 71 var $pullRequestListTable = $('#pull_request_list_table');
59 72
60 73 // object list
@@ -115,6 +128,15 b''
115 128 $pullRequestListTable.css('opacity', 0.3);
116 129 });
117 130
131 // filter
132 $('#q_filter').on('keyup',
133 $.debounce(250, function() {
134 $pullRequestListTable.DataTable().search(
135 $('#q_filter').val()
136 ).draw();
137 })
138 );
139
118 140 });
119 141
120 142 </script>
General Comments 0
You need to be logged in to leave comments. Login now