2018-05-09 12:01:36 +05:30
|
|
|
import $ from 'jquery';
|
2019-09-30 21:07:59 +05:30
|
|
|
import { slugify } from './lib/utils/text_utility';
|
2018-05-09 12:01:36 +05:30
|
|
|
|
2017-08-17 22:00:37 +05:30
|
|
|
export default class Group {
|
|
|
|
constructor() {
|
|
|
|
this.groupPath = $('#group_path');
|
|
|
|
this.groupName = $('#group_name');
|
|
|
|
this.updateHandler = this.update.bind(this);
|
|
|
|
this.resetHandler = this.reset.bind(this);
|
|
|
|
if (this.groupName.val() === '') {
|
2018-12-13 13:39:08 +05:30
|
|
|
this.groupName.on('keyup', this.updateHandler);
|
|
|
|
this.groupPath.on('keydown', this.resetHandler);
|
2017-08-17 22:00:37 +05:30
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
update() {
|
2019-09-30 21:07:59 +05:30
|
|
|
const slug = slugify(this.groupName.val());
|
2018-12-13 13:39:08 +05:30
|
|
|
this.groupPath.val(slug);
|
2017-08-17 22:00:37 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
reset() {
|
2018-12-13 13:39:08 +05:30
|
|
|
this.groupName.off('keyup', this.updateHandler);
|
|
|
|
this.groupPath.off('keydown', this.resetHandler);
|
2017-08-17 22:00:37 +05:30
|
|
|
}
|
|
|
|
}
|