Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
238c6d1
removed session pay input validation; refactored cp fetching code
Aug 27, 2017
4505ef0
refactored tapp fetching code
Aug 27, 2017
21b4e4f
added update functionality to session pay input
Aug 27, 2017
f4278a0
added session selector to navbar in cp admin view
Aug 27, 2017
5d1ceec
added selectedSession to cp appState
Aug 27, 2017
510f09d
added selected session filtering to control panel offers table
Aug 27, 2017
b574b28
fixed fetch response->resp bug
Aug 29, 2017
38de08c
fixed small bugs in navbar sessions menu
Aug 29, 2017
f46b823
added session menu sorting and fixed bug with viewing all sessions
Aug 29, 2017
ebd40cd
fixed small typos in tapp fetch
Aug 29, 2017
f08d9d0
session pay update now functional; fixed offer table styling
Aug 29, 2017
4c54a4c
fixed bug in checkbox range select
Aug 29, 2017
42bdcc9
changed session dates to input fields (non-functional for now)
Aug 29, 2017
7d99ed7
added the ability to email applicants their contract link
Aug 29, 2017
9829e91
added checks for the number of offers selected when attempting to per…
Aug 29, 2017
caeabfa
removed front-end offer status checking
Aug 29, 2017
9aea49d
updated fetching code for split-routes
Aug 29, 2017
b35f74f
added offer parsing as ints
Aug 29, 2017
c84bab5
finished updating 'withdrawOffer' functionality; fixed a number of fe…
Aug 29, 2017
7849db8
fixed filter id bug in tapp
Aug 29, 2017
9d74102
added global session sorting in cp appstate
Aug 29, 2017
c739fcf
added horizontal scrolling for the session form
Aug 29, 2017
581b588
moved session selection out of navbar; removed the ability to change …
Aug 30, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 19 additions & 15 deletions app/assets/stylesheets/cp.scss
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
--navbar-height: 71px; /* includes margins */
--table-menu-height: calc(34px + 1vh);
--main-div-height: calc(100vh - var(--navbar-height) - var(--footer-height));
--sessions-height: calc(100px + 1.5vh);
--min-row-height: 52px; /* assumes that header is two rows high */
--sessions-height: calc(55px + 1.5vh);
}

html {
Expand Down Expand Up @@ -100,24 +101,28 @@ footer div p {
margin-left: 3vw;
}

/* for Table in admin view */
#offers-grid table {
margin: 0;
}

#offers-grid .table-body {
/* for Table in admin view */
#offers-grid .sessions ~ .table-container .table-body {
/* note that this assumes that the header is at most one row high */
max-height: calc(
var(--main-div-height) - var(--table-menu-height) - var(--min-row-height)
var(--main-div-height) - var(--table-menu-height) - var(--min-row-height) - var(--sessions-height)
);
overflow: auto;
}

#offers-grid .admin-table .table-body {
#offers-grid .table-body {
/* note that this assumes that the header is at most one row high */
max-height: calc(
var(--main-div-height) - var(--table-menu-height) - var(--min-row-height) - var(--sessions-height)
var(--main-div-height) - var(--table-menu-height) - var(--min-row-height)
);
overflow: auto;
}

#offers-grid .table-container th {
text-overflow: ellipsis;
}

#offers-grid .table-container td,
Expand All @@ -127,20 +132,19 @@ footer div p {

#offers-grid .sessions {
margin: 0 0 1.5vh 0;
border: 1px solid #ddd;
}

#offers-grid .nav-tabs {
background-color: #f5f5f5;
#offers-grid .sessions .panel-body {
height: calc(35px + 10px + 10px);
padding: 10px 15px;
}

#offers-grid .tab-content {
height: calc(35px + 5px + 5px);
padding: 5px 15px;
#offers-grid .sessions #pay {
margin-left: 1vw;
}

#offers-grid .sessions .input-group {
width: 150px;
#offers-grid .sessions #pay input {
width: 100px;
}

