Subversion Repositories SmartDukaan

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
33973 tejus.loha 1
$(document).on('click', ".super-catalog-list", function () {
2
    doGetAjaxRequestHandler(context + "/super-catalog",
3
        (response) => {
4
            $('#' + 'main-content').html(response);
5
        });
6
});
7
 
8
$(document).on('click', ".save_super_model", function () {
9
    let mappingArr = [];
10
    $('#catalogMapping').find('tr').each(function () {
11
        const catalogId = $(this).find('select#catalog_id').val();
12
        const variantName = $(this).find('input#variant_name').val();
13
        const mappingId = $(this).find('input#mapping_id').val();
14
        if (catalogId > 0) {
15
            mappingArr.push({
16
                catalogId: catalogId,
17
                variantName: variantName,
18
                superCatalogId: parseInt($('#super_catalog_name').val()),
19
                id: mappingId
20
            })
21
        }
22
    });
23
    const params = {
24
        id: mappingArr.length ? mappingArr[0].id : 0,
25
        brandId: parseInt($('#brand_id').val()),
26
        mappingArr: mappingArr,
27
        superCatalogName: parseInt($('#super_catalog_name').val()) || $('#super_catalog_name').val(),
28
    };
29
    console.log('params',params);
30
    if (!params.brandId || mappingArr.length === 0 || !params.superCatalogName){
31
        alert("Please fill all details"); return;
32
    }
33
    doAjaxRequestWithJsonHandler(context + "/super-catalog", "POST", JSON.stringify(params), (response) => {
34
        if (response) {
35
            $('.super-catalog-list').trigger('click');
36
            $('#manageSuperCatalogModal').modal('hide');
37
            alert("Saved successfully");
38
        } else {
39
            alert("Something went wrong!");
40
        }
41
    });
42
});
43
 
44
$(document).on('click', ".delete-super-catalog-mapping", function() {
45
    const id = parseInt($(this).closest('td').data('id')) || 0;
46
    console.log("id",id);
47
    if (confirm("Are you sure you want to delete this record")) {
48
        if (id > 0) {
49
            doDeleteAjaxRequestHandler(context + "/super-catalog/" + id, (response) => {
50
                if (response) {
51
                    $(this).parent('td').closest('tr').remove();
52
                    $('.super-catalog-list').trigger('click');
53
                    alert("Deleted successfully");
54
                } else {
55
                    alert("Something went wrong!");
56
                }
57
            });
58
        } else {
59
            $(this).parent('td').closest('tr').remove();
60
        }
61
    }
62
});