[Notice] Announcing the End of Demo Server [Read me]
issue-search: apply enhanced select2 dropdown box
- applied to author, assignee, milestone filter at issue list page
@9187b9b9ca162fee4aa2626da7a7ee91af5fd036
+++ app/assets/stylesheets/less/_override.less
... | ... | @@ -0,0 +1,4 @@ |
1 | +.select2-results .select2-highlighted { | |
2 | + background: #5abee2 ; | |
3 | + color: #fff; | |
4 | +}(No newline at end of file) |
--- app/assets/stylesheets/less/_page.less
+++ app/assets/stylesheets/less/_page.less
... | ... | @@ -3035,6 +3035,9 @@ |
3035 | 3035 |
dd { |
3036 | 3036 |
margin:0; |
3037 | 3037 |
.btn-group { width:100%; } |
3038 |
+ select { |
|
3039 |
+ width: 100%; |
|
3040 |
+ } |
|
3038 | 3041 |
} |
3039 | 3042 |
} |
3040 | 3043 |
.label-editor { |
--- app/assets/stylesheets/yobi.less
+++ app/assets/stylesheets/yobi.less
... | ... | @@ -7,3 +7,4 @@ |
7 | 7 |
@import "less/_yobiUI.less"; |
8 | 8 |
@import "less/_temporary.less"; |
9 | 9 |
@import "less/_markdown.less"; |
10 |
+@import "less/_override.less"; |
--- app/views/issue/list.scala.html
+++ app/views/issue/list.scala.html
... | ... | @@ -8,6 +8,7 @@ |
8 | 8 |
@views.html.issue.partial_search(title, currentPage, param, project) |
9 | 9 |
</div> |
10 | 10 |
</div> |
11 |
+<script src="/assets/javascripts/lib/select2/select2.js"></script> |
|
11 | 12 |
<script type="text/javascript"> |
12 | 13 |
$(document).ready(function(){ |
13 | 14 |
var htPjaxOptions = { |
--- app/views/issue/partial_search.scala.html
+++ app/views/issue/partial_search.scala.html
... | ... | @@ -78,82 +78,68 @@ |
78 | 78 |
<dl class="issue-option"> |
79 | 79 |
<dt>@Messages("issue.author")</dt> |
80 | 80 |
<dd> |
81 |
- <div class="btn-group" data-name="authorId"> |
|
82 |
- <button class="btn dropdown-toggle auto" data-toggle="dropdown"> |
|
83 |
- <span class="d-label">@Messages("common.order.all")</span> |
|
84 |
- <span class="d-caret"><span class="caret"></span></span> |
|
85 |
- </button> |
|
86 |
- <ul class="dropdown-menu"> |
|
87 |
- <li data-value=""><a>@Messages("common.order.all")</a></li> |
|
88 |
- @if(ProjectUser.isMember(UserApp.currentUser().id, project.id)){ |
|
89 |
- <li data-value="@UserApp.currentUser().id"><a>@Messages("issue.list.authoredByMe")</a></li> |
|
81 |
+ <select id="authorId" name="authorId"> |
|
82 |
+ <option value="">@Messages("common.order.all")</option> |
|
83 |
+ @if(ProjectUser.isMember(UserApp.currentUser().id, project.id)){ |
|
84 |
+ <option value="@UserApp.currentUser().id">@Messages("issue.list.authoredByMe")</option> |
|
85 |
+ } |
|
86 |
+ @for(author <- User.findIssueAuthorsByProjectId(project.id)) { |
|
87 |
+ <option value="@author.id" |
|
88 |
+ @if(param.authorId != null && param.authorId == author.id){ |
|
89 |
+ selected |
|
90 | 90 |
} |
91 |
- <li class="divider"></li> |
|
92 |
- @for(author <- User.findIssueAuthorsByProjectId(project.id)) { |
|
93 |
- <li data-value="@author.id" @if(param.authorId != null && param.authorId == author.id){data-selected="true" class="active"}> |
|
94 |
- <a class="usf-group"> |
|
95 |
- <span class="avatar-wrap smaller"> |
|
96 |
- <img src="@author.avatarUrl" width="20" height="20"> |
|
97 |
- </span> |
|
98 |
- |
|
99 |
- <strong class="name">@author.name</strong> |
|
100 |
- <span class="loginid"> <strong>@{"@"}</strong>@author.loginId</span> |
|
101 |
- </a> |
|
102 |
- </li> |
|
103 |
- } |
|
104 |
- </ul> |
|
105 |
- </div> |
|
91 |
+ data-avatar-url="@author.avatarUrl" |
|
92 |
+ data-login-id="@author.loginId"> |
|
93 |
+ @author.name |
|
94 |
+ </option> |
|
95 |
+ } |
|
96 |
+ </select> |
|
106 | 97 |
</dd> |
107 | 98 |
</dl> |
108 | 99 |
|
109 | 100 |
<dl class="issue-option"> |
110 | 101 |
<dt>@Messages("issue.assignee")</dt> |
111 | 102 |
<dd> |
112 |
- <div class="btn-group" data-name="assigneeId"> |
|
113 |
- <button class="btn dropdown-toggle auto" data-toggle="dropdown"> |
|
114 |
- <span class="d-label">@Messages("common.order.all")</span> |
|
115 |
- <span class="d-caret"><span class="caret"></span></span> |
|
116 |
- </button> |
|
117 |
- <ul class="dropdown-menu"> |
|
118 |
- <li data-value=""><a>@Messages("common.order.all")</a></li> |
|
119 |
- <li data-value="@User.anonymous.id" @if(param.assigneeId != null && param.assigneeId == User.anonymous.id){data-selected="true" class="active"}><a>@Messages("issue.noAssignee")</a></li> |
|
120 |
- @if(ProjectUser.isMember(UserApp.currentUser().id, project.id)){ |
|
121 |
- <li data-value="@UserApp.currentUser().id"><a>@Messages("issue.list.assignedToMe")</a></li> |
|
103 |
+ <select id="assigneeId" name="assigneeId"> |
|
104 |
+ <option value="">@Messages("common.order.all")</option> |
|
105 |
+ <option value="@User.anonymous.id" @if(param.assigneeId != null && param.assigneeId == User.anonymous.id){ selected }>@Messages("issue.noAssignee")</option> |
|
106 |
+ @if(ProjectUser.isMember(UserApp.currentUser().id, project.id)){ |
|
107 |
+ <option value="@UserApp.currentUser().id">@Messages("issue.list.assignedToMe")</a></option>} |
|
108 |
+ @for(member <- project.members) { |
|
109 |
+ <option value="@member.user.id" |
|
110 |
+ @if(param.assigneeId != null |
|
111 |
+ && param.assigneeId == member.user.id){ |
|
112 |
+ selected |
|
122 | 113 |
} |
123 |
- <li class="divider"></li> |
|
124 |
- @for(member <- project.members) { |
|
125 |
- <li data-value="@member.user.id" @if(param.assigneeId != null && param.assigneeId == member.user.id){data-selected="true" class="active"}> |
|
126 |
- <a class="usf-group"> |
|
127 |
- <span class="avatar-wrap smaller"> |
|
128 |
- <img src="@member.user.avatarUrl" width="20" height="20"> |
|
129 |
- </span> |
|
130 |
- |
|
131 |
- <strong class="name">@member.user.name</strong> |
|
132 |
- <span class="loginid"> <strong>@{"@"}</strong>@member.user.loginId</span> |
|
133 |
- </a> |
|
134 |
- </li> |
|
135 |
- } |
|
136 |
- </ul> |
|
137 |
- </div> |
|
114 |
+ data-avatar-url="@member.user.avatarUrl" |
|
115 |
+ data-login-id="@member.user.loginId"> |
|
116 |
+ @member.user.name |
|
117 |
+ </option> |
|
118 |
+ } |
|
119 |
+ </select> |
|
138 | 120 |
</dd> |
139 | 121 |
</dl> |
122 |
+ |
|
140 | 123 |
<dl class="issue-option"> |
141 | 124 |
<dt>@Messages("milestone")</dt> |
142 | 125 |
<dd> |
143 |
- <div class="btn-group" data-name="milestoneId"> |
|
144 |
- <button class="btn dropdown-toggle auto" data-toggle="dropdown"> |
|
145 |
- <span class="d-label">@Messages("milestone.state.all")</span> |
|
146 |
- <span class="d-caret"><span class="caret"></span></span> |
|
147 |
- </button> |
|
148 |
- <ul class="dropdown-menu"> |
|
149 |
- <li data-value=""><a>@Messages("milestone.state.all")</a></li> |
|
150 |
- <li data-value="@Milestone.NULL_MILESTONE_ID" @if(param.milestoneId != null && param.milestoneId == Milestone.NULL_MILESTONE_ID){data-selected="true" class="active"}><a>@Messages("issue.noMilestone")</a></li> |
|
151 |
- <li class="divider"></li> |
|
152 |
- @for(milestone <- Milestone.findByProjectId(project.id)) { |
|
153 |
- <li data-value="@milestone.id" @if(param.milestoneId != null && param.milestoneId == milestone.id){data-selected="true" class="active"}><a>@milestone.title</a></li> |
|
154 |
- } |
|
155 |
- </ul> |
|
156 |
- </div> |
|
126 |
+ <select id="milestoneId" name="milestoneId"> |
|
127 |
+ <option value="">@Messages("milestone.state.all")</option> |
|
128 |
+ @if(param.milestoneId != null |
|
129 |
+ && param.milestoneId == Milestone.NULL_MILESTONE_ID){ |
|
130 |
+ <option value="@Milestone.NULL_MILESTONE_ID"> |
|
131 |
+ @Messages("issue.noMilestone") |
|
132 |
+ </option> |
|
133 |
+ } |
|
134 |
+ @for(milestone <- Milestone.findByProjectId(project.id)) { |
|
135 |
+ <option value="@milestone.id" |
|
136 |
+ @if(param.milestoneId != null && param.milestoneId == milestone.id){ |
|
137 |
+ selected |
|
138 |
+ }> |
|
139 |
+ @milestone.title |
|
140 |
+ </option> |
|
141 |
+ } |
|
142 |
+ </select> |
|
157 | 143 |
</dd> |
158 | 144 |
</dl> |
159 | 145 |
</div> |
... | ... | @@ -222,28 +208,62 @@ |
222 | 208 |
|
223 | 209 |
<script type="text/javascript"> |
224 | 210 |
$(document).ready(function(){ |
225 |
- yobi.Label.init({ |
|
226 |
- "sURLLabels" : "@routes.IssueLabelApp.labels(project.owner, project.name)", |
|
227 |
- "sURLPost" : "@routes.IssueLabelApp.newLabel(project.owner, project.name)", |
|
228 |
- "bRefresh" : true |
|
229 |
- @if(param.labelIds != null){ |
|
230 |
- , "aSelectedLabels" : [@StringUtils.join(param.labelIds, ",")] |
|
231 |
- } else { |
|
232 |
- , "aSelectedLabels" : [] |
|
233 |
- } |
|
234 |
- }); |
|
211 |
+ $("#assigneeId, #authorId") |
|
212 |
+ .select2({ |
|
213 |
+ formatResult: format, |
|
214 |
+ formatSelection: format, |
|
215 |
+ width: "resolve" |
|
216 |
+ }) |
|
217 |
+ .on("change", function(e){ |
|
218 |
+ $("form[name='search']" ).submit(); |
|
219 |
+ }); |
|
235 | 220 |
|
236 |
- $yobi.loadModule("issue.List", { |
|
237 |
- "welSearchOrder": $("a[orderBy]"), |
|
238 |
- "welSearchState": $("a[state]"), |
|
239 |
- "welSearchAuthor": $("div[data-name='authorId']"), |
|
240 |
- "welSearchAssignee": $("div[data-name='assigneeId']"), |
|
241 |
- "welSearchMilestone": $("div[data-name='milestoneId']"), |
|
242 |
- "welSearchForm":$("form[name='search']"), |
|
243 |
- "welFilter": $("a[pjax-filter]"), |
|
244 |
- "elPagination": $("#pagination"), |
|
245 |
- "nTotalPages" : @currentPage.getTotalPageCount() |
|
246 |
- }); |
|
221 |
+ $("#milestoneId") |
|
222 |
+ .select2({ |
|
223 |
+ width: "resolve" |
|
224 |
+ }) |
|
225 |
+ .on("change", function(e){ |
|
226 |
+ $("form[name='search']").submit(); |
|
227 |
+ }); |
|
228 |
+ |
|
229 |
+ /** |
|
230 |
+ * select box list customization using select2 |
|
231 |
+ * |
|
232 |
+ */ |
|
233 |
+ function format(state) { |
|
234 |
+ var originalOption = state.element; |
|
235 |
+ if($(originalOption).data('avatar-url')){ |
|
236 |
+ return "<img src='"+$(originalOption).data('avatar-url') +"' width='20' height='20'>" |
|
237 |
+ + "<span style='font-weight: bold'>" + state.text + "</span>" |
|
238 |
+ +"<span style='color: gray'>@{"@"}" + $(originalOption).data('login-id') + "</span>"; |
|
239 |
+ } else { |
|
240 |
+ return state.text; |
|
241 |
+ } |
|
242 |
+ } |
|
243 |
+ }); |
|
244 |
+ </script> |
|
245 |
+ <script type="text/javascript"> |
|
246 |
+ $(document).ready(function(){ |
|
247 |
+ yobi.Label.init({ |
|
248 |
+ "sURLLabels" : "@routes.IssueLabelApp.labels(project.owner, project.name)", |
|
249 |
+ "sURLPost" : "@routes.IssueLabelApp.newLabel(project.owner, project.name)", |
|
250 |
+ "bRefresh" : true |
|
251 |
+ @if(param.labelIds != null){ |
|
252 |
+ , "aSelectedLabels" : [@StringUtils.join(param.labelIds, ",")] |
|
253 |
+ } else { |
|
254 |
+ , "aSelectedLabels" : [] |
|
255 |
+ } |
|
256 |
+ }); |
|
257 |
+ |
|
258 |
+ $yobi.loadModule("issue.List", { |
|
259 |
+ "welSearchOrder": $("a[orderBy]"), |
|
260 |
+ "welSearchState": $("a[state]"), |
|
261 |
+ "welSearchMilestone": $("div[data-name='milestoneId']"), |
|
262 |
+ "welSearchForm":$("form[name='search']"), |
|
263 |
+ "welFilter": $("a[pjax-filter]"), |
|
264 |
+ "elPagination": $("#pagination"), |
|
265 |
+ "nTotalPages" : @currentPage.getTotalPageCount() |
|
266 |
+ }); |
|
247 | 267 |
|
248 | 268 |
yobi.ShortcutKey.setKeymapLink({ |
249 | 269 |
"N": "@routes.IssueApp.newIssueForm(project.owner, project.name)" |
--- app/views/layout.scala.html
+++ app/views/layout.scala.html
... | ... | @@ -13,6 +13,7 @@ |
13 | 13 |
<link rel="stylesheet" type="text/css" media="screen" href="@routes.Assets.at("stylesheets/yobi.css")"> |
14 | 14 |
<link rel="stylesheet" type="text/css" media="screen" href="@routes.Assets.at("stylesheets/yobicon/style.css")"> |
15 | 15 |
<link rel="stylesheet" type="text/css" media="screen" href="@routes.Assets.at("javascripts/lib/zenform/zen-form.css")"> |
16 |
+<link rel="stylesheet" type="text/css" media="screen" href="@routes.Assets.at("javascripts/lib/select2/select2.css")"/> |
|
16 | 17 |
|
17 | 18 |
<script type="text/javascript" src="@routes.Assets.at("javascripts/lib/jquery/jquery-1.9.0.js")"></script> |
18 | 19 |
<script type="text/javascript" src="@routes.Assets.at("javascripts/lib/jquery/jquery.pjax.js")"></script> |
--- public/javascripts/service/yobi.issue.List.js
+++ public/javascripts/service/yobi.issue.List.js
... | ... | @@ -31,7 +31,7 @@ |
31 | 31 |
*/ |
32 | 32 |
function _initVar(htOptions){ |
33 | 33 |
htVar.nTotalPages = htOptions.nTotalPages || 1; |
34 |
- |
|
34 |
+ |
|
35 | 35 |
htVar.oSearchAuthor = new yobi.ui.Dropdown({"elContainer": htOptions.welSearchAuthor}); |
36 | 36 |
htVar.oSearchAssignee = new yobi.ui.Dropdown({"elContainer": htOptions.welSearchAssignee}); |
37 | 37 |
htVar.oSearchMilestone = new yobi.ui.Dropdown({"elContainer": htOptions.welSearchMilestone}); |
... | ... | @@ -115,16 +115,16 @@ |
115 | 115 |
yobi.Label.resetLabel($(this).attr('data-labelId')); |
116 | 116 |
htElement.welSearchForm.submit(); |
117 | 117 |
} |
118 |
- |
|
118 |
+ |
|
119 | 119 |
function _onChangeSearchField() { |
120 | 120 |
htElement.welSearchForm.submit(); |
121 | 121 |
} |
122 | 122 |
|
123 | 123 |
function _onClickSearchFilter(event) { |
124 | 124 |
event.preventDefault(); |
125 |
- htVar.oSearchAuthor.selectByValue($(this).attr("authorId")); |
|
126 |
- htVar.oSearchAssignee.selectByValue($(this).attr("assigneeId")); |
|
127 |
- htVar.oSearchMilestone.selectByValue($(this).attr("milestoneId")); |
|
125 |
+ $("#authorId").val($(this).attr("authorId")); |
|
126 |
+ $("#assigneeId").val($(this).attr("assigneeId")); |
|
127 |
+ $("#milestoneId").val($(this).attr("milestoneId")); |
|
128 | 128 |
htElement.welSearchForm.submit(); |
129 | 129 |
} |
130 | 130 |
|
Add a comment
Delete comment
Once you delete this comment, you won't be able to recover it. Are you sure you want to delete this comment?