Revision 2934e509 snf-astakos-app/astakos/im/static/im/js/quotas.js
b/snf-astakos-app/astakos/im/static/im/js/quotas.js | ||
---|---|---|
97 | 97 |
|
98 | 98 |
|
99 | 99 |
}); |
100 |
|
|
100 | 101 |
|
101 | 102 |
// if you fill _proxy fields do stuff |
102 | 103 |
$('.quotas-form .quota input[type="text"]').change(function () { |
... | ... | |
107 | 108 |
|
108 | 109 |
// get value from input |
109 | 110 |
var value = $(this).val(); |
110 |
|
|
111 |
|
|
111 | 112 |
//get input name without _proxy |
112 | 113 |
hidden_name = $(this).attr('name').replace("_proxy",""); |
113 | 114 |
var hidden_input = $("input[name='"+hidden_name+"']"); |
114 | 115 |
|
115 | 116 |
if (value) { |
117 |
|
|
116 | 118 |
// actions for humanize fields |
117 | 119 |
if ($(this).hasClass('dehumanize')){ |
118 | 120 |
|
... | ... | |
171 | 173 |
} |
172 | 174 |
|
173 | 175 |
} |
174 |
} |
|
175 |
|
|
176 |
|
|
177 |
|
|
178 |
} |
|
179 |
|
|
180 |
|
|
181 |
|
|
176 |
} |
|
177 |
} |
|
182 | 178 |
|
183 | 179 |
if ( flag == '1' ){ |
184 | 180 |
$(this).parents('.form-row').addClass('with-errors'); |
... | ... | |
219 | 215 |
} |
220 | 216 |
|
221 | 217 |
} else { |
218 |
; $(this).parents('.with-errors').removeClass('with-errors') |
|
222 | 219 |
hidden_input.removeAttr('value'); |
223 | 220 |
} |
224 | 221 |
$('#icons span.info').removeClass('error-msg'); |
... | ... | |
242 | 239 |
} |
243 | 240 |
}); |
244 | 241 |
|
245 |
|
|
246 |
/* |
|
247 |
// if input_uplimit fields are filled, |
|
248 |
// fill the _uplimit_proxy ones |
|
249 |
|
|
250 |
$('.with-info input[name$="_uplimit"]').each(function() { |
|
251 |
if ($(this).val()){ |
|
252 |
|
|
253 |
// get value from input |
|
254 |
var value = $(this).val(); |
|
255 |
|
|
256 |
|
|
257 |
// get hidden input name |
|
258 |
hidden_name = $(this).attr('name'); |
|
259 |
var field = $("input[name='"+hidden_name+"_proxy']"); |
|
260 |
|
|
261 |
|
|
262 |
if ( (field.hasClass('dehumanize')) && !($(this).parents('.form-row').hasClass('with-errors'))) { |
|
263 |
// for dehumanize fields transform bytes to KB, MB, etc |
|
264 |
// unless there is an error |
|
265 |
field.val(bytesToSize2(value)) |
|
266 |
} else { |
|
267 |
// else just return the value |
|
268 |
field.val(value); |
|
269 |
} |
|
270 |
|
|
271 |
var group_class = field.parents('div[class^="group"]').attr('class').replace('group ', ''); |
|
272 |
|
|
273 |
|
|
274 |
|
|
275 |
|
|
276 |
// select group icon |
|
277 |
$('.quotas-form ul li a').each(function() { |
|
278 |
|
|
279 |
if($(this).attr('id') == group_class) { |
|
280 |
$(this).addClass('selected'); |
|
281 |
$(this).siblings('input[type="hidden"]').attr('checked', 'checked'); |
|
282 |
|
|
283 |
// get the hidden input field without the proxy |
|
284 |
// and check the python form field |
|
285 |
hidden_name = $(this).siblings('input[type="hidden"]').attr('name').replace("proxy_",""); |
|
286 |
$("input[name='"+hidden_name+"']").attr('checked', 'checked'); |
|
287 |
|
|
288 |
group_form_show_resources($(this)); |
|
289 |
|
|
290 |
} |
|
291 |
}); |
|
292 |
|
|
293 |
|
|
294 |
|
|
295 |
// if the field has class error, transfer error to the proxy fields |
|
296 |
if ( $(this).parents('.form-row').hasClass('with-errors') ) { |
|
297 |
field.parents('.form-row').addClass('with-errors'); |
|
298 |
} |
|
299 |
|
|
300 |
|
|
301 |
} |
|
302 |
});*/ |
|
303 |
// if input_uplimit fields are filled, |
|
304 |
// fill the _uplimit_proxy ones |
|
242 |
|
|
305 | 243 |
|
306 | 244 |
$('.group input[name$="_uplimit_proxy"]').each(function() { |
307 | 245 |
if ($(this).val()){ |
... | ... | |
359 | 297 |
} |
360 | 298 |
}); |
361 | 299 |
|
362 |
// todo den doulevei |
|
300 |
function goToByScroll(id){ |
|
301 |
$('html,body').animate({scrollTop: $("#"+id).offset().top},'slow'); |
|
302 |
} |
|
303 |
|
|
304 |
|
|
363 | 305 |
$('#group_create_form').submit(function(){ |
364 |
if ($('.quotas-form .group .form-row.with-errors').length>0 ){ |
|
365 |
return false; |
|
366 |
} |
|
367 |
var flag = 0; |
|
306 |
|
|
307 |
var flag = 0; |
|
368 | 308 |
$('.quotas-form .group input[type="text"]').each(function() { |
369 |
// get value from input |
|
370 | 309 |
var value = $(this).val(); |
371 | 310 |
if (value){ |
372 |
flag =1; |
|
311 |
flag = 1;
|
|
373 | 312 |
} |
374 | 313 |
}); |
314 |
|
|
315 |
console.info(flag); |
|
316 |
|
|
375 | 317 |
if (flag =='0') { |
318 |
$('#icons').focus(); |
|
376 | 319 |
$('#icons span.info').addClass('error-msg'); |
377 | 320 |
$('#icons span.info').find('span').html('You must fill in at least one resource'); |
321 |
goToByScroll("icons"); |
|
322 |
|
|
378 | 323 |
return false; |
379 | 324 |
|
380 | 325 |
} |
326 |
if ($('.quotas-form .group .form-row.with-errors').length>0 ){ |
|
327 |
$('.quotas-form .group .form-row.with-errors input[type="text"]')[0].focus(); |
|
328 |
return false; |
|
329 |
|
|
330 |
} |
|
331 |
|
|
332 |
|
|
333 |
|
|
381 | 334 |
}); |
382 | 335 |
|
383 | 336 |
|
Also available in: Unified diff