2020-02-05 20:57:43 +05:00
|
|
|
import Topics from "../collections/topics";
|
|
|
|
|
|
|
|
|
|
export default class Notebook {
|
|
|
|
|
/**
|
|
|
|
|
*
|
2020-04-12 11:04:30 +05:00
|
|
|
* @param {import ('../collections/notebooks').default} notebooks
|
2020-02-05 20:57:43 +05:00
|
|
|
* @param {Object} notebook
|
|
|
|
|
*/
|
|
|
|
|
constructor(notebooks, notebook) {
|
2020-02-22 21:53:56 +05:00
|
|
|
this._notebook = notebook;
|
|
|
|
|
this._notebooks = notebooks;
|
2020-02-05 20:57:43 +05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
get title() {
|
2020-02-22 21:53:56 +05:00
|
|
|
return this._notebook.title;
|
2020-02-05 20:57:43 +05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
get data() {
|
2020-02-22 21:53:56 +05:00
|
|
|
return this._notebook;
|
2020-02-05 20:57:43 +05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
get topics() {
|
2020-02-22 21:53:56 +05:00
|
|
|
return new Topics(this._notebooks, this._notebook.id);
|
2020-02-05 20:57:43 +05:00
|
|
|
}
|
|
|
|
|
|
2020-03-19 15:14:29 +05:00
|
|
|
get dateEdited() {
|
|
|
|
|
return this._notebook.dateEdited;
|
|
|
|
|
}
|
|
|
|
|
|
2020-02-22 21:53:56 +05:00
|
|
|
_toggle(prop) {
|
|
|
|
|
return this._notebooks.add({
|
|
|
|
|
id: this._notebook.id,
|
2020-04-12 11:04:30 +05:00
|
|
|
[prop]: !this._notebook[prop],
|
2020-02-22 17:59:48 +05:00
|
|
|
});
|
2020-02-05 20:57:43 +05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pin() {
|
2020-02-22 21:53:56 +05:00
|
|
|
return this._toggle("pinned");
|
2020-02-05 20:57:43 +05:00
|
|
|
}
|
|
|
|
|
}
|