-
-
Notifications
You must be signed in to change notification settings - Fork 356
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
supporting "percentage fee" additional items (#1357)
* initial work for supporting "percentage fee" additional items * WIP list page * WIP: preview markdown content * WIP edit form * add available quantity * improve styling * fix reservation API * fix list + add * fix error when defining decimal percentage * fields validation * edit / delete item * fix compilation issue * fix broken test * reload list on save * implement feedback; remove growl * fix compilation errors after merge * fix form errors * public UI modifications * apply suggested modifications * fix sonar warnings
- Loading branch information
Showing
78 changed files
with
2,712 additions
and
1,454 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
73 changes: 73 additions & 0 deletions
73
frontend/admin/src/display-common-mark-preview/display-common-mark-preview.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
import {customElement, property, state} from "lit/decorators.js"; | ||
import {unsafeHTML} from 'lit/directives/unsafe-html.js'; | ||
import {css, html, LitElement, TemplateResult} from "lit"; | ||
import {Task} from "@lit/task"; | ||
import {UtilService} from "../service/util.ts"; | ||
import {row} from "../styles.ts"; | ||
|
||
@customElement('alfio-display-commonmark-preview') | ||
export class DisplayCommonMarkPreview extends LitElement { | ||
|
||
static styles = [ | ||
row, | ||
css` | ||
sl-button.left::part(base) { | ||
justify-content: start; | ||
} | ||
sl-button.right::part(base) { | ||
justify-content: end; | ||
} | ||
` | ||
] | ||
|
||
@property({ type: String, attribute: 'data-button-text' }) | ||
buttonText?: string; | ||
|
||
@property({ type: String, attribute: 'data-text' }) | ||
text?: string; | ||
|
||
@state() | ||
dialogOpen = false; | ||
|
||
private task?: Task<ReadonlyArray<any>, string>; | ||
|
||
protected render(): TemplateResult { | ||
return html` | ||
<div class="row"> | ||
<sl-button class="left" variant="text" target="_blank" href="https://commonmark.org/help/" size="small"><sl-icon name="markdown" slot="prefix"></sl-icon> How to format text</sl-button> | ||
<sl-button class="right" variant="text" .disabled=${(this.text ?? '').trim().length === 0} @click=${this.openDialog} size="small"><sl-icon name="easel3" slot="prefix"></sl-icon> ${this.buttonText}</sl-button> | ||
</div> | ||
<sl-dialog ?open=${this.dialogOpen} label="Text Preview" style="--width: 50vw;" class="dialog-markdown-preview" > | ||
<div style="height: 50vh; border: dashed 1px var(--sl-color-neutral-200); padding: 0 1rem;"> | ||
${this.renderText()} | ||
</div> | ||
<sl-button slot="footer" variant="default" @click=${this.closeDialog}>Close</sl-button> | ||
</sl-dialog> | ||
`; | ||
} | ||
|
||
private openDialog(): void { | ||
this.dialogOpen = true; | ||
this.task = new Task<ReadonlyArray<any>, string>(this, | ||
async () => { | ||
return await UtilService.renderMarkdown(this.text!); | ||
}, () => []); | ||
} | ||
|
||
private closeDialog(): void { | ||
this.dialogOpen = false; | ||
} | ||
|
||
private renderText(): TemplateResult { | ||
return this.task?.render({ | ||
initial: () => html`init`, | ||
complete: (value) => html`${unsafeHTML(value)}` | ||
}) ?? html`error`; | ||
} | ||
} | ||
|
||
declare global { | ||
interface HTMLElementTagNameMap { | ||
'alfio-display-commonmark-preview': DisplayCommonMarkPreview | ||
} | ||
} |
Oops, something went wrong.