Revision 30dd9e0e snf-astakos-app/astakos/im/static/im/js/quotas.js

b/snf-astakos-app/astakos/im/static/im/js/quotas.js
35 35
	$('.quotas-form ul li a').click(function(e){
36 36
		
37 37
		// check the hidden input field
38
		$(this).siblings('input[type="hidden"]').attr('checked','checked');
38
		$(this).siblings('input[type="hidden"]').val("1");
39 39
		
40 40
		// get the hidden input field without the proxy
41 41
		// and check the python form field
42 42
	 	hidden_name = $(this).siblings('input[type="hidden"]').attr('name').replace("proxy_","");
43
	 	$("input[name='"+hidden_name+"']").attr('checked','checked');  
43
	 	$("input[name='"+hidden_name+"']").val("1");  
44 44
		
45 45
 		// prevent extra actions if it is checked		 
46 46
		if ( $(this).hasClass('selected')){
......
78 78
		$('.quotas-form ul li a').each(function() {
79 79
			if($(this).attr('id')==group_class) {
80 80
				$(this).removeClass('selected');
81
				$(this).siblings('input[type="hidden"]').removeAttr('checked');
81
				$(this).siblings('input[type="hidden"]').val('0');
82 82
				
83 83
				// get the hidden input field without the proxy
84 84
				// and check the python form field
85 85
			 	hidden_name = $(this).siblings('input[type="hidden"]').attr('name').replace("proxy_","");
86
			 	$("input[name='"+hidden_name+"']").removeAttr('checked');  
86
			 	$("input[name='"+hidden_name+"']").val('0');  
87 87
				
88 88
			}
89 89
		}); 
......
226 226
	
227 227
	// if hidden checkboxes are checked, the right group is selected 
228 228
	$('.with-info input[name^="is_selected_"]').each(function() {
229
		if ($(this).attr('checked')){
229
		if ( ($(this).val()) == 1 ){
230 230
			
231 231
			// get hidden input name
232 232
			hidden_name = $(this).attr('name');
233
			$("input[name='proxy_"+hidden_name+"']").attr('checked','checked'); 
233
			$("input[name='proxy_"+hidden_name+"']").val("1"); 
234 234
			
235 235
			// pretend to check the ul li a
236 236
			// show the relevant fieldsets
......
241 241
	}); 
242 242
	
243 243
	
244
	
244
	/*
245 245
	// if input_uplimit fields are filled,
246 246
	// fill the _uplimit_proxy ones
247 247
	 
......
297 297
			
298 298
			 
299 299
		}
300
	}); 
300
	});*/
301
	// if input_uplimit fields are filled,
302
	// fill the _uplimit_proxy ones
303
	 
304
	$('.group input[name$="_uplimit_proxy"]').each(function() {
305
		if ($(this).val()){
306
			
307
			// get value from input
308
	 		var value = $(this).val();
309
			
310
			
311
			// get hidden input name
312
			hidden_name = $(this).attr('name');
313
			hidden_field_name = hidden_name.replace("_proxy","");
314
			$("input[name='"+hidden_field_name+"']").val(value);
315
			var field = $(this); 
316
			
317
			
318
			if ( (field.hasClass('dehumanize')) && !($(this).parents('.form-row').hasClass('with-errors'))) {
319
				// for dehumanize fields transform bytes to KB, MB, etc
320
				// unless there is an error
321
				field.val(bytesToSize2(value))
322
			} else {
323
				// else just return the value
324
				field.val(value);	
325
			}
326
			
327
			var group_class = field.parents('div[class^="group"]').attr('class').replace('group ', '');
328
			
329
			 
330
			 
331
			
332
			// select group icon
333
			$('.quotas-form ul li a').each(function() {
334
				
335
				if($(this).attr('id') == group_class) {
336
					$(this).addClass('selected');
337
					$(this).siblings('input[type="hidden"]').val("1");
338
					
339
					// get the hidden input field without the proxy
340
					// and check the python form field
341
				 	hidden_name = $(this).siblings('input[type="hidden"]').attr('name').replace("proxy_","");
342
				 	$("input[name='"+hidden_name+"']").val("1");  
343
				 	
344
				 	group_form_show_resources($(this));
345
					
346
				}
347
			}); 
348
			
349
		
350
			
351
			// if the field has class error, transfer error to the proxy fields
352
			if ( $(this).parents('.form-row').hasClass('with-errors') ) {
353
				field.parents('.form-row').addClass('with-errors');
354
			}
355
			
356
			 
357
		}
358
	});  
301 359
	
302 360
});

Also available in: Unified diff