@zywave/notes-widget
Advanced tools
Comparing version 1.0.0-rc.25 to 1.0.0-rc.30
import { Note, NoteCategory, CreateNoteRequest } from '../types'; | ||
export declare const apiClient: { | ||
loadNotes(): Promise<Note[]>; | ||
loadNotes(accountId: number, numberOfNotes: number): Promise<Note[]>; | ||
loadNoteCategories(): Promise<NoteCategory[]>; | ||
@@ -5,0 +5,0 @@ createNote(newNote: CreateNoteRequest): Promise<Note>; |
@@ -14,7 +14,8 @@ var _a; | ||
export const apiClient = { | ||
async loadNotes() { | ||
async loadNotes(accountId, numberOfNotes) { | ||
if (!zywaveApiClient) { | ||
return mockApiCall(mockNotes); | ||
} | ||
await zywaveApiClient.fetch(`${apiUrl}/notes`, { | ||
var notes; | ||
await zywaveApiClient.fetch(`${apiUrl}/notes?accountId=${accountId}&pageIndex=0&pageSize=${numberOfNotes}&sortBy=noteId&sortDirection=1`, { | ||
...defaultOptions, | ||
@@ -25,5 +26,5 @@ method: 'GET', | ||
.then((data) => { | ||
return data.items; | ||
notes = data.items; | ||
}); | ||
return new Array; | ||
return notes; | ||
}, | ||
@@ -30,0 +31,0 @@ async loadNoteCategories() { |
@@ -6,2 +6,4 @@ import { LitElement } from 'lit'; | ||
static styles: import("lit").CSSResult; | ||
accountId: number; | ||
notesUri: string; | ||
note: Note; | ||
@@ -8,0 +10,0 @@ expanded: boolean; |
@@ -36,12 +36,11 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { | ||
<p class="note-description"> | ||
<truncated-text text=${this.note.text} lines="7"> | ||
<zui-button | ||
<truncated-text text=${this.note.text} lines="7"></truncated-text> | ||
</p> | ||
<zui-button | ||
data-autom="note-expander_button_view-more" | ||
type="link" | ||
slot="viewMore" | ||
> | ||
<a href=${`${this.notesUri}/account/${this.accountId}/note/${this.note.noteId}`}></a> | ||
View more | ||
</zui-button> | ||
</truncated-text> | ||
</p> | ||
</div> | ||
@@ -114,2 +113,8 @@ </zui-expander> | ||
property() | ||
], NoteExpander.prototype, "accountId", void 0); | ||
__decorate([ | ||
property() | ||
], NoteExpander.prototype, "notesUri", void 0); | ||
__decorate([ | ||
property() | ||
], NoteExpander.prototype, "note", void 0); | ||
@@ -116,0 +121,0 @@ __decorate([ |
@@ -57,3 +57,2 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { | ||
</span> | ||
${this.isTruncated ? html `<slot name="viewMore"></slot>` : nothing} | ||
`; | ||
@@ -60,0 +59,0 @@ } |
@@ -9,2 +9,3 @@ import { LitElement } from 'lit'; | ||
private numberOfNotes; | ||
private notesUri; | ||
private _expandedNotes; | ||
@@ -11,0 +12,0 @@ private _addNoteDialog; |
@@ -20,6 +20,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { | ||
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._notes = await apiClient.loadNotes(this.accountId, this.numberOfNotes); | ||
return this._notes; | ||
@@ -110,2 +111,3 @@ } | ||
> | ||
<a href=${`${this.notesUri}/account/${this.accountId}`}></a> | ||
View all notes | ||
@@ -119,3 +121,5 @@ </zui-button> | ||
return html ` | ||
<note-expander | ||
<note-expander | ||
.notesUri=${this.notesUri} | ||
.accountId=${this.accountId} | ||
.note=${note} | ||
@@ -175,2 +179,5 @@ .expanded=${this._expandedNotes.has(note.noteId)} | ||
__decorate([ | ||
property() | ||
], NotesWidget.prototype, "notesUri", void 0); | ||
__decorate([ | ||
state() | ||
@@ -177,0 +184,0 @@ ], NotesWidget.prototype, "_expandedNotes", void 0); |
{ | ||
"name": "@zywave/notes-widget", | ||
"version": "1.0.0-rc.25", | ||
"version": "1.0.0-rc.30", | ||
"description": "A custom web component for notes functionality through a widget", | ||
@@ -5,0 +5,0 @@ "main": "dist/notes-widget.js", |
@@ -17,3 +17,3 @@ import {Note, NoteCategory, CreateNoteRequest} from '../types'; | ||
export const apiClient = { | ||
async loadNotes(): Promise<Note[]> { | ||
async loadNotes(accountId: number, numberOfNotes: number): Promise<Note[]> { | ||
if (!zywaveApiClient) { | ||
@@ -23,3 +23,5 @@ return mockApiCall(mockNotes); | ||
await zywaveApiClient.fetch(`${apiUrl}/notes`, { | ||
var notes: Note[]; | ||
await zywaveApiClient.fetch(`${apiUrl}/notes?accountId=${accountId}&pageIndex=0&pageSize=${numberOfNotes}&sortBy=noteId&sortDirection=1`, { | ||
...defaultOptions, | ||
@@ -30,6 +32,6 @@ method: 'GET', | ||
.then((data: { items: Note[]; }) => { | ||
return data.items} | ||
notes = data.items} | ||
); | ||
return new Array<Note>; | ||
return notes; | ||
}, | ||
@@ -36,0 +38,0 @@ |
@@ -61,2 +61,8 @@ import { LitElement, html, css, nothing } from 'lit'; | ||
@property() | ||
accountId: number; | ||
@property() | ||
notesUri: string; | ||
@property() | ||
note: Note; | ||
@@ -87,12 +93,11 @@ | ||
<p class="note-description"> | ||
<truncated-text text=${this.note.text} lines="7"> | ||
<zui-button | ||
<truncated-text text=${this.note.text} lines="7"></truncated-text> | ||
</p> | ||
<zui-button | ||
data-autom="note-expander_button_view-more" | ||
type="link" | ||
slot="viewMore" | ||
> | ||
<a href=${`${this.notesUri}/account/${this.accountId}/note/${this.note.noteId}`}></a> | ||
View more | ||
</zui-button> | ||
</truncated-text> | ||
</p> | ||
</div> | ||
@@ -99,0 +104,0 @@ </zui-expander> |
@@ -84,3 +84,2 @@ import { LitElement, html, nothing, css } from 'lit'; | ||
</span> | ||
${this.isTruncated ? html`<slot name="viewMore"></slot>`: nothing} | ||
`; | ||
@@ -87,0 +86,0 @@ } |
@@ -49,2 +49,5 @@ import { LitElement, html, css, nothing } from 'lit'; | ||
private numberOfNotes = 4; | ||
@property() | ||
private notesUri = 'https://notes.zywave.com' | ||
@@ -62,3 +65,3 @@ @state() | ||
try { | ||
this._notes = await apiClient.loadNotes(); | ||
this._notes = await apiClient.loadNotes(this.accountId, this.numberOfNotes); | ||
return this._notes; | ||
@@ -137,2 +140,3 @@ } catch (error) { | ||
> | ||
<a href=${`${this.notesUri}/account/${this.accountId}`}></a> | ||
View all notes | ||
@@ -147,3 +151,5 @@ </zui-button> | ||
return html` | ||
<note-expander | ||
<note-expander | ||
.notesUri=${this.notesUri} | ||
.accountId=${this.accountId} | ||
.note=${note} | ||
@@ -150,0 +156,0 @@ .expanded=${this._expandedNotes.has(note.noteId)} |
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
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 too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
240194
3004