Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Khalid Ali
schedules
Commits
db741bce
Commit
db741bce
authored
Apr 16, 2018
by
Zac Wood
Browse files
Refactor
parent
7d79df48
Changes
4
Hide whitespace changes
Inline
Side-by-side
schedules_api/start_server
100644 → 100755
View file @
db741bce
File mode changed from 100644 to 100755
schedules_web/src/Components/App.js
View file @
db741bce
...
...
@@ -9,22 +9,25 @@ class App extends Component {
sections
:
[],
};
this
.
addToSchedule
=
this
.
addToSchedule
.
bind
(
this
);
this
.
addSectionToScheduleIfUnique
=
this
.
addSectionToScheduleIfUnique
.
bind
(
this
);
this
.
isSectionInSchedule
=
this
.
isSectionInSchedule
.
bind
(
this
);
}
addToSchedule
(
event
,
section
)
{
if
(
this
.
state
.
sections
!==
undefined
&&
!
this
.
state
.
sections
.
includes
(
section
))
{
this
.
setState
({
sections
:
[...
this
.
state
.
sections
,
section
],
});
addSectionToScheduleIfUnique
(
section
)
{
if
(
!
this
.
isSectionInSchedule
(
section
))
{
this
.
setState
({
sections
:
[...
this
.
state
.
sections
,
section
]
});
}
}
isSectionInSchedule
(
section
)
{
return
this
.
state
.
sections
!==
undefined
&&
this
.
state
.
sections
.
includes
(
section
);
}
render
()
{
return
(
<
div
className
=
"
App
"
>
<
h1
>
Schedules
<
/h1
>
<
Search
addToSchedule
=
{
this
.
addToSchedule
}
/
>
<
Search
addToSchedule
=
{
this
.
add
Section
ToSchedule
IfUnique
}
/
>
<
Schedule
sections
=
{
this
.
state
.
sections
}
/
>
<
/div
>
);
...
...
schedules_web/src/Components/SectionsList.js
View file @
db741bce
import
React
,
{
Component
}
from
'
react
'
;
export
default
class
SectionsList
extends
Component
{
constructor
(
props
)
{
super
(
props
);
this
.
getRowsForSections
=
this
.
getRowsForSections
.
bind
(
this
);
this
.
getRowForSection
=
this
.
getRowForSection
.
bind
(
this
);
this
.
getLastColumn
=
this
.
getLastColumn
.
bind
(
this
);
}
getRowsForSections
()
{
return
this
.
props
.
sections
.
map
(
section
=>
{
return
this
.
getRowForSection
(
section
);
});
}
getRowForSection
(
section
)
{
return
(
<
tr
key
=
{
section
.
id
}
>
<
td
>
{
section
.
name
}
<
/td
>
<
td
>
{
section
.
title
}
<
/td
>
<
td
>
{
section
.
crn
}
<
/td
>
<
td
>
{
section
.
instructor
}
<
/td
>
<
td
>
{
section
.
location
}
<
/td
>
<
td
>
{
section
.
days
}
<
/td
>
<
td
>
{[
section
.
start_time
,
section
.
end_time
].
join
(
'
-
'
)}
<
/td
>
{
this
.
getLastColumn
(
section
)}
<
/tr
>
);
}
getLastColumn
(
section
)
{
if
(
this
.
props
.
addToSchedule
)
{
return
(
<
td
>
<
button
onClick
=
{
e
=>
this
.
props
.
addToSchedule
(
section
)}
>
Add
to
schedule
<
/button
>
<
/td
>
);
}
else
{
return
<
td
/>
;
}
}
render
()
{
return
(
<
div
>
...
...
@@ -17,31 +59,7 @@ export default class SectionsList extends Component {
<
th
>
Times
<
/th
>
<
th
/>
<
/tr
>
{
this
.
props
.
sections
.
map
(
section
=>
{
return
(
<
tr
key
=
{
section
.
id
}
>
<
td
>
{
section
.
name
}
<
/td
>
<
td
>
{
section
.
title
}
<
/td
>
<
td
>
{
section
.
crn
}
<
/td
>
<
td
>
{
section
.
instructor
}
<
/td
>
<
td
>
{
section
.
location
}
<
/td
>
<
td
>
{
section
.
days
}
<
/td
>
<
td
>
{[
section
.
start_time
,
section
.
end_time
].
join
(
'
-
'
)}
<
/td
>
{
/* If the addToSchedule prop exists, include an
add to schedule button to the last column */
}
{
this
.
props
.
addToSchedule
?
(
<
td
>
<
button
onClick
=
{
e
=>
this
.
props
.
addToSchedule
(
e
,
section
)}
>
Add
to
schedule
<
/button
>
<
/td
>
)
:
(
<
td
/>
)}
<
/tr
>
);
})}
{
this
.
getRowsForSections
()}
<
/tbody
>
<
/table
>
<
/div
>
...
...
schedules_web/yarn.lock
View file @
db741bce
...
...
@@ -5575,9 +5575,9 @@ react-dev-utils@^5.0.1:
strip-ansi "3.0.1"
text-table "0.2.0"
react-dom@16.3.1:
version "16.3.
1
"
resolved "https://registry.yarnpkg.com/react-dom/-/react-dom-16.3.
1
.tgz#
6a3c90a4fb62f915bdbcf6204422d93a7d4ca573
"
react-dom@
^
16.3.1:
version "16.3.
2
"
resolved "https://registry.yarnpkg.com/react-dom/-/react-dom-16.3.
2
.tgz#
cb90f107e09536d683d84ed5d4888e9640e0e4df
"
dependencies:
fbjs "^0.8.16"
loose-envify "^1.1.0"
...
...
@@ -5633,9 +5633,9 @@ react-scripts@1.1.4:
optionalDependencies:
fsevents "^1.1.3"
react@16.3.1:
version "16.3.
1
"
resolved "https://registry.yarnpkg.com/react/-/react-16.3.
1
.tgz#
4a2da433d471251c69b6033ada30e2ed1202cfd8
"
react@
^
16.3.1:
version "16.3.
2
"
resolved "https://registry.yarnpkg.com/react/-/react-16.3.
2
.tgz#
fdc8420398533a1e58872f59091b272ce2f91ea9
"
dependencies:
fbjs "^0.8.16"
loose-envify "^1.1.0"
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment