##// END OF EJS Templates
gists: move update button to the left as other forms has action buttons on the left.
marcink -
r4125:9987e5fd default
parent child Browse files
Show More
@@ -1,137 +1,137 b''
1 ## -*- coding: utf-8 -*-
1 ## -*- coding: utf-8 -*-
2 <%inherit file="/base/base.mako"/>
2 <%inherit file="/base/base.mako"/>
3
3
4 <%def name="title()">
4 <%def name="title()">
5 ${_('Edit Gist')} &middot; ${c.gist.gist_access_id}
5 ${_('Edit Gist')} &middot; ${c.gist.gist_access_id}
6 %if c.rhodecode_name:
6 %if c.rhodecode_name:
7 &middot; ${h.branding(c.rhodecode_name)}
7 &middot; ${h.branding(c.rhodecode_name)}
8 %endif
8 %endif
9 </%def>
9 </%def>
10
10
11 <%def name="breadcrumbs_links()"></%def>
11 <%def name="breadcrumbs_links()"></%def>
12
12
13 <%def name="menu_bar_nav()">
13 <%def name="menu_bar_nav()">
14 ${self.menu_items(active='gists')}
14 ${self.menu_items(active='gists')}
15 </%def>
15 </%def>
16
16
17 <%def name="main()">
17 <%def name="main()">
18 <div class="box">
18 <div class="box">
19 <!-- box / title -->
19 <!-- box / title -->
20 <div class="title">
20 <div class="title">
21
21
22 </div>
22 </div>
23
23
24 <div class="table">
24 <div class="table">
25 <div id="files_data">
25 <div id="files_data">
26 ${h.secure_form(h.route_path('gist_update', gist_id=c.gist.gist_access_id), id='eform', request=request)}
26 ${h.secure_form(h.route_path('gist_update', gist_id=c.gist.gist_access_id), id='eform', request=request)}
27 <div>
27 <div>
28 <input type="hidden" value="${c.file_last_commit.raw_id}" name="parent_hash">
28 <input type="hidden" value="${c.file_last_commit.raw_id}" name="parent_hash">
29 <div>
29 <div>
30 <span class="gist-gravatar">
30 <span class="gist-gravatar">
31 ${self.gravatar(h.email_or_none(c.rhodecode_user.full_contact), 30)}
31 ${self.gravatar(h.email_or_none(c.rhodecode_user.full_contact), 30)}
32 </span>
32 </span>
33 <label for='lifetime'>${_('Gist lifetime')}</label>
33 <label for='lifetime'>${_('Gist lifetime')}</label>
34 ${h.dropdownmenu('lifetime', '0', c.lifetime_options)}
34 ${h.dropdownmenu('lifetime', '0', c.lifetime_options)}
35
35
36 <label for='gist_acl_level'>${_('Gist access level')}</label>
36 <label for='gist_acl_level'>${_('Gist access level')}</label>
37 ${h.dropdownmenu('gist_acl_level', c.gist.acl_level, c.acl_options)}
37 ${h.dropdownmenu('gist_acl_level', c.gist.acl_level, c.acl_options)}
38
38
39 <textarea style="margin-top: 5px; border-color: #dbd9da" id="description" name="description"
39 <textarea style="margin-top: 5px; border-color: #dbd9da" id="description" name="description"
40 placeholder="${_('Gist description ...')}">${c.gist.gist_description}</textarea>
40 placeholder="${_('Gist description ...')}">${c.gist.gist_description}</textarea>
41 </div>
41 </div>
42 </div>
42 </div>
43
43
44 ## peppercorn schema
44 ## peppercorn schema
45 <input type="hidden" name="__start__" value="nodes:sequence"/>
45 <input type="hidden" name="__start__" value="nodes:sequence"/>
46 % for cnt, file in enumerate(c.files):
46 % for cnt, file in enumerate(c.files):
47 <input type="hidden" name="__start__" value="file:mapping"/>
47 <input type="hidden" name="__start__" value="file:mapping"/>
48 <div id="codeblock" class="codeblock" >
48 <div id="codeblock" class="codeblock" >
49 <div class="code-header">
49 <div class="code-header">
50 <div class="form">
50 <div class="form">
51 <div class="fields">
51 <div class="fields">
52 <input type="hidden" name="filename_org" value="${file.path}" >
52 <input type="hidden" name="filename_org" value="${file.path}" >
53 <input id="filename_${h.FID('f',file.path)}" name="filename" size="30" type="text" value="${file.path}">
53 <input id="filename_${h.FID('f',file.path)}" name="filename" size="30" type="text" value="${file.path}">
54 ${h.dropdownmenu('mimetype' ,'plain',[('plain',_('plain'))],enable_filter=True, id='mimetype_'+h.FID('f',file.path))}
54 ${h.dropdownmenu('mimetype' ,'plain',[('plain',_('plain'))],enable_filter=True, id='mimetype_'+h.FID('f',file.path))}
55 </div>
55 </div>
56 </div>
56 </div>
57 </div>
57 </div>
58 <div class="editor_container">
58 <div class="editor_container">
59 <pre id="editor_pre"></pre>
59 <pre id="editor_pre"></pre>
60 <textarea id="editor_${h.FID('f',file.path)}" name="content" >${file.content}</textarea>
60 <textarea id="editor_${h.FID('f',file.path)}" name="content" >${file.content}</textarea>
61 </div>
61 </div>
62 </div>
62 </div>
63 <input type="hidden" name="__end__" />
63 <input type="hidden" name="__end__" />
64
64
65 ## dynamic edit box.
65 ## dynamic edit box.
66 <script type="text/javascript">
66 <script type="text/javascript">
67 $(document).ready(function(){
67 $(document).ready(function(){
68 var myCodeMirror = initCodeMirror(
68 var myCodeMirror = initCodeMirror(
69 "editor_${h.FID('f',file.path)}", '');
69 "editor_${h.FID('f',file.path)}", '');
70
70
71 var modes_select = $("#mimetype_${h.FID('f',file.path)}");
71 var modes_select = $("#mimetype_${h.FID('f',file.path)}");
72 fillCodeMirrorOptions(modes_select);
72 fillCodeMirrorOptions(modes_select);
73
73
74 // try to detect the mode based on the file we edit
74 // try to detect the mode based on the file we edit
75 var mimetype = "${file.mimetype}";
75 var mimetype = "${file.mimetype}";
76 var detected_mode = detectCodeMirrorMode(
76 var detected_mode = detectCodeMirrorMode(
77 "${file.path}", mimetype);
77 "${file.path}", mimetype);
78
78
79 if(detected_mode){
79 if(detected_mode){
80 $(modes_select).select2("val", mimetype);
80 $(modes_select).select2("val", mimetype);
81 $(modes_select).change();
81 $(modes_select).change();
82 setCodeMirrorMode(myCodeMirror, detected_mode);
82 setCodeMirrorMode(myCodeMirror, detected_mode);
83 }
83 }
84
84
85 var filename_selector = "#filename_${h.FID('f',file.path)}";
85 var filename_selector = "#filename_${h.FID('f',file.path)}";
86 // on change of select field set mode
86 // on change of select field set mode
87 setCodeMirrorModeFromSelect(
87 setCodeMirrorModeFromSelect(
88 modes_select, filename_selector, myCodeMirror, null);
88 modes_select, filename_selector, myCodeMirror, null);
89
89
90 // on entering the new filename set mode, from given extension
90 // on entering the new filename set mode, from given extension
91 setCodeMirrorModeFromInput(
91 setCodeMirrorModeFromInput(
92 modes_select, filename_selector, myCodeMirror, null);
92 modes_select, filename_selector, myCodeMirror, null);
93 });
93 });
94 </script>
94 </script>
95 %endfor
95 %endfor
96 <input type="hidden" name="__end__" />
96 <input type="hidden" name="__end__" />
97
97
98 <div class="pull-right">
98 <div class="pull-left">
99 ${h.submit('update',_('Update Gist'),class_="btn btn-success")}
99 ${h.submit('update',_('Update Gist'),class_="btn btn-success")}
100 <a class="btn" href="${h.route_path('gist_show', gist_id=c.gist.gist_access_id)}">${_('Cancel')}</a>
100 <a class="btn" href="${h.route_path('gist_show', gist_id=c.gist.gist_access_id)}">${_('Cancel')}</a>
101 </div>
101 </div>
102 ${h.end_form()}
102 ${h.end_form()}
103 </div>
103 </div>
104 </div>
104 </div>
105
105
106 </div>
106 </div>
107 <script>
107 <script>
108 $('#update').on('click', function(e){
108 $('#update').on('click', function(e){
109 e.preventDefault();
109 e.preventDefault();
110
110
111 $(this).val('Updating...');
111 $(this).val('Updating...');
112 $(this).attr('disabled', 'disabled');
112 $(this).attr('disabled', 'disabled');
113 // check for newer version.
113 // check for newer version.
114 $.ajax({
114 $.ajax({
115 url: "${h.route_path('gist_edit_check_revision', gist_id=c.gist.gist_access_id)}",
115 url: "${h.route_path('gist_edit_check_revision', gist_id=c.gist.gist_access_id)}",
116 data: {
116 data: {
117 'revision': '${c.file_last_commit.raw_id}'
117 'revision': '${c.file_last_commit.raw_id}'
118 },
118 },
119 dataType: 'json',
119 dataType: 'json',
120 type: 'GET',
120 type: 'GET',
121 success: function(data) {
121 success: function(data) {
122 if(data.success === false){
122 if(data.success === false){
123 message = '${h.literal(_('Gist was updated since you started editing. Copy your changes and click %(here)s to reload the new version.')
123 message = '${h.literal(_('Gist was updated since you started editing. Copy your changes and click %(here)s to reload the new version.')
124 % {'here': h.link_to('here', h.route_path('gist_edit', gist_id=c.gist.gist_access_id))})}'
124 % {'here': h.link_to('here', h.route_path('gist_edit', gist_id=c.gist.gist_access_id))})}'
125 alertMessage = [{"message": {
125 alertMessage = [{"message": {
126 "message": message, "force": "true", "level": "warning"}}];
126 "message": message, "force": "true", "level": "warning"}}];
127 $.Topic('/notifications').publish(alertMessage[0]);
127 $.Topic('/notifications').publish(alertMessage[0]);
128 }
128 }
129 else{
129 else{
130 $('#eform').submit();
130 $('#eform').submit();
131 }
131 }
132 }
132 }
133 });
133 });
134 })
134 })
135
135
136 </script>
136 </script>
137 </%def>
137 </%def>
General Comments 0
You need to be logged in to leave comments. Login now