@zywave/notes-widget
Advanced tools
Comparing version 1.0.0 to 1.0.1
import { LitElement } from 'lit'; | ||
import './truncated-text.js'; | ||
import '@lit-labs/virtualizer'; | ||
import './components/note-dialog.js'; | ||
import './components/note-expander.js'; | ||
export declare class NotesWidget extends LitElement { | ||
static styles: import("lit").CSSResult; | ||
agencyId: number; | ||
private loading; | ||
private notes; | ||
private currentExpandedNote; | ||
firstUpdated(): void; | ||
render(): import("lit").TemplateResult<1>; | ||
private handleNoteExpanderChange; | ||
private accountId; | ||
private numberOfNotes; | ||
private notesUri; | ||
private _expandedNotes; | ||
private _addNoteDialog; | ||
private _loadNotesTask; | ||
private _notes; | ||
firstUpdated(): Promise<void>; | ||
disconnectedCallback(): void; | ||
render(): unknown; | ||
private renderTopbar; | ||
private renderNote; | ||
private renderNoteLabels; | ||
private handleNoteExpanderChange; | ||
private showNotification; | ||
private loadNotes; | ||
private openAddNoteDialog; | ||
private addCreatedNoteToList; | ||
} | ||
@@ -18,0 +24,0 @@ declare global { |
@@ -7,13 +7,28 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { | ||
}; | ||
import { LitElement, html, css, nothing } from 'lit'; | ||
import { property, customElement, state } from 'lit/decorators.js'; | ||
import { map } from 'lit/directives/map.js'; | ||
import './truncated-text.js'; | ||
import { client } from './client.js'; | ||
import { LitElement, html, css } from 'lit'; | ||
import { property, customElement, state, query } from 'lit/decorators.js'; | ||
import { when } from 'lit/directives/when.js'; | ||
import { Task } from '@lit-labs/task'; | ||
import '@lit-labs/virtualizer'; | ||
import './components/note-dialog.js'; | ||
import './components/note-expander.js'; | ||
import { apiClient } from './api/apiClient.js'; | ||
let NotesWidget = class NotesWidget extends LitElement { | ||
constructor() { | ||
super(...arguments); | ||
this.loading = true; | ||
this.notes = new Array(); | ||
this.currentExpandedNote = null; | ||
this.accountId = 0; | ||
this.numberOfNotes = 4; | ||
this.notesUri = 'https://notes.zywave.com'; | ||
this._expandedNotes = new Set(); | ||
this._loadNotesTask = new Task(this, async () => { | ||
try { | ||
this._notes = await apiClient.loadNotes(this.accountId, this.numberOfNotes); | ||
return this._notes; | ||
} | ||
catch (error) { | ||
this.showNotification('error', 'Failure', 'Failed to load notes'); | ||
return []; | ||
} | ||
}, () => []); | ||
this._notes = []; | ||
this.showNotification = (type, header, message) => { | ||
@@ -23,53 +38,59 @@ const shell = document.querySelector('zywave-shell'); | ||
}; | ||
this.openAddNoteDialog = () => { | ||
var _a; | ||
(_a = this._addNoteDialog) === null || _a === void 0 ? void 0 : _a.open(); | ||
}; | ||
this.addCreatedNoteToList = (event) => { | ||
this._loadNotesTask = new Task(this, () => { | ||
this.showNotification("success", "Success", "Note created successfully"); | ||
var newLength = this._notes.unshift(event.detail); | ||
if (newLength > this.numberOfNotes) | ||
this._notes.pop(); | ||
return this._notes; | ||
}, () => []); | ||
}; | ||
} | ||
firstUpdated() { | ||
this.loadNotes(); | ||
async firstUpdated() { | ||
var _a; | ||
(_a = this._addNoteDialog) === null || _a === void 0 ? void 0 : _a.addEventListener('note-created', this.addCreatedNoteToList); | ||
} | ||
disconnectedCallback() { | ||
var _a; | ||
(_a = this._addNoteDialog) === null || _a === void 0 ? void 0 : _a.removeEventListener('note-created', this.addCreatedNoteToList); | ||
} | ||
render() { | ||
if (this.loading) { | ||
return html ` | ||
<zui-table> | ||
${this.renderTopbar()} | ||
<zui-table-row class="table-row-centered"> | ||
<zui-table-cell> | ||
<zui-spinner active></zui-spinner> | ||
</zui-table-cell> | ||
</zui-table-row> | ||
</zui-table> | ||
`; | ||
} | ||
if (!this.notes.length) { | ||
return html ` | ||
<zui-table> | ||
${this.renderTopbar()} | ||
<zui-table-row class="table-row-centered"> | ||
<zui-table-cell> | ||
<p>You haven't added any notes for this account yet</p> | ||
</zui-table-cell> | ||
</zui-table-row> | ||
</zui-table> | ||
`; | ||
} | ||
return html ` | ||
<note-dialog .accountId=${this.accountId}></note-dialog> | ||
<zui-table> | ||
${this.renderTopbar()} | ||
<zui-expander-group type="group-standard"> | ||
${map(this.notes, note => { | ||
return html `${this.renderNote(note)}`; | ||
${this._loadNotesTask.render({ | ||
pending: () => html ` | ||
<zui-table-row> | ||
<zui-table-cell> | ||
<zui-spinner active></zui-spinner> | ||
</zui-table-cell> | ||
</zui-table-row> | ||
`, | ||
complete: (notes) => html ` | ||
${when(!notes.length, () => html ` | ||
<zui-table-row> | ||
<zui-table-cell> | ||
<p>You haven't added any notes for this account yet</p> | ||
</zui-table-cell> | ||
</zui-table-row> | ||
`)} | ||
${when(notes.length, () => html ` | ||
<lit-virtualizer | ||
scroller | ||
.items=${notes} | ||
.renderItem=${(note) => html `${this.renderNote(note)}`} | ||
></lit-virtualizer> | ||
`)} | ||
`, | ||
})} | ||
</zui-expander-group> | ||
</zui-table> | ||
`; | ||
} | ||
handleNoteExpanderChange({ detail }, note) { | ||
var _a; | ||
const currentOpenNoteId = (_a = this.currentExpandedNote) === null || _a === void 0 ? void 0 : _a.noteId; | ||
if (!(detail === null || detail === void 0 ? void 0 : detail.open) && currentOpenNoteId && currentOpenNoteId !== note.noteId) { | ||
return; | ||
} | ||
this.currentExpandedNote = detail.open ? note : null; | ||
setTimeout(() => { | ||
window.dispatchEvent(new Event('resize')); | ||
}, 10); | ||
} | ||
renderTopbar() { | ||
@@ -80,4 +101,16 @@ return html ` | ||
<div class="topbar-actions"> | ||
<zui-button type="secondary">Add a note</zui-button> | ||
<zui-button type="secondary">View all notes</zui-button> | ||
<zui-button | ||
data-autom="notes-widget_button_add-note" | ||
type="secondary" | ||
@click=${this.openAddNoteDialog} | ||
> | ||
Add a note | ||
</zui-button> | ||
<zui-button | ||
data-autom="notes-widget_button_view-all-notes" | ||
type="secondary" | ||
> | ||
<a href=${`${this.notesUri}/account/${this.accountId}`}></a> | ||
View all notes | ||
</zui-button> | ||
</div> | ||
@@ -88,49 +121,23 @@ </zui-table-topbar> | ||
renderNote(note) { | ||
var _a; | ||
return html ` | ||
<zui-expander type="group-standard" key=${note.noteId} @openchanged=${(event) => this.handleNoteExpanderChange(event, note)}> | ||
<div slot="title"> | ||
<div class="note-title"> | ||
<h3 class="note-title-category"> | ||
<a href="#">${note === null || note === void 0 ? void 0 : note.policyName}</a> | ||
</h3> | ||
${this.renderNoteLabels(note)} | ||
</div> | ||
<p class="note-short-description"> | ||
${((_a = this.currentExpandedNote) === null || _a === void 0 ? void 0 : _a.noteId) === note.noteId ? nothing : html ` | ||
<truncated-text text=${note.text}></truncated-text> | ||
`} | ||
</p> | ||
</div> | ||
<div slot="content" class="note-content"> | ||
<p class="note-description"> | ||
<truncated-text text=${note.text} lines="7"> | ||
<zui-button type="link" slot="viewMore">View more</zui-button> | ||
</truncated-text> | ||
</p> | ||
</div> | ||
</zui-expander> | ||
`; | ||
<note-expander | ||
.notesUri=${this.notesUri} | ||
.accountId=${this.accountId} | ||
.note=${note} | ||
.expanded=${this._expandedNotes.has(note.noteId)} | ||
key=${note.noteId} | ||
@openchanged=${(event) => this.handleNoteExpanderChange(event, note)} | ||
></note-expander> | ||
`; | ||
} | ||
renderNoteLabels(note) { | ||
const isShowLabels = (note === null || note === void 0 ? void 0 : note.isAlertActive) || (note === null || note === void 0 ? void 0 : note.isConfidential); | ||
return isShowLabels ? html ` | ||
<div class="note-title-labels"> | ||
${(note === null || note === void 0 ? void 0 : note.isConfidential) ? html `<zui-tag color="gray">Confidential</zui-tag>` : nothing} | ||
${(note === null || note === void 0 ? void 0 : note.isAlertActive) ? html `<zui-tag color="blue">Alert Enabled</zui-tag>` : nothing} | ||
</div> | ||
` : null; | ||
} | ||
async loadNotes() { | ||
try { | ||
this.notes = await client.loadNotes(this.agencyId); | ||
handleNoteExpanderChange({ detail }, note) { | ||
if (detail.open) { | ||
this._expandedNotes = new Set([...this._expandedNotes, note.noteId]); | ||
} | ||
catch (error) { | ||
this.showNotification('error', 'Failure', 'Failed to load notes'); | ||
else { | ||
this._expandedNotes = new Set([...this._expandedNotes].filter((value) => value !== note.noteId)); | ||
} | ||
finally { | ||
this.loading = false; | ||
} | ||
setTimeout(() => { | ||
window.dispatchEvent(new Event('resize')); | ||
}, 10); | ||
} | ||
@@ -149,43 +156,17 @@ }; | ||
.table-row-centered { | ||
text-align: center; | ||
} | ||
.note-content { | ||
padding-top: 0; | ||
padding-bottom: 15px; | ||
padding-right: 50px; | ||
} | ||
.note-description { | ||
margin: -20px 0 0; | ||
} | ||
.note-short-description { | ||
margin: 2px 0 0; | ||
} | ||
.note-title { | ||
zui-table-row { | ||
display: flex; | ||
justify-content: center; | ||
align-items: center; | ||
width: 100%; | ||
min-height: var(--notes-widget-list-height, 350px); | ||
} | ||
.note-title-category { | ||
margin: 0; | ||
font-weight: 700; | ||
font-size: 14px; | ||
lit-virtualizer { | ||
width: 100%; | ||
min-height: var(--notes-widget-list-height, 350px) !important; | ||
} | ||
.note-title-category:hover { | ||
color: var(--zui-blue-500); | ||
cursor: pointer; | ||
} | ||
.note-title-category > a { | ||
text-decoration: none; | ||
color: inherit | ||
} | ||
.note-title-labels { | ||
margin-left: 20px; | ||
gap: 5px; | ||
display: flex; | ||
text-transform: uppercase; | ||
lit-virtualizer::-webkit-scrollbar { | ||
display: none; | ||
} | ||
@@ -195,12 +176,21 @@ `; | ||
property() | ||
], NotesWidget.prototype, "agencyId", void 0); | ||
], NotesWidget.prototype, "accountId", void 0); | ||
__decorate([ | ||
property() | ||
], NotesWidget.prototype, "numberOfNotes", void 0); | ||
__decorate([ | ||
property() | ||
], NotesWidget.prototype, "notesUri", void 0); | ||
__decorate([ | ||
state() | ||
], NotesWidget.prototype, "loading", void 0); | ||
], NotesWidget.prototype, "_expandedNotes", void 0); | ||
__decorate([ | ||
query('note-dialog') | ||
], NotesWidget.prototype, "_addNoteDialog", void 0); | ||
__decorate([ | ||
state() | ||
], NotesWidget.prototype, "notes", void 0); | ||
], NotesWidget.prototype, "_loadNotesTask", void 0); | ||
__decorate([ | ||
state() | ||
], NotesWidget.prototype, "currentExpandedNote", void 0); | ||
], NotesWidget.prototype, "_notes", void 0); | ||
NotesWidget = __decorate([ | ||
@@ -207,0 +197,0 @@ customElement('notes-widget') |
@@ -6,19 +6,50 @@ declare global { | ||
} | ||
interface WidgetEvent { | ||
target: any; | ||
type: string; | ||
} | ||
export interface NoteExpanderChangeEvent extends WidgetEvent { | ||
detail: { | ||
open: boolean; | ||
}; | ||
} | ||
export interface ToggleChangeEvent extends WidgetEvent { | ||
detail: { | ||
checked: boolean; | ||
}; | ||
} | ||
export interface InputChangeEvent extends WidgetEvent { | ||
detail: string; | ||
} | ||
export interface SelectDropdownChangeEvent extends WidgetEvent { | ||
detail: string; | ||
} | ||
export interface NoteCreatedEvent extends WidgetEvent { | ||
detail?: Note; | ||
} | ||
export interface Note { | ||
noteId: number; | ||
agencyId: number; | ||
categoryId: number; | ||
policyId: number; | ||
policyName: string; | ||
categoryName: string; | ||
text: string; | ||
isConfidential: boolean; | ||
isAlertActive?: boolean; | ||
alertDate?: Date; | ||
isAlertActive: boolean; | ||
alertDate?: string; | ||
} | ||
export interface ExpanderChangeEvent { | ||
detail: { | ||
open: boolean; | ||
}; | ||
target: any; | ||
export interface NoteCategory { | ||
categoryId: number; | ||
name: string; | ||
isActive: boolean; | ||
isConfidential: boolean; | ||
defaultNote?: string | null; | ||
} | ||
export interface CreateNoteRequest { | ||
accountId: number; | ||
categoryId: number; | ||
text: string; | ||
isConfidential: boolean; | ||
isAlertEnabled: boolean; | ||
alertDate?: string; | ||
} | ||
export {}; | ||
//# sourceMappingURL=types.d.ts.map |
{ | ||
"name": "@zywave/notes-widget", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "A custom web component for notes functionality through a widget", | ||
@@ -13,3 +13,3 @@ "main": "dist/notes-widget.js", | ||
"scripts": { | ||
"build": "tsc", | ||
"build": "tsc && npm run rollup", | ||
"build:watch": "tsc --watch", | ||
@@ -22,8 +22,8 @@ "clean": "rimraf dist/notes-widget.{d.ts,d.ts.map,js,js.map}", | ||
"docs": "npm run docs:clean && npm run build && npm run analyze && npm run docs:build && npm run docs:assets && npm run docs:gen", | ||
"docs:clean": "rimraf public", | ||
"docs:clean": "rimraf ../../../public", | ||
"docs:gen": "eleventy --config=.eleventy.cjs", | ||
"docs:gen:watch": "eleventy --config=.eleventy.cjs --watch", | ||
"docs:build": "rollup -c --file public/notes-widget.bundle.js", | ||
"docs:assets": "cp node_modules/prismjs/themes/prism-okaidia.css public/", | ||
"docs:serve": "wds --root-dir=public --node-resolve --watch", | ||
"docs:build": "rollup -c --dir ../../../public/notes-widget-bundle", | ||
"docs:assets": "cp node_modules/prismjs/themes/prism-okaidia.css ../../../public/", | ||
"docs:serve": "wds --root-dir=../../../public --node-resolve --watch", | ||
"analyze": "wca analyze \"src/**/*.ts\" --outFile custom-elements.json", | ||
@@ -72,4 +72,6 @@ "serve": "wds --watch", | ||
"dependencies": { | ||
"@lit-labs/task": "^2.0.0", | ||
"@lit-labs/virtualizer": "^0.7.2", | ||
"lit": "^2.3.1" | ||
} | ||
} |
import { LitElement, html, css, nothing } from 'lit'; | ||
import { property, customElement, state } from 'lit/decorators.js'; | ||
import { map } from 'lit/directives/map.js'; | ||
import { property, customElement, state, query } from 'lit/decorators.js'; | ||
import { when } from 'lit/directives/when.js'; | ||
import { Task } from '@lit-labs/task'; | ||
import '@lit-labs/virtualizer'; | ||
import './truncated-text.js'; | ||
import './components/note-dialog.js'; | ||
import './components/note-expander.js'; | ||
import { NoteDialog } from './components/note-dialog.js'; | ||
import { NoteExpanderChangeEvent, Note, NoteCreatedEvent } from './types'; | ||
import { apiClient } from './api/apiClient.js'; | ||
import { ExpanderChangeEvent, Note } from './types'; | ||
import { client } from './client.js'; | ||
@customElement('notes-widget') | ||
@@ -23,43 +26,17 @@ export class NotesWidget extends LitElement { | ||
.table-row-centered { | ||
text-align: center; | ||
} | ||
.note-content { | ||
padding-top: 0; | ||
padding-bottom: 15px; | ||
padding-right: 50px; | ||
} | ||
.note-description { | ||
margin: -20px 0 0; | ||
} | ||
.note-short-description { | ||
margin: 2px 0 0; | ||
} | ||
.note-title { | ||
zui-table-row { | ||
display: flex; | ||
justify-content: center; | ||
align-items: center; | ||
width: 100%; | ||
min-height: var(--notes-widget-list-height, 350px); | ||
} | ||
.note-title-category { | ||
margin: 0; | ||
font-weight: 700; | ||
font-size: 14px; | ||
lit-virtualizer { | ||
width: 100%; | ||
min-height: var(--notes-widget-list-height, 350px) !important; | ||
} | ||
.note-title-category:hover { | ||
color: var(--zui-blue-500); | ||
cursor: pointer; | ||
} | ||
.note-title-category > a { | ||
text-decoration: none; | ||
color: inherit | ||
} | ||
.note-title-labels { | ||
margin-left: 20px; | ||
gap: 5px; | ||
display: flex; | ||
text-transform: uppercase; | ||
lit-virtualizer::-webkit-scrollbar { | ||
display: none; | ||
} | ||
@@ -69,67 +46,77 @@ `; | ||
@property() | ||
agencyId: number; | ||
private accountId = 0; | ||
@property() | ||
private numberOfNotes = 4; | ||
@property() | ||
private notesUri = 'https://notes.zywave.com' | ||
@state() | ||
private loading: boolean = true; | ||
private _expandedNotes: Set<number> = new Set(); | ||
@query('note-dialog') | ||
private _addNoteDialog: NoteDialog; | ||
@state() | ||
private notes = new Array<Note>(); | ||
private _loadNotesTask = new Task( | ||
this, | ||
async () => { | ||
try { | ||
this._notes = await apiClient.loadNotes(this.accountId, this.numberOfNotes); | ||
return this._notes; | ||
} catch (error) { | ||
this.showNotification('error', 'Failure', 'Failed to load notes'); | ||
return []; | ||
} | ||
}, | ||
() => [] | ||
); | ||
@state() | ||
private currentExpandedNote: Note = null; | ||
private _notes: Note[] = []; | ||
override firstUpdated(): void { | ||
this.loadNotes(); | ||
override async firstUpdated(): Promise<void> { | ||
this._addNoteDialog?.addEventListener('note-created', this.addCreatedNoteToList); | ||
} | ||
override render() { | ||
if (this.loading) { | ||
return html` | ||
<zui-table> | ||
${this.renderTopbar()} | ||
<zui-table-row class="table-row-centered"> | ||
<zui-table-cell> | ||
<zui-spinner active></zui-spinner> | ||
</zui-table-cell> | ||
</zui-table-row> | ||
</zui-table> | ||
` | ||
} | ||
override disconnectedCallback(): void { | ||
this._addNoteDialog?.removeEventListener('note-created', this.addCreatedNoteToList); | ||
} | ||
if (!this.notes.length) { | ||
return html` | ||
<zui-table> | ||
${this.renderTopbar()} | ||
<zui-table-row class="table-row-centered"> | ||
<zui-table-cell> | ||
<p>You haven't added any notes for this account yet</p> | ||
</zui-table-cell> | ||
</zui-table-row> | ||
</zui-table> | ||
` | ||
} | ||
override render(): unknown { | ||
return html` | ||
<note-dialog .accountId=${this.accountId}></note-dialog> | ||
<zui-table> | ||
${this.renderTopbar()} | ||
<zui-expander-group type="group-standard"> | ||
${map(this.notes, note => { | ||
return html`${this.renderNote(note)}`; | ||
})} | ||
</zui-expander-group> | ||
</zui-table> | ||
` | ||
} | ||
private handleNoteExpanderChange({ detail }: ExpanderChangeEvent, note:Note): void { | ||
const currentOpenNoteId = this.currentExpandedNote?.noteId; | ||
if(!detail?.open && currentOpenNoteId && currentOpenNoteId !== note.noteId){ | ||
return; | ||
} | ||
${this._loadNotesTask.render({ | ||
pending: () => html` | ||
<zui-table-row> | ||
<zui-table-cell> | ||
<zui-spinner active></zui-spinner> | ||
</zui-table-cell> | ||
</zui-table-row> | ||
`, | ||
this.currentExpandedNote = detail.open ? note : null; | ||
setTimeout(() => { | ||
window.dispatchEvent(new Event('resize')); | ||
}, 10); | ||
complete: (notes: Note[]) => html` | ||
${when(!notes.length, () => html` | ||
<zui-table-row> | ||
<zui-table-cell> | ||
<p>You haven't added any notes for this account yet</p> | ||
</zui-table-cell> | ||
</zui-table-row> | ||
`)} | ||
${when(notes.length, () => html` | ||
<lit-virtualizer | ||
scroller | ||
.items=${notes} | ||
.renderItem=${(note: Note) => html`${this.renderNote(note)}`} | ||
></lit-virtualizer> | ||
`)} | ||
`, | ||
})} | ||
</zui-table> | ||
`; | ||
} | ||
@@ -142,4 +129,16 @@ | ||
<div class="topbar-actions"> | ||
<zui-button type="secondary">Add a note</zui-button> | ||
<zui-button type="secondary">View all notes</zui-button> | ||
<zui-button | ||
data-autom="notes-widget_button_add-note" | ||
type="secondary" | ||
@click=${this.openAddNoteDialog} | ||
> | ||
Add a note | ||
</zui-button> | ||
<zui-button | ||
data-autom="notes-widget_button_view-all-notes" | ||
type="secondary" | ||
> | ||
<a href=${`${this.notesUri}/account/${this.accountId}`}></a> | ||
View all notes | ||
</zui-button> | ||
</div> | ||
@@ -152,37 +151,23 @@ </zui-table-topbar> | ||
return html` | ||
<zui-expander type="group-standard" key=${note.noteId} @openchanged=${(event: ExpanderChangeEvent) => this.handleNoteExpanderChange(event, note)}> | ||
<div slot="title"> | ||
<div class="note-title"> | ||
<h3 class="note-title-category"> | ||
<a href="#">${note?.policyName}</a> | ||
</h3> | ||
${this.renderNoteLabels(note)} | ||
</div> | ||
<p class="note-short-description"> | ||
${this.currentExpandedNote?.noteId === note.noteId ? nothing : html` | ||
<truncated-text text=${note.text}></truncated-text> | ||
`} | ||
</p> | ||
</div> | ||
<div slot="content" class="note-content"> | ||
<p class="note-description"> | ||
<truncated-text text=${note.text} lines="7"> | ||
<zui-button type="link" slot="viewMore">View more</zui-button> | ||
</truncated-text> | ||
</p> | ||
</div> | ||
</zui-expander> | ||
`; | ||
<note-expander | ||
.notesUri=${this.notesUri} | ||
.accountId=${this.accountId} | ||
.note=${note} | ||
.expanded=${this._expandedNotes.has(note.noteId)} | ||
key=${note.noteId} | ||
@openchanged=${(event: NoteExpanderChangeEvent) => this.handleNoteExpanderChange(event, note)} | ||
></note-expander> | ||
`; | ||
} | ||
private renderNoteLabels(note: Note): unknown { | ||
const isShowLabels = note?.isAlertActive || note?.isConfidential; | ||
return isShowLabels ? html` | ||
<div class="note-title-labels"> | ||
${note?.isConfidential ? html`<zui-tag color="gray">Confidential</zui-tag>` : nothing} | ||
${note?.isAlertActive ? html`<zui-tag color="blue">Alert Enabled</zui-tag>` : nothing} | ||
</div> | ||
`: null; | ||
private handleNoteExpanderChange({ detail }: NoteExpanderChangeEvent, note:Note): void { | ||
if(detail.open) { | ||
this._expandedNotes = new Set([...this._expandedNotes, note.noteId]); | ||
} else { | ||
this._expandedNotes = new Set([...this._expandedNotes].filter((value: number) => value !== note.noteId)); | ||
} | ||
setTimeout(() => { | ||
window.dispatchEvent(new Event('resize')); | ||
}, 10); | ||
} | ||
@@ -195,11 +180,21 @@ | ||
private async loadNotes(): Promise<void> { | ||
try { | ||
this.notes = await client.loadNotes(this.agencyId) | ||
} catch (error) { | ||
this.showNotification('error', 'Failure', 'Failed to load notes'); | ||
} finally { | ||
this.loading = false; | ||
} | ||
private openAddNoteDialog = (): void => { | ||
this._addNoteDialog?.open(); | ||
} | ||
private addCreatedNoteToList = (event: NoteCreatedEvent): void =>{ | ||
this._loadNotesTask = new Task( | ||
this, | ||
() => { | ||
this.showNotification("success", "Success", "Note created successfully"); | ||
var newLength = this._notes.unshift(event.detail); | ||
if(newLength > this.numberOfNotes) | ||
this._notes.pop(); | ||
return this._notes; | ||
}, | ||
() => [] | ||
); | ||
} | ||
} | ||
@@ -206,0 +201,0 @@ |
@@ -7,19 +7,55 @@ declare global { | ||
interface WidgetEvent { | ||
target: any; | ||
type: string; | ||
} | ||
export interface NoteExpanderChangeEvent extends WidgetEvent { | ||
detail: { | ||
open: boolean; | ||
}; | ||
} | ||
export interface ToggleChangeEvent extends WidgetEvent { | ||
detail: { | ||
checked: boolean; | ||
}; | ||
} | ||
export interface InputChangeEvent extends WidgetEvent { | ||
detail: string; | ||
} | ||
export interface SelectDropdownChangeEvent extends WidgetEvent { | ||
detail: string; | ||
} | ||
export interface NoteCreatedEvent extends WidgetEvent { | ||
detail?: Note; | ||
} | ||
export interface Note { | ||
noteId: number; | ||
agencyId : number; | ||
categoryId: number; | ||
policyId: number; | ||
policyName: string; | ||
categoryName: string; | ||
text: string; | ||
isConfidential: boolean; | ||
isAlertActive?: boolean; | ||
alertDate?: Date; | ||
isAlertActive: boolean; | ||
alertDate?: string; | ||
} | ||
export interface ExpanderChangeEvent { | ||
detail: { | ||
open: boolean; | ||
}; | ||
target: any; | ||
export interface NoteCategory { | ||
categoryId: number; | ||
name: string; | ||
isActive: boolean; | ||
isConfidential: boolean; | ||
defaultNote?: string | null; | ||
} | ||
export interface CreateNoteRequest { | ||
accountId: number; | ||
categoryId: number; | ||
text: string; | ||
isConfidential: boolean; | ||
isAlertEnabled: boolean; | ||
alertDate?: string; | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
240344
57
3010
1
3
+ Added@lit-labs/task@^2.0.0
+ Added@lit-labs/virtualizer@^0.7.2
+ Added@lit-labs/task@2.1.2(transitive)
+ Added@lit-labs/virtualizer@0.7.2(transitive)
+ Addedevent-target-shim@6.0.2(transitive)
+ Addedtslib@2.8.1(transitive)