This commit is contained in:
Alex Wied
2026-07-07 22:06:39 -04:00
parent b7b52e3c09
commit 25dd1ba832
7 changed files with 118 additions and 413 deletions
+16 -29
View File
@@ -20,6 +20,7 @@ use oxigraph::model::vocab::{rdf, rdfs};
use oxigraph::model::{BaseDirection, Dataset, NamedNode, NamedNodeRef, Quad, Term};
use tracing::{debug, debug_span, error, trace};
use crate::rdf::language;
use crate::rdf::vocab::rda;
use crate::widget::iri_input::iri_input;
#[derive(Clone, Debug)]
@@ -314,7 +315,7 @@ impl Publisher {
if let Some(search_state) = &mut self.search_state {
search_state.action = action;
} else {
if let Some(entity) = self.ontology.labeled_entities(&*language::ENGLISH_OR_UNTAGGED).next() {
if let Some(entity) = self.ontology.searchable_classes(&*language::ENGLISH_OR_UNTAGGED).next() {
let (id, window_task) = window::open(Settings::default());
self.search_state = Some(SearchState {
window_id: id,
@@ -450,7 +451,7 @@ impl Publisher {
Message::SaveGraph(overwrite) => {
let client = self.http_client.clone();
let options = SerializationOptions::from_format(RdfFormat::Turtle)
;//.with_filter(self.ontology.exclude_read_only());
.with_filter(self.ontology.exclude_read_only());
let request = self
.document
.to_update(options)
@@ -540,21 +541,9 @@ impl Publisher {
container(space()).width(BUTTON_WIDTH)
};
let property_label = self
.ontology
.info(&triple.predicate, &*language::ENGLISH_OR_UNTAGGED)
.label;
let property: Element<Message> = if state.read_only {
text(property_label).into()
} else {
button(text(property_label))
.on_press(Message::OpenQueryWindow(
SearchResultClickAction::Predicate(key),
))
.style(button::text)
.into()
};
let predicate_input = iri_input(self.ontology.prefixes(), "Predicate", triple.predicate.as_str())
.on_input(move |value| Message::ValueUpdated(key, value))
.on_control_click(Message::OpenQueryWindow(SearchResultClickAction::Predicate(key)));
let term = TermHelper::new(&triple.object);
@@ -630,7 +619,7 @@ impl Publisher {
let row = row![
button_area,
property,
predicate_input,
value_label,
object_input,
datatype_selector,
@@ -646,15 +635,12 @@ impl Publisher {
fn view_new_entity_buttons(
&self,
entities: impl Iterator<Item = NamedNode>,
entities: impl IntoIterator<Item = LabeledIri>,
) -> Element<'_, Message> {
let buttons = entities.map(|entity| {
let label = self
.ontology
.info(&entity, &*language::ENGLISH_OR_UNTAGGED)
.label;
let buttons = entities.into_iter().map(|entity| {
let label = format!("{} ({})", entity.label, self.ontology.abbreviate(entity.iri.as_ref()));
button(text(label))
.on_press(Message::NewDocument(entity))
.on_press(Message::NewDocument(entity.iri))
.into()
});
@@ -671,7 +657,7 @@ impl Publisher {
text_input("Query", &search_state.query).on_input(Message::QueryUpdated);
let mut entities = self.ontology
.labeled_entities(&*language::ENGLISH_OR_UNTAGGED)
.searchable_classes(&*language::ENGLISH_OR_UNTAGGED)
.collect::<Vec<_>>();
entities.sort_by(|a, b| Ord::cmp(&a.label, &b.label));
@@ -743,11 +729,12 @@ impl Publisher {
.collect();
let body: Element<Message> = if self.show_new_document_buttons {
let subclasses = self.ontology.subclasses_of(&rda::ENTITY.into_owned());
let labeled_subclasses = subclasses.iter().map(|iri| self.ontology.info(iri, &*language::ENGLISH_OR_UNTAGGED));
column![
//self.view_new_entity_buttons(self.ontology.subclass_of(gl::ENTITY)),
//self.view_new_entity_buttons(self.ontology.subclass_of(rda::ENTITY)),
]
.into()
self.view_new_entity_buttons(labeled_subclasses),
].into()
} else {
column(rows).into()
};