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
|
|
|
|
|
|
|
class ProjectMembers {
|
|
|
|
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-08-31 14:28:58 +00:00
|
|
|
$('.js-member-update-control').on('change', function () {
|
2016-09-01 10:56:21 +00:00
|
|
|
$(this).closest('form')
|
|
|
|
.trigger("submit.rails");
|
2016-09-01 15:22:53 +00:00
|
|
|
$(this).disable();
|
|
|
|
});
|
|
|
|
$('.js-edit-member-form').on('ajax:success', function () {
|
|
|
|
$(this).find('.js-member-update-control').enable();
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
submitForm() {
|
2016-09-01 10:56:21 +00:00
|
|
|
|
2016-08-31 14:28:58 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
gl.ProjectMembers = ProjectMembers;
|
|
|
|
})(window);
|