##// END OF EJS Templates
pullrequest: don't do in the ajax callback what can be done in no time right now
Mads Kiilerich -
r3513:a2a61978 beta
parent child Browse files
Show More
@@ -1,204 +1,207
1 <%inherit file="/base/base.html"/>
1 <%inherit file="/base/base.html"/>
2
2
3 <%def name="title()">
3 <%def name="title()">
4 ${c.repo_name} ${_('New pull request')}
4 ${c.repo_name} ${_('New pull request')}
5 </%def>
5 </%def>
6
6
7 <%def name="breadcrumbs_links()">
7 <%def name="breadcrumbs_links()">
8 ${h.link_to(_(u'Home'),h.url('/'))}
8 ${h.link_to(_(u'Home'),h.url('/'))}
9 &raquo;
9 &raquo;
10 ${h.repo_link(c.rhodecode_db_repo.groups_and_repo)}
10 ${h.repo_link(c.rhodecode_db_repo.groups_and_repo)}
11 &raquo;
11 &raquo;
12 ${_('new pull request')}
12 ${_('new pull request')}
13 </%def>
13 </%def>
14
14
15 <%def name="main()">
15 <%def name="main()">
16
16
17 <div class="box">
17 <div class="box">
18 <!-- box / title -->
18 <!-- box / title -->
19 <div class="title">
19 <div class="title">
20 ${self.breadcrumbs()}
20 ${self.breadcrumbs()}
21 </div>
21 </div>
22 ${h.form(url('pullrequest', repo_name=c.repo_name), method='post', id='pull_request_form')}
22 ${h.form(url('pullrequest', repo_name=c.repo_name), method='post', id='pull_request_form')}
23 <div style="float:left;padding:0px 30px 30px 30px">
23 <div style="float:left;padding:0px 30px 30px 30px">
24 ##ORG
24 ##ORG
25 <div style="float:left">
25 <div style="float:left">
26 <div>
26 <div>
27 <span style="font-size: 20px">
27 <span style="font-size: 20px">
28 ${h.select('org_repo','',c.org_repos,class_='refs')}:${h.select('org_ref',c.default_org_ref,c.org_refs,class_='refs')}
28 ${h.select('org_repo','',c.org_repos,class_='refs')}:${h.select('org_ref',c.default_org_ref,c.org_refs,class_='refs')}
29 </span>
29 </span>
30 <div style="padding:5px 3px 3px 20px;">${c.rhodecode_db_repo.description}</div>
30 <div style="padding:5px 3px 3px 20px;">${c.rhodecode_db_repo.description}</div>
31 </div>
31 </div>
32 <div style="clear:both;padding-top: 10px"></div>
32 <div style="clear:both;padding-top: 10px"></div>
33 </div>
33 </div>
34 <div style="float:left;font-size:24px;padding:0px 20px">
34 <div style="float:left;font-size:24px;padding:0px 20px">
35 <img height=32 width=32 src="${h.url('/images/arrow_right_64.png')}"/>
35 <img height=32 width=32 src="${h.url('/images/arrow_right_64.png')}"/>
36 </div>
36 </div>
37
37
38 ##OTHER, most Probably the PARENT OF THIS FORK
38 ##OTHER, most Probably the PARENT OF THIS FORK
39 <div style="float:left">
39 <div style="float:left">
40 <div>
40 <div>
41 <span style="font-size: 20px">
41 <span style="font-size: 20px">
42 ${h.select('other_repo',c.default_other_repo,c.other_repos,class_='refs')}:${h.select('other_ref',c.default_other_ref,c.default_other_refs,class_='refs')}
42 ${h.select('other_repo',c.default_other_repo,c.other_repos,class_='refs')}:${h.select('other_ref',c.default_other_ref,c.default_other_refs,class_='refs')}
43 </span>
43 </span>
44 <div id="other_repo_desc" style="padding:5px 3px 3px 20px;"></div>
44 <div id="other_repo_desc" style="padding:5px 3px 3px 20px;"></div>
45 </div>
45 </div>
46 <div style="clear:both;padding-top: 10px"></div>
46 <div style="clear:both;padding-top: 10px"></div>
47 </div>
47 </div>
48 <div style="clear:both;padding-top: 10px"></div>
48 <div style="clear:both;padding-top: 10px"></div>
49 ## overview pulled by ajax
49 ## overview pulled by ajax
50 <div style="float:left" id="pull_request_overview"></div>
50 <div style="float:left" id="pull_request_overview"></div>
51 <div style="float:left;clear:both;padding:10px 10px 10px 0px;display:none">
51 <div style="float:left;clear:both;padding:10px 10px 10px 0px;display:none">
52 <a id="pull_request_overview_url" href="#">${_('Detailed compare view')}</a>
52 <a id="pull_request_overview_url" href="#">${_('Detailed compare view')}</a>
53 </div>
53 </div>
54 </div>
54 </div>
55 <div style="float:left; border-left:1px dashed #eee">
55 <div style="float:left; border-left:1px dashed #eee">
56 <h4>${_('Pull request reviewers')}</h4>
56 <h4>${_('Pull request reviewers')}</h4>
57 <div id="reviewers" style="padding:0px 0px 0px 15px">
57 <div id="reviewers" style="padding:0px 0px 0px 15px">
58 ## members goes here !
58 ## members goes here !
59 <div class="group_members_wrap">
59 <div class="group_members_wrap">
60 <ul id="review_members" class="group_members">
60 <ul id="review_members" class="group_members">
61 %for member in c.review_members:
61 %for member in c.review_members:
62 <li id="reviewer_${member.user_id}">
62 <li id="reviewer_${member.user_id}">
63 <div class="reviewers_member">
63 <div class="reviewers_member">
64 <div class="gravatar"><img alt="gravatar" src="${h.gravatar_url(member.email,14)}"/> </div>
64 <div class="gravatar"><img alt="gravatar" src="${h.gravatar_url(member.email,14)}"/> </div>
65 <div style="float:left">${member.full_name} (${_('owner')})</div>
65 <div style="float:left">${member.full_name} (${_('owner')})</div>
66 <input type="hidden" value="${member.user_id}" name="review_members" />
66 <input type="hidden" value="${member.user_id}" name="review_members" />
67 <span class="delete_icon action_button" onclick="removeReviewMember(${member.user_id})"></span>
67 <span class="delete_icon action_button" onclick="removeReviewMember(${member.user_id})"></span>
68 </div>
68 </div>
69 </li>
69 </li>
70 %endfor
70 %endfor
71 </ul>
71 </ul>
72 </div>
72 </div>
73
73
74 <div class='ac'>
74 <div class='ac'>
75 <div class="reviewer_ac">
75 <div class="reviewer_ac">
76 ${h.text('user', class_='yui-ac-input')}
76 ${h.text('user', class_='yui-ac-input')}
77 <span class="help-block">${_('Add reviewer to this pull request.')}</span>
77 <span class="help-block">${_('Add reviewer to this pull request.')}</span>
78 <div id="reviewers_container"></div>
78 <div id="reviewers_container"></div>
79 </div>
79 </div>
80 </div>
80 </div>
81 </div>
81 </div>
82 </div>
82 </div>
83 <h3>${_('Create new pull request')}</h3>
83 <h3>${_('Create new pull request')}</h3>
84
84
85 <div class="form">
85 <div class="form">
86 <!-- fields -->
86 <!-- fields -->
87
87
88 <div class="fields">
88 <div class="fields">
89
89
90 <div class="field">
90 <div class="field">
91 <div class="label">
91 <div class="label">
92 <label for="pullrequest_title">${_('Title')}:</label>
92 <label for="pullrequest_title">${_('Title')}:</label>
93 </div>
93 </div>
94 <div class="input">
94 <div class="input">
95 ${h.text('pullrequest_title',size=30)}
95 ${h.text('pullrequest_title',size=30)}
96 </div>
96 </div>
97 </div>
97 </div>
98
98
99 <div class="field">
99 <div class="field">
100 <div class="label label-textarea">
100 <div class="label label-textarea">
101 <label for="pullrequest_desc">${_('description')}:</label>
101 <label for="pullrequest_desc">${_('description')}:</label>
102 </div>
102 </div>
103 <div class="textarea text-area editor">
103 <div class="textarea text-area editor">
104 ${h.textarea('pullrequest_desc',size=30)}
104 ${h.textarea('pullrequest_desc',size=30)}
105 </div>
105 </div>
106 </div>
106 </div>
107
107
108 <div class="buttons">
108 <div class="buttons">
109 ${h.submit('save',_('Send pull request'),class_="ui-btn large")}
109 ${h.submit('save',_('Send pull request'),class_="ui-btn large")}
110 ${h.reset('reset',_('Reset'),class_="ui-btn large")}
110 ${h.reset('reset',_('Reset'),class_="ui-btn large")}
111 </div>
111 </div>
112 </div>
112 </div>
113 </div>
113 </div>
114 ${h.end_form()}
114 ${h.end_form()}
115
115
116 </div>
116 </div>
117
117
118 <script type="text/javascript">
118 <script type="text/javascript">
119 var _USERS_AC_DATA = ${c.users_array|n};
119 var _USERS_AC_DATA = ${c.users_array|n};
120 var _GROUPS_AC_DATA = ${c.users_groups_array|n};
120 var _GROUPS_AC_DATA = ${c.users_groups_array|n};
121 PullRequestAutoComplete('user', 'reviewers_container', _USERS_AC_DATA, _GROUPS_AC_DATA);
121 PullRequestAutoComplete('user', 'reviewers_container', _USERS_AC_DATA, _GROUPS_AC_DATA);
122
122
123 var other_repos_info = ${c.other_repos_info|n};
123 var other_repos_info = ${c.other_repos_info|n};
124
124
125 var loadPreview = function(){
125 var loadPreview = function(){
126 YUD.setStyle(YUD.get('pull_request_overview_url').parentElement,'display','none');
126 YUD.setStyle(YUD.get('pull_request_overview_url').parentElement,'display','none');
127 //url template
127 //url template
128 var url = "${h.url('compare_url',
128 var url = "${h.url('compare_url',
129 repo_name='__other_repo__',
129 repo_name='__other_repo__',
130 org_ref_type='__other_ref_type__',
130 org_ref_type='__other_ref_type__',
131 org_ref='__other_ref__',
131 org_ref='__other_ref__',
132 other_repo='__org_repo__',
132 other_repo='__org_repo__',
133 other_ref_type='__org_ref_type__',
133 other_ref_type='__org_ref_type__',
134 other_ref='__org_ref__',
134 other_ref='__org_ref__',
135 as_form=True,
135 as_form=True,
136 merge=True,
136 merge=True,
137 )}";
137 )}";
138 var org_repo = YUQ('#pull_request_form #org_repo')[0].value;
138 var org_repo = YUQ('#pull_request_form #org_repo')[0].value;
139 var org_ref = YUQ('#pull_request_form #org_ref')[0].value.split(':');
139 var org_ref = YUQ('#pull_request_form #org_ref')[0].value.split(':');
140
140
141 var other_repo = YUQ('#pull_request_form #other_repo')[0].value;
141 var other_repo = YUQ('#pull_request_form #other_repo')[0].value;
142 var other_ref = YUQ('#pull_request_form #other_ref')[0].value.split(':');
142 var other_ref = YUQ('#pull_request_form #other_ref')[0].value.split(':');
143
143
144 var select_refs = YUQ('#pull_request_form select.refs')
144 var select_refs = YUQ('#pull_request_form select.refs')
145 var rev_data = {
145 var rev_data = {
146 'org_repo': org_repo,
146 'org_repo': org_repo,
147 'org_ref': org_ref[2],
147 'org_ref': org_ref[2],
148 'org_ref_type': 'rev',
148 'org_ref_type': 'rev',
149 'other_repo': other_repo,
149 'other_repo': other_repo,
150 'other_ref': other_ref[2],
150 'other_ref': other_ref[2],
151 'other_ref_type': 'rev',
151 'other_ref_type': 'rev',
152 }; // gather the org/other ref and repo here
152 }; // gather the org/other ref and repo here
153
153
154 for (k in rev_data){
154 for (k in rev_data){
155 url = url.replace('__'+k+'__',rev_data[k]);
155 url = url.replace('__'+k+'__',rev_data[k]);
156 }
156 }
157
157
158 YUD.get('pull_request_overview').innerHTML = "${_('Loading ...')}";
158 YUD.get('pull_request_overview').innerHTML = "${_('Loading ...')}";
159 ypjax(url,'pull_request_overview');
160
159 YUD.get('pull_request_overview_url').href = url; // shouldn't have as_form ... but ...
161 YUD.get('pull_request_overview_url').href = url; // shouldn't have as_form ... but ...
160 YUD.setStyle(YUD.get('pull_request_overview_url').parentElement,'display','');
162 YUD.setStyle(YUD.get('pull_request_overview_url').parentElement,'display','');
161 ypjax(url,'pull_request_overview', function(data){
163
162 var sel_box = YUQ('#pull_request_form #other_repo')[0];
164 var sel_box = YUQ('#pull_request_form #other_repo')[0];
163 var repo_name = sel_box.options[sel_box.selectedIndex].value;
165 var repo_name = sel_box.options[sel_box.selectedIndex].value;
166
164 YUD.get('other_repo_desc').innerHTML = other_repos_info[repo_name]['description'];
167 YUD.get('other_repo_desc').innerHTML = other_repos_info[repo_name]['description'];
165 // replace options of other_ref with the ones for the current other_repo
168 // replace options of other_ref with the ones for the current other_repo
166 var other_ref_selector = YUD.get('other_ref');
169 var other_ref_selector = YUD.get('other_ref');
167 var new_select = YUD.createElementFromMarkup(other_repos_info[repo_name]['revs']);
170 var new_select = YUD.createElementFromMarkup(other_repos_info[repo_name]['revs']);
168 var new_selectedIndex = new_select.selectedIndex;
171 var new_selectedIndex = new_select.selectedIndex;
169 other_ref_selector.innerHTML = ""; // clear old options
172 other_ref_selector.innerHTML = ""; // clear old options
170 while (new_select.length > 0){ // children will be popped when appened to other_ref_selector
173 while (new_select.length > 0){ // children will be popped when appened to other_ref_selector
171 other_ref_selector.appendChild(new_select.children[0]);
174 other_ref_selector.appendChild(new_select.children[0]);
172 }
175 }
173 // browsers lost track of selected when appendChild was used
176 // browsers lost track of selected when appendChild was used
174 other_ref_selector.selectedIndex = new_selectedIndex;
177 other_ref_selector.selectedIndex = new_selectedIndex;
178
175 // reset && add the reviewer based on selected repo
179 // reset && add the reviewer based on selected repo
176 var _data = other_repos_info[repo_name];
180 var _data = other_repos_info[repo_name];
177 YUD.get('review_members').innerHTML = '';
181 YUD.get('review_members').innerHTML = '';
178 addReviewMember(_data.user.user_id, _data.user.firstname,
182 addReviewMember(_data.user.user_id, _data.user.firstname,
179 _data.user.lastname, _data.user.username,
183 _data.user.lastname, _data.user.username,
180 _data.user.gravatar_link);
184 _data.user.gravatar_link);
181 })
182 }
185 }
183
186
184 ## refresh automatically when something changes (org_repo can't change)
187 ## refresh automatically when something changes (org_repo can't change)
185
188
186 YUE.on('org_ref', 'change', function(e){
189 YUE.on('org_ref', 'change', function(e){
187 loadPreview();
190 loadPreview();
188 });
191 });
189
192
190 YUE.on('other_repo', 'change', function(e){
193 YUE.on('other_repo', 'change', function(e){
191 var repo_name = e.currentTarget.value;
194 var repo_name = e.currentTarget.value;
192 loadPreview();
195 loadPreview();
193 });
196 });
194
197
195 YUE.on('other_ref', 'change', function(e){
198 YUE.on('other_ref', 'change', function(e){
196 loadPreview();
199 loadPreview();
197 });
200 });
198
201
199 //lazy load overview after 0.5s
202 //lazy load overview after 0.5s
200 setTimeout(loadPreview, 500)
203 setTimeout(loadPreview, 500)
201
204
202 </script>
205 </script>
203
206
204 </%def>
207 </%def>
General Comments 0
You need to be logged in to leave comments. Login now