Skip to content

Commit 10c2407

Browse files
authored
Merge pull request #434 from thoth-pub/feature/display_ordered_relationships
Feature/display ordered relationships
2 parents b48cc64 + 5684178 commit 10c2407

4 files changed

Lines changed: 14 additions & 4 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1717
- [#424](https://github.com/thoth-pub/thoth/issues/424) - Fix inactive tag on catalogue
1818
- Added derives for `Eq` alongside `PartialEq` to comply with [`rustc 1.63.0`](https://github.com/rust-lang/rust/releases/tag/1.63.0)
1919
- Upgrade rust to `1.63.0` in development `Dockerfile`
20+
- Order contributions and relations by ordinal, and subjects by type and ordinal
2021

2122
## [[0.8.8]](https://github.com/thoth-pub/thoth/releases/tag/v0.8.8) - 2022-08-02
2223
### Added

thoth-api/src/model/subject/mod.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@ use thoth_errors::ThothResult;
1515

1616
#[cfg_attr(feature = "backend", derive(DbEnum, juniper::GraphQLEnum))]
1717
#[cfg_attr(feature = "backend", DieselType = "Subject_type")]
18-
#[derive(Debug, Clone, PartialEq, Eq, Deserialize, Serialize, EnumString, Display)]
18+
#[derive(
19+
Debug, Clone, PartialEq, Eq, Ord, PartialOrd, Deserialize, Serialize, EnumString, Display,
20+
)]
1921
#[serde(rename_all = "SCREAMING_SNAKE_CASE")]
2022
pub enum SubjectType {
2123
#[strum(serialize = "BIC")]

thoth-app/src/component/subjects_form.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ impl Component for SubjectsFormComponent {
235235
}
236236

237237
fn view(&self, ctx: &Context<Self>) -> Html {
238-
let subjects = ctx.props().subjects.clone().unwrap_or_default();
238+
let mut subjects = ctx.props().subjects.clone().unwrap_or_default();
239239
let open_modal = ctx.link().callback(|e: MouseEvent| {
240240
e.prevent_default();
241241
Msg::ToggleAddFormDisplay(true)
@@ -244,6 +244,13 @@ impl Component for SubjectsFormComponent {
244244
e.prevent_default();
245245
Msg::ToggleAddFormDisplay(false)
246246
});
247+
subjects.sort_by(|a, b| {
248+
if a.subject_type == b.subject_type {
249+
a.subject_ordinal.partial_cmp(&b.subject_ordinal).unwrap()
250+
} else {
251+
a.subject_type.partial_cmp(&b.subject_type).unwrap()
252+
}
253+
});
247254
html! {
248255
<nav class="panel">
249256
<p class="panel-heading">

thoth-app/src/models/work/work_query.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ pub const WORK_QUERY: &str = "
4242
firstPage
4343
lastPage
4444
pageInterval
45-
relations {
45+
relations(order: {field: RELATION_ORDINAL, direction: ASC}) {
4646
workRelationId
4747
relatorWorkId
4848
relatedWorkId
@@ -61,7 +61,7 @@ pub const WORK_QUERY: &str = "
6161
updatedAt
6262
}
6363
}
64-
contributions {
64+
contributions(order: {field: CONTRIBUTION_ORDINAL, direction: ASC}) {
6565
contributionId
6666
workId
6767
contributorId

0 commit comments

Comments
 (0)