Make provision name in presets page as hyperlink
This commit is contained in:
1 parent
6d5d94652e
commit
ebff97e795
1 file changed
+33
-13
+33
-13
@@ -211,6 +211,7 @@ export const component: ClosureComponent = (): Component => {
|
||||
});
|
||||
const count = store.count("presets", filter);
|
||||
|
||||
const userDefinedProvisions: Set<string> = new Set();
|
||||
const provisions = store.fetch("provisions", true);
|
||||
if (provisions.fulfilled) {
|
||||
const provisionAttr = attributes.find(attr => {
|
||||
@@ -227,7 +228,10 @@ export const component: ClosureComponent = (): Component => {
|
||||
"instances"
|
||||
]);
|
||||
|
||||
for (const p of provisions.value) provisionIds.add(p["_id"]);
|
||||
for (const p of provisions.value) {
|
||||
userDefinedProvisions.add(p["_id"]);
|
||||
provisionIds.add(p["_id"]);
|
||||
}
|
||||
|
||||
provisionAttr["options"] = Array.from(provisionIds);
|
||||
}
|
||||
@@ -235,19 +239,35 @@ export const component: ClosureComponent = (): Component => {
|
||||
const downloadUrl = getDownloadUrl(filter);
|
||||
|
||||
const valueCallback = (attr, preset): {} => {
|
||||
if (attr.id !== "precondition") return preset[attr.id];
|
||||
let devicesUrl = "/#!/devices";
|
||||
if (preset["precondition"].length) {
|
||||
devicesUrl += `?${m.buildQueryString({
|
||||
filter: preset["precondition"]
|
||||
})}`;
|
||||
}
|
||||
if (attr.id === "precondition") {
|
||||
let devicesUrl = "/#!/devices";
|
||||
if (preset["precondition"].length) {
|
||||
devicesUrl += `?${m.buildQueryString({
|
||||
filter: preset["precondition"]
|
||||
})}`;
|
||||
}
|
||||
|
||||
return m(
|
||||
"a",
|
||||
{ href: devicesUrl, title: preset["precondition"] },
|
||||
preset["precondition"]
|
||||
);
|
||||
return m(
|
||||
"a",
|
||||
{ href: devicesUrl, title: preset["precondition"] },
|
||||
preset["precondition"]
|
||||
);
|
||||
} else if (
|
||||
attr.id === "provision" &&
|
||||
userDefinedProvisions.has(preset[attr.id])
|
||||
) {
|
||||
return m(
|
||||
"a",
|
||||
{
|
||||
href: `/#!/admin/provisions?${m.buildQueryString({
|
||||
filter: `Q("ID", "${preset["provision"]}")`
|
||||
})}`
|
||||
},
|
||||
preset["provision"]
|
||||
);
|
||||
} else {
|
||||
return preset[attr.id];
|
||||
}
|
||||
};
|
||||
|
||||
const attrs = {};
|
||||
|
||||
Reference in new issue
Block a user