|
|
@@ -47,15 +47,17 @@
|
|
|
|
|
|
_ws.makeView('add-repo-form', {
|
|
|
|
|
|
+ init: function() {
|
|
|
+ this.$inputTitle = this.$elem.find('input[name="title"]');
|
|
|
+ },
|
|
|
+
|
|
|
render: function() {
|
|
|
console.log('render form add repo', this);
|
|
|
this.$elem.addClass('in');
|
|
|
this.$btn.removeClass('in');
|
|
|
- this.$elem.find('input[name="title"]').focus();
|
|
|
+ this.$inputTitle.focus();
|
|
|
},
|
|
|
|
|
|
- $btn: $('#add-repo-btn'),
|
|
|
-
|
|
|
events: {
|
|
|
'click .icon-cross': function() {
|
|
|
this.$elem.removeClass('in');
|
|
|
@@ -64,9 +66,19 @@
|
|
|
|
|
|
'submit': function(e) {
|
|
|
e.preventDefault();
|
|
|
- console.log('submit form');
|
|
|
+ var title = this.$inputTitle.val();
|
|
|
+ rp.post('/collections', { title: title })
|
|
|
+ .then(function(c) {
|
|
|
+ _ws.notify('success', 'Collection créée: ' + c.title);
|
|
|
+ })
|
|
|
+ .catch(function(err) {
|
|
|
+ console.error(err);
|
|
|
+ _ws.notify('error', 'Impossible de créer la collection: ' + err.message);
|
|
|
+ });
|
|
|
}
|
|
|
- }
|
|
|
+ },
|
|
|
+
|
|
|
+ $btn: $('#add-repo-btn')
|
|
|
|
|
|
});
|
|
|
|