|
|
@ -23,6 +23,7 @@ pub struct RenderedField<'a> { |
|
|
|
pub max: String, |
|
|
|
pub max: String, |
|
|
|
pub all_tags_json: String, |
|
|
|
pub all_tags_json: String, |
|
|
|
pub tags_json: String, |
|
|
|
pub tags_json: String, |
|
|
|
|
|
|
|
pub tags: Option<Vec<String>>, |
|
|
|
pub options: Option<Vec<&'a String>>, |
|
|
|
pub options: Option<Vec<&'a String>>, |
|
|
|
pub value: Cow<'a, str>, |
|
|
|
pub value: Cow<'a, str>, |
|
|
|
pub checked: bool, |
|
|
|
pub checked: bool, |
|
|
@ -118,7 +119,6 @@ impl<'a> RenderedField<'a> { |
|
|
|
FieldKind::Tags { options } => { |
|
|
|
FieldKind::Tags { options } => { |
|
|
|
rendered.kind = "tags"; |
|
|
|
rendered.kind = "tags"; |
|
|
|
rendered.options = Some(options.iter().collect()); |
|
|
|
rendered.options = Some(options.iter().collect()); |
|
|
|
|
|
|
|
|
|
|
|
rendered.all_tags_json = serde_json::to_string(options).unwrap(); |
|
|
|
rendered.all_tags_json = serde_json::to_string(options).unwrap(); |
|
|
|
} |
|
|
|
} |
|
|
|
FieldKind::FreeTags { tag_group } => { |
|
|
|
FieldKind::FreeTags { tag_group } => { |
|
|
@ -145,12 +145,12 @@ impl<'a> RenderedField<'a> { |
|
|
|
} |
|
|
|
} |
|
|
|
FieldKind::Tags { .. } | FieldKind::FreeTags { .. } => { |
|
|
|
FieldKind::Tags { .. } | FieldKind::FreeTags { .. } => { |
|
|
|
if let Some(v) = value { |
|
|
|
if let Some(v) = value { |
|
|
|
rendered.value = serde_json::from_value::<Vec<String>>(v.clone()) |
|
|
|
let tags = serde_json::from_value::<Vec<String>>(v.clone()).unwrap(); |
|
|
|
.unwrap() |
|
|
|
rendered.value = tags.join(",").into(); |
|
|
|
.join(" ") |
|
|
|
rendered.tags = Some(tags); |
|
|
|
.into(); |
|
|
|
|
|
|
|
rendered.tags_json = serde_json::to_string(v).unwrap(); |
|
|
|
rendered.tags_json = serde_json::to_string(v).unwrap(); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
|
|
|
|
rendered.tags = Some(vec![]); |
|
|
|
rendered.tags_json = "[]".into(); |
|
|
|
rendered.tags_json = "[]".into(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -274,7 +274,7 @@ pub fn collect_card_form(store: &Store, mut form: MapFromForm) -> IndexMap<Strin |
|
|
|
} |
|
|
|
} |
|
|
|
FieldKind::Tags { options } => { |
|
|
|
FieldKind::Tags { options } => { |
|
|
|
let mut tags: Vec<String> = input |
|
|
|
let mut tags: Vec<String> = input |
|
|
|
.split(' ') |
|
|
|
.split(',') |
|
|
|
.map(ToOwned::to_owned) |
|
|
|
.map(ToOwned::to_owned) |
|
|
|
.filter_map(|tag| { |
|
|
|
.filter_map(|tag| { |
|
|
|
if options.contains(&tag) { |
|
|
|
if options.contains(&tag) { |
|
|
@ -291,7 +291,7 @@ pub fn collect_card_form(store: &Store, mut form: MapFromForm) -> IndexMap<Strin |
|
|
|
} |
|
|
|
} |
|
|
|
FieldKind::FreeTags { .. } => { |
|
|
|
FieldKind::FreeTags { .. } => { |
|
|
|
let mut tags: Vec<String> = input |
|
|
|
let mut tags: Vec<String> = input |
|
|
|
.split(' ') |
|
|
|
.split(',') |
|
|
|
.map(str::trim) |
|
|
|
.map(str::trim) |
|
|
|
.filter(|s| !s.is_empty()) |
|
|
|
.filter(|s| !s.is_empty()) |
|
|
|
.map(ToOwned::to_owned) |
|
|
|
.map(ToOwned::to_owned) |
|
|
|