added comments, fixed repo error
This commit is contained in:
parent
7068ae402e
commit
952917d415
2 changed files with 16 additions and 5 deletions
|
|
@ -79,6 +79,7 @@ export class StrapiNoteRepository implements NoteRepository {
|
||||||
}
|
}
|
||||||
|
|
||||||
static getAuthorizationHeader() {
|
static getAuthorizationHeader() {
|
||||||
|
// @ts-ignore
|
||||||
const jwt = parseCookies('/').jwt;
|
const jwt = parseCookies('/').jwt;
|
||||||
return `bearer ${jwt}`
|
return `bearer ${jwt}`
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@
|
||||||
|
|
||||||
let noteRepo: StrapiNoteRepository;
|
let noteRepo: StrapiNoteRepository;
|
||||||
let currentNote: Note;
|
let currentNote: Note;
|
||||||
|
|
||||||
onMount(async () => {
|
onMount(async () => {
|
||||||
noteRepo = StrapiNoteRepository.getInstance();
|
noteRepo = StrapiNoteRepository.getInstance();
|
||||||
try {
|
try {
|
||||||
|
|
@ -16,19 +17,24 @@
|
||||||
content = (<Note>currentNote).content;
|
content = (<Note>currentNote).content;
|
||||||
})
|
})
|
||||||
|
|
||||||
function save() {
|
/**
|
||||||
|
* saves the currently opened Note and returns to listing
|
||||||
|
*/
|
||||||
|
function saveAndQuit() {
|
||||||
noteRepo.updateNote(currentNote.id, {
|
noteRepo.updateNote(currentNote.id, {
|
||||||
"title": title,
|
"title": title,
|
||||||
"content": content
|
"content": content,
|
||||||
})
|
})
|
||||||
returnToListing();
|
returnToListing();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* redirects to listing
|
||||||
|
*/
|
||||||
function returnToListing() {
|
function returnToListing() {
|
||||||
window.location = "/";
|
window.location = "/";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
export let title: string, content: string;
|
export let title: string, content: string;
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
@ -44,10 +50,10 @@
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
<div class="offset-3 col-6 wrapper">
|
<div class="offset-3 col-6 wrapper">
|
||||||
<h1 class="">{title}</h1>
|
<h1 class="">{title}</h1>
|
||||||
<input bind:value={title} class="input"> <br />
|
<input bind:value={title} class="input"> <br/>
|
||||||
<textarea bind:value={content} class="input textarea"></textarea>
|
<textarea bind:value={content} class="input textarea"></textarea>
|
||||||
<div class="button-container">
|
<div class="button-container">
|
||||||
<button on:click={() => save()} class="btn btn-primary">Save</button>
|
<button on:click={() => saveAndQuit()} class="btn btn-primary">Save</button>
|
||||||
<button on:click={() => returnToListing()} class="btn btn-outline-danger">Cancel</button>
|
<button on:click={() => returnToListing()} class="btn btn-outline-danger">Cancel</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -55,16 +61,20 @@
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
@import "../../customBootstrap.css";
|
@import "../../customBootstrap.css";
|
||||||
|
|
||||||
.wrapper {
|
.wrapper {
|
||||||
margin-top: 20px;
|
margin-top: 20px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.input {
|
.input {
|
||||||
margin-bottom: 10px;
|
margin-bottom: 10px;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
.button-container {
|
.button-container {
|
||||||
float: right;
|
float: right;
|
||||||
}
|
}
|
||||||
|
|
||||||
.textarea {
|
.textarea {
|
||||||
height: 300px;
|
height: 300px;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue