Commit 2c79d608 authored by Robert Lyon's avatar Robert Lyon Committed by Aaron Wells
Browse files

Bug 1393536: More tidying up



Including:
- making add connection form cancel back to connections page
with correct institution selected
- Adding a help icon/page (needs content) for add connections
- Display tick/cross next to connection name to see if it is enabled
- Have the 'enable connection manager' master switch bunched with the
others
- Changing some strings to make thing clearer

behatnotneeded

Change-Id: I875ad6ec745cd136338017e27ef49542157cac7c
Signed-off-by: default avatarRobert Lyon <robertl@catalyst.net.nz>
parent 104d14fd
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -53,8 +53,9 @@ $string['usernameinvalidadminform'] = 'Usernames may contain letters, numbers an
$string['youmaynotregisterwithouttandc'] = 'You may not register unless you agree to abide by the <a href="terms.php">Terms and Conditions</a>.';


$string['pluginconnections'] = 'Plugin connection objects';
$string['pcdescription'] = 'Create connections connected to the Connection Objects of registered plugins.';
$string['pluginconnections'] = 'Connection objects';
$string['pcdescription'] = 'Select a connection';
$string['instancelistempty'] = 'No connection objects for this institution.';

$string['addconnection'] = 'Add Client Connection';
$string['editconnection'] = 'Edit Client Connection';
+4 −0
Original line number Diff line number Diff line
<!-- @license http://www.gnu.org/copyleft/gpl.html GNU GPL version 3 or later -->
<!-- @copyright For copyright information on Mahara, please see the README file distributed with this software. -->
<h3>Connection manager</h3>
<p>Connections are designed to allow ...[more text to come]</p>
+6 −2
Original line number Diff line number Diff line
@@ -2060,11 +2060,16 @@ abstract class Plugin implements IPlugin {
    public static function get_webservice_connections($user=null) {
        global $USER;

        // are web service connections enabled?
        // is the web service connection switch enabled?
        if (!get_config('webservice_connections_enabled')) {
            log_debug('get_webservice_connections: disabled');
            return array();
        }
        // do we have any defined connections enabled?
        if (!get_records_array('client_connections_institution', 'enable', 1, '', 'id', 0, 1)) {
            log_debug('get_webservice_connections: no active connections');
            return array();
        }

        require_once(get_config('docroot') . 'webservice/lib.php');

@@ -2182,7 +2187,6 @@ abstract class Plugin implements IPlugin {
                $connections[]= $client;
            }
        }

        return $connections;
    }

