aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-web/src/main/js/apps/users/form-view.js
diff options
context:
space:
mode:
authorStas Vilchik <vilchiks@gmail.com>2015-05-20 10:54:59 +0200
committerStas Vilchik <vilchiks@gmail.com>2015-05-22 15:53:42 +0200
commite009561a5e3210480c7bef0ee20cebbc83d531bc (patch)
treef12b4c8f21213d882cd3ca1427cc7fc48b2df4b6 /server/sonar-web/src/main/js/apps/users/form-view.js
parent06cafc9839cb231a8f71e1d1c41da43ac1dc0139 (diff)
downloadsonarqube-e009561a5e3210480c7bef0ee20cebbc83d531bc.tar.gz
sonarqube-e009561a5e3210480c7bef0ee20cebbc83d531bc.zip
SONAR-6565 refactor users page
Diffstat (limited to 'server/sonar-web/src/main/js/apps/users/form-view.js')
-rw-r--r--server/sonar-web/src/main/js/apps/users/form-view.js52
1 files changed, 52 insertions, 0 deletions
diff --git a/server/sonar-web/src/main/js/apps/users/form-view.js b/server/sonar-web/src/main/js/apps/users/form-view.js
new file mode 100644
index 00000000000..2cf2e1ac3f1
--- /dev/null
+++ b/server/sonar-web/src/main/js/apps/users/form-view.js
@@ -0,0 +1,52 @@
+define([
+ 'components/common/modal-form',
+ './templates'
+], function (ModalForm) {
+
+ var $ = jQuery;
+
+ return ModalForm.extend({
+ template: Templates['users-form'],
+
+ events: function () {
+ return _.extend(ModalForm.prototype.events.apply(this, arguments), {
+ 'click #create-user-add-scm-account': 'onAddScmAccountClick'
+ });
+ },
+
+ onRender: function () {
+ ModalForm.prototype.onRender.apply(this, arguments);
+ this.$('[data-toggle="tooltip"]').tooltip({ container: 'body', placement: 'bottom' });
+ },
+
+ onClose: function () {
+ ModalForm.prototype.onClose.apply(this, arguments);
+ this.$('[data-toggle="tooltip"]').tooltip('destroy');
+ },
+
+ onFormSubmit: function () {
+ ModalForm.prototype.onFormSubmit.apply(this, arguments);
+ this.sendRequest();
+ },
+
+ onAddScmAccountClick: function (e) {
+ e.preventDefault();
+ this.addScmAccount();
+ },
+
+ getScmAccounts: function () {
+ var scmAccounts = this.$('[name="scmAccounts"]').map(function () {
+ return $(this).val();
+ }).toArray();
+ return scmAccounts.filter(function (value) {
+ return !!value;
+ });
+ },
+
+ addScmAccount: function () {
+ var fields = this.$('[name="scmAccounts"]');
+ fields.first().clone().val('').insertAfter(fields.last());
+ }
+ });
+
+});