-
Notifications
You must be signed in to change notification settings - Fork 652
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #12749 from CartoDB/12740-static-account
Account Static View
- Loading branch information
Showing
65 changed files
with
2,199 additions
and
555 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
module.exports = exports = { | ||
PublicClient: require('./lib/clients/public.js.babel'), | ||
AuthenticatedClient: require('./lib/clients/authenticated.js.babel') | ||
}; |
25 changes: 25 additions & 0 deletions
25
lib/assets/core/javascripts/carto-node/lib/clients/authenticated.js.babel
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
const PublicClient = require('./public.js.babel'); | ||
|
||
class AuthenticatedClient extends PublicClient { | ||
getConfig (callback) { | ||
return this.get(['me'], callback); | ||
} | ||
|
||
putConfig (payload, callback) { | ||
var opts = { | ||
data: JSON.stringify(payload), | ||
dataType: 'json' | ||
}; | ||
return this.put(['me'], opts, callback); | ||
} | ||
|
||
deleteUser (payload, callback) { | ||
var opts = { | ||
data: JSON.stringify(payload), | ||
dataType: 'json' | ||
}; | ||
return this.delete(['me'], opts, callback); | ||
} | ||
} | ||
|
||
module.exports = exports = AuthenticatedClient; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
9 changes: 0 additions & 9 deletions
9
lib/assets/core/javascripts/cartodb3/carto-node/lib/clients/authenticated.js
This file was deleted.
Oops, something went wrong.
2 changes: 1 addition & 1 deletion
2
...to-node/lib/clients/authenticated.spec.js → ...to-node/lib/clients/authenticated.spec.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
104 changes: 104 additions & 0 deletions
104
lib/assets/javascripts/cartodb/account/account_content_view.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
var _ = require('underscore-cdb-v3'); | ||
var cdb = require('cartodb.js-v3'); | ||
var PagesSubheader = require('../common/pages_subheader'); | ||
var AccountFormView = require('./account_form_view'); | ||
|
||
module.exports = cdb.core.View.extend({ | ||
initialize: function () { | ||
_.each(['flashMessageModel'], function (name) { | ||
if (!this.options[name]) throw new Error(name + ' is required'); | ||
}, this); | ||
|
||
this.template = cdb.templates.getTemplate('account/views/account_content'); | ||
|
||
this._initModels(); | ||
this._initBinds(); | ||
}, | ||
|
||
_initBinds: function () { | ||
this.model.on('change:isLoading', this.render, this); | ||
this.model.on('change:errors', this.render, this); | ||
}, | ||
|
||
render: function () { | ||
this.clearSubViews(); | ||
|
||
this.$el.html(this.template()); | ||
|
||
this._initViews(); | ||
|
||
return this; | ||
}, | ||
|
||
_initModels: function () { | ||
this._userModel = this.options.user; | ||
this._client = this.options.client; | ||
this.model = new cdb.core.Model(); | ||
}, | ||
|
||
_initViews: function () { | ||
var pagesSubheader = new PagesSubheader({ | ||
user: this._userModel | ||
}); | ||
this.$('.js-SideMenu').append(pagesSubheader.render().el); | ||
this.addView(pagesSubheader); | ||
|
||
var accountFormView = new AccountFormView({ | ||
user: this._userModel, | ||
errors: this.model.get('errors'), | ||
setLoading: this._setLoading.bind(this), | ||
onSuccess: this._showSuccess.bind(this), | ||
onError: this._showErrors.bind(this), | ||
renderModel: this.model, | ||
client: this._client | ||
}); | ||
|
||
this.$('.js-AccountContent').append(accountFormView.render().el); | ||
this.addView(accountFormView); | ||
}, | ||
|
||
_setLoading: function (message) { | ||
this.options.flashMessageModel.hide(); | ||
|
||
this.model.set({ | ||
isLoading: !!message, | ||
loadingText: message, | ||
errors: [] | ||
}); | ||
}, | ||
|
||
_setFlashMessage: function (data, message, type) { | ||
this._setLoading(''); | ||
|
||
var str; | ||
try { | ||
var errors = data && data.responseJSON.errors; | ||
|
||
this.model.set({ | ||
errors: errors | ||
}); | ||
|
||
str = data && data.responseJSON.message; | ||
} catch (err) { | ||
str = message; | ||
} | ||
|
||
this.options.flashMessageModel.show(str, type); | ||
}, | ||
|
||
_showSuccess: function (data) { | ||
$(window).scrollTop(0); | ||
|
||
_.extend(this._userModel.attributes, | ||
data.user_data, { | ||
should_display_old_password: data.should_display_old_password | ||
}); | ||
|
||
this._setFlashMessage(data, _t('account.flash_messages.save_changes.success'), 'success'); | ||
}, | ||
|
||
_showErrors: function (data) { | ||
$(window).scrollTop(0); | ||
this._setFlashMessage(data, _t('account.flash_messages.save_changes.error'), 'error'); | ||
} | ||
}); |
Oops, something went wrong.