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 count = store.count("presets", filter);
|
||||||
|
|
||||||
|
const userDefinedProvisions: Set<string> = new Set();
|
||||||
const provisions = store.fetch("provisions", true);
|
const provisions = store.fetch("provisions", true);
|
||||||
if (provisions.fulfilled) {
|
if (provisions.fulfilled) {
|
||||||
const provisionAttr = attributes.find(attr => {
|
const provisionAttr = attributes.find(attr => {
|
||||||
@@ -227,7 +228,10 @@ export const component: ClosureComponent = (): Component => {
|
|||||||
"instances"
|
"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);
|
provisionAttr["options"] = Array.from(provisionIds);
|
||||||
}
|
}
|
||||||
@@ -235,19 +239,35 @@ export const component: ClosureComponent = (): Component => {
|
|||||||
const downloadUrl = getDownloadUrl(filter);
|
const downloadUrl = getDownloadUrl(filter);
|
||||||
|
|
||||||
const valueCallback = (attr, preset): {} => {
|
const valueCallback = (attr, preset): {} => {
|
||||||
if (attr.id !== "precondition") return preset[attr.id];
|
if (attr.id === "precondition") {
|
||||||
let devicesUrl = "/#!/devices";
|
let devicesUrl = "/#!/devices";
|
||||||
if (preset["precondition"].length) {
|
if (preset["precondition"].length) {
|
||||||
devicesUrl += `?${m.buildQueryString({
|
devicesUrl += `?${m.buildQueryString({
|
||||||
filter: preset["precondition"]
|
filter: preset["precondition"]
|
||||||
})}`;
|
})}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
return m(
|
return m(
|
||||||
"a",
|
"a",
|
||||||
{ href: devicesUrl, title: preset["precondition"] },
|
{ href: devicesUrl, title: preset["precondition"] },
|
||||||
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 = {};
|
const attrs = {};
|
||||||
|
|||||||
Reference in new issue
Block a user