Skip to content

Commit

Permalink
Merged PR 12280: Fix validation error and add small features
Browse files Browse the repository at this point in the history
Apply several changes:

- Fix validation inside blocklist
- Add titles to icons for tooltips
- Add a button to remove the icon
- Update frontend dependencies
  • Loading branch information
D-Inventor committed Apr 9, 2024
1 parent 9011fe3 commit 541f5df
Show file tree
Hide file tree
Showing 11 changed files with 1,411 additions and 1,291 deletions.
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
<ng-icomoonpicker-editor></ng-icomoonpicker-editor>
<ng-form name="icomoonEditorForm">
<input type="hidden" name="modelValue" ng-model="model.value" ng-required="model.validation.mandatory" />
</ng-form>

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
<ng-icomoonpicker-editor></ng-icomoonpicker-editor>
<ng-form name="icomoonEditorForm">
<input type="hidden" name="modelValue" ng-model="model.value" ng-required="model.validation.mandatory" />
</ng-form>
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export function AngularBridgeMixin<TBase extends LitElementConstructor>(

protected render(): unknown {
return html`
<angular-icon-registry> ${contentTemplate} </angular-icon-registry>
<ic-icomoonpicker-angular-icon-registry> ${contentTemplate} </ic-icomoonpicker-angular-icon-registry>
`;
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class AngularIconRegistry extends UUIIconRegistry {
}
}

export const AngularIconRegistryElementTag = "angular-icon-registry";
export const AngularIconRegistryElementTag = "ic-icomoonpicker-angular-icon-registry";

@customElement(AngularIconRegistryElementTag)
export class AngularIconRegistryElement extends LitElement {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { IScope } from "@/models/scope.model";
import { IcomoonService } from "@/services/icomoon.service";
import { cloneSvgNode } from "@/util/clonesvgnode.util";
import { consume } from "@lit/context";
import { LitElement, css, html, svg } from "lit";
import { LitElement, css, html, nothing, svg } from "lit";
import { customElement, state } from "lit/decorators.js";

export const ContentElementTag = "ic-icomoonpicker-editor-content";
Expand Down Expand Up @@ -66,15 +66,19 @@ export class IcomoonPickerContent extends LitElement {
}

submitPanel = (value: string) => {
this.model = value;
this.$scope.model.value = this.model;
this.setValue(value);
this.closePanel();
};

closePanel = () => {
this.editorService!.close();
};

setValue = (value: string) => {
this.model = value;
this.$scope.model.value = this.model;
}

async getIcons() {
if (!this.$scope?.$parent.model.config)
throw new Error("This element requires icomoon config");
Expand All @@ -99,9 +103,23 @@ export class IcomoonPickerContent extends LitElement {
}
}

resetButtonOrNothing() {

if (this.model.length){
return html`
<uui-button look="secondary"
label="Click here to make this value empty"
@click=${() => this.setValue('')}>
<span><uui-icon name="icon-trash"></uui-icon>Remove</span>
</uui-button>`
}

return nothing;
}

loadedContent() {
return html` ${!this.model
? html`<p>no icon selected</p>`
? html`<p>No icon selected</p>`
: svg`<svg class=${`icomoon-icon ${this.model}`}>
<use href=${`#${this.model}`}></use>
</svg>`}
Expand All @@ -111,8 +129,9 @@ export class IcomoonPickerContent extends LitElement {
@click=${() => this.edit()}
?disabled=${this.loading}
>
<span><uui-icon name="icon-edit"></uui-icon>edit</span>
</uui-button>`;
<span><uui-icon name="icon-edit"></uui-icon>Edit</span>
</uui-button>
${this.resetButtonOrNothing()}`;
}

protected render() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,21 +57,38 @@ export class IcomoonPickerContent extends LitElement {
this.$scope!.model.submit(icon);
}

getName(icon: string) {
if (icon.startsWith('icon-')) {
icon = icon.substring(5);
}

icon = icon.replaceAll('-', ' ');
return icon;
}

renderSvg(icon: string): unknown {

return svg`
<svg
class="icomoon-icon ${icon}"
@click=${() => this.select(icon)}
>
<use href=${`#${icon}`}></use>
</svg>`
}

protected render() {
return html`
<uui-box
headline=${ifDefined(this.$scope?.model.title)}
headline-variant="h1"
>
<div class="umb-iconpicker">
${this.icons.map(
(icon) => svg`<svg
class=${`icomoon-icon ${icon}`}
@click=${() => this.select(icon)}
>
<use href=${`#${icon}`}></use>
</svg>`
)}
${this.icons.map((icon) => html`
<div title=${this.getName(icon)}>
${this.renderSvg(icon)}
</div>`
)}
</div>
</uui-box>
`;
Expand Down
Loading

0 comments on commit 541f5df

Please sign in to comment.