Skip to content

Commit

Permalink
Merge branch 'release/6.6.10'
Browse files Browse the repository at this point in the history
  • Loading branch information
jorg-vr committed Mar 23, 2023
2 parents 7109b8b + 7fa364b commit 60e1008
Show file tree
Hide file tree
Showing 48 changed files with 1,197 additions and 248 deletions.
112 changes: 56 additions & 56 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,67 +2,67 @@ GEM
remote: https://rubygems.org/
specs:
ace-rails-ap (4.5)
actioncable (7.0.4.2)
actionpack (= 7.0.4.2)
activesupport (= 7.0.4.2)
actioncable (7.0.4.3)
actionpack (= 7.0.4.3)
activesupport (= 7.0.4.3)
nio4r (~> 2.0)
websocket-driver (>= 0.6.1)
actionmailbox (7.0.4.2)
actionpack (= 7.0.4.2)
activejob (= 7.0.4.2)
activerecord (= 7.0.4.2)
activestorage (= 7.0.4.2)
activesupport (= 7.0.4.2)
actionmailbox (7.0.4.3)
actionpack (= 7.0.4.3)
activejob (= 7.0.4.3)
activerecord (= 7.0.4.3)
activestorage (= 7.0.4.3)
activesupport (= 7.0.4.3)
mail (>= 2.7.1)
net-imap
net-pop
net-smtp
actionmailer (7.0.4.2)
actionpack (= 7.0.4.2)
actionview (= 7.0.4.2)
activejob (= 7.0.4.2)
activesupport (= 7.0.4.2)
actionmailer (7.0.4.3)
actionpack (= 7.0.4.3)
actionview (= 7.0.4.3)
activejob (= 7.0.4.3)
activesupport (= 7.0.4.3)
mail (~> 2.5, >= 2.5.4)
net-imap
net-pop
net-smtp
rails-dom-testing (~> 2.0)
actionpack (7.0.4.2)
actionview (= 7.0.4.2)
activesupport (= 7.0.4.2)
actionpack (7.0.4.3)
actionview (= 7.0.4.3)
activesupport (= 7.0.4.3)
rack (~> 2.0, >= 2.2.0)
rack-test (>= 0.6.3)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.2.0)
actiontext (7.0.4.2)
actionpack (= 7.0.4.2)
activerecord (= 7.0.4.2)
activestorage (= 7.0.4.2)
activesupport (= 7.0.4.2)
actiontext (7.0.4.3)
actionpack (= 7.0.4.3)
activerecord (= 7.0.4.3)
activestorage (= 7.0.4.3)
activesupport (= 7.0.4.3)
globalid (>= 0.6.0)
nokogiri (>= 1.8.5)
actionview (7.0.4.2)
activesupport (= 7.0.4.2)
actionview (7.0.4.3)
activesupport (= 7.0.4.3)
builder (~> 3.1)
erubi (~> 1.4)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.1, >= 1.2.0)
activejob (7.0.4.2)
activesupport (= 7.0.4.2)
activejob (7.0.4.3)
activesupport (= 7.0.4.3)
globalid (>= 0.3.6)
activemodel (7.0.4.2)
activesupport (= 7.0.4.2)
activerecord (7.0.4.2)
activemodel (= 7.0.4.2)
activesupport (= 7.0.4.2)
activestorage (7.0.4.2)
actionpack (= 7.0.4.2)
activejob (= 7.0.4.2)
activerecord (= 7.0.4.2)
activesupport (= 7.0.4.2)
activemodel (7.0.4.3)
activesupport (= 7.0.4.3)
activerecord (7.0.4.3)
activemodel (= 7.0.4.3)
activesupport (= 7.0.4.3)
activestorage (7.0.4.3)
actionpack (= 7.0.4.3)
activejob (= 7.0.4.3)
activerecord (= 7.0.4.3)
activesupport (= 7.0.4.3)
marcel (~> 1.0)
mini_mime (>= 1.1.0)
activesupport (7.0.4.2)
activesupport (7.0.4.3)
concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (>= 1.6, < 2)
minitest (>= 5.1)
Expand Down Expand Up @@ -254,7 +254,7 @@ GEM
method_source (1.0.0)
mini_magick (4.11.0)
mini_mime (1.1.2)
minitest (5.17.0)
minitest (5.18.0)
minitest-ci (3.4.0)
minitest (>= 5.0.6)
minitest-utils (0.4.8)
Expand Down Expand Up @@ -338,7 +338,7 @@ GEM
pundit (2.3.0)
activesupport (>= 3.0.0)
racc (1.6.2)
rack (2.2.6.3)
rack (2.2.6.4)
rack-mini-profiler (3.0.0)
rack (>= 1.2.0)
rack-oauth2 (1.21.3)
Expand All @@ -349,22 +349,22 @@ GEM
rack (>= 2.1.0)
rack-protection (3.0.4)
rack
rack-test (2.0.2)
rack-test (2.1.0)
rack (>= 1.3)
rails (7.0.4.2)
actioncable (= 7.0.4.2)
actionmailbox (= 7.0.4.2)
actionmailer (= 7.0.4.2)
actionpack (= 7.0.4.2)
actiontext (= 7.0.4.2)
actionview (= 7.0.4.2)
activejob (= 7.0.4.2)
activemodel (= 7.0.4.2)
activerecord (= 7.0.4.2)
activestorage (= 7.0.4.2)
activesupport (= 7.0.4.2)
rails (7.0.4.3)
actioncable (= 7.0.4.3)
actionmailbox (= 7.0.4.3)
actionmailer (= 7.0.4.3)
actionpack (= 7.0.4.3)
actiontext (= 7.0.4.3)
actionview (= 7.0.4.3)
activejob (= 7.0.4.3)
activemodel (= 7.0.4.3)
activerecord (= 7.0.4.3)
activestorage (= 7.0.4.3)
activesupport (= 7.0.4.3)
bundler (>= 1.15.0)
railties (= 7.0.4.2)
railties (= 7.0.4.3)
rails-controller-testing (1.0.5)
actionpack (>= 5.0.1.rc1)
actionview (>= 5.0.1.rc1)
Expand All @@ -377,9 +377,9 @@ GEM
rails-i18n (7.0.6)
i18n (>= 0.7, < 2)
railties (>= 6.0.0, < 8)
railties (7.0.4.2)
actionpack (= 7.0.4.2)
activesupport (= 7.0.4.2)
railties (7.0.4.3)
actionpack (= 7.0.4.3)
activesupport (= 7.0.4.3)
method_source
rake (>= 12.2)
thor (~> 1.0)
Expand Down
70 changes: 70 additions & 0 deletions app/assets/javascripts/components/copy_button.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
import { ShadowlessLitElement } from "components/shadowless_lit_element";
import { html, PropertyValues, TemplateResult } from "lit";
import { customElement, property } from "lit/decorators.js";
import { initTooltips, ready } from "util.js";

