Commit c6518cb2 authored by alexeyomelchenko's avatar alexeyomelchenko Committed by Robert Lyon

Bug 1646229: Eliminate Mochikit from Admin Section: admin/users

behatnotneeded: same functionality

Change-Id: Ied3a5f105dbe0bee6db2c9773163a437c7dfad44
Signed-off-by: 's avataralexeyomelchenko <alexeyomelchenko@catalyst.net.nz>
parent 47913f5e
......@@ -112,44 +112,44 @@ function auth_config_submit(Pieform $form, $values) {
}
$js = <<<EOF
function authloginmsgVisibility() {
// If Parent authority is 'None'
if ($('auth_config_parent').value != 0) {
addElementClass('auth_config_authloginmsg_container', 'hidden');
}
else {
removeElementClass('auth_config_authloginmsg_container', 'hidden');
}
}
var ssoAllOptions = {
'updateuserinfoonlogin': 'theyssoin',
'weautocreateusers': 'theyssoin',
'theyautocreateusers': 'wessoout',
'weimportcontent': 'theyssoin'
};
function updateSsoOptions() {
var current = $('auth_config_ssodirection').value;
for (var opt in ssoAllOptions) {
if (ssoAllOptions[opt] == current) {
removeElementClass('auth_config_' + opt + '_container', 'hidden');
}
else {
addElementClass('auth_config_' + opt + '_container', 'hidden');
}
}
}
addLoadEvent(
function() {
if ($('auth_config_parent')) {
connect('auth_config_parent', 'onchange', authloginmsgVisibility);
authloginmsgVisibility();
}
if ($('auth_config_ssodirection')) {
connect('auth_config_ssodirection', 'onchange', updateSsoOptions);
updateSsoOptions();
}
}
);
jQuery(function($) {
function authloginmsgVisibility() {
// If Parent authority is 'None'
if ($('#auth_config_parent').val() != 0) {
$('#auth_config_authloginmsg_container').addClass('hidden');
}
else {
$('#auth_config_authloginmsg_container').removeClass('hidden');
}
}
var ssoAllOptions = {
'updateuserinfoonlogin': 'theyssoin',
'weautocreateusers': 'theyssoin',
'theyautocreateusers': 'wessoout',
'weimportcontent': 'theyssoin'
};
function updateSsoOptions() {
var current = $('#auth_config_ssodirection').val();
for (var opt in ssoAllOptions) {
if (ssoAllOptions[opt] == current) {
$('#auth_config_' + opt + '_container').removeClass('hidden');
}
else {
$('#auth_config_' + opt + '_container').addClass('hidden');
}
}
}
if ($('#auth_config_parent').length) {
$('#auth_config_parent').on('change', authloginmsgVisibility);
authloginmsgVisibility();
}
if ($('#auth_config_ssodirection').length) {
$('#auth_config_ssodirection').on('change', updateSsoOptions);
updateSsoOptions();
}
});
EOF;
$institution = get_record('institution', 'name', $institution);
......
......@@ -93,7 +93,7 @@ function adminusers_submit(Pieform $form, $values) {
$smarty->assign('institutionselector', $s['institutionselector']);
$smarty->assign('INLINEJAVASCRIPT', $s['institutionselectorjs'] . '
addLoadEvent(function() {
jQuery(function($) {
formchangemanager.add(\'adminusers\');
formchangemanager.unbindForm(\'adminusers\');
});');
......
......@@ -655,14 +655,14 @@ else {
$smarty->assign('searchform', $searchform);
$js = <<< EOF
addLoadEvent(function () {
p = {$data['pagination_js']}
connect('search_submit', 'onclick', function (event) {
replaceChildNodes('messages');
var params = {'query': $('search_query').value};
jQuery(function($) {
p = {$data['pagination_js']}
$('#search_submit').on('click', function(event) {
$('#messages').empty();
var params = {'query': $('#search_query').val()};
p.sendQuery(params);
event.stop();
});
event.preventDefault();
});
});
EOF;
......
......@@ -92,9 +92,9 @@ function staffusers_submit(Pieform $form, $values) {
$smarty->assign('institutionselector', $s['institutionselector']);
$smarty->assign('INLINEJAVASCRIPT', $s['institutionselectorjs'] . '
addLoadEvent(function() {
formchangemanager.add(\'staffusers\');
formchangemanager.unbindForm(\'staffusers\');
jQuery(function($) {
formchangemanager.add(\'staffusers\');
formchangemanager.unbindForm(\'staffusers\');
});');
$smarty->assign('staffusersform', pieform($form));
$smarty->display('admin/users/institutionstaff.tpl');
......@@ -277,24 +277,26 @@ function institutionusers_submit(Pieform $form, $values) {
$wwwroot = get_config('wwwroot');
$js = <<< EOF
function reloadUsers() {
var last = '';
if ($('usertypeselect_lastinstitution')) {
last = '&lastinstitution=' + $('usertypeselect_lastinstitution').value;
}
var inst = '';
if ($('institutionselect_institution')) {
inst = '&institution=' + $('institutionselect_institution').value;
jQuery(function($) {
function reloadUsers() {
var last = '';
if ($('#usertypeselect_lastinstitution').length) {
last = '&lastinstitution=' + $('#usertypeselect_lastinstitution').val();
}
var inst = '';
if ($('#institutionselect_institution').length) {
inst = '&institution=' + $('#institutionselect_institution').val();
}
window.location.href = '{$wwwroot}admin/users/institutionusers.php?usertype='+$('#usertypeselect_usertype').val()+last+inst;
}
window.location.href = '{$wwwroot}admin/users/institutionusers.php?usertype='+$('usertypeselect_usertype').value+last+inst;
}
addLoadEvent(function() {
connect($('usertypeselect_usertype'), 'onchange', reloadUsers);
if ($('usertypeselect_lastinstitution')) {
connect($('usertypeselect_lastinstitution'), 'onchange', reloadUsers);
// on load
$('#usertypeselect_usertype').on('change', reloadUsers);
if ($('#usertypeselect_lastinstitution').length) {
$('#usertypeselect_lastinstitution').on('change', reloadUsers);
}
if ($('institutionselect_institution')) {
connect($('institutionselect_institution'), 'onchange', reloadUsers);
if ($('#institutionselect_institution').length) {
$('#institutionselect_institution').on('change', reloadUsers);
}
formchangemanager.add('institutionusers');
// Unbind the handler for standard pieform input
......
......@@ -66,11 +66,12 @@ $data = build_pending_html($pending, $institution);
$wwwroot = get_config('wwwroot');
$js = <<< EOF
function reloadUsers() {
window.location.href = '{$wwwroot}admin/users/pendingregistrations.php?institution='+$('usertypeselect_institution').value;
}
addLoadEvent(function() {
connect($('usertypeselect_institution'), 'onchange', reloadUsers);
jQuery(function($) {
function reloadUsers() {
window.location.href = '{$wwwroot}admin/users/pendingregistrations.php?institution='+$('#usertypeselect_institution').val();
}
$('#usertypeselect_institution').on('change', reloadUsers);
});
EOF;
......
......@@ -225,11 +225,12 @@ function progressbarform_submit(Pieform $form, $values) {
$wwwroot = get_config('wwwroot');
$js = <<< EOF
function reloadBar() {
window.location.href = '{$wwwroot}admin/users/progressbar.php?institution='+$('progressbarselect_institution').value;
}
addLoadEvent(function() {
connect($('progressbarselect_institution'), 'onchange', reloadBar);
jQuery(function($) {
function reloadBar() {
window.location.href = '{$wwwroot}admin/users/progressbar.php?institution='+$('#progressbarselect_institution').val();
}
$('#progressbarselect_institution').on('change', reloadBar);
});
EOF;
......
......@@ -84,11 +84,11 @@ $searchParams = $search; //store search as it's about to change
list($html, $columns, $pagination, $search) = build_admin_user_search_results($search, $offset, $limit);
$js = <<<EOF
addLoadEvent(function() {
jQuery(function($) {
var p = {$pagination['javascript']}
new UserSearch(p);
})
});
EOF;
$smarty = smarty(array('adminusersearch', 'paginator'), array(), array('ascending' => 'mahara', 'descending' => 'mahara'));
......
......@@ -89,14 +89,14 @@ default:
$wwwroot = get_config('wwwroot');
$js = <<< EOF
addLoadEvent(function () {
jQuery(function ($) {
{$data['table']['pagination_js']}
});
function reloadStats() {
window.location.href = '{$wwwroot}admin/users/statistics.php?institution='+$('usertypeselect_institution').value+'&type={$type}';
}
addLoadEvent(function() {
connect($('usertypeselect_institution'), 'onchange', reloadStats);
function reloadStats() {
window.location.href = '{$wwwroot}admin/users/statistics.php?institution='+$('#usertypeselect_institution').val() +'&type={$type}';
}
$('#usertypeselect_institution').on('change', reloadStats);
});
EOF;
......
......@@ -119,9 +119,9 @@ $smarty->assign('data', $data);
$smarty->assign('INLINEJAVASCRIPT', <<<EOF
addLoadEvent(function () {
jQuery(function ($) {
p = {$pagination['javascript']}
connect('usertype_type', 'onchange', function (event) {
$('#usertype_type').on('change', function (event) {
var params = {
'limit': $limit,
'offset': 0,
......@@ -130,34 +130,34 @@ addLoadEvent(function () {
'type': $('usertype_type').value,
};
p.sendQuery(params);
event.stop();
event.preventDefault();
// Show the buttons relating to the 'type' selected
show_buttons(params.type);
});
function show_buttons(type) {
if (type == 'suspended') {
jQuery('#buttons_unsuspend').show();
jQuery('#buttons_unexpire').hide();
$('#buttons_unsuspend').show();
$('#buttons_unexpire').hide();
}
else if (type == 'expired') {
jQuery('#buttons_unsuspend').hide();
jQuery('#buttons_unexpire').show();
$('#buttons_unsuspend').hide();
$('#buttons_unexpire').show();
}
}
show_buttons('$type');
});
jQuery(window).on('pageupdated', {}, function(e, data) {
// For when we are switching between suspended and expired
var tmp = jQuery('<div>').append(data.data.pagination);
var paginationid = tmp.find('.pagination-wrapper').attr('id');
if (paginationid !== jQuery('.pagination-wrapper').attr('id')) {
jQuery('.pagination-wrapper').replaceWith(data.data.pagination);
p = eval(data.data.pagination_js);
}
});
$(window).on('pageupdated', {}, function(e, data) {
// For when we are switching between suspended and expired
var tmp = $('<div>').append(data.data.pagination);
var paginationid = tmp.find('.pagination-wrapper').attr('id');
if (paginationid !== $('.pagination-wrapper').attr('id')) {
$('.pagination-wrapper').replaceWith(data.data.pagination);
p = eval(data.data.pagination_js);
}
});
show_buttons('$type');
});
EOF
);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment