/*global alert */

var SettingsUserController = Ember.Controller.extend({
    cover: function () {
        // @TODO: add {{asset}} subdir path
        return this.user.getWithDefault('cover', '/shared/img/user-cover.png');
    }.property('user.cover'),

    coverTitle: function () {
        return this.get('user.name') + '\'s Cover Image';
    }.property('user.name'),

    image: function () {
        // @TODO: add {{asset}} subdir path
        return 'background-image: url(' + this.user.getWithDefault('image', '/shared/img/user-image.png') + ')';
    }.property('user.image'),

    actions: {
        save: function () {
            alert('@TODO: Saving user...');

            if (this.user.validate().get('isValid')) {
                this.user.save().then(function (response) {
                    alert('Done saving' + JSON.stringify(response));
                }, function () {
                    alert('Error saving.');
                });
            } else {
                alert('Errors found! ' + JSON.stringify(this.user.get('errors')));
            }
        },

        password: function () {
            alert('@TODO: Changing password...');
            var passwordProperties = this.getProperties('password', 'newPassword', 'ne2Password');

            if (this.user.validatePassword(passwordProperties).get('passwordIsValid')) {
                this.user.saveNewPassword(passwordProperties).then(function () {
                    alert('Success!');
                    // Clear properties from view
                    this.setProperties({
                        'password': '',
                        'newpassword': '',
                        'ne2password': ''
                    });
                }.bind(this), function (errors) {
                    alert('Errors ' + JSON.stringify(errors));
                });
            } else {
                alert('Errors found! ' + JSON.stringify(this.user.get('passwordErrors')));
            }
        }
    }

});

export default SettingsUserController;
@@ -11,17 +11,16 @@
 lert */%0A
-%0A
 var Sett
@@ -66,16 +66,64 @@
 xtend(%7B%0A
+    coverDefault: '/shared/img/user-cover.png',%0A
     cove
@@ -187,30 +187,35 @@
 ath%0A        
-return
+var cover =
  this.user.g
@@ -220,58 +220,136 @@
 .get
-WithDefault('cover', '/shared/img/user-cover.png')
+('cover');%0A        if (typeof cover !== 'string') %7B%0A            cover = this.get('coverDefault');%0A        %7D%0A        return cover
 ;%0A  
@@ -373,16 +373,32 @@
 r.cover'
+, 'coverDefault'
 ),%0A%0A    

Fix default user cover on settings pane