in source/webapp/src/lib/js/labelEditor.js [339:409]
async onModify(action, event) {
const grandparent = $(this.target).parent().parent();
const trackCategory = grandparent.data('track-category');
const trackType = grandparent.data('track-type');
const trackGroup = $(this.target).data('track-group');
let id = LabelEditor.Constants.Form.Checkbox.Id;
const applyAll = this.modal.find(`input#${id}`).first().prop('checked');
id = LabelEditor.Constants.Form.Input.Id;
const input = this.modal.find(`input#${id}`).first();
const olabel = input.data('label-original');
const nlabel = input.val().trim();
const list = [];
id = LabelEditor.Constants.Form.Table.Id;
this.modal.find(`#${id}`).first().find('input[type="checkbox"]').each((k, v) => {
const elem = $(v);
if (elem.prop('checked') || applyAll) {
list.push({
startTime: Number.parseInt(elem.data('start-time'), 10),
endTime: Number.parseInt(elem.data('end-time'), 10),
});
}
});
if (!list.length && !applyAll) {
alert('select the timecode(s) or \'apply to all\' to modify the label');
return;
}
if (action === 'apply' && olabel.toLowerCase() === nlabel.toLowerCase()) {
alert('original and new label names are the same. nothing to modify.');
return;
}
const response = await ApiHelper.editLabel({
uuid: this.parent.current.uuid,
trackCategory,
trackType,
trackGroup,
track: {
name: {
original: olabel,
modified: nlabel,
},
action,
[action]: list,
applyAll,
},
});
let forceReloadAiml = false;
Object.keys(response.vtt).forEach((x) => {
if (response.vtt[x].deleted) {
this.parent.removeLabel(trackCategory, trackGroup, x, response.vtt[x].deleted);
forceReloadAiml = true;
}
if (response.vtt[x].added) {
this.parent.addLabel(trackCategory, trackGroup, x, response.vtt[x].added);
forceReloadAiml = true;
}
if (response.vtt[x].modified) {
this.parent.reloadLabel(trackCategory, trackGroup, x, response.vtt[x].modified);
}
});
if (forceReloadAiml) {
await this.parent.reloadAimlResults();
}
this.modal.modal('hide');
}