Fixes in scripts edit
This commit is contained in:
parent
6220d8a4f0
commit
fbab7917ef
3 changed files with 44 additions and 14 deletions
|
|
@ -676,15 +676,50 @@ def pastafari2_change_order_scripts():
|
|||
|
||||
arr_server=server.select_a_row(server_id)
|
||||
|
||||
update_server.set_conditions('WHERE server_id=%s', [server_id])
|
||||
update_server.set_conditions('WHERE server_id=%s', [server_id]).set_order({'position': 0})
|
||||
|
||||
arr_update_server=update_server.select_to_array()
|
||||
|
||||
return t.load_template('change_order_scripts.phtml', title=I18n.lang('pastafari2', 'edit_update', 'Edit update'), path_module='admin_app.pastafari2_change_order_scripts', server_data=arr_server, scripts=arr_update_server)
|
||||
|
||||
"""
|
||||
def field_position(url, row_id, arr_row):
|
||||
@admin_app.route('/pastafari2/save_positions' , methods=['POST'])
|
||||
def pastafari2_save_positions():
|
||||
|
||||
return '<input type="number" name="position_'+row_id+'" value="'+arr_row['position']+'"/>'
|
||||
db=g.connection
|
||||
|
||||
"""
|
||||
error=0
|
||||
|
||||
error_form={}
|
||||
|
||||
txt_error=''
|
||||
|
||||
text=''
|
||||
|
||||
server_id=request.args.get('server_id', '0').strip()
|
||||
|
||||
server=ServerDbTask(db)
|
||||
|
||||
update_server=UpdateServerScripts(db)
|
||||
|
||||
update_server.create_forms()
|
||||
|
||||
update_server.safe_query()
|
||||
|
||||
arr_server=server.set_conditions('WHERE id=%s', [server_id]).select_a_row_where([], True)
|
||||
|
||||
if arr_server:
|
||||
|
||||
order_id=json.loads(request.form.get('order_id', '{}'))
|
||||
|
||||
#print(order_id)
|
||||
position=0
|
||||
|
||||
for item_id in order_id:
|
||||
|
||||
update_server.set_conditions('WHERE server_id=%s AND id=%s', [server_id, item_id]).update({'position': position})
|
||||
position+=1
|
||||
|
||||
pass
|
||||
|
||||
return {'error': error, 'form': error_form, 'txt_error': txt_error}
|
||||
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
<div id="scripts_list" class="form">
|
||||
% for script in scripts:
|
||||
|
||||
<p><label>${script['name']}</label>: <span class="position" id="position_${script['id']}">${script['position']}</span></p>
|
||||
<p>${script['name']}<input type="hidden" class="position" id="position_${script['id']}" value="${script['position']}"></p>
|
||||
|
||||
% endfor
|
||||
</div>
|
||||
|
|
@ -29,7 +29,7 @@ $('#change_order').click(function () {
|
|||
|
||||
$('.position').each(function () {
|
||||
|
||||
var item_id=$(this).attr('id').replace('postion_', '');
|
||||
var item_id=$(this).attr('id').replace('position_', '');
|
||||
|
||||
order_id.push(item_id);
|
||||
|
||||
|
|
@ -37,7 +37,7 @@ $('#change_order').click(function () {
|
|||
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url:"",
|
||||
url:"${url_for('admin_app.pastafari2_save_positions', server_id=server_data['id'])}",
|
||||
data: {order_id: JSON.stringify(order_id)},
|
||||
success: function (data) {
|
||||
|
||||
|
|
@ -46,7 +46,7 @@ $('#change_order').click(function () {
|
|||
if(!data.error) {
|
||||
|
||||
|
||||
|
||||
alert("${lang('pastafari2', 'positions_updated', 'Positions updated')}");
|
||||
|
||||
}
|
||||
else {
|
||||
|
|
|
|||
|
|
@ -10,11 +10,6 @@ ${edit_update|n}
|
|||
<%block name="jscript_block">
|
||||
<script type="text/javascript" src="${make_media_url('js/Sortable.min.js', 'pastafari2')}"></script>
|
||||
<script>
|
||||
sortable_list=document.getElementById('updateserverscripts_table_rows');
|
||||
|
||||
sortable_var=new Sortable(sortable_list, {
|
||||
animation: 150,
|
||||
/*ghostClass: 'blue-background-class'*/
|
||||
});
|
||||
</script>
|
||||
</%block>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue