events() {
return {
...ModalForm.prototype.events.apply(this, arguments),
- 'click #create-user-add-scm-account': 'onAddScmAccountClick'
+ 'click #create-user-add-scm-account': 'onAddScmAccountClick',
+ 'click .js-remove-scm': 'onRemoveScmAccountClick'
};
},
},
addScmAccount() {
- const fields = this.$('[name="scmAccounts"]');
- fields
+ const fields = this.$('.js-scm-input');
+ const newField = fields
.first()
.clone()
+ .removeClass('hidden');
+ newField.insertAfter(fields.last());
+ newField
+ .find('input')
.val('')
- .insertAfter(fields.last());
+ .focus();
+ },
+
+ onRemoveScmAccountClick(e) {
+ $(e.currentTarget)
+ .parent()
+ .remove();
}
});
{{/unless}}
<div class="modal-field">
<label>{{t 'my_profile.scm_accounts'}}</label>
- {{#each scmAccounts}}
- <input name="scmAccounts" type="text" size="50" maxlength="255" value="{{this}}">
- {{else}}
+ <span class="js-scm-input hidden">
<input name="scmAccounts" type="text" size="50" maxlength="255">
+ <a class="icon-delete js-remove-scm" href="#"></a>
+ </span>
+ {{#each scmAccounts}}
+ <span class="js-scm-input">
+ <input name="scmAccounts" type="text" size="50" maxlength="255" value="{{this}}">
+ <a class="icon-delete js-remove-scm" href="#"></a>
+ </span>
{{/each}}
- <a id="create-user-add-scm-account" class="icon-plus" href="#" title="Add another SCM account"
- data-toggle="tooltip"></a>
+ <div class="spacer-bottom">
+ <a id="create-user-add-scm-account" class="button" href="#">
+ {{t 'add_verb'}}
+ </a>
+ </div>
<p class="note">{{t 'user.login_or_email_used_as_scm_account'}}</p>
</div>
</div>