+50 −51
Original line number Diff line number Diff line
@@ -37,34 +37,44 @@
        return false;
    }

    function rebuildInstanceList(outputArray) {
        var displayArray = new Array();
        var instanceListDiv = document.getElementById('instanceList');

        // Take each auth instance div, remove its span tag (containing arrow links) and clone it
        // adding the clone to the displayArray list
        for (i = 0; i < outputArray.length; i++) {
            var myDiv =  document.getElementById('instanceDiv' + outputArray[i]);
            replaceChildNodes(getFirstElementByTagAndClassName('span', 'authIcons', 'instanceDiv' + outputArray[i]));
            displayArray.push(myDiv.cloneNode(true));
    function buttonOptions (id, length, i) {
        // Make the buttons a row should have
        var buttons = '';        
        if (length > 1) {
            if (i + 1 != length) {
                buttons += '<a class="btn btn-link text-midtone" href="" onclick="move_down(' + id + '); return false;"><span class="icon icon-long-arrow-down" role="presentation" aria-hidden="true"></span><span class="sr-only">' + get_string('moveitemdown') + '</span></a>'
            }
            else {
                buttons += '<span class="emptybtnspace"></span>';
            }

        emptyThisNode(instanceListDiv);
            if (i != 0) {
                buttons += '<a class="btn btn-link text-midtone" href="" onclick="move_up(' + id + '); return false;"><span class="icon icon-long-arrow-up" role="presentation" aria-hidden="true"></span><span class="sr-only">' + get_string('moveitemup') + '</span></a>';
            }
            else {

        for(i = 0; i < displayArray.length; i++) {
            if(displayArray.length > 1) {
                if (i + 1 != displayArray.length) {
                    getFirstElementByTagAndClassName('span', 'authIcons', displayArray[i]).innerHTML += '<a class="btn btn-link text-midtone" href="" onclick="move_down('+outputArray[i]+'); return false;"><span class="icon icon-long-arrow-down" role="presentation" aria-hidden="true"></span><span class="sr-only">'+get_string('moveitemdown')+'</span></a>'+"\n";
                buttons += '<span class="emptybtnspace"></span>';
            }
                if(i != 0) {
                    getFirstElementByTagAndClassName('span', 'authIcons', displayArray[i]).innerHTML += '<a class="btn btn-link text-midtone" href="" onclick="move_up('+outputArray[i]+'); return false;"><span class="icon icon-long-arrow-up" role="presentation" aria-hidden="true"></span><span class="sr-only">'+get_string('moveitemup')+'</span></a>'+"\n";
        }
        buttons += '<a class="btn btn-default btn-sm" href="" onclick="removeConnection(' + id + '); return false;"><span class="icon icon-trash icon-lg text-danger" role="presentation" aria-hidden="true"></span><span class="sr-only">' + get_string('deleteitem') + '</span></a>' + "\n";
        return buttons;
    }

            getFirstElementByTagAndClassName('span', 'authIcons', displayArray[i]).innerHTML += '<a class="btn btn-default btn-sm" href="" onclick="removeConnection('+outputArray[i]+'); return false;"><span class="icon icon-trash icon-lg text-danger" role="presentation" aria-hidden="true"></span><span class="sr-only">'+get_string('deleteitem')+'</span></a>'+"\n";
    function rebuildInstanceList(outputArray) {
        var displayArray = new Array();
        var instanceList = jQuery('.authInstance');

            instanceListDiv.appendChild(displayArray[i]);
        // Take each connection row, remove its icons and add back new ones
        for (i = 0; i < outputArray.length; i++) {
            var row = jQuery('#instanceDiv' + outputArray[i]);
            row.data('order', i);
            row.find('.authIcons').html(buttonOptions(outputArray[i], outputArray.length, i));
        }
        // Now re-sort the rows
        instanceList.sort(function(a, b) {
            return jQuery(a).data('order') - jQuery(b).data('order');
        });
        jQuery("#instanceList").html(instanceList);
        document.getElementById('instancePriority').value = outputArray.join(',');
    }

@@ -94,12 +104,6 @@
        return false;
    }

    function emptyThisNode(node) {
        while(node.hasChildNodes()) {
            node.removeChild(node.childNodes[0]);
        }
    }

    function addinstance() {
        var selectedPlugin = document.getElementById('dummySelect').value;
        var institution = '{{$institution}}';
@@ -112,35 +116,22 @@
        return;
    }

    function addConnection(id, name, connectionname) {
        var newDiv = '<div class="authInstance" id="instanceDiv'+id+'"> '+
            '<label class="authLabel"><a href="" onclick="editinstance('+id+',\''+connectionname+'\'); return false;">'+name+'</a></label> '+
            '<span class="authIcons" id="arrows'+id+'"></span> </div>';
        document.getElementById('instanceList').innerHTML += newDiv;
        if(document.getElementById('instancePriority').value.length) {
            instanceArray = document.getElementById('instancePriority').value.split(',');
        } else {
            instanceArray = new Array();
        }
        instanceArray.push(id);
        rebuildInstanceList(instanceArray);
        if (typeof formchangemanager !== 'undefined') {
            var form = jQuery('div#instanceList').closest('form')[0];
            formchangemanager.setFormState(form, FORM_CHANGED);
        }
        replaceChildNodes('messages');
    }

</script>
{{*

IMPORTANT: do not introduce any new whitespace into the instanceList div.

*}}
{{if $instancelist}}
<div id="instanceList">
    {{foreach $instancelist instance}}
    <div class="authInstance" id="instanceDiv{{$instance->id}}">
    <div class="authInstance" id="instanceDiv{{$instance->id}}" data-order="1">
        <label class="authLabel">
            {{if $instance->enable}}
                <span class="icon icon-lg icon-check text-success" title="{{str tag='enabled'}}"></span>
            {{else}}
                <span class="icon icon-lg icon-times text-danger" title="{{str tag='disabled'}}"></span>
            {{/if}}
            <a href="" onclick="editinstance({{$instance->id}},'{{$instance->name}}'); return false;">
            {{$instance->name}}</a>
        </label>
@@ -150,12 +141,16 @@ IMPORTANT: do not introduce any new whitespace into the instanceList div.
                <span class="icon icon-long-arrow-down" role="presentation" aria-hidden="true"></span>
                <span class="sr-only">{{str tag=moveitemdown}}</span>
            </a>
            {{else}}
                <span class="emptybtnspace"></span>
            {{/if}}
            {{if $instance->index != 0 }}
            <a class="btn btn-link text-midtone" href="" onclick="move_up({{$instance->id}}); return false;">
                <span class="icon icon-long-arrow-up" role="presentation" aria-hidden="true"></span>
                <span class="sr-only">{{str tag=moveitemup}}</span>
            </a>
            {{else}}
                <span class="emptybtnspace"></span>
            {{/if}}
            <a href="" class="btn btn-default btn-sm" onclick="removeConnection({{$instance->id}}); return false;">
                <span class="icon icon-trash icon-lg text-danger" role="presentation" aria-hidden="true"></span>
@@ -165,6 +160,10 @@ IMPORTANT: do not introduce any new whitespace into the instanceList div.
    </div>
    {{/foreach}}
</div>
{{else}}
<div>{{str tag='instancelistempty' section='auth.webservice'}}</div>
{{/if}}
<div class="postlist">{{str tag='pcdescription' section='auth.webservice'}}</div>
<div class="select connections">
    <span class="picker">
        <select class="select form-control" name="dummy" id="dummySelect">
+5 −0
Original line number Diff line number Diff line
@@ -441,3 +441,8 @@
.connections button {
    margin-top: 10px;
}

.emptybtnspace {
    display: inline-block;
    width: 30px;
}
Loading