/**
* A button that copies the text content of a given element to the clipboard.
* The button is styled as a small icon button.
* The button is a tooltip that shows the current status of the copy operation.
*
* @element d-copy-button
*
* @property {HTMLElement} codeElement - The element whose text content is copied to the clipboard.
*/
@customElement("d-copy-button")
export class CopyButton extends ShadowlessLitElement {
@property({ type: Object })
codeElement: HTMLElement;

get code(): string {
return this.codeElement.textContent;
}

@property({ state: true })
status: "idle" | "success" | "error" = "idle";

async copyCode(): Promise<void> {
try {
await navigator.clipboard.writeText(this.code);
this.status = "success";
} catch (err) {
window.getSelection().selectAllChildren(this.codeElement);
this.status = "error";
}
}

get tooltip(): string {
switch (this.status) {
case "success":
return I18n.t("js.copy-success");
case "error":
return I18n.t("js.copy-fail");
default:
return I18n.t("js.code.copy-to-clipboard");
}
}

protected updated(_changedProperties: PropertyValues): void {
super.updated(_changedProperties);
initTooltips(this);
}

constructor() {
super();

// Reload when I18n is loaded
ready.then(() => this.requestUpdate());
}

protected render(): TemplateResult {
return html`<button class="btn btn-icon copy-btn"
@click=${() => this.copyCode()}
@focusout=${() => this.status = "idle"}
data-bs-placement="top"
data-bs-toggle="tooltip"
title="${this.tooltip}">
<i class="mdi mdi-clipboard-outline"></i>
</button>`;
}
}
8 changes: 5 additions & 3 deletions app/assets/javascripts/components/filter_button.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ export class FilterButton extends LitElement {
value: string;
@property({ type: Boolean })
multi = false;
@property({ type: Object })
searchQuery = searchQuery;

static styles = css`
:host {
Expand All @@ -33,11 +35,11 @@ export class FilterButton extends LitElement {

addFilter(): void {
if (this.multi) {
const selected = new Set(searchQuery.arrayQueryParams.params.get(this.param));
const selected = new Set(this.searchQuery.arrayQueryParams.params.get(this.param));
selected.add(this.value);
searchQuery.arrayQueryParams.updateParam(this.param, Array.from(selected));
this.searchQuery.arrayQueryParams.updateParam(this.param, Array.from(selected));
} else {
searchQuery.queryParams.updateParam(this.param, this.value);
this.searchQuery.queryParams.updateParam(this.param, this.value);
}
}

Expand Down
22 changes: 12 additions & 10 deletions app/assets/javascripts/components/filter_collection_element.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { property } from "lit/decorators.js";
import { searchQuery } from "search";
import { SearchQuery, searchQuery } from "search";
import { ShadowlessLitElement } from "components/shadowless_lit_element";

export type Label = {id: string, name: string};
Expand Down Expand Up @@ -30,13 +30,15 @@ export class FilterCollectionElement extends ShadowlessLitElement {
paramVal: (l: Label) => string;
@property({ type: Array })
labels: Array<Label> = [];
@property({ type: Object })
searchQuery: SearchQuery = searchQuery;
@property({ state: true })
private multiSelected: string[] = [];
@property({ state: true })
private singleSelected = "";

update(changedProperties: Map<string, unknown>): void {
if ((changedProperties.has("param") || changedProperties.has("multi")) &&
if ((changedProperties.has("param") || changedProperties.has("multi") || changedProperties.has("searchQuery")) &&
this.param !== undefined && this.multi !== undefined) {
if (this.multi) {
this.multiSubscribeToQueryParams();
Expand All @@ -58,39 +60,39 @@ export class FilterCollectionElement extends ShadowlessLitElement {
}

private multiUnSelect(label: Label): void {
searchQuery.arrayQueryParams.updateParam(this.param, this.multiSelected.filter(s => s !== this.str(label)));
this.searchQuery.arrayQueryParams.updateParam(this.param, this.multiSelected.filter(s => s !== this.str(label)));
}

private multiIsSelected(label: Label): boolean {
return this.multiSelected.includes(this.str(label));
}

private multiSelect(label: Label): void {
searchQuery.arrayQueryParams.updateParam(this.param, [...this.multiSelected, this.str(label)]);
this.searchQuery.arrayQueryParams.updateParam(this.param, [...this.multiSelected, this.str(label)]);
}

private multiSubscribeToQueryParams(): void {
this.multiSelected = searchQuery.arrayQueryParams.params.get(this.param) || [];
searchQuery.arrayQueryParams.subscribeByKey(this.param, (k, o, n) => {
this.multiSelected = this.searchQuery.arrayQueryParams.params.get(this.param) || [];
this.searchQuery.arrayQueryParams.subscribeByKey(this.param, (k, o, n) => {
this.multiSelected = n || [];
});
}

private singleUnSelect(label: Label): void {
searchQuery.queryParams.updateParam(this.param, undefined);
this.searchQuery.queryParams.updateParam(this.param, undefined);
}

private singleSelect(label: Label): void {
searchQuery.queryParams.updateParam(this.param, this.str(label));
this.searchQuery.queryParams.updateParam(this.param, this.str(label));
}

private singleIsSelected(label: Label): boolean {
return this.singleSelected === this.str(label);
}

private singleSubscribeToQueryParams(): void {
this.singleSelected = searchQuery.queryParams.params.get(this.param);
searchQuery.queryParams.subscribeByKey(this.param, (k, o, n) => this.singleSelected = n || "");
this.singleSelected = this.searchQuery.queryParams.params.get(this.param);
this.searchQuery.queryParams.subscribeByKey(this.param, (k, o, n) => this.singleSelected = n || "");
}

isSelected = this.singleIsSelected;
Expand Down
Loading

0 comments on commit 60e1008

Please sign in to comment.