All files / src/pages quickaction.js

0% Statements 0/22
0% Branches 0/2
0% Functions 0/7
0% Lines 0/22

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62                                                                                                                           
/**
 * Methods for the quickaction module
 * -> deprecated and stalled for now
 */
import LOG from '../components/lslog';
 
const quickActionMethods = {
    surveyQuickActionTrigger : () => {
        LOG.log('surveyQuickActionTrigger');
        const $self = $(this);
        $.ajax({
            url : $self.data('url'),
            type : 'GET',
            dataType : 'json',
            data: {currentState: $self.data('active')},
            // html contains the buttons
            success : function(data, statut){
                const newState = parseInt(data.newState);
                LOG.log('quickaction resolve', data);
                LOG.log('quickaction new state', newState);
                $self.data('active', newState);
                if(newState === 1){
                    $('#survey-action-container').slideDown(500);
                } else {
                    $('#survey-action-container').slideUp(500);
                }
                $('#survey-action-chevron').find('i').toggleClass('fa-caret-up').toggleClass('fa-caret-down');
                
            },
            error :  function(html, statut){
                LOG.error('ERROR!', html, statut);
            }
        });
    },
}
 
const quickActionBindings = ()=>{
    LOG.log('quickActionBindings');
    $('#switchchangeformat button').on('click', function(event, state) {
        $('#switchchangeformat button.active').removeClass('active');
        $(this).addClass('active');
 
        const value = $(this).data('value');
        const url = $('#switch-url').attr('data-url')+'/format/'+value;
 
        $.ajax({
            url : url,
            type : 'GET',
            dataType : 'html',
 
            // html contains the buttons
            success : function(html, statut){
            },
            error :  function(html, statut){
                alert('error');
            }
        });
 
    });
}
 
export {quickActionMethods, quickActionBindings};