| 21627 |
kshitij.so |
1 |
$(function() {
|
| 36890 |
aman |
2 |
|
| 27754 |
amit.gupta |
3 |
$(document).on('click', ".contact-us", function() {
|
| 22354 |
ashik.ali |
4 |
console.log("Contact Us Button Clicked...")
|
|
|
5 |
contactUs("main-content");
|
|
|
6 |
});
|
| 36890 |
aman |
7 |
|
|
|
8 |
// ----- Add / Edit / Delete contact entries (authorised users only) -----
|
|
|
9 |
|
|
|
10 |
// Open the modal in "add" mode for the clicked section.
|
|
|
11 |
$(document).on('click', ".contact-add-btn", function() {
|
|
|
12 |
var section = $(this).data('section');
|
|
|
13 |
$('#contactUsForm')[0].reset();
|
|
|
14 |
$('#cuId').val(0);
|
|
|
15 |
$('#cuSection').val(section);
|
|
|
16 |
$('#contactUsModalTitle').text(section === 'ESCALATION' ? 'Add Escalation' : 'Add Contact');
|
|
|
17 |
$('#cuBaseAreaLabel').text(section === 'ESCALATION' ? 'Region' : 'Base Area');
|
|
|
18 |
$('#contactUsModal').modal('show');
|
|
|
19 |
});
|
|
|
20 |
|
|
|
21 |
// Open the modal pre-filled in "edit" mode.
|
|
|
22 |
$(document).on('click', ".contact-edit-btn", function() {
|
|
|
23 |
var btn = $(this);
|
|
|
24 |
var section = btn.data('section');
|
|
|
25 |
var mobile = String(btn.data('mobile'));
|
|
|
26 |
$('#contactUsForm')[0].reset();
|
|
|
27 |
$('#cuId').val(btn.data('id'));
|
|
|
28 |
$('#cuSection').val(section);
|
|
|
29 |
$('#cuArea').val(btn.data('area'));
|
|
|
30 |
$('#cuBaseArea').val(btn.data('basearea'));
|
|
|
31 |
$('#cuName').val(btn.data('name'));
|
|
|
32 |
$('#cuDesignation').val(btn.data('designation'));
|
|
|
33 |
$('#cuMobile').val(mobile === '-' ? '' : mobile);
|
|
|
34 |
$('#cuEmail').val(btn.data('email'));
|
|
|
35 |
$('#contactUsModalTitle').text('Edit Contact');
|
|
|
36 |
$('#cuBaseAreaLabel').text(section === 'ESCALATION' ? 'Region' : 'Base Area');
|
|
|
37 |
$('#contactUsModal').modal('show');
|
|
|
38 |
});
|
|
|
39 |
|
|
|
40 |
// Persist add / edit.
|
|
|
41 |
$(document).on('click', "#contactUsSaveBtn", function() {
|
|
|
42 |
var name = $.trim($('#cuName').val());
|
|
|
43 |
if (name === '') {
|
|
|
44 |
alert('Name is required.');
|
|
|
45 |
return;
|
|
|
46 |
}
|
|
|
47 |
var params = {
|
|
|
48 |
id: $('#cuId').val(),
|
|
|
49 |
section: $('#cuSection').val(),
|
|
|
50 |
area: $('#cuArea').val(),
|
|
|
51 |
baseArea: $('#cuBaseArea').val(),
|
|
|
52 |
name: name,
|
|
|
53 |
designation: $('#cuDesignation').val(),
|
|
|
54 |
mobile: $('#cuMobile').val(),
|
|
|
55 |
email: $('#cuEmail').val()
|
|
|
56 |
};
|
|
|
57 |
doPostAjaxRequestWithParamsHandler(context + "/contactUs/save", params, function(response) {
|
|
|
58 |
if (response && response.success) {
|
|
|
59 |
$('#contactUsModal').modal('hide');
|
|
|
60 |
contactUs("main-content");
|
|
|
61 |
} else {
|
|
|
62 |
alert((response && response.message) ? response.message : 'Could not save contact.');
|
|
|
63 |
}
|
|
|
64 |
});
|
|
|
65 |
});
|
|
|
66 |
|
| 36892 |
aman |
67 |
// Soft-delete an entry (with a styled confirmation).
|
| 36890 |
aman |
68 |
$(document).on('click', ".contact-delete-btn", function() {
|
|
|
69 |
var name = $(this).data('name');
|
| 36892 |
aman |
70 |
var id = $(this).data('id');
|
|
|
71 |
var doDelete = function() {
|
|
|
72 |
doPostAjaxRequestWithParamsHandler(context + "/contactUs/delete", { id: id }, function(response) {
|
|
|
73 |
if (response && response.success) {
|
|
|
74 |
contactUs("main-content");
|
|
|
75 |
} else {
|
|
|
76 |
alert((response && response.message) ? response.message : 'Could not remove contact.');
|
|
|
77 |
}
|
|
|
78 |
});
|
|
|
79 |
};
|
|
|
80 |
if (typeof bootbox !== 'undefined' && bootbox.confirm) {
|
|
|
81 |
bootbox.confirm({
|
|
|
82 |
title: "Delete contact",
|
|
|
83 |
message: "Are you sure you want to remove <b>" + name + "</b> from the contact list?",
|
|
|
84 |
buttons: {
|
|
|
85 |
confirm: { label: '<i class="fa fa-trash"></i> Yes, delete', className: 'btn-danger' },
|
|
|
86 |
cancel: { label: 'Cancel', className: 'btn-default' }
|
|
|
87 |
},
|
|
|
88 |
callback: function(result) { if (result) { doDelete(); } }
|
|
|
89 |
});
|
|
|
90 |
} else if (confirm('Remove ' + name + ' from the contact list?')) {
|
|
|
91 |
doDelete();
|
| 36890 |
aman |
92 |
}
|
|
|
93 |
});
|
|
|
94 |
|
| 22661 |
amit.gupta |
95 |
});
|
|
|
96 |
|
| 23343 |
ashik.ali |
97 |
function contactUs(domId){
|
| 23500 |
ashik.ali |
98 |
doGetAjaxRequestHandler(context+"/contactUs", function(response){
|
|
|
99 |
console.log("doGetAjaxRequest");
|
| 36890 |
aman |
100 |
// Drop any previously relocated modal to avoid duplicate #contactUsModal ids.
|
|
|
101 |
$('#contactUsModal').remove();
|
| 23343 |
ashik.ali |
102 |
$('#' + domId).html(response);
|
| 36890 |
aman |
103 |
// The dashboard applies `zoom` to #main-content > .wrapper, which traps a
|
|
|
104 |
// Bootstrap modal behind its body-level backdrop ("screen dims, no popup").
|
|
|
105 |
// Move the modal out to <body> so it renders above the backdrop.
|
|
|
106 |
$('#contactUsModal').appendTo('body');
|
| 22245 |
ashik.ali |
107 |
});
|
| 36890 |
aman |
108 |
}
|