#86 - implement basic bookmarks in sidebar
Some checks failed
continuous-integration/drone/push Build is failing
Some checks failed
continuous-integration/drone/push Build is failing
This commit is contained in:
parent
8c253ac283
commit
6a75900908
@ -227,12 +227,19 @@ export class AppComponent implements OnInit {
|
||||
const options = [
|
||||
{name: 'Make Virtual Root', icon: 'fa fa-search-plus', value: 'virtual_root'},
|
||||
{name: 'Export to HTML', icon: 'fa fa-file-export', value: 'export_html'},
|
||||
// {name: 'Export as PDF', icon: 'fa fa-file-export', value: 'export_pdf'},
|
||||
];
|
||||
|
||||
const manageOptions = [
|
||||
{name: 'Share Sub-Tree', icon: 'fa fa-share-alt', value: 'share'},
|
||||
];
|
||||
|
||||
if ( this.menuTarget.data.bookmark ) {
|
||||
options.push({name: 'Remove Bookmark', icon: 'fa fa-star', value: 'bookmark_remove'});
|
||||
} else {
|
||||
options.push({name: 'Bookmark', icon: 'fa fa-star', value: 'bookmark_add'});
|
||||
}
|
||||
|
||||
const popover = await this.popover.create({
|
||||
component: OptionMenuComponent,
|
||||
componentProps: {
|
||||
@ -263,8 +270,14 @@ export class AppComponent implements OnInit {
|
||||
});
|
||||
} else if ( result.data === 'export_html' ) {
|
||||
this.exportTargetAsHTML();
|
||||
} else if ( result.data === 'export_pdf' ) {
|
||||
this.exportTargetAsPDF();
|
||||
} else if ( result.data === 'virtual_root' ) {
|
||||
this.setVirtualRoot();
|
||||
} else if ( result.data === 'bookmark_add' ) {
|
||||
this.addBookmark();
|
||||
} else if ( result.data === 'bookmark_remove' ) {
|
||||
this.removeBookmark();
|
||||
}
|
||||
});
|
||||
|
||||
@ -303,6 +316,25 @@ export class AppComponent implements OnInit {
|
||||
window.open(dlUrl, '_blank');
|
||||
}
|
||||
|
||||
addBookmark() {
|
||||
const bookmarks = this.session.get('user.preferences.bookmark_page_ids') || [];
|
||||
|
||||
if ( !bookmarks.includes(this.menuTarget.data.id) ) {
|
||||
bookmarks.push(this.menuTarget.data.id);
|
||||
}
|
||||
|
||||
this.session.set('user.preferences.bookmark_page_ids', bookmarks);
|
||||
this.session.save().then(() => this.navService.requestSidebarRefresh({ quiet: true }));
|
||||
}
|
||||
|
||||
removeBookmark() {
|
||||
let bookmarks = this.session.get('user.preferences.bookmark_page_ids') || [];
|
||||
bookmarks = bookmarks.filter(x => x !== this.menuTarget.data.id);
|
||||
|
||||
this.session.set('user.preferences.bookmark_page_ids', bookmarks);
|
||||
this.session.save().then(() => this.navService.requestSidebarRefresh({ quiet: true }));
|
||||
}
|
||||
|
||||
async onCreateClick($event: MouseEvent) {
|
||||
const menuItems = [
|
||||
{
|
||||
|
@ -1,5 +1,5 @@
|
||||
<ion-list>
|
||||
<ion-item *ngFor="let menuItem of menuItems; let i = index" button (click)="onSelect(menuItems[i].value)" [title]="menuItems[i].title">
|
||||
<ion-item *ngFor="let menuItem of menuItems; let i = index" button (click)="onSelect(menuItems[i].value)" [title]="menuItems[i].title || ''">
|
||||
<i slot="start" [ngClass]="menuItems[i].icon"></i>
|
||||
<ion-label>{{ menuItems[i].name }}</ion-label>
|
||||
</ion-item>
|
||||
|
@ -35,6 +35,7 @@ export class DatabaseService extends Dexie {
|
||||
constructor(
|
||||
) {
|
||||
super('NodedLocalDatabase');
|
||||
this.createSchemata();
|
||||
}
|
||||
|
||||
public async getKeyValue(key: string): Promise<KeyValue> {
|
||||
|
Loading…
Reference in New Issue
Block a user