-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1061 from UniversityOfHelsinkiCS/trunk
Student home_country to db, CLI works and other lies
- Loading branch information
Showing
19 changed files
with
193 additions
and
68 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
services/backend/shared/migrations/20190701_01_add_home_country_to_student.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
module.exports = { | ||
up: async (queryInterface, Sequelize) => { | ||
await queryInterface.addColumn('student', 'home_country_en', { type: Sequelize.STRING }) | ||
await queryInterface.addColumn('student', 'home_country_fi', { type: Sequelize.STRING }) | ||
await queryInterface.addColumn('student', 'home_country_sv', { type: Sequelize.STRING }) | ||
}, | ||
down: async () => { | ||
await queryInterface.removeColumn('student', 'home_country_en') | ||
await queryInterface.removeColumn('student', 'home_country_fi') | ||
await queryInterface.removeColumn('student', 'home_country_sv') | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
services/backend/shared/migrations/20190701_02_remove_unused_old_country_from_student.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
module.exports = { | ||
up: async (queryInterface, Sequelize) => { | ||
await queryInterface.removeColumn('student', 'country') | ||
}, | ||
down: async () => { | ||
await queryInterface.addColumn('student', 'country', { type: Sequelize.STRING }) | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
services/oodikone2-frontend/src/components/Faculty/FacultySelector/index.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import React, { useEffect } from 'react' | ||
import { withRouter } from 'react-router' | ||
import { connect } from 'react-redux' | ||
import { string, func, arrayOf, shape } from 'prop-types' | ||
import { getFaculties } from '../../../redux/faculties' | ||
import { getTextIn } from '../../../common' | ||
import SortableTable from '../../SortableTable' | ||
|
||
|
||
|
||
const FacultySelector = ({ language, handleSelect, dispatchGetFaculties, faculties }) => { | ||
const fetchFaculties = async () => { | ||
await dispatchGetFaculties() | ||
} | ||
useEffect(() => { | ||
fetchFaculties() | ||
}, []) | ||
|
||
if (!faculties) return null | ||
const headers = [ | ||
{ | ||
key: 'name', | ||
title: 'name', | ||
getRowVal: faculty => getTextIn(faculty.name, language) | ||
}, | ||
{ | ||
key: 'code', | ||
title: 'code', | ||
getRowVal: faculty => faculty.code | ||
} | ||
] | ||
|
||
|
||
return ( | ||
<SortableTable | ||
columns={headers} | ||
getRowKey={faculty => faculty.code} | ||
getRowProps={faculty => ({ onClick: () => handleSelect(faculty.code), style: { cursor: 'pointer' } })} | ||
data={faculties} | ||
/> | ||
) | ||
} | ||
FacultySelector.propTypes = { | ||
language: string.isRequired, | ||
handleSelect: func.isRequired, | ||
dispatchGetFaculties: func.isRequired, | ||
faculties: arrayOf(shape({})).isRequired | ||
} | ||
|
||
const mapStateToProps = ({ faculties, settings }) => ({ | ||
faculties: faculties.data, | ||
language: settings.language | ||
}) | ||
|
||
export default connect(mapStateToProps, { dispatchGetFaculties: getFaculties })(withRouter(FacultySelector)) |
18 changes: 18 additions & 0 deletions
18
services/oodikone2-frontend/src/components/Faculty/index.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import React from 'react' | ||
import { withRouter } from 'react-router' | ||
import { Header, Segment } from 'semantic-ui-react' | ||
import FacultySelector from './FacultySelector' | ||
|
||
const Faculty = () => ( | ||
<div className="segmentContainer"> | ||
<Header className="segmentTitle" size="large"> | ||
Faculties | ||
</Header> | ||
<Segment className="contentSegment" > | ||
<FacultySelector /> | ||
</Segment> | ||
</div> | ||
) | ||
|
||
|
||
export default withRouter(Faculty) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.