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
7b3ad293
Commit
7b3ad293
authored
May 05, 2018
by
Zac Wood
Browse files
Added "remove from schedule" button
parent
d8818812
Changes
3
Hide whitespace changes
Inline
Side-by-side
schedules_web/src/components/App.tsx
View file @
7b3ad293
...
...
@@ -21,7 +21,11 @@ class App extends React.Component<any, State> {
<
h2
>
Search
</
h2
>
<
Search
addSearchResultCallback
=
{
this
.
addSectionToCurrentScheduleIfUnique
}
/>
<
h2
>
Your schedule
</
h2
>
<
SectionList
sections
=
{
this
.
state
.
currentSchedule
}
/>
<
SectionList
sections
=
{
this
.
state
.
currentSchedule
}
buttonText
=
"Remove from schedule"
selectSectionCallback
=
{
this
.
removeFromSchedule
}
/>
<
button
onClick
=
{
this
.
generateSchedule
}
>
Generate Schedule
</
button
>
</
div
>
);
...
...
@@ -46,9 +50,15 @@ class App extends React.Component<any, State> {
})
.
then
(
response
=>
response
.
text
())
.
then
(
text
=>
{
const
blob
=
new
Blob
([
text
],
{
type
:
'
text/plain;charset=utf-
9
'
});
const
blob
=
new
Blob
([
text
],
{
type
:
'
text/plain;charset=utf-
8
'
});
FileSaver
.
saveAs
(
blob
,
'
GMU Fall 2018.ics
'
);
});
};
removeFromSchedule
=
(
section
:
Section
)
=>
{
this
.
setState
({
currentSchedule
:
this
.
state
.
currentSchedule
.
filter
(
other
=>
section
!==
other
),
});
};
}
export
default
App
;
schedules_web/src/components/Search.tsx
View file @
7b3ad293
...
...
@@ -23,6 +23,7 @@ export default class Search extends React.Component<Props, State> {
<
SearchBar
onSearch
=
{
this
.
searchForSections
}
/>
<
SectionList
sections
=
{
this
.
state
.
sections
}
buttonText
=
"Add to schedule"
selectSectionCallback
=
{
this
.
props
.
addSearchResultCallback
}
/>
</
div
>
...
...
schedules_web/src/components/SectionList.tsx
View file @
7b3ad293
...
...
@@ -3,6 +3,7 @@ import Section from '../section';
interface
Props
{
sections
:
Section
[];
buttonText
:
string
;
selectSectionCallback
?:
(
section
:
Section
)
=>
void
;
}
...
...
@@ -49,7 +50,9 @@ export default class SectionList extends React.Component<Props, any> {
const
sectionWithCRN
=
this
.
getSectionWithCRN
(
rowCRN
);
return
(
<
td
>
<
button
onClick
=
{
()
=>
this
.
props
.
selectSectionCallback
(
sectionWithCRN
)
}
>
Add to schedule
</
button
>
<
button
onClick
=
{
()
=>
this
.
props
.
selectSectionCallback
(
sectionWithCRN
)
}
>
{
this
.
props
.
buttonText
}
</
button
>
</
td
>
);
}
else
{
...
...
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