added comments, fixed repo error

This commit is contained in:
j-weissen 2022-10-18 09:00:19 +02:00
parent 7068ae402e
commit 952917d415
2 changed files with 16 additions and 5 deletions

View file

@ -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}`
} }

View file

@ -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>
@ -47,7 +53,7 @@
<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;
} }