Subversion Repositories SmartDukaan

Rev

Rev 37256 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 37256 Rev 37270
Line 28... Line 28...
28
 
28
 
29
    // All five attributes are mandatory with NO defaults - the add form starts empty
29
    // All five attributes are mandatory with NO defaults - the add form starts empty
30
    function readAddAttributes() {
30
    function readAddAttributes() {
31
        var warranty = $('#hot-deal-warranty').val();
31
        var warranty = $('#hot-deal-warranty').val();
32
        var condition = $('#hot-deal-condition').val();
32
        var condition = $('#hot-deal-condition').val();
33
        var activated = $('#hot-deal-activated').val();
33
        var fresh = $('#hot-deal-fresh').val();
34
        var finance = $('#hot-deal-finance').val();
34
        var finance = $('#hot-deal-finance').val();
35
        var affordability = $('#hot-deal-affordability').val();
35
        var affordability = $('#hot-deal-affordability').val();
36
        if (warranty === '' || warranty === null) {
36
        if (warranty === '' || warranty === null) {
37
            alert("Warranty months is required (0 = no warranty, up to 12)");
37
            alert("Warranty months is required (0 = no warranty, up to 12)");
38
            return null;
38
            return null;
Line 44... Line 44...
44
        }
44
        }
45
        if (!condition) {
45
        if (!condition) {
46
            alert("Condition is required");
46
            alert("Condition is required");
47
            return null;
47
            return null;
48
        }
48
        }
49
        if (!activated) {
49
        if (!fresh) {
50
            alert("Activated (Yes/No) is required");
50
            alert("Fresh (Yes/No) is required");
51
            return null;
51
            return null;
52
        }
52
        }
53
        if (!finance) {
53
        if (!finance) {
54
            alert("Finance mapping (Yes/No) is required");
54
            alert("Finance mapping (Yes/No) is required");
55
            return null;
55
            return null;
Line 57... Line 57...
57
        if (!affordability) {
57
        if (!affordability) {
58
            alert("Affordability (Yes/No) is required");
58
            alert("Affordability (Yes/No) is required");
59
            return null;
59
            return null;
60
        }
60
        }
61
        return "&warrantyMonths=" + warrantyNum + "&condition=" + condition
61
        return "&warrantyMonths=" + warrantyNum + "&condition=" + condition
62
            + "&activated=" + activated + "&financeMapping=" + finance
62
            + "&fresh=" + fresh + "&financeMapping=" + finance
63
            + "&affordability=" + affordability;
63
            + "&affordability=" + affordability;
64
    }
64
    }
65
 
65
 
66
    $(document).on('click', ".add-hot-deal", function () {
66
    $(document).on('click', ".add-hot-deal", function () {
67
        var brandId = $('#hot-deal-brand').val();
67
        var brandId = $('#hot-deal-brand').val();
Line 96... Line 96...
96
                    loadDealsTable();
96
                    loadDealsTable();
97
                    loadHotDealModels(brandId);
97
                    loadHotDealModels(brandId);
98
                    loadSlots(brandId);
98
                    loadSlots(brandId);
99
                    $('#hot-deal-model-search').val('').removeData('catalogId');
99
                    $('#hot-deal-model-search').val('').removeData('catalogId');
100
                    $('#hot-deal-warranty').val('');
100
                    $('#hot-deal-warranty').val('');
101
                    $('#hot-deal-condition, #hot-deal-activated, #hot-deal-finance, #hot-deal-affordability').val('');
101
                    $('#hot-deal-condition, #hot-deal-fresh, #hot-deal-finance, #hot-deal-affordability').val('');
102
                } else {
102
                } else {
103
                    alert(response);
103
                    alert(response);
104
                }
104
                }
105
            });
105
            });
106
    });
106
    });
Line 129... Line 129...
129
            dealsPage++;
129
            dealsPage++;
130
            loadDealsTable();
130
            loadDealsTable();
131
        }
131
        }
132
    });
132
    });
133
 
133
 
-
 
134
    // Model selection for the manual Solr push
-
 
135
    function refreshPushButton() {
-
 
136
        $('.push-solr').prop('disabled', $('.hot-deal-select:checked').length === 0);
-
 
137
    }
-
 
138
 
-
 
139
    $(document).on('change', "#hot-deal-select-all", function () {
-
 
140
        $('.hot-deal-select').prop('checked', $(this).prop('checked'));
-
 
141
        refreshPushButton();
-
 
142
    });
-
 
143
 
-
 
144
    $(document).on('change', ".hot-deal-select", refreshPushButton);
-
 
145
 
-
 
146
    $(document).on('click', ".push-solr", function () {
-
 
147
        var catalogIds = $('.hot-deal-select:checked').map(function () {
-
 
148
            return $(this).closest('tr').data('catalogId');
-
 
149
        }).get();
-
 
150
        if (catalogIds.length === 0) {
-
 
151
            alert("Select at least one model to push");
-
 
152
            return false;
-
 
153
        }
-
 
154
        if (!confirm("Push " + catalogIds.length + " model(s) to Solr now?")) {
-
 
155
            return false;
-
 
156
        }
-
 
157
        var btn = $(this);
-
 
158
        btn.prop('disabled', true).text('Pushing...');
-
 
159
        doPostAjaxRequestHandler(context + "/hotDeals/pushSolr?catalogIds=" + catalogIds.join(','),
-
 
160
            function (response) {
-
 
161
                btn.prop('disabled', false).html('<i class="fa fa-cloud-upload"></i> Push to Solr');
-
 
162
                alert(response);
-
 
163
                refreshPushButton();
-
 
164
            });
-
 
165
    });
-
 
166
 
134
    $(document).on('change', ".hot-deal-row-start, .hot-deal-row-end, .hot-deal-row-field", function () {
167
    $(document).on('change', ".hot-deal-row-start, .hot-deal-row-end, .hot-deal-row-field", function () {
135
        $(this).closest('tr').find('.save-hot-deal').show();
168
        $(this).closest('tr').find('.save-hot-deal').show();
136
    });
169
    });
137
 
170
 
138
    $(document).on('click', ".save-hot-deal", function () {
171
    $(document).on('click', ".save-hot-deal", function () {
Line 156... Line 189...
156
        }
189
        }
157
        doPostAjaxRequestHandler(context + "/hotDeals/update?id=" + id
190
        doPostAjaxRequestHandler(context + "/hotDeals/update?id=" + id
158
            + "&startDate=" + startDate + "&endDate=" + endDate
191
            + "&startDate=" + startDate + "&endDate=" + endDate
159
            + "&warrantyMonths=" + warrantyNum
192
            + "&warrantyMonths=" + warrantyNum
160
            + "&condition=" + row.find('.hot-deal-row-condition').val()
193
            + "&condition=" + row.find('.hot-deal-row-condition').val()
161
            + "&activated=" + row.find('.hot-deal-row-activated').val()
194
            + "&fresh=" + row.find('.hot-deal-row-fresh').val()
162
            + "&financeMapping=" + row.find('.hot-deal-row-finance').val()
195
            + "&financeMapping=" + row.find('.hot-deal-row-finance').val()
163
            + "&affordability=" + row.find('.hot-deal-row-affordability').val(),
196
            + "&affordability=" + row.find('.hot-deal-row-affordability').val(),
164
            function (response) {
197
            function (response) {
165
                if (response == 'true') {
198
                if (response == 'true') {
166
                    loadDealsTable();
199
                    loadDealsTable();