.
This commit is contained in:
+33
-11
@@ -18,7 +18,7 @@ use ldp::traverse::Traverse;
|
||||
use ldp::{RdfSource, RdfSourceUpdateResponse, ResourceRequestBuilder, SerializationOptions};
|
||||
use oxigraph::io::RdfFormat;
|
||||
use oxigraph::model::vocab::{rdf, rdfs};
|
||||
use oxigraph::model::{BaseDirection, Dataset, NamedNode, Quad, Term};
|
||||
use oxigraph::model::{BaseDirection, Dataset, NamedNode, NamedOrBlankNode, Quad, Term};
|
||||
use tracing::{debug_span, error, field, trace};
|
||||
use crate::navigator::Navigator;
|
||||
use crate::rdf::curie::CurieHelper;
|
||||
@@ -56,6 +56,7 @@ pub(crate) enum Message {
|
||||
SearchResultClicked(NamedNode),
|
||||
DatatypeUpdated(QuadKey, Option<String>),
|
||||
LanguageUpdated(QuadKey, Option<String>),
|
||||
SubjectUpdated(QuadKey, String),
|
||||
PredicateUpdated(QuadKey, String),
|
||||
ObjectUpdated(QuadKey, String),
|
||||
DirectionToggled(QuadKey, BaseDirection),
|
||||
@@ -129,7 +130,7 @@ impl Publisher {
|
||||
let mut abbreviated_datatypes = ontology
|
||||
.datatypes()
|
||||
.into_iter()
|
||||
.map(|node| curie_helper.abbreviate(node.as_str())
|
||||
.map(|node| curie_helper.abbreviate(None, node.as_str())
|
||||
.unwrap_or(node.as_str().to_string())
|
||||
).collect::<Vec<_>>();
|
||||
abbreviated_datatypes.sort();
|
||||
@@ -238,7 +239,7 @@ impl Publisher {
|
||||
Schema::iri_field() => individual.as_str(),
|
||||
);
|
||||
|
||||
if let Some(curie) = curie_helper.abbreviate(individual.as_str()) {
|
||||
if let Some(curie) = curie_helper.abbreviate(None, individual.as_str()) {
|
||||
document.add_text(Schema::curie_field(), curie);
|
||||
}
|
||||
|
||||
@@ -340,7 +341,7 @@ impl Publisher {
|
||||
let term = TermHelper::new(&quad.object);
|
||||
let datatype = term
|
||||
.datatype()
|
||||
.map(|datatype| self.curie_helper.abbreviate(datatype.as_str())
|
||||
.map(|datatype| self.curie_helper.abbreviate(None, datatype.as_str())
|
||||
.unwrap_or(datatype.as_str().to_string()));
|
||||
|
||||
let datatype_state = combo_box::State::with_selection(
|
||||
@@ -454,7 +455,7 @@ impl Publisher {
|
||||
Message::DatatypeUpdated(key, Some(maybe_prefixed_iri)) => {
|
||||
let node = self
|
||||
.curie_helper
|
||||
.expand(&maybe_prefixed_iri)
|
||||
.expand(None, &maybe_prefixed_iri)
|
||||
.unwrap_or(maybe_prefixed_iri);
|
||||
|
||||
if let Some(quad) = self.document.dataset_mut().quads.get_mut(key) {
|
||||
@@ -484,6 +485,12 @@ impl Publisher {
|
||||
self.modified = true;
|
||||
}
|
||||
}
|
||||
Message::SubjectUpdated(key, value) => {
|
||||
if let Some(quad) = self.document.dataset_mut().quads.get_mut(key) {
|
||||
quad.subject = NamedOrBlankNode::NamedNode(NamedNode::new_unchecked(value));
|
||||
self.modified = true;
|
||||
}
|
||||
}
|
||||
Message::PredicateUpdated(key, value) => {
|
||||
if let Some(quad) = self.document.dataset_mut().quads.get_mut(key) {
|
||||
quad.predicate = NamedNode::new_unchecked(value);
|
||||
@@ -627,7 +634,21 @@ impl Publisher {
|
||||
container(space()).width(BUTTON_WIDTH)
|
||||
};
|
||||
|
||||
let predicate_input_base = iri_input(&self.curie_helper, "Predicate", triple.predicate.as_str());
|
||||
let base = self.document.origin().as_str();
|
||||
|
||||
let subject = match &triple.subject {
|
||||
NamedOrBlankNode::NamedNode(subject) => subject.as_str(),
|
||||
_ => "",
|
||||
};
|
||||
|
||||
let subject_input_base = iri_input(&self.curie_helper, "Subject", Some(&base), subject);
|
||||
let subject_input = if self.ontology.is_read_only(triple.as_ref()) {
|
||||
subject_input_base
|
||||
} else {
|
||||
subject_input_base.on_input(move |value| Message::SubjectUpdated(key, value))
|
||||
};
|
||||
|
||||
let predicate_input_base = iri_input(&self.curie_helper, "Predicate", Some(&base), triple.predicate.as_str());
|
||||
let predicate_input = if self.ontology.is_read_only(triple.as_ref()) {
|
||||
predicate_input_base
|
||||
} else {
|
||||
@@ -659,7 +680,7 @@ impl Publisher {
|
||||
})
|
||||
.unwrap_or(Horizontal::Left);
|
||||
|
||||
let object_input_base = iri_input(&self.curie_helper, "Object", value.as_str())
|
||||
let object_input_base = iri_input(&self.curie_helper, "Object", Some(&base), value.as_str())
|
||||
.on_shift_click(Message::NavigateToObject(key));
|
||||
let object_input = if self.ontology.is_read_only(triple.as_ref()) {
|
||||
object_input_base
|
||||
@@ -670,7 +691,7 @@ impl Publisher {
|
||||
};
|
||||
|
||||
let selected_datatype = term.datatype()
|
||||
.and_then(|node| self.curie_helper.abbreviate(node.as_str()));
|
||||
.and_then(|node| self.curie_helper.abbreviate(None, node.as_str()));
|
||||
|
||||
let datatype_selector: Element<Message> = if state.read_only {
|
||||
selected_datatype.map(text).into()
|
||||
@@ -720,6 +741,7 @@ impl Publisher {
|
||||
|
||||
let row = row![
|
||||
button_area,
|
||||
subject_input,
|
||||
predicate_input,
|
||||
predicate_label,
|
||||
object_input,
|
||||
@@ -740,7 +762,7 @@ impl Publisher {
|
||||
entities: impl IntoIterator<Item = LabeledIri>,
|
||||
) -> Element<'_, Message> {
|
||||
let buttons = entities.into_iter().map(|entity| {
|
||||
let abbreviation = self.curie_helper.abbreviate(entity.iri.as_str())
|
||||
let abbreviation = self.curie_helper.abbreviate(None, entity.iri.as_str())
|
||||
.unwrap_or_else(|| entity.iri.as_str().to_string());
|
||||
|
||||
let label = format!("{} ({})", entity.label, abbreviation);
|
||||
@@ -775,7 +797,7 @@ impl Publisher {
|
||||
.and_then(|value| value.as_str())
|
||||
.unwrap_or_default();
|
||||
|
||||
let abbreviated_iri = self.curie_helper.abbreviate(iri)
|
||||
let abbreviated_iri = self.curie_helper.abbreviate(None, iri)
|
||||
.unwrap_or_else(|| iri.to_string());
|
||||
|
||||
button(text(abbreviated_iri).wrapping(Wrapping::Word))
|
||||
@@ -830,7 +852,7 @@ impl Publisher {
|
||||
|
||||
let reindex_ontology_button = button("Rebuild index").on_press(Message::RebuildIndex);
|
||||
|
||||
let address_input = iri_input(&self.curie_helper, "URL", &self.url_input)
|
||||
let address_input = iri_input(&self.curie_helper, "URL", None, &self.url_input)
|
||||
.on_input(Message::URLInputChanged)
|
||||
.on_submit(Message::URLInputSubmitted)
|
||||
.on_control_click(Message::OpenQueryWindow(SearchResultClickAction::URLInput));
|
||||
|
||||
Reference in New Issue
Block a user