Fix exclusion dropdown & removal in crawl config edit (#372)
* fix dialog closing on regex * fix unable to delete regex with same text
This commit is contained in:
parent
4d4ce40443
commit
13d5ab7d2b
@ -81,6 +81,8 @@ export class QueueExclusionForm extends LiteElement {
|
||||
placeholder=${msg("Select Type")}
|
||||
size="small"
|
||||
.value=${this.selectValue}
|
||||
@sl-hide=${this.stopProp}
|
||||
@sl-after-hide=${this.stopProp}
|
||||
@sl-select=${(e: any) => {
|
||||
this.selectValue = e.target.value;
|
||||
}}
|
||||
@ -223,4 +225,13 @@ export class QueueExclusionForm extends LiteElement {
|
||||
}) as ExclusionAddEvent
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Stop propgation of sl-select events.
|
||||
* Prevents bug where sl-dialog closes when dropdown closes
|
||||
* https://github.com/shoelace-style/shoelace/issues/170
|
||||
*/
|
||||
private stopProp(e: CustomEvent) {
|
||||
e.stopPropagation();
|
||||
}
|
||||
}
|
||||
|
||||
@ -9,7 +9,7 @@ import { regexEscape } from "../utils/string";
|
||||
import type { Exclusion } from "./queue-exclusion-form";
|
||||
|
||||
export type ExclusionRemoveEvent = CustomEvent<{
|
||||
value: string;
|
||||
regex: string;
|
||||
}>;
|
||||
|
||||
/**
|
||||
@ -205,12 +205,14 @@ export class QueueExclusionTable extends LiteElement {
|
||||
return [typeColClass, valueColClass, actionColClass];
|
||||
}
|
||||
|
||||
private removeExclusion(exclusion: Exclusion) {
|
||||
this.exclusionToRemove = exclusion.value;
|
||||
private removeExclusion({ value, type }: Exclusion) {
|
||||
this.exclusionToRemove = value;
|
||||
|
||||
this.dispatchEvent(
|
||||
new CustomEvent("on-remove", {
|
||||
detail: exclusion,
|
||||
detail: {
|
||||
regex: type == "text" ? regexEscape(value) : value,
|
||||
},
|
||||
}) as ExclusionRemoveEvent
|
||||
);
|
||||
}
|
||||
|
||||
@ -1062,7 +1062,7 @@ export class CrawlTemplatesDetail extends LiteElement {
|
||||
editable
|
||||
@on-remove=${(e: ExclusionRemoveEvent) => {
|
||||
if (!this.exclusions) return;
|
||||
const { value } = e.detail;
|
||||
const { regex: value } = e.detail;
|
||||
this.exclusions = this.exclusions.filter((v) => v !== value);
|
||||
}}
|
||||
></btrix-queue-exclusion-table>
|
||||
|
||||
@ -537,9 +537,9 @@ export class CrawlTemplatesNew extends LiteElement {
|
||||
}
|
||||
|
||||
private handleRemoveRegex(e: ExclusionRemoveEvent) {
|
||||
const { value } = e.detail;
|
||||
if (!this.exclusions || !value) return;
|
||||
this.exclusions = this.exclusions.filter((v) => v !== value);
|
||||
const { regex } = e.detail;
|
||||
if (!this.exclusions || !regex) return;
|
||||
this.exclusions = this.exclusions.filter((v) => v !== regex);
|
||||
}
|
||||
|
||||
private handleAddRegex(e: ExclusionAddEvent) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user