-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.js
41 lines (33 loc) · 869 Bytes
/
main.js
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
import Ember from 'ember';
import { Database, transient } from 'sofa';
import design from '../../design';
const {
computed: { reads },
RSVP: { all }
} = Ember;
const session = key => {
return reads(`session.${key}`);
}
export default Database.extend({
session: transient('session', 'singleton'),
sections: session('sections'),
insertDesignDocuments() {
let promises = [];
for(let name in design) {
let ddoc = design[name];
promises.push(this.get('documents.design').save(name, ddoc));
}
return all(promises);
},
deselectSections() {
this.get('sections').forEach(model => {
model.set('isOpen', false);
});
},
didSelectSection(model) {
let models = [...model.ancestors(), model];
this.get('sections').forEach(model => {
model.set('isOpen', models.indexOf(model) !== -1);
});
}
});