##// END OF EJS Templates
my-account: updated bookmarks UX
milka -
r4688:40a39d56 stable
parent child Browse files
Show More
@@ -1,226 +1,217 b''
1 1 <%namespace name="dt" file="/data_table/_dt_elements.mako"/>
2 2
3 3 <%def name="form_item(position=None, title=None, redirect_url=None, repo=None, repo_group=None)">
4 4 <tr>
5 5 <td class="td-align-top" >
6 6 <div class="label">
7 7 <label for="position">${_('Position')}:</label>
8 8 </div>
9 9 <div class="input">
10 10 <input type="text" name="position" value="${position}" style="width: 40px"/>
11 11 ${h.hidden('cur_position', position)}
12 12 </div>
13 13 </td>
14 14
15 15 <td>
16 16 <div class="label">
17 17 <label for="title">${_('Bookmark title (max 30 characters, optional)')}:</label>
18 18 </div>
19 19 <div class="input">
20 20 <input type="text" name="title" value="${title}" style="width: 300px" maxlength="30"/>
21 21
22 22 <div class="field pull-right">
23 23 <div>
24 24 <label class="btn-link btn-danger">${_('Clear')}:</label>
25 25 ${h.checkbox('remove', value=True)}
26 26 </div>
27 27 </div>
28 28 </div>
29 <p class="help-block help-block-inline" >
30 ${_('Server URL is available as ${server_url} variable. E.g. Redirect url: ${server_url}/_admin/exception_tracker')}
31 </p>
32 29
33 <div class="label">
30 <div class="label" style="margin-top:10px">
34 31 <label for="redirect_url">${_('Redirect URL')}:</label>
35 32 </div>
36 33 <div class="input">
37 34 <input type="text" name="redirect_url" value="${redirect_url}" style="width: 600px"/>
38 35 </div>
39
36 <p class="help-block help-block-inline">
37 ${_('Server URL is available as ${server_url} variable. E.g. Redirect url: ${server_url}/_admin/exception_tracker')}
38 </p>
40 39
41 <div class="select">
40 <div class="select" style="margin-top:5px">
41 <div class="label">
42 <label for="redirect_url">${_('Templates')}:</label>
43 </div>
44
42 45 % if repo:
43 <div class="label">
44 <label for="redirect_url">${_('Repository template')}:</label>
45 </div>
46 46 ${dt.repo_name(name=repo.repo_name, rtype=repo.repo_type,rstate=None,private=None,archived=False,fork_of=False)}
47 47 ${h.hidden('bookmark_repo', repo.repo_id)}
48 48 % elif repo_group:
49 <div class="label">
50 <label for="redirect_url">${_('Repository group template')}:</label>
51 </div>
52 49 ${dt.repo_group_name(repo_group.group_name)}
53 50 ${h.hidden('bookmark_repo_group', repo_group.group_id)}
54 51 % else:
55 <div class="label">
56 <label for="redirect_url">${_('Template Repository or Repository group')}:</label>
52 <div>
53 ${h.hidden('bookmark_repo', class_='bookmark_repo')}
54 <p class="help-block help-block-inline">${_('Available as ${repo_url} e.g. Redirect url: ${repo_url}/changelog')}</p>
57 55 </div>
58 ${h.hidden('bookmark_repo', class_='bookmark_repo')}
59 <span style="padding-right:15px">OR</span>
56 <div style="margin-top:5px">
60 57 ${h.hidden('bookmark_repo_group', class_='bookmark_repo_group')}
58 <p class="help-block help-block-inline">${_('Available as ${repo_group_url} e.g. Redirect url: ${repo_group_url}')}</p>
59 </div>
60
61 61 % endif
62 62 </div>
63 63
64 <p class="help-block help-block-inline" >
65 % if repo:
66 ${_('Available as ${repo_url} e.g. Redirect url: ${repo_url}/changelog')}
67 % elif repo_group:
68 ${_('Available as ${repo_group_url} e.g. Redirect url: ${repo_group_url}')}
69 % else:
70 ${_('Available as full url variables in redirect url. i.e: ${repo_url}, ${repo_group_url}.')}
71 % endif
72 </p>
73 64 </td>
74 65
75 66 </tr>
76 67 </%def>
77 68
78 69 <div class="panel panel-default">
79 70 <div class="panel-heading">
80 71 <h3 class="panel-title">${_('Your Bookmarks')}</h3>
81 72 </div>
82 73
83 74 <div class="panel-body">
84 75 <p>
85 76 ${_('Store upto 10 bookmark links to favorite repositories, external issue tracker or CI server. ')}
86 77 <br/>
87 78 ${_('Bookmarks are accessible from your username dropdown or by keyboard shortcut `g 0-9`')}
88 79 </p>
89 80
90 81 ${h.secure_form(h.route_path('my_account_bookmarks_update'), request=request)}
91 82 <div class="form-vertical">
92 83 <table class="rctable">
93 84 ## generate always 10 entries
94 85 <input type="hidden" name="__start__" value="bookmarks:sequence"/>
95 86 % for item in (c.bookmark_items + [None for i in range(10)])[:10]:
96 87 <input type="hidden" name="__start__" value="bookmark:mapping"/>
97 88 % if item is None:
98 89 ## empty placehodlder
99 90 ${form_item()}
100 91 % else:
101 92 ## actual entry
102 93 ${form_item(position=item.position, title=item.title, redirect_url=item.redirect_url, repo=item.repository, repo_group=item.repository_group)}
103 94 % endif
104 95 <input type="hidden" name="__end__" value="bookmark:mapping"/>
105 96 % endfor
106 97 <input type="hidden" name="__end__" value="bookmarks:sequence"/>
107 98 </table>
108 99 <div class="buttons">
109 100 ${h.submit('save',_('Save'),class_="btn")}
110 101 </div>
111 102 </div>
112 103 ${h.end_form()}
113 104 </div>
114 105 </div>
115 106
116 107 <script>
117 108 $(document).ready(function(){
118 109
119 110
120 111 var repoFilter = function (data) {
121 112 var results = [];
122 113
123 114 if (!data.results[0]) {
124 115 return data
125 116 }
126 117
127 118 $.each(data.results[0].children, function () {
128 119 // replace name to ID for submision
129 120 this.id = this.repo_id;
130 121 results.push(this);
131 122 });
132 123
133 124 data.results[0].children = results;
134 125 return data;
135 126 };
136 127
137 128
138 129 $(".bookmark_repo").select2({
139 130 cachedDataSource: {},
140 131 minimumInputLength: 2,
141 132 placeholder: "${_('repository')}",
142 133 dropdownAutoWidth: true,
143 134 containerCssClass: "drop-menu",
144 135 dropdownCssClass: "drop-menu-dropdown",
145 136 formatResult: formatRepoResult,
146 137 query: $.debounce(250, function (query) {
147 138 self = this;
148 139 var cacheKey = query.term;
149 140 var cachedData = self.cachedDataSource[cacheKey];
150 141
151 142 if (cachedData) {
152 143 query.callback({results: cachedData.results});
153 144 } else {
154 145 $.ajax({
155 146 url: pyroutes.url('repo_list_data'),
156 147 data: {'query': query.term},
157 148 dataType: 'json',
158 149 type: 'GET',
159 150 success: function (data) {
160 151 data = repoFilter(data);
161 152 self.cachedDataSource[cacheKey] = data;
162 153 query.callback({results: data.results});
163 154 },
164 155 error: function (data, textStatus, errorThrown) {
165 156 alert("Error while fetching entries.\nError code {0} ({1}).".format(data.status, data.statusText));
166 157 }
167 158 })
168 159 }
169 160 }),
170 161 });
171 162
172 163 var repoGroupFilter = function (data) {
173 164 var results = [];
174 165
175 166 if (!data.results[0]) {
176 167 return data
177 168 }
178 169
179 170 $.each(data.results[0].children, function () {
180 171 // replace name to ID for submision
181 172 this.id = this.repo_group_id;
182 173 results.push(this);
183 174 });
184 175
185 176 data.results[0].children = results;
186 177 return data;
187 178 };
188 179
189 180 $(".bookmark_repo_group").select2({
190 181 cachedDataSource: {},
191 182 minimumInputLength: 2,
192 183 placeholder: "${_('repository group')}",
193 184 dropdownAutoWidth: true,
194 185 containerCssClass: "drop-menu",
195 186 dropdownCssClass: "drop-menu-dropdown",
196 187 formatResult: formatRepoGroupResult,
197 188 query: $.debounce(250, function (query) {
198 189 self = this;
199 190 var cacheKey = query.term;
200 191 var cachedData = self.cachedDataSource[cacheKey];
201 192
202 193 if (cachedData) {
203 194 query.callback({results: cachedData.results});
204 195 } else {
205 196 $.ajax({
206 197 url: pyroutes.url('repo_group_list_data'),
207 198 data: {'query': query.term},
208 199 dataType: 'json',
209 200 type: 'GET',
210 201 success: function (data) {
211 202 data = repoGroupFilter(data);
212 203 self.cachedDataSource[cacheKey] = data;
213 204 query.callback({results: data.results});
214 205 },
215 206 error: function (data, textStatus, errorThrown) {
216 207 alert("Error while fetching entries.\nError code {0} ({1}).".format(data.status, data.statusText));
217 208 }
218 209 })
219 210 }
220 211 })
221 212 });
222 213
223 214
224 215 });
225 216
226 217 </script>
General Comments 1
Under Review
author

Auto status change to "Under Review"

You need to be logged in to leave comments. Login now