-
Notifications
You must be signed in to change notification settings - Fork 25
Expand file tree
/
Copy pathNoteManager.js
More file actions
51 lines (41 loc) · 1.04 KB
/
NoteManager.js
File metadata and controls
51 lines (41 loc) · 1.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import './NoteManager.scss';
import Note from './Note';
export default class NoteManager {
constructor({el, notes}) {
this.el = el;
this.el.className = 'tc-notes-wrapper';
this.notesEl = null;
this.notes = notes.map(note => new Note(note, this));
this.onNoteChange = () => {
};
this.createNewNoteButton();
this.createNotesWrapper();
this.renderNotes();
}
addNote(note) {
this.notes.push(new Note(note, this));
this.renderNotes();
}
prependNote(note) {
this.notes.unshift(new Note(note, this));
this.renderNotes();
}
removeNote(note) {
this.notes.splice(this.notes.indexOf(note), 1);
this.renderNotes();
}
createNewNoteButton(){
}
createNotesWrapper() {
this.notesEl = document.createElement('div');
this.notesEl.className = 'tc-notes';
this.el.appendChild(this.notesEl);
}
renderNotes() {
this.notesEl.innerHTML = '';
this.notes.forEach(note => this.renderNote(note));
}
renderNote(note) {
this.notesEl.appendChild(note.createNoteEl())
}
}