Commit 51e144f0 authored by Kevin Dibble's avatar Kevin Dibble Committed by Robert Lyon
Browse files

bug 1528118 : preview collections in export section

This outputs a link to the
first page in a collection
when viewing export previews.

Also removed old Mochkit function
MochiKit.Base.partial

behatnotneeded

Change-Id: I429f70fba7db4d290280a85e222a3ac1ddb328e4
parent b948e2c0
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -45,7 +45,7 @@ $shownav = $collection->get('navigation');
if ($shownav) {
    if ($views = $collection->get('views')) {
        if (count($views['views']) > 1) {
            $smarty->assign('collection', array_chunk($views['views'], 5));
            $smarty->assign('collection', $views['views']);
        }
    }
}
+8 −4
Original line number Diff line number Diff line
@@ -74,23 +74,27 @@ if ($viewids = get_column_sql('SELECT id FROM {view} WHERE owner = ? AND type =
        'js/lodash/lodash.js',
        'js/gridstack/gridstack.js',
        'js/gridlayout.js',
        'js/collection-navigation.js',
    );

    $collections = get_records_sql_array('
        SELECT c.id, c.name, c.description
        FROM {collection} c JOIN {collection_view} cv ON c.id = cv.collection
        SELECT c.id, c.name, c.description, cv.view
        FROM {collection} c
        JOIN {collection_view} cv ON c.id = cv.collection
        WHERE c.owner = ?
        GROUP BY c.id, c.name, c.description
        HAVING COUNT(cv.view) > 0',
        AND cv.view IS NOT NULL
        AND cv.displayorder = 0',
        array($USER->get('id'))
    );
    if ($collections) {
        $elements['what']['options']['collections'] = get_string('justsomecollections', 'export');
        foreach ($collections as $collection) {
            $view = new View($collection->view);
            $elements['collection_' . $collection->id] = array(
                'type' => 'checkbox',
                'class' => 'checkbox',
                'title' => $collection->name,
                'viewlink' => $view ? $view->get_url(true, true) : '',
                'description' => $collection->description,
            );
        }
+49 −43
Original line number Diff line number Diff line
@@ -9,14 +9,10 @@
 * @copyright  For copyright information on Mahara, please see the README file distributed with this software.
 *
 */

jQuery(function($) {
"use strict";

// this feature relies on a custom dropdown element which is initialised in style.js

// initialise previous and next buttons
    (function() {
function collection_nav_init(preview=false) {
    var currentIndex = $('#currentindex').data('currentindex');
    var indexLength = $('.custom-dropdown > ul').children().length;

@@ -24,21 +20,27 @@ jQuery(function($) {
        $('.custom-dropdown > ul').children().each(function() {
            var elem = $($(this).children()[0]);
            if (elem.data('index') === target && elem.data('location')) {
                if (preview) {
                    elem.trigger('click');
                }
                else {
                    document.location.href = elem.data('location');
                }
            }
        });
    }

    // setup prev
    if (currentIndex !== 0) {
        $('.prevpage').removeClass('disabled');

        $('.prevpage').off("click");
        $('.prevpage').on("click", function() {
            var target = currentIndex - 1;
            findLink(target);
        });
        if (isTouchDevice()) {
            // setup swipe prev
            $('#header-content').off('swiperight');
            $('#header-content').on('swiperight', function() {
                var target = currentIndex - 1;
                findLink(target);
@@ -49,23 +51,27 @@ jQuery(function($) {
    // setup next
    if (currentIndex !== (indexLength - 1)) {
        $('.nextpage').removeClass('disabled');

        $('.nextpage').off("click");
        $('.nextpage').on("click", function() {
            var target = currentIndex + 1;
            findLink(target);
        });
        if (isTouchDevice()) {
            // setup swipe next
            $('#header-content').off('swipeleft');
            $('#header-content').on('swipeleft', function() {
                var target = currentIndex + 1;
                findLink(target);
            });
        }
    }

    }());
}

function isTouchDevice() {
    return 'ontouchstart' in document.documentElement;
}

jQuery(function($) {
"use strict";
    collection_nav_init();
});
+4 −2
Original line number Diff line number Diff line
@@ -5,13 +5,14 @@ function export_form_cell_html($element) {
    $strclicktopreview = get_string('clicktopreview', 'export');
    $strpreview = get_string('Preview');
    $element['description'] = clean_html($element['description']);
    $showlink = trim($element['viewlink']) != '' ? '' : 'd-none';
return <<<EOF
<div class="checkbox">
    {$element['html']}
    {$element['labelhtml']}
    <div class="text-small text-midtone with-label">
        {$element['description']}
        <a href="{$element['viewlink']}" class="viewlink text-small nojs-hidden-inline">{$strclicktopreview}</a>
        <a href="{$element['viewlink']}" class="{$showlink} viewlink text-small nojs-hidden-inline">{$strclicktopreview}</a>
    </div>
</div>
EOF;
@@ -71,7 +72,8 @@ $row = $col = 0;
$itemsinrow = 3;
foreach ($elements as $key => $element) {
    if (substr($key, 0, 11) == 'collection_') {
        $body[$row][$col] = '<div class="checkbox">' . $element['html'] . $element['labelhtml'] . '<p class="with-label text-small text-midtone labeldescriptpreview">' . hsc($element['description']) . '</p></div>';
        $element['description'] = '<p class="text-small text-midtone labeldescriptpreview">' . hsc($element['description']) . '</p>';
        $body[$row][$col] = export_form_cell_html($element);
        $col++;
        if ($col % $itemsinrow == 0) {
            $row++;
+6 −0
Original line number Diff line number Diff line
@@ -38,3 +38,9 @@
        min-width: 12.5rem; // 200px;
    }
}

.modal-body {
    .collection-nav {
        margin-top: 40px;
    }
}
Loading