2018-03-09 20:18:59 +00:00
|
|
|
import $ from 'jquery';
|
2019-07-03 08:20:57 +00:00
|
|
|
import { slugify } from './lib/utils/text_utility';
|
2018-03-09 20:18:59 +00:00
|
|
|
|
2017-03-12 15:22:00 +00:00
|
|
|
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-10-30 16:23:47 +00:00
|
|
|
this.groupName.on('keyup', this.updateHandler);
|
|
|
|
this.groupPath.on('keydown', this.resetHandler);
|
2017-03-12 15:22:00 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
update() {
|
2019-07-03 08:20:57 +00:00
|
|
|
const slug = slugify(this.groupName.val());
|
2018-10-30 16:23:47 +00:00
|
|
|
this.groupPath.val(slug);
|
2017-03-12 15:22:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
reset() {
|
2018-10-30 16:23:47 +00:00
|
|
|
this.groupName.off('keyup', this.updateHandler);
|
|
|
|
this.groupPath.off('keydown', this.resetHandler);
|
2017-03-12 15:22:00 +00:00
|
|
|
}
|
|
|
|
}
|