Fix error editing preset when missing permissions

This commit is contained in:
Shweelan Samson authored and Zaid Abdulla committed 2019-07-24 03:02:03 -07:00
1 parent 2a3d155e85
commit 9a5f259c87
2 files changed
+21 -12

No files matched your search

+7 -7
View File
@@ -212,11 +212,6 @@ export const component: ClosureComponent = (): Component => {
const count = store.count("presets", filter); const count = store.count("presets", filter);
const userDefinedProvisions: Set<string> = new Set(); const userDefinedProvisions: Set<string> = new Set();
const provisions = store.fetch("provisions", true);
if (provisions.fulfilled) {
const provisionAttr = attributes.find(attr => {
return attr.id === "provision";
});
const provisionIds = new Set([ const provisionIds = new Set([
"refresh", "refresh",
@@ -228,14 +223,19 @@ export const component: ClosureComponent = (): Component => {
"instances" "instances"
]); ]);
const provisions = store.fetch("provisions", true);
if (provisions.fulfilled) {
for (const p of provisions.value) { for (const p of provisions.value) {
userDefinedProvisions.add(p["_id"]); userDefinedProvisions.add(p["_id"]);
provisionIds.add(p["_id"]); provisionIds.add(p["_id"]);
} }
provisionAttr["options"] = Array.from(provisionIds);
} }
const provisionAttr = attributes.find(attr => {
return attr.id === "provision";
});
provisionAttr["options"] = Array.from(provisionIds);
const downloadUrl = getDownloadUrl(filter); const downloadUrl = getDownloadUrl(filter);
const valueCallback = (attr, preset): {} => { const valueCallback = (attr, preset): {} => {
+14 -5
View File
@@ -32,12 +32,18 @@ const singular = {
function createField(current, attr, focus): Children { function createField(current, attr, focus): Children {
if (attr.type === "combo") { if (attr.type === "combo") {
const options = [m("option", { value: "" }, "--Please choose--")];
for (const op of attr.options) options.push(m("option", { value: op }, op));
let selected = ""; let selected = "";
if (attr.options.includes(current.object[attr.id])) let optionsValues = attr.options;
if (current.object[attr.id] != null) {
if (!optionsValues.includes(current.object[attr.id]))
optionsValues = optionsValues.concat([current.object[attr.id]]);
selected = current.object[attr.id]; selected = current.object[attr.id];
}
const options = [m("option", { value: "" }, "")];
for (const op of optionsValues)
options.push(m("option", { value: op }, op));
return m( return m(
"select", "select",
{ {
@@ -56,8 +62,11 @@ function createField(current, attr, focus): Children {
options options
); );
} else if (attr.type === "multi") { } else if (attr.type === "multi") {
const optionsValues = Array.from(
new Set(attr.options.concat(current.object[attr.id] || []))
);
const currentSelected = new Set(current.object[attr.id]); const currentSelected = new Set(current.object[attr.id]);
const options = attr.options.map(op => { const options = optionsValues.map(op => {
const id = `${attr.id}-${op}`; const id = `${attr.id}-${op}`;
const opts = { const opts = {
type: "checkbox", type: "checkbox",