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) {
|
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-02-22 21:53:56 +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() {
|
2020-02-22 21:53:56 +05:00
|
|
|
return this._toggle("pinned");
|
2020-02-05 20:57:43 +05:00
|
|
|
}
|
|
|
|
|
}
|