web/admin: fix Forms with file uploads not handling errors correctly
Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
parent
fb70769358
commit
8f5af464a2
|
@ -53,41 +53,37 @@ export class ApplicationForm extends ModelForm<Application, string> {
|
|||
return super.styles.concat(PFDropdown);
|
||||
}
|
||||
|
||||
send = (data: Application): Promise<Application | void> => {
|
||||
let writeOp: Promise<Application>;
|
||||
send = async (data: Application): Promise<Application | void> => {
|
||||
let app: Application;
|
||||
if (this.instance) {
|
||||
writeOp = new CoreApi(DEFAULT_CONFIG).coreApplicationsUpdate({
|
||||
app = await new CoreApi(DEFAULT_CONFIG).coreApplicationsUpdate({
|
||||
slug: this.instance.slug,
|
||||
applicationRequest: data,
|
||||
});
|
||||
} else {
|
||||
writeOp = new CoreApi(DEFAULT_CONFIG).coreApplicationsCreate({
|
||||
app = await new CoreApi(DEFAULT_CONFIG).coreApplicationsCreate({
|
||||
applicationRequest: data,
|
||||
});
|
||||
}
|
||||
return config().then((c) => {
|
||||
const c = await config();
|
||||
if (c.capabilities.includes(CapabilitiesEnum.SaveMedia)) {
|
||||
const icon = this.getFormFile();
|
||||
if (icon || this.clearIcon) {
|
||||
return writeOp.then((app) => {
|
||||
return new CoreApi(DEFAULT_CONFIG).coreApplicationsSetIconCreate({
|
||||
await new CoreApi(DEFAULT_CONFIG).coreApplicationsSetIconCreate({
|
||||
slug: app.slug,
|
||||
file: icon,
|
||||
clear: this.clearIcon,
|
||||
});
|
||||
});
|
||||
}
|
||||
} else {
|
||||
return writeOp.then((app) => {
|
||||
return new CoreApi(DEFAULT_CONFIG).coreApplicationsSetIconUrlCreate({
|
||||
await new CoreApi(DEFAULT_CONFIG).coreApplicationsSetIconUrlCreate({
|
||||
slug: app.slug,
|
||||
filePathRequest: {
|
||||
url: data.metaIcon || "",
|
||||
},
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
return app;
|
||||
};
|
||||
|
||||
groupProviders(providers: Provider[]): TemplateResult {
|
||||
|
|
|
@ -38,41 +38,37 @@ export class FlowForm extends ModelForm<Flow, string> {
|
|||
@property({ type: Boolean })
|
||||
clearBackground = false;
|
||||
|
||||
send = (data: Flow): Promise<void | Flow> => {
|
||||
let writeOp: Promise<Flow>;
|
||||
send = async (data: Flow): Promise<void | Flow> => {
|
||||
let flow: Flow;
|
||||
if (this.instance) {
|
||||
writeOp = new FlowsApi(DEFAULT_CONFIG).flowsInstancesUpdate({
|
||||
flow = await new FlowsApi(DEFAULT_CONFIG).flowsInstancesUpdate({
|
||||
slug: this.instance.slug,
|
||||
flowRequest: data,
|
||||
});
|
||||
} else {
|
||||
writeOp = new FlowsApi(DEFAULT_CONFIG).flowsInstancesCreate({
|
||||
flow = await new FlowsApi(DEFAULT_CONFIG).flowsInstancesCreate({
|
||||
flowRequest: data,
|
||||
});
|
||||
}
|
||||
return config().then((c) => {
|
||||
const c = await config();
|
||||
if (c.capabilities.includes(CapabilitiesEnum.SaveMedia)) {
|
||||
const icon = this.getFormFile();
|
||||
if (icon || this.clearBackground) {
|
||||
return writeOp.then((app) => {
|
||||
return new FlowsApi(DEFAULT_CONFIG).flowsInstancesSetBackgroundCreate({
|
||||
slug: app.slug,
|
||||
await new FlowsApi(DEFAULT_CONFIG).flowsInstancesSetBackgroundCreate({
|
||||
slug: flow.slug,
|
||||
file: icon,
|
||||
clear: this.clearBackground,
|
||||
});
|
||||
});
|
||||
}
|
||||
} else {
|
||||
return writeOp.then((app) => {
|
||||
return new FlowsApi(DEFAULT_CONFIG).flowsInstancesSetBackgroundUrlCreate({
|
||||
slug: app.slug,
|
||||
await new FlowsApi(DEFAULT_CONFIG).flowsInstancesSetBackgroundUrlCreate({
|
||||
slug: flow.slug,
|
||||
filePathRequest: {
|
||||
url: data.background || "",
|
||||
},
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
return flow;
|
||||
};
|
||||
|
||||
renderDesignations(): TemplateResult {
|
||||
|
|
Reference in a new issue