Skip to content

Commit

Permalink
Finished add follow up #60
Browse files Browse the repository at this point in the history
  • Loading branch information
cjdellomes committed Jan 24, 2017
1 parent aa2e339 commit ad61911
Show file tree
Hide file tree
Showing 4 changed files with 118 additions and 5 deletions.
68 changes: 64 additions & 4 deletions static/js/profile.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ $(function (event) {
var table = $('#followups');
var tableBody = $('#followups > tbody');

console.log('TEST');

var getCaseManagerFollowUps = function (casemanagerID) {
$.ajax({
xhrFields: {
Expand All @@ -31,7 +29,11 @@ $(function (event) {
'</tr>')
});

table = table.DataTable();
if (!$.fn.DataTable.isDataTable('#followups') ) {
table = table.DataTable();
}

getClients();

},
error: function (xhr) {
Expand All @@ -54,12 +56,13 @@ $(function (event) {
beforeSend: function (xhr) {
xhr.setRequestHeader('Authorization', localStorage.getItem("authorization"));
},
url: 'api/followups/',
url: 'api/followups',
method: 'POST',
data: data,
success: function (data) {
console.log(data);
getCaseManagerFollowUps(localStorage.getItem("userID"));
$('#add-followup-modal').modal('hide');
},
error: function (xhr) {
console.log(xhr);
Expand Down Expand Up @@ -126,6 +129,63 @@ $(function (event) {
});
};

var getClients = function () {
$.ajax({
xhrFields: {
withCredentials: true
},
beforeSend: function (xhr) {
xhr.setRequestHeader('Authorization', localStorage.getItem("authorization"));
},
url: 'api/clients',
method: 'GET',
success: function (data) {
console.log(data);
var clients = data.result;
clientDropdown(clients);
},
error: function (xhr) {
console.log(xhr);

if (xhr.status === 401) {
localStorage.removeItem("authorization");
}
}
}).done(function (data) {

});
};

var clientDropdown = function (clients) {
var clientDropdown = $('#add-followup-client');
clientDropdown.empty();
clients.forEach(function (client) {
clientDropdown.append('<option value="' + client.id + '">' + client.firstName + ' ' + client.lastName + '</option>');
});
};

var gatherInput = function () {
var casemanagerID = localStorage.getItem('userID');
var timestamp = $('#add-followup-date').val();
var clientID = $('#add-followup-client').val();
var location = $('#add-followup-location').val();
var note = $('#add-followup-note').val();
var data = {
casemanagerID: casemanagerID,
timestamp: timestamp,
clientID: clientID,
location: location,
note: note
};

return data;
};

$('#add-followup-submit').click(function() {
var data = gatherInput();
createFollowUp(data);
});

getCaseManagerFollowUps(localStorage.getItem("userID"));

});
31 changes: 31 additions & 0 deletions templates/components/_addfollowup.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<div class = "container" id="add-followup-view">
<div class="row">
<div id="user-id" hidden>
</div>
<div class="form-group row">
<label for="add-followup-date" class="col-xs-2 col-form-label">Date & Time</label>
<div class="col-xs-5">
<input class="form-control" type="datetime-local" value="" id="add-followup-date">
</div>
</div>
<div class="form-group row">
<label for="add-followup-client" class="col-xs-2 col-form-label">Client</label>
<div class="col-xs-5">
<!-- <input type="number" placeholder="1" id="client-id" min="1"> -->
<select id="add-followup-client">
<option value="">Client Name</option>
</select>
</div>
<label for="add-followup-location" class="col-xs-2 col-form-label">Location</label>
<div class="col-xs-3">
<input type="text" id="add-followup-location" class="form-control"></textarea>
</div>
</div>
<div class="form-group row">
<label for="add-followup-note" class="col-xs-2 col-form-label">Note</label>
<div class="col-xs-12">
<textarea id="add-followup-note" class="form-control" rows="10"></textarea>
</div>
</div>
</div>
</div>
18 changes: 18 additions & 0 deletions templates/modals/addfollowup.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<div class="modal fade" id="add-followup-modal" tabindex="-1" role="dialog">
<div class="modal-dialog modal-lg" role="document">
<div class="modal-content">
<div class="modal-header">
Add Follow Up
</div>
<div class="modal-body">
{% include "components/_addfollowup.html" %}

<div id="content">

</div>

<button type="button" id="add-followup-submit" class="btn btn-outline-primary">Submit</button>
</div>
</div>
</div>
</div>
6 changes: 5 additions & 1 deletion templates/profile.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,11 @@
</tr>
</tbody>
</table>
<button id="add-followup" class="btn btn-success" data-toggle="modal" data-target="#add-file-modal" style="float: left;">Add New Follow Up <i class="fa fa-plus" aria-hidden="true"></i></button>
<button id="add-followup" class="btn btn-success" data-toggle="modal" data-target="#add-followup-modal" style="float: left;">
Add New Follow Up
<i class="fa fa-plus" aria-hidden="true"></i>
</button>
{% include "modals/addfollowup.html" %}
</div>
</div>

Expand Down

0 comments on commit ad61911

Please sign in to comment.