2016-08-31 14:28:58 +00:00
|
|
|
((w) => {
|
2016-09-01 15:22:53 +00:00
|
|
|
w.gl = w.gl || {};
|
2016-08-31 14:28:58 +00:00
|
|
|
|
2016-09-02 13:19:11 +00:00
|
|
|
class Members {
|
2016-08-31 14:28:58 +00:00
|
|
|
constructor() {
|
|
|
|
this.removeListeners();
|
|
|
|
this.addListeners();
|
|
|
|
}
|
|
|
|
|
|
|
|
removeListeners() {
|
2016-09-01 14:27:42 +00:00
|
|
|
$('.project_member, .group_member').off('ajax:success');
|
2016-08-31 14:28:58 +00:00
|
|
|
$('.js-member-update-control').off('change');
|
2016-09-01 15:22:53 +00:00
|
|
|
$('.js-edit-member-form').off('ajax:success');
|
2016-08-31 14:28:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
addListeners() {
|
2016-09-01 14:27:42 +00:00
|
|
|
$('.project_member, .group_member').on('ajax:success', this.removeRow);
|
2016-09-05 14:11:45 +00:00
|
|
|
$('.js-member-update-control').on('change', this.formSubmit);
|
|
|
|
$('.js-edit-member-form').on('ajax:success', this.formSuccess);
|
2016-08-31 14:28:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
removeRow(e) {
|
|
|
|
const $target = $(e.target);
|
|
|
|
|
|
|
|
if ($target.hasClass('btn-remove')) {
|
2016-09-02 08:25:53 +00:00
|
|
|
$target.closest('.member')
|
|
|
|
.fadeOut(function () {
|
|
|
|
$(this).remove();
|
|
|
|
});
|
2016-08-31 14:28:58 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-09-05 14:11:45 +00:00
|
|
|
formSubmit() {
|
2016-09-07 11:36:21 +00:00
|
|
|
$(this).closest('form')
|
|
|
|
.trigger("submit.rails")
|
|
|
|
.end()
|
|
|
|
.disable();
|
2016-09-05 14:11:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
formSuccess() {
|
|
|
|
$(this).find('.js-member-update-control').enable();
|
2016-08-31 14:28:58 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-09-02 13:19:11 +00:00
|
|
|
gl.Members = Members;
|
2016-08-31 14:28:58 +00:00
|
|
|
})(window);
|