mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-10-31 21:27:00 -06:00
Graphic Styles: addFromLibrary treats ids: null as left out
graphicStyle.addFromLibrary with apply: true and ids: null tried to apply the style to no objects and failed with "no such objects" when nothing was selected. A null `ids` now behaves as leaving `ids` out: the style is applied to the selection when there is one, and only added otherwise.
This commit is contained in:
@@ -194,10 +194,11 @@ fn add(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
"existing": existing.iter().map(|g| &g.name).collect::<Vec<_>>(),
|
||||
});
|
||||
let first = picked.first().map(|g| doc_name(&g.name));
|
||||
let targets = p.get("ids").is_some() || !super::appearance::appearance_targets(s, &json!({}))?.is_empty();
|
||||
let ids = p.get("ids").filter(|v| !v.is_null());
|
||||
let targets = ids.is_some() || !super::appearance::appearance_targets(s, &json!({}))?.is_empty();
|
||||
if let Some(name) = first.filter(|_| apply && targets) {
|
||||
let mut params = json!({"name": name, "add": add});
|
||||
if let Some(ids) = p.get("ids") {
|
||||
if let Some(ids) = ids {
|
||||
params["ids"] = ids.clone();
|
||||
}
|
||||
s.execute("graphicStyle.apply", ¶ms)?;
|
||||
|
||||
Reference in New Issue
Block a user