Files
notesnook/packages/core/models/notebook.js

42 lines
743 B
JavaScript
Raw Normal View History

2020-02-05 20:57:43 +05:00
import Notebooks from "../collections/notebooks";
import Topics from "../collections/topics";
export default class Notebook {
/**
*
* @param {Notebooks} notebooks
* @param {Object} notebook
*/
constructor(notebooks, notebook) {
this.notebook = notebook;
this.notebooks = notebooks;
}
get title() {
return this.notebook.title;
}
get data() {
return this.notebook;
}
get topics() {
return new Topics(this.notebooks, this.notebooks.notes, this.notebook.id);
}
toggle(prop) {
2020-02-22 17:59:48 +05:00
return this.notebooks.add({
id: this.notebook.id,
[prop]: !this.notebook[prop]
});
2020-02-05 20:57:43 +05:00
}
pin() {
return this.toggle("pinned");
}
favorite() {
return this.toggle("favorite");
}
}