1
0
mirror of https://github.com/pcvolkmer/osc-variant.git synced 2025-07-03 01:02:55 +00:00

Sort dependencies and requirements

This commit is contained in:
2023-09-30 13:26:25 +02:00
parent 8cae6ce706
commit d0de76770f
4 changed files with 32 additions and 3 deletions

View File

@ -27,7 +27,7 @@ use crate::model::data_form::DataForm;
use crate::model::onkostar_editor::OnkostarEditor;
use crate::model::property_catalogue::PropertyCatalogue;
use crate::model::unterformular::Unterformular;
use crate::model::Listable;
use crate::model::{Comparable, Listable, Sortable};
#[allow(clippy::enum_variant_names)]
pub enum Requirement<'a> {
@ -48,6 +48,25 @@ pub enum Requirement<'a> {
ExternalUnterformularSubform(String),
}
impl Sortable for Requirement<'_> {
fn sorting_key(&self) -> String {
match self {
Requirement::PropertyCatalogue(item) => item.get_name(),
Requirement::DataCatalogue(item) => item.get_name(),
Requirement::DataFormReference(item) => item.get_name(),
Requirement::UnterformularReference(item) => item.get_name(),
Requirement::DataFormSubform(item) => item.get_name(),
Requirement::UnterformularSubform(item) => item.get_name(),
Requirement::ExternalPropertyCatalogue(name)
| Requirement::ExternalDataCatalogue(name)
| Requirement::ExternalDataFormReference(name)
| Requirement::ExternalDataFormSubform(name)
| Requirement::ExternalUnterformularReference(name)
| Requirement::ExternalUnterformularSubform(name) => name.to_string(),
}
}
}
impl ToString for Requirement<'_> {
fn to_string(&self) -> String {
match self {