* fix bug in new note link

* clean up and style the create note modal
* add example of references to note
This commit is contained in:
walljm 2020-02-01 16:04:23 -05:00
parent f5ba1850f8
commit 87cc470bfa
10 changed files with 136 additions and 89 deletions

File diff suppressed because one or more lines are too long

View File

@ -1,24 +1,21 @@
<ion-header> <ion-header>
<ion-toolbar> <ion-toolbar>
<ion-title> <ion-title> <ion-icon name="text" item-left></ion-icon> Create a Note </ion-title>
<ion-icon name="text" item-left></ion-icon> Create a Note <ion-buttons start>
</ion-title> <button ion-button (click)="dismiss()" large>
<ion-buttons start> <ion-icon name="md-close"></ion-icon>
<button ion-button (click)="dismiss()" large> </button>
<ion-icon name="md-close"></ion-icon> </ion-buttons>
</button> </ion-toolbar>
</ion-buttons> </ion-header>
</ion-toolbar> <ion-content padding *ngIf="item !== undefined">
</ion-header> <ion-item>
<ion-content padding *ngIf="item !== undefined"> <ion-input placeholder="Title" text [(ngModel)]="item.title"></ion-input>
<ion-item> </ion-item>
<ion-label>Title</ion-label> <ion-item class="note-text">
<ion-input text [(ngModel)]="item.title"></ion-input> <ion-textarea placeholder="Note Text" [(ngModel)]="item.content"></ion-textarea>
</ion-item> </ion-item>
<ion-item> <div style="float: right">
<ion-label>Text</ion-label> <button ion-button right (click)="save()">Save</button>
<br> </div>
<ion-textarea [(ngModel)]="item.content"></ion-textarea> </ion-content>
</ion-item>
<button ion-button (click)="save()">Save</button>
</ion-content>

View File

@ -1,6 +1,13 @@
note-create-modal { note-create-modal {
font-family: var(--card-font); font-family: var(--card-font);
textarea { textarea {
height: 100px; height: 100px;
} }
} }
.note-text {
min-height: 370px;
textarea {
min-height: 370px;
}
}

View File

@ -1,4 +1,4 @@
<ion-item class="title note-title" (swipe)="close()"> <ion-item class="title note-title" (swipe)="close($event)">
<ion-icon name="clipboard" item-left></ion-icon> <ion-icon name="clipboard" item-left></ion-icon>
<span *ngIf="data !== undefined">{{ data.title }}</span> <span *ngIf="data !== undefined">{{ data.title }}</span>
<!-- TODO(jwall): Put the crossreference somewhere if it exists. --> <!-- TODO(jwall): Put the crossreference somewhere if it exists. -->
@ -8,9 +8,22 @@
</ion-item> </ion-item>
<ion-card-content> <ion-card-content>
<markdown *ngIf="data !== undefined" [data]="data.content"></markdown> <markdown *ngIf="data !== undefined" [data]="data.content"></markdown>
<!--
<div class="references">
<h2>References</h2>
<dl>
<dd><a (click)="openPassage(p.r)">Psalm 123:4</a></dd>
<dd><a (click)="openPassage(p.r)">Psalm 123:4</a></dd>
</dl>
</div>
-->
</ion-card-content> </ion-card-content>
<div style="float: right"> <div style="float: right">
<button ion-button icon-start clear (click)="edit()"> <button ion-button icon-center clear (click)="edit()">
<ion-icon name="create"></ion-icon> <ion-icon name="create"></ion-icon>
</button> </button>
<button ion-button icon-center clear (click)="contextMenu()">
<ion-icon name="more"></ion-icon>
</button>
</div> </div>

View File

