root / snf-cyclades-app / synnefo / ui / new_ui / ui / javascripts / ember / controllers / tag.js @ 2a4126d7
History | View | Annotate | Download (1.1 kB)
1 |
App.TagController = Ember.ObjectController.extend({ |
---|---|
2 |
actions: {
|
3 |
createTag: function(data, model) { |
4 |
var tag = this.store.createRecord('tag', data); |
5 |
tag.save(); |
6 |
|
7 |
// model can be any model class instance which
|
8 |
// shares the tags interface used below.
|
9 |
if (model) {
|
10 |
model.get('tags').addObject(tag);
|
11 |
} |
12 |
} |
13 |
}, |
14 |
}); |
15 |
|
16 |
|
17 |
var _defaultNewTagColor = 'cornflowerblue'; |
18 |
|
19 |
App.AddTagController = App.TagController.extend({ |
20 |
newTagName: '', |
21 |
newTagColor: _defaultNewTagColor,
|
22 |
closed: false, |
23 |
actions: {
|
24 |
handleSubmit: function() { |
25 |
// resolve form params
|
26 |
var tagDetails = {
|
27 |
name: this.get('newTagName'), |
28 |
color: this.get('newTagColor') |
29 |
}; |
30 |
|
31 |
// validate ???
|
32 |
// failed validation messages ???
|
33 |
|
34 |
// do create tag
|
35 |
this.send('createTag', tagDetails, this.get('model')); |
36 |
|
37 |
// hide form (view should use this attr)
|
38 |
this.set('closed', true); |
39 |
|
40 |
// reset the newTagXXX shit
|
41 |
this.set('newTagName', ''); |
42 |
this.set('newTagColor', _defaultNewTagColor); |
43 |
} |
44 |
} |
45 |
}); |