.highlightOnHover:hover {
Expand Down
192 changes: 89 additions & 103 deletions app/javascript/cp/appState.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ const initialState = {
selectedSortFields: [],
selectedFilters: {},

selectedSession: '',

/** DB data **/
offers: { fetching: 0, list: null },
sessions: { fetching: 0, list: null },
Expand Down Expand Up @@ -143,6 +145,10 @@ class AppState {
return this.get('selectedFilters');
}

getSelectedSession() {
return this.get('selectedSession');
}

getSorts() {
return this.get('selectedSortFields');
}
Expand Down Expand Up @@ -177,12 +183,16 @@ class AppState {
this.set('selectedSortFields', sorts.delete(i));
}

selectSession(session) {
this.set('selectedSession', session);
}

setCurrentUserName(user) {
return this.set('user', user);
this.set('user', user);
}

setCurrentUserRole(role) {
return this.set('role', role);
this.set('role', role);
}

// toggle a filter on the offers table
Expand Down Expand Up @@ -232,9 +242,43 @@ class AppState {
return [this.get('offers.list'), this.get('sessions.list')].some(val => val == null);
}

// email applicants
email(offers) {
let allOffers = this.getOffersList();
fetch.email(offers.map(offer => allOffers.getIn([offer, 'email'])));
let emails = offers.map(offer => allOffers.getIn([offer, 'email']));

var a = document.createElement('a');
a.href =
emails.length == 1
? 'mailto:' + emails[0] // if there is only a single recipient, send normally
: 'mailto:?bcc=' + emails.join(';'); // if there are multiple recipients, bcc all
a.click();
}

// email mangled contract link to a single applicant
emailContract(offers) {
if (offers.length != 1) {
this.alert('<b>Error:</b> Can only email a contract link to a single applicant.');
return;
}

let offer = this.getOffersList().get(offers[0]);
if (!offer.get('link')) {
// offers does not have a contract link
this.alert(
'<b>Error:</b> Offer to ' +
offer.get('lastName') +
', ' +
offer.get('firstName') +
' does not have an associated contract'
);
return;
}

var a = document.createElement('a');
a.href =
'mailto:' + offer.get('email') + '?body=Link%20to%20contract:%20' + offer.get('link');
a.click();
}

// check if offers are being fetched
Expand Down Expand Up @@ -286,86 +330,39 @@ class AppState {
}

nag(offers) {
let pendingOffers = [],
allOffers = this.getOffersList();

for (var offer of offers) {
if (allOffers.getIn([offer, 'status']) == 'Pending') {
pendingOffers.push(parseInt(offer));
} else {
// offers that are not 'pending' cannot be nagged about
this.alert(
'<b>Error:</b> Offer to ' +
allOffers.getIn([offer, 'lastName']) +
', ' +
allOffers.getIn([offer, 'firstName']) +
' is not pending'
);
}
if (offers.length == 0) {
this.alert('<b>Error</b>: No offer selected');
return;
}

fetch.nag(pendingOffers);
fetch.nag(offers.map(offer => parseInt(offer)));
}

print(offers) {
fetch.print(offers);
if (offers.length == 0) {
this.alert('<b>Error</b>: No offer selected');
return;
}

fetch.print(offers.map(offer => parseInt(offer)));
}

sendContracts(offers) {
let status,
unsentOffers = [],
allOffers = this.getOffersList();

for (var offer of offers) {
status = allOffers.getIn([offer, 'status']);

switch (status) {
// can only send contracts that are unsent
case 'Unsent':
unsentOffers.push(parseInt(offer));
break;
case 'Withdrawn':
this.alert(
'<b>Error:</b> Cannot send contract to ' +
allOffers.getIn([offer, 'lastName']) +
', ' +
allOffers.getIn([offer, 'firstName']) +
'. Offer was withdrawn.'
);
break;
default:
this.alert(
'<b>Error:</b> Contract has already been sent to ' +
allOffers.getIn([offer, 'lastName']) +
', ' +
allOffers.getIn([offer, 'firstName'])
);
}
if (offers.length == 0) {
this.alert('<b>Error</b>: No offer selected');
return;
}

fetch.sendContracts(unsentOffers);
fetch.sendContracts(offers.map(offer => parseInt(offer)));
}

setDdahAccepted(offers) {
let acceptedOffers = [],
allOffers = this.getOffersList();

for (var offer of offers) {
// can only accept DDAH form for accepted offers
if (allOffers.getIn([offer, 'status']) == 'Accepted') {
acceptedOffers.push(parseInt(offer));
} else {
this.alert(
'<b>Error:</b> Cannot accept DDAH form for ' +
allOffers.getIn([offer, 'lastName']) +
', ' +
allOffers.getIn([offer, 'firstName']) +
'. Offer is not accepted.'
);
}
if (offers.length == 0) {
this.alert('<b>Error</b>: No offer selected');
return;
}

fetch.setDdahAccepted(acceptedOffers);
fetch.setDdahAccepted(offers.map(offer => parseInt(offer)));
}

setFetchingOffersList(fetching, success) {
Expand Down Expand Up @@ -405,25 +402,12 @@ class AppState {
}

setHrProcessed(offers) {
let acceptedOffers = [],
allOffers = this.getOffersList();

for (var offer of offers) {
// can only process contract for accepted offers
if (allOffers.getIn([offer, 'status']) == 'Accepted') {
acceptedOffers.push(parseInt(offer));
} else {
this.alert(
'<b>Error:</b> Cannot process contract for ' +
allOffers.getIn([offer, 'lastName']) +
', ' +
allOffers.getIn([offer, 'firstName']) +
'. Offer is not accepted.'
);
}
if (offers.length == 0) {
this.alert('<b>Error</b>: No offer selected');
return;
}

fetch.setHrProcessed(acceptedOffers);
fetch.setHrProcessed(offers.map(offer => parseInt(offer)));
}

setImporting(importing, success) {
Expand All @@ -449,6 +433,18 @@ class AppState {
}

setSessionsList(list) {
let semesterOrder = ['Winter', 'Spring', 'Fall', 'Year'];
// sort sesions in order of most recent to least recent
list.sort((sessionA, sessionB) => {
if (sessionA.get('year') > sessionB.get('year')) {
return -1;
}
if (sessionA.get('year') < sessionB.get('year')) {
return 1;
}
return semesterOrder.indexOf(sessionA.get('semester')) - semesterOrder.indexOf(sessionB.get('semester'));
});

this.set('sessions.list', list);
}

Expand All @@ -460,27 +456,17 @@ class AppState {
fetch.showContractHr(offer);
}

updateSessionPay(session, pay) {
fetch.updateSessionPay(session, pay);
}

withdrawOffers(offers) {
let status,
pendingOffers = [],
allOffers = this.getOffersList();

for (var offer of offers) {
// cannot withdraw unsent offers
if (allOffers.getIn([offer, 'status']) == 'Unsent') {
this.alert(
'<b>Error:</b> Offer to ' +
allOffers.getIn([offer, 'lastName']) +
', ' +
allOffers.getIn([offer, 'firstName']) +
' has not been sent'
);
} else {
pendingOffers.push(parseInt(offer));
}
if (offers.length == 0) {
this.alert('<b>Error</b>: No offer selected');
return;
}

fetch.withdrawOffers(pendingOffers);
fetch.withdrawOffers(offers);
}
}

Expand Down
Loading