Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix multiple table view issues #337

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 25 additions & 1 deletion client/gui/keyboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,11 @@ const KEYS = {
K: 75,
L: 76,
M: 77,
N: 78,
P: 80,
R: 82,
S: 83,
T: 84,
X: 88,
Y: 89,
Z: 90,
Expand Down Expand Up @@ -93,6 +95,13 @@ function keyup(app, event) {
return;
}

if (pressed.has(KEYS.OPT) && event.which === KEYS.N && corpus.format === 'CoNLL-U') {
gui.config.is_table_visible = true;
gui.refresh();
gui.table.toggleEditing(false);
return;
}

const focus = $(':focus');

if (focus.is('.conllu-table')) {
Expand Down Expand Up @@ -137,7 +146,22 @@ function keyup(app, event) {

case (KEYS.ESC):
const originalValue = td.attr('original-value') || '';
td.text(originalValue).blur();
td.text(originalValue);
table.toggleEditing(false);
break;

case (KEYS.BACKSPACE):
case (KEYS.DELETE):
if (table.editing)
break;
td.text('')
table.toggleEditing(false);
break;

case (KEYS.MINUS_):
case (KEYS.MINUS):
if (!table.editing)
$('th').filter(`[col-id="${td.attr('col-id')}"]`).trigger('click');
break;
}

Expand Down
28 changes: 18 additions & 10 deletions client/gui/table.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,8 @@ class Table {
.focus();

}
if (td.hasClass('column-hide'))
$('#table-data th').filter(`[col-id=${this.col.toString()}]`).trigger('click');

console.log(td.prop('contenteditable'))
}
Expand All @@ -142,18 +144,24 @@ class Table {

const self = this;

$('#table-data th').click(e => {
$(window).resize(function() {
$('#data-container > div').css({'width':'', 'height':''})
});

const target = $(e.target),
col = target.attr('col-id'),
columns = self.gui.config.column_visibilities;
$('#table-data th')
.off()
.click(e => {

if (!target.hasClass('hideable'))
return;
const target = $(e.target),
col = target.closest('.hideable').attr('col-id'),
columns = self.gui.config.column_visibilities;

columns[col] = !columns[col];
self.refresh();
});
if (!target.closest('.hideable').length)
return;

columns[col] = !columns[col];
self.refresh();
});

$('#table-data td')
.click(e => {
Expand Down Expand Up @@ -275,7 +283,7 @@ class Table {
.attr('field', field)
.attr('original-value', value)
.attr('name', j === 0 ? 'index' : 'content')
.css('visibility', visibilities[j] ? 'visible' : 'hidden');
.addClass(visibilities[j] ? 'column-show' : 'column-hide');

inputSpan.text(value);

Expand Down
37 changes: 32 additions & 5 deletions server/public/js/bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -10746,9 +10746,11 @@ var KEYS = {
K: 75,
L: 76,
M: 77,
N: 78,
P: 80,
R: 82,
S: 83,
T: 84,
X: 88,
Y: 89,
Z: 90,
Expand Down Expand Up @@ -10804,6 +10806,13 @@ function keyup(app, event) {
return;
}

if (pressed.has(KEYS.OPT) && event.which === KEYS.N && corpus.format === 'CoNLL-U') {
gui.config.is_table_visible = true;
gui.refresh();
gui.table.toggleEditing(false);
return;
}

var focus = $(':focus');

if (focus.is('.conllu-table')) {
Expand Down Expand Up @@ -10844,7 +10853,20 @@ function keyup(app, event) {

case KEYS.ESC:
var originalValue = td.attr('original-value') || '';
td.text(originalValue).blur();
td.text(originalValue);
table.toggleEditing(false);
break;

case KEYS.BACKSPACE:
case KEYS.DELETE:
if (table.editing) break;
td.text('');
table.toggleEditing(false);
break;

case KEYS.MINUS_:
case KEYS.MINUS:
if (!table.editing) $('th').filter('[col-id="' + td.attr('col-id') + '"]').trigger('click');
break;
}

Expand Down Expand Up @@ -13069,6 +13091,7 @@ var Table = function () {
td.blur();
$('[col-id="' + this.col + '"][row-id="' + this.row + '"]').addClass('focused').focus();
}
if (td.hasClass('column-hide')) $('#table-data th').filter('[col-id=' + this.col.toString() + ']').trigger('click');

console.log(td.prop('contenteditable'));
}
Expand All @@ -13078,13 +13101,17 @@ var Table = function () {

var self = this;

$('#table-data th').click(function (e) {
$(window).resize(function () {
$('#data-container > div').css({ 'width': '', 'height': '' });
});

$('#table-data th').off().click(function (e) {

var target = $(e.target),
col = target.attr('col-id'),
col = target.closest('.hideable').attr('col-id'),
columns = self.gui.config.column_visibilities;

if (!target.hasClass('hideable')) return;
if (!target.closest('.hideable').length) return;

columns[col] = !columns[col];
self.refresh();
Expand Down Expand Up @@ -13169,7 +13196,7 @@ var Table = function () {

var visibilities = _this.gui.config.column_visibilities;

td.addClass('conllu-table').attr('tabindex', '-1').attr('row-id', i).attr('col-id', j).attr('num', 10 * i + j).attr('uuid', token.uuid).attr('field', field).attr('original-value', value).attr('name', j === 0 ? 'index' : 'content').css('visibility', visibilities[j] ? 'visible' : 'hidden');
td.addClass('conllu-table').attr('tabindex', '-1').attr('row-id', i).attr('col-id', j).attr('num', 10 * i + j).attr('uuid', token.uuid).attr('field', field).attr('original-value', value).attr('name', j === 0 ? 'index' : 'content').addClass(visibilities[j] ? 'column-show' : 'column-hide');

inputSpan.text(value);

Expand Down