Sha256: 73c8815dfc5db62f5f2a1cee9a117346cd86b1aec4339226cacf7481b083f6eb

Contents?: true

Size: 1.86 KB

Versions: 62

Compression:

Stored size: 1.86 KB

Contents

/**
 * Handles the display of dynamic data within a dashboard as a user toggles
 * between a given dashboard's date range.
 *
 * TODO remove in v4, not used >= 3.4
 *
 * @namespace WORKAREA.dashboardToggles
 */
WORKAREA.registerModule('dashboardToggles', (function () {
    'use strict';

    var toggleCharts = function ($dashboard, period) {
            var $chartSections = $('[data-dashboard-toggle-chart]', $dashboard);

            $chartSections.each(function (index, section) {
                var chartData = $(section).data('dashboardToggleChart')[period],
                    $chart = $('.chart__canvas', section);

                WORKAREA.dashboardCharts.update($chart, chartData);
            });
        },

        getChosenSection = function ($allSections, chosenPeriod) {
            return $allSections.filter(function (index, section) {
                var period = $(section).data('dashboardToggleSection');
                return period === chosenPeriod;
            });
        },

        toggleSections = function ($dashboard, period) {
            var $allSections = $('[data-dashboard-toggle-section]', $dashboard),
                $sectionsForPeriod = getChosenSection($allSections, period);

            $allSections.addClass('hidden');
            $sectionsForPeriod.removeClass('hidden');
        },

        updateDashboard = function (event) {
            var $dashboard = $(event.delegateTarget),
                period = event.currentTarget.value;

            toggleSections($dashboard, period);
            toggleCharts($dashboard, period);
        },

        /**
         * @method
         * @name init
         * @memberof WORKAREA.dashboardToggles
         */
        init = function ($scope) {
            $('.dashboard__card', $scope)
            .on('change', '[data-dashboard-toggle]', updateDashboard);
        };

    return {
        init: init
    };
}()));

Version data entries

62 entries across 62 versions & 1 rubygems

Version Path
workarea-admin-3.5.27 app/assets/javascripts/workarea/admin/modules/dashboard_toggles.js
workarea-admin-3.5.26 app/assets/javascripts/workarea/admin/modules/dashboard_toggles.js
workarea-admin-3.4.45 app/assets/javascripts/workarea/admin/modules/dashboard_toggles.js
workarea-admin-3.5.25 app/assets/javascripts/workarea/admin/modules/dashboard_toggles.js
workarea-admin-3.5.23 app/assets/javascripts/workarea/admin/modules/dashboard_toggles.js
workarea-admin-3.4.44 app/assets/javascripts/workarea/admin/modules/dashboard_toggles.js
workarea-admin-3.5.22 app/assets/javascripts/workarea/admin/modules/dashboard_toggles.js
workarea-admin-3.4.43 app/assets/javascripts/workarea/admin/modules/dashboard_toggles.js
workarea-admin-3.5.21 app/assets/javascripts/workarea/admin/modules/dashboard_toggles.js
workarea-admin-3.4.42 app/assets/javascripts/workarea/admin/modules/dashboard_toggles.js
workarea-admin-3.5.20 app/assets/javascripts/workarea/admin/modules/dashboard_toggles.js
workarea-admin-3.4.41 app/assets/javascripts/workarea/admin/modules/dashboard_toggles.js
workarea-admin-3.5.19 app/assets/javascripts/workarea/admin/modules/dashboard_toggles.js
workarea-admin-3.4.40 app/assets/javascripts/workarea/admin/modules/dashboard_toggles.js
workarea-admin-3.5.18 app/assets/javascripts/workarea/admin/modules/dashboard_toggles.js
workarea-admin-3.4.39 app/assets/javascripts/workarea/admin/modules/dashboard_toggles.js
workarea-admin-3.5.17 app/assets/javascripts/workarea/admin/modules/dashboard_toggles.js
workarea-admin-3.4.38 app/assets/javascripts/workarea/admin/modules/dashboard_toggles.js
workarea-admin-3.5.16 app/assets/javascripts/workarea/admin/modules/dashboard_toggles.js
workarea-admin-3.4.37 app/assets/javascripts/workarea/admin/modules/dashboard_toggles.js