web/admin: default FlowStageBinding's order to 0

Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
Jens Langhammer 2021-04-04 13:19:52 +02:00
parent 616b1f4a05
commit 97ea859315
2 changed files with 5 additions and 1 deletions

View file

@ -87,7 +87,7 @@ export class FlowForm extends Form<Flow> {
<p class="pf-c-form__helper-text">${t`Shown as the Title in Flow pages.`}</p>
</ak-form-element-horizontal>
<ak-form-element-horizontal
label=${t`Name`}
label=${t`Slug`}
?required=${true}
name="slug">
<input type="text" value="${ifDefined(this.flow?.slug)}" class="pf-c-form-control" required>

View file

@ -41,6 +41,7 @@ export class StageBindingForm extends Form<FlowStageBinding> {
groupStages(stages: Stage[]): TemplateResult {
return html`
<option value="">---------</option>
${groupBy<Stage>(stages, (s => s.verboseName || "")).map(([group, stages]) => {
return html`<optgroup label=${group}>
${stages.map(stage => {
@ -60,6 +61,9 @@ export class StageBindingForm extends Form<FlowStageBinding> {
target: this.targetPk || "",
}).then(bindings => {
const orders = bindings.results.map(binding => binding.order);
if (orders.length < 1) {
return 0;
}
return Math.max(...orders) + 1;
});
}