@ -5,15 +5,33 @@ note {
} }
font-family: var(--card-font); font-family: var(--card-font);
markdown { markdown {
padding: 2rem 3rem 0 3rem; padding: 2rem 3rem 0 3rem;
display: block; display: block;
h1,
h1 { h2,
h3,
h4,
h5,
h6 {
font-family: 'Roboto Condensed'; font-family: 'Roboto Condensed';
} }
} }
.references {
padding-left: 3rem;
padding-bottom: 0;
h1,
h2,
h3,
h4,
h5,
h6 {
font-family: 'Roboto Condensed';
font-size: 2rem;
}
}
} }
note .button { note .button {

View File

@ -1,10 +1,13 @@
import { Component, EventEmitter, Output, Input, OnInit, ElementRef } from '@angular/core'; import { Component, EventEmitter, Output, Input, OnInit, ElementRef } from '@angular/core';
import { UUID } from 'angular2-uuid'; import { UUID } from 'angular2-uuid';
import { ModalController } from 'ionic-angular'; import { ModalController, ActionSheetController, AlertController } from 'ionic-angular';
import { OpenData, CardItem, SearchPage } from '../../pages/search/search'; import { OpenData, CardItem, SearchPage } from '../../pages/search/search';
import { NoteItem, NotesService } from '../../services/notes-service'; import { NoteItem, NotesService } from '../../services/notes-service';
import { NoteCreateModal } from '../../components/note-create-modal/note-create-modal'; import { NoteCreateModal } from '../../components/note-create-modal/note-create-modal';
import { PagesService } from '../../services/pages-service';
import { ProfileService } from '../../services/profile-service';
import { cardContextMenu } from '../../libs/Common';
@Component({ @Component({
selector: 'note', selector: 'note',
@ -25,12 +28,25 @@ export class Note implements OnInit {
data: NoteItem | null; data: NoteItem | null;
constructor(private elementRef: ElementRef, private noteService: NotesService, public modalCtrl: ModalController) { constructor(
this.data = { id: UUID.UUID(), title: 'A note!', xref: null, content: 'Testing 1 2 3' }; private _elementRef: ElementRef,
private _noteService: NotesService,
public _modalCtrl: ModalController,
private _actionSheet: ActionSheetController,
private _pagesSvc: PagesService,
private _alertCtrl: AlertController,
public _profileService: ProfileService
) {
this.data = {
id: UUID.UUID(),
title: 'This is your note title',
xref: null,
content: 'Replace this with your own content'
};
} }
ngOnInit(): void { ngOnInit(): void {
this.noteService this._noteService
.getNoteAsPromise(this.cardItem.qry) .getNoteAsPromise(this.cardItem.qry)
.then(note => { .then(note => {
console.log('Got note from service: ', note); console.log('Got note from service: ', note);
@ -39,13 +55,17 @@ export class Note implements OnInit {
.catch(e => console.log(e)); .catch(e => console.log(e));
} }
contextMenu() {
cardContextMenu(this._profileService, this._actionSheet, this._pagesSvc, this._alertCtrl, this.cardItem);
}
close(ev) { close(ev) {
let translate = 'translate3d(110%, 0, 0)'; let translate = 'translate3d(110%, 0, 0)';
if (ev != null && ev.direction === 2) { if (ev != null && ev.direction === 2) {
translate = 'translate3d(-110%, 0, 0)'; translate = 'translate3d(-110%, 0, 0)';
} }
let d = 250; let d = 250;
this.elementRef.nativeElement.parentElement.animate( this._elementRef.nativeElement.parentElement.animate(
{ {
transform: ['none', translate] transform: ['none', translate]
}, },
@ -62,11 +82,11 @@ export class Note implements OnInit {
} }
edit() { edit() {
const modal = this.modalCtrl.create(NoteCreateModal, { data: this.data }); const modal = this._modalCtrl.create(NoteCreateModal, { data: this.data });
modal.present(); modal.present();
} }
delete() { delete() {
this.noteService.deleteNote(this.data).catch(err => console.log(err)); this._noteService.deleteNote(this.data).catch(err => console.log(err));
} }
} }

View File

@ -5,11 +5,20 @@ passage {
} }
font-family: var(--card-font); font-family: var(--card-font);
h2 {
// chapter heading
font-size: 2rem !important;
font-family: $chapterHeadingFontFamily !important;
}
h3 {
// paragraph heading
font-size: 1.6rem !important;
font-family: $paragraphHeadingFontFamily !important;
}
} }
passage .button { passage .button {
color: #3D5699; color: #3d5699;
} }
.passage-title { .passage-title {
@ -22,6 +31,6 @@ passage .passage-text {
margin: auto; margin: auto;
} }
.passage-text+.passage-text { .passage-text + .passage-text {
padding-top: 12px; padding-top: 12px;
} }

View File

@ -1,41 +1,24 @@
import { Component } from '@angular/core'; import { Component } from '@angular/core';
import { ProfileService } from '../../services/profile-service'; import { ProfileService } from '../../services/profile-service';
import { NotesService } from '../../services/notes-service';
import { SearchPage } from '../../pages/search/search'; import { SearchPage } from '../../pages/search/search';
@Component({ @Component({
selector: 'settings', selector: 'settings',
templateUrl: 'settings.html' templateUrl: 'settings.html'
}) })
export class Settings { export class Settings {
constructor( constructor(public profileService: ProfileService, public searchPage: SearchPage) {}
public profileService: ProfileService,
public noteService: NotesService,
public searchPage: SearchPage,
) {}
textSizeChanged() {
this.profileService.textSizeChanged();
this.profileService.localSave();
}
textSizeChanged() fontFamilyChanged() {
{ this.profileService.fontFamilyChanged();
this.profileService.textSizeChanged(); this.profileService.localSave();
this.profileService.localSave(); }
} reset() {
this.profileService.reset();
fontFamilyChanged() }
{
this.profileService.fontFamilyChanged();
this.profileService.localSave();
}
reset()
{
this.profileService.reset();
}
newNote() {
this.noteService.newNote().then(note => {
this.searchPage.updateUIwithItems("note:" + note.id, false)
this.profileService.localSave();
}).catch(e => console.log(e));
}
} }

View File

@ -27,7 +27,8 @@ ion-auto-complete ul {
ion-auto-complete { ion-auto-complete {
width: 100%; width: 100%;
-webkit-box-shadow: 0 2px 2px 0 rgba(0, 0, 0, 0.14), 0 3px 1px -2px rgba(0, 0, 0, 0.2), 0 1px 5px 0 rgba(0, 0, 0, 0.12); -webkit-box-shadow: 0 2px 2px 0 rgba(0, 0, 0, 0.14), 0 3px 1px -2px rgba(0, 0, 0, 0.2),
0 1px 5px 0 rgba(0, 0, 0, 0.12);
box-shadow: 0 2px 2px 0 rgba(0, 0, 0, 0.14), 0 3px 1px -2px rgba(0, 0, 0, 0.2), 0 1px 5px 0 rgba(0, 0, 0, 0.12); box-shadow: 0 2px 2px 0 rgba(0, 0, 0, 0.14), 0 3px 1px -2px rgba(0, 0, 0, 0.2), 0 1px 5px 0 rgba(0, 0, 0, 0.12);
margin-right: 0.1em; margin-right: 0.1em;
} }
@ -60,16 +61,6 @@ body {
} }
.card { .card {
h2 {
// chapter heading
font-size: 2rem;
font-family: $chapterHeadingFontFamily;
}
h3 {
// paragraph heading
font-size: 1.6rem;
font-family: $paragraphHeadingFontFamily;
}
max-width: 800px; max-width: 800px;
margin: 12px auto; margin: 12px auto;

View File

@ -137,6 +137,15 @@ export class SearchPage implements OnInit {
this.menu.open('actions'); this.menu.open('actions');
} }
newNote() {
this.noteService
.newNote()
.then(note => {
this.updateUIwithItems('note:' + note.id, false);
this.profileService.localSave();
})
.catch(e => console.log(e));
}
addPage() { addPage() {
const alert = this.alertCtrl.create({ const alert = this.alertCtrl.create({
title: 'Save Search as Page', title: 'Save Search as Page',