Skip to content

Commit

Permalink
Fix parsing tags
Browse files Browse the repository at this point in the history
  • Loading branch information
snpefk committed Dec 22, 2024
1 parent c870998 commit 5451d76
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 5 deletions.
1 change: 1 addition & 0 deletions crates/opensi-core/src/serde_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,4 @@ generate_serde_mod!(atoms: crate::v5::AtomV5 as atom);
generate_serde_mod!(answers: crate::v5::AnswerV5 as answer);
generate_serde_mod!(authors: String as author);
generate_serde_mod!(sources: String as source);
generate_serde_mod!(tags: crate::v5::Tag as tag);
6 changes: 6 additions & 0 deletions crates/opensi-core/src/v5/components.rs
Original file line number Diff line number Diff line change
Expand Up @@ -174,3 +174,9 @@ pub struct AtomV5 {
#[serde(rename = "$value", skip_serializing_if = "Option::is_none")]
pub body: Option<String>,
}

#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]
pub struct Tag {
#[serde(rename = "$value", skip_serializing_if = "Option::is_none")]
pub body: Option<String>,
}
6 changes: 3 additions & 3 deletions crates/opensi-core/src/v5/package.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use std::{fs::File, io, io::Read};
use zip::write::FileOptions;
use zip::{CompressionMethod, ZipArchive, ZipWriter};

use super::components::{AtomV5, InfoV5, RoundV5};
use super::components::{AtomV5, InfoV5, RoundV5, Tag};
use crate::package_trait::RoundContainer;
use crate::serde_impl;

Expand Down Expand Up @@ -46,8 +46,8 @@ pub struct PackageV5 {
pub info: InfoV5,
#[serde(default, with = "serde_impl::rounds")]
pub rounds: Vec<RoundV5>,
#[serde(default, skip_serializing_if = "Vec::is_empty")]
pub tags: Vec<String>,
#[serde(default, with = "serde_impl::tags", skip_serializing_if = "Vec::is_empty")]
pub tags: Vec<Tag>,

// resources
#[serde(skip)]
Expand Down
4 changes: 2 additions & 2 deletions crates/opensi-editor/src/element/common.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::fmt::Display;

use opensi_core::prelude::*;

use opensi_core::v5::Tag;
use super::{property::Properties, PropertyTable};

/// A generic error label.
Expand Down Expand Up @@ -44,7 +44,7 @@ pub fn unselectable_label(text: impl Into<egui::WidgetText>, ui: &mut egui::Ui)

pub fn string_list(
id: impl Into<egui::Id>,
list: &mut Vec<String>,
list: &mut Vec<Tag>,
ui: &mut egui::Ui,
) -> egui::Response {
ui.push_id(id.into(), |ui| {
Expand Down

0 comments on commit 5451d76

Please sign in to comment.