Subversion Repositories SmartDukaan

Rev

Rev 36703 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 36703 Rev 37620
Line 1... Line 1...
1
$(document).ready(function () {
1
$(document).ready(function () {
-
 
2
    $(document).on('change', 'select.criteria-brands, input.include-inactive', function () {
-
 
3
        $(this).closest('.item-criteria').data('dirty', true);
-
 
4
    });
-
 
5
    // Excluded models must be pickable even if delisted, else brand-level payout still hits them
2
    $(document).on('change', 'select.criteria-brands', function () {
6
    $(document).on('change', 'input.exclude', function () {
-
 
7
        let $block = $(this).closest('.item-criteria');
-
 
8
        if ($(this).is(':checked') && !$block.find('input.include-inactive').is(':checked')) {
-
 
9
            $block.find('input.include-inactive').prop('checked', true);
3
        changed = true;
10
            $block.data('dirty', true);
-
 
11
        }
4
    });
12
    });
5
    $(document).on('click', ".scheme_offer", function () {
13
    $(document).on('click', ".scheme_offer", function () {
6
        loadOffer("main-content");
14
        loadOffer("main-content");
7
    });
15
    });
8
    $(document).on('click', '#yearmonth-submit', function () {
16
    $(document).on('click', '#yearmonth-submit', function () {
Line 379... Line 387...
379
 
387
 
380
    });
388
    });
381
}
389
}
382
 
390
 
383
$(document).on('click', 'select.criteria-catalogids+div > button', function () {
391
$(document).on('click', 'select.criteria-catalogids+div > button', function () {
-
 
392
    let $block = $(this).closest('.item-criteria');
384
    if (changed) {
393
    if ($block.data('dirty')) {
385
        let brands = $(this).closest('.item-criteria').find('select').val();
394
        let brands = $(this).closest('.item-criteria').find('select').val();
-
 
395
        let includeInactive = $block.find('input.include-inactive').is(':checked');
386
        let led = $(this).closest('.item-criteria').find('input[name=led]').is(":checked");
396
        let led = $(this).closest('.item-criteria').find('input[name=led]').is(":checked");
387
        let tablet = $(this).closest('.item-criteria').find('input[name=tablet]').is(":checked");
397
        let tablet = $(this).closest('.item-criteria').find('input[name=tablet]').is(":checked");
388
        let smartWatch = $(this).closest('.item-criteria').find('input[name=smartwatch]').is(":checked");
398
        let smartWatch = $(this).closest('.item-criteria').find('input[name=smartwatch]').is(":checked");
389
        let openBoxLapTops = $(this).closest('.item-criteria').find('input[name=openboxlaptops]').is(":checked");
399
        let openBoxLapTops = $(this).closest('.item-criteria').find('input[name=openboxlaptops]').is(":checked");
390
        $brandsContainer = $(this);
400
        $brandsContainer = $(this);
Line 400... Line 410...
400
        }
410
        }
401
 
411
 
402
        if (openBoxLapTops) {
412
        if (openBoxLapTops) {
403
            categoryId = 6;
413
            categoryId = 6;
404
        }
414
        }
405
        var url = `${context}/entity?brands=${brands.join(",")}&categoryId=${categoryId}&limit=0`;
415
        var url = `${context}/entity?brands=${encodeURIComponent(brands.join(","))}&categoryId=${categoryId}&limit=0&activeOnly=${!includeInactive}`;
406
        $select = $brandsContainer.closest('.item-criteria').find('.criteria-catalogids');
416
        let $select = $brandsContainer.closest('.item-criteria').find('.criteria-catalogids');
-
 
417
        let selectedIds = ($select.val() || []).map(String);
407
        $select.html('');
418
        $select.html('');
408
        if (brands.length > 0) {
419
        if (brands.length > 0) {
409
            doGetAjaxRequestHandler(url, function (response) {
420
            doGetAjaxRequestHandler(url, function (response) {
410
                data = JSON.parse(response);
421
                data = JSON.parse(response);
411
                for (i = 0; i < data.length; i++) {
422
                for (i = 0; i < data.length; i++) {
-
 
423
                    let catalogId = String(data[i].catalogId_i);
-
 
424
                    let label = data[i].title_s + (includeInactive && data[i].active_b === false ? ' (inactive)' : '');
-
 
425
                    let selected = selectedIds.indexOf(catalogId) >= 0 ? ' selected' : '';
412
                    $select.append(`<option value="${data[i].catalogId_i}">${data[i].title_s}</option>`);
426
                    $select.append(`<option value="${catalogId}"${selected}>${label}</option>`);
413
                }
427
                }
414
                $select.multiselect('rebuild');
428
                $select.multiselect('rebuild');
415
            });
429
            });
416
        } else {
430
        } else {
417
            $select.html('');
431
            $select.html('');
418
            $select.multiselect('rebuild');
432
            $select.multiselect('rebuild');
419
        }
433
        }
420
        changed = !changed;
434
        $block.data('dirty', false);
421
    }
435
    }
422
});
436
});
423
 
437
 
424
var ckEditor;
438
var ckEditor;
425
 
439