Parent: [9194e9] (diff)

Child: [a4546e] (diff)

Download this file

project_tools.html    229 lines (223 with data), 9.6 kB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
{% extends g.theme.master %}
{% block title %}{{c.project.name}} / Tools{% endblock %}
{% block header %}Select Tools for {{c.project.shortname}}{% endblock %}
{% block content %}
{% if c.project.deleted %}
<div class="notice">This project has been deleted and is not visible to non-admin users</div>
{% endif %}
{% if h.has_project_access('tool')() %}
<p>Drag and drop tools to reorder.</p>
{% endif %}
<table>
<thead>
<tr>
<th>Type</th>
<th>Mount Point</th>
<th>Label</th>
{% if h.has_project_access('tool')() %}
<th>Edit</th>
<th></th>
{% endif %}
</tr>
</thead>
<tbody id="tool_admin">
{% for item in mounts %}
{% set i = loop.index0 %}
<tr class="sortables">
{% if 'ac' in item %}
<td>Tool: {{item['ac'].tool_name}}</td>
<td>{{item['ac'].options.mount_point}}</td>
<td>
<form method="POST" action="update_mounts" id="mounts_edit">
<input type="hidden"
name="tool-{{i}}.mount_point"
class="mount_point"
value="{{item['ac'].options.mount_point}}"/>
<input type="hidden"
name="tool-{{i}}.ordinal"
value="{{'ordinal' in item['ac'].options and item['ac'].options.ordinal or 0}}"/>
{% if h.has_project_access('tool')() and item['ac'].load().installable %}
<div class="editable viewing span-15 last">
<div class="viewer">{{item['ac'].options.mount_label}}</div>
<div class="editor">
<input type="text"
name="tool-{{i}}.mount_label"
value="{{item['ac'].options.mount_label}}"/>
</div>
</div>
{% else %}
<div>
{{item['ac'].options.mount_label}}
</div>
{% endif %}
</form>
</td>
<td>
{% if h.has_project_access('tool')() and item['ac'].load().installable %}
<a href="{{item['ac'].options.mount_point}}/"
class="ico-l">
<b class="ui-icon ui-icon-pencil"></b> <span>Edit</span>
</a>
{% endif %}
</td>
<td>
<form method="POST" action="update_mounts" id="mounts_edit">
<input type="hidden"
name="tool-{{i}}.mount_point"
value="{{item['ac'].options.mount_point}}"/>
<input name="tool-{{i}}.delete" type="hidden" value="Delete"/>
{% if h.has_project_access('tool')() and item['ac'].load().installable %}
<input class="mount_delete" type="button" value="Delete"/>
{% endif %}
</form>
</td>
{% endif %}
{% if 'sub' in item and not item['sub'].deleted %}
<td>Subproject</td>
<td>{{item['sub'].shortname}}</td>
<td>
<form method="POST" action="update_mounts" id="mounts_edit">
<input type="hidden"
name="subproject-{{i}}.shortname"
class="shortname"
value="{{item['sub'].shortname}}"/>
<input type="hidden"
name="subproject-{{i}}.ordinal"
value="{{'ordinal' in item['sub'] and item['sub'].ordinal or 0}}"/>
<div class="editable viewing span-15 last">
<div class="viewer">{{item['sub'].name}}</div>
<div class="editor">
<input type="text"
name="subproject-{{i}}.name"
value="{{item['sub'].name}}"/>
</div>
</div>
</form>
</td>
{% if h.has_project_access('tool')() %}
<td><a href="{{item['sub'].url() + 'admin/'}}" class="ico-l">
<b class="ui-icon ui-icon-pencil"></b> <span>Edit</span>
</a></td>
{% endif %}
<td>
<form method="POST" action="update_mounts" id="mounts_edit">
<input type="hidden"
name="subproject-{{i}}.shortname"
value="{{item['sub'].shortname}}"/>
<input name="subproject-{{i}}.delete" type="hidden" value="Delete"/>
{% if h.has_project_access('tool')() %}
<input class="mount_delete" type="button" value="Delete"/>
{% endif %}
</form>
</td>
{% endif %}
</tr>
{% endfor %}
<form method="POST" action="update_mounts">
<input type="hidden" name="new.ordinal" value="{{installable_tools|length + c.project.direct_subprojects|length}}"/>
{% if h.has_project_access('tool')() %}
<tr>
<td>
<select name="new.ep_name" class="new_ep_name">
<option value="" disabled="disabled">New Tool</option>
{% for tool in installable_tools %}
<option value="{{tool.name}}">{{tool.app.tool_label}}
{{'(%s)' % tool.app.status if tool.app.status != 'production' else ''}}
</option>
{% endfor %}
<option value="">Subproject</option>
</select>
</td>
<td>
<input name="new.mount_point" class="new_mount_point"/>
</td>
<td>
<input name="new.mount_label" class="new_mount_label"/>
</td>
<td colspan="2">
<input type="submit" value="Install" name="new.install"/>
</td>
</tr>
{% endif %}
</form>
</tbody>
</table>
{% if h.has_project_access('tool')() %}
<input type="button" id="save_order" value="Save Tool Order" style="display:none" />
<div id="delete-confirm">Warning: This will destroy all data in this tool and is non reversable!</div>
{% endif %}
{% endblock %}
{% block extra_js %}
<script type="text/javascript">
var form_to_delete = null;
var defaults = {
{% for tool in installable_tools %}
'{{tool.name}}':{'default_label':'{{tool.app.default_mount_label}}','default_mount':'{{tool.app.default_mount_point}}'},
{% endfor %}
};
$('select.new_ep_name').change(function() {
var tool = defaults[$(this).val()];
var row = $(this).closest('tr')
row.find('input.new_mount_point').val(tool.default_mount);
row.find('input.new_mount_label').val(tool.default_label);
});
{% if h.has_project_access('tool')() %}
/*<![CDATA[*/
$('#tool_admin').sortable({
items: 'tr.sortables',
axis: 'y',
update: function(e){
$('#save_order').show();
}
});
$('#save_order').click(function(e){
var sortables = $('#tool_admin .sortables');
var tools = 0
var subs = 0
var params = {}
for(var i=0,len=sortables.length; i<len; i++){
var item = $(sortables[i])
var mount_point = item.find('input.mount_point');
var shortname = item.find('input.shortname');
if(mount_point.length){
params['tools-'+tools+'.mount_point']=mount_point.val();
params['tools-'+tools+'.ordinal']=i;
tools++;
}
if(shortname.length){
params['subs-'+subs+'.shortname']=shortname.val();
params['subs-'+subs+'.ordinal']=i;
subs++;
}
}
$.post('update_mount_order', params, function(){
location.reload();
});
});
$("#delete-confirm").dialog({
resizable: false,
height:200,
modal: true,
autoOpen: false,
buttons: {
'Delete': function() {
form_to_delete.submit();
$(this).dialog('close');
form_to_delete = null;
},
Cancel: function() {
$(this).dialog('close');
form_to_delete = null;
}
}
});
$('input.mount_delete').click(function() {
form_to_delete = this.parentNode;
$('#delete-confirm').dialog('open');
$('div.ui-dialog-buttonpane > button:last').focus();
return false;
});
/*]]>*/
{% endif %}
</script>
{% endblock %}