<%= navigation %>
<%= render 'show_graph' %> <% javascript_tag do %> function suggest_changes (refresh) { var opened_groups = $$("#suggest-result>ul>li.secondary").select(function (li) {return li.visible()}).collect(function (li) { return li.classNames().toArray()[1].split("-")[1]; }).uniq(); if (refresh) $("spinner").show(); else $("suggest-result").innerHTML = "Searching..."; $("suggest-result").show(); new Ajax.Updater({success: 'suggest-result'}, '<%= suggest_change_authorization_rules_path %>', { method: 'get', onFailure: function(request) { $("suggest-result").innerHTML = "Error while searching." }, onComplete: function () { $("spinner").hide(); opened_groups.each(function (group_no) { show_group_approaches(group_no); }); }, parameters: $H($('change').down('form').serialize(true)).merge(refresh ? {show_all: "true"} : {}).toQueryString() }); if (!refresh) location.hash = 'suggest-result'; } function show_suggest_graph (changes, filter_roles_params, filter_context, user_ids) { var params = {changes: changes, highlight_privilege: $F('privilege'), stacked_roles: '1'}; if (filter_context) params['filter_contexts'] = filter_context; if (user_ids) params['user_ids[]'] = user_ids; show_graph_with_params('suggest-graph', params); } document.observe('dom:loaded', function() { install_change_observers(); }); function install_change_observers () { $$('#change select').each(function (el) { el.observe('change', function (event) { var form = $('change').down('form'); new Ajax.Updater({success: 'change'}, '<%= url_for %>', { parameters: Form.serializeElements(form.select('select').concat(form.getInputs('radio', 'affected_users')), true), method: 'get', onComplete: function () { install_change_observers(); if ($('graph-container').visible()) show_current_permissions(); } }); }); }); $('prohibited_actions').observe('click', function (event) { var target = event.findElement(); if (target.hasClassName('remove')) { target.up().remove(); if ($('prohibited_actions').childElements().length == 0) $('prohibited_actions').previous().hide(); suggest_changes(); } }); } function show_current_permissions () { show_graph($F('privilege'), $F('context')/*, relevant_user_ids()*/); } function show_all_groups () { $$('#suggest-result>ul>li.primary').invoke("show"); } function show_group_approaches (group_no) { $$('#suggest-result>ul>li.secondary.group-' + group_no).invoke("show"); $$('#suggest-result>ul>li.primary.group-' + group_no + ' a.show-others-in-group').invoke("hide"); } function hide_group_approaches (group_no) { $$('#suggest-result>ul>li.secondary.group-' + group_no).invoke("hide"); $$('#suggest-result>ul>li.primary.group-' + group_no + ' a.show-others-in-group').invoke("show"); } function relevant_user_ids () { return $$('#change .user_id').collect(function (el) { return el.innerHTML; }).reject(function (id) { return $('user_' + id + '_permission_undetermined').checked; }); } var prohibited_action_template = new Template('