Allow action URIs to be retrieved without errors if they are missing

thingActionUrl may now be told to return `undefined` insstead of throwing an error if the action is missing.
This commit is contained in:
Richard Bowman 2024-01-17 13:43:22 +00:00
parent 653e1a4159
commit 0b45a5dc76
2 changed files with 3 additions and 2 deletions

View file

@ -71,12 +71,12 @@ Vue.mixin({
} }
await axios.put(url, value); await axios.put(url, value);
}, },
thingActionUrl(thing, action) { thingActionUrl(thing, action, allow_missing=false) {
let url = this.$store.getters["wot/thingActionUrl"]( let url = this.$store.getters["wot/thingActionUrl"](
thing, thing,
action, action,
"invokeaction", "invokeaction",
false allow_missing
); );
return url; return url;
}, },

View file

@ -120,6 +120,7 @@ export const wotStoreModule = {
export function findFormHref(affordance, op) { export function findFormHref(affordance, op) {
// Find the form in the affordance that matches the given operation type // Find the form in the affordance that matches the given operation type
if (affordance == undefined) return undefined;
let forms = affordance.forms; let forms = affordance.forms;
let matchingForm = forms.find(f => f.op == op || f.op.includes(op)); let matchingForm = forms.find(f => f.op == op || f.op.includes(op));
if (matchingForm == undefined) return undefined; if (matchingForm == undefined) return undefined;