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

38 lines
676 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;
2020-02-05 20:57:43 +05:00
}
get title() {
return this._notebook.title;
2020-02-05 20:57:43 +05:00
}
get data() {
return this._notebook;
2020-02-05 20:57:43 +05:00
}
get topics() {
return new Topics(this._notebooks, this._notebook.id);
2020-02-05 20:57:43 +05:00
}
_toggle(prop) {
return this._notebooks.add({
id: this._notebook.id,
[prop]: !this._notebook[prop]
2020-02-22 17:59:48 +05:00
});
2020-02-05 20:57:43 +05:00
}
pin() {
return this._toggle("pinned");
2020-02-05 20:57:43 +05:00
}
}