Fix UI issues, unclickable user column, add confirm dialog

pull/1/head
yflory 8 years ago
parent 740b6e955e
commit f26cdb1a21

@ -434,6 +434,7 @@ div.realtime table thead td {
padding: 0px 5px; padding: 0px 5px;
background: #4c443f; background: #4c443f;
border-radius: 20px 20px 0 0; border-radius: 20px 20px 0 0;
text-align: center;
} }
form.realtime table thead td input[type="text"], form.realtime table thead td input[type="text"],
div.realtime table thead td input[type="text"] { div.realtime table thead td input[type="text"] {

@ -480,6 +480,7 @@ form.realtime, div.realtime {
padding: 0px 5px; padding: 0px 5px;
background: @less-light-base; background: @less-light-base;
border-radius: 20px 20px 0 0; border-radius: 20px 20px 0 0;
text-align: center;
input { input {
&[type="text"] { &[type="text"] {
width: 100%; width: 100%;

@ -91,6 +91,7 @@ define([
$('input[disabled="disabled"][data-rt-id^="' + id + '"]').removeAttr('disabled'); $('input[disabled="disabled"][data-rt-id^="' + id + '"]').removeAttr('disabled');
$('input[type="checkbox"][data-rt-id^="' + id + '"]').addClass('enabled'); $('input[type="checkbox"][data-rt-id^="' + id + '"]').addClass('enabled');
$('[data-rt-id="' + id + '"] ~ .edit').css('visibility', 'hidden'); $('[data-rt-id="' + id + '"] ~ .edit').css('visibility', 'hidden');
$('.lock[data-rt-id="' + id + '"]').html('🔓');
if (isOwnColumnCommitted()) { return; } if (isOwnColumnCommitted()) { return; }
$('[data-rt-id^="' + id + '"]').closest('td').addClass("uncommitted"); $('[data-rt-id^="' + id + '"]').closest('td').addClass("uncommitted");
@ -108,11 +109,12 @@ define([
$('input[disabled="disabled"][data-rt-id^="' + id + '"]').removeAttr('disabled'); $('input[disabled="disabled"][data-rt-id^="' + id + '"]').removeAttr('disabled');
$('input[type="checkbox"][data-rt-id^="' + id + '"]').addClass('enabled'); $('input[type="checkbox"][data-rt-id^="' + id + '"]').addClass('enabled');
$('span.edit[data-rt-id="' + id + '"]').css('visibility', 'hidden'); $('span.edit[data-rt-id="' + id + '"]').css('visibility', 'hidden');
$('.lock[data-rt-id="' + id + '"]').html('🔓');
}); });
}; };
var updateTableButtons = function () { var updateTableButtons = function () {
if ($('.checkbox-cell').length && !isOwnColumnCommitted()) { if (!isOwnColumnCommitted()) {
$('#commit').show(); $('#commit').show();
} }
@ -246,9 +248,12 @@ define([
var isRemove = span.className && span.className.split(' ').indexOf('remove') !== -1; var isRemove = span.className && span.className.split(' ').indexOf('remove') !== -1;
var isEdit = span.className && span.className.split(' ').indexOf('edit') !== -1; var isEdit = span.className && span.className.split(' ').indexOf('edit') !== -1;
if (isRemove) { if (isRemove) {
Cryptpad.confirm(Messages.poll_removeOption, function (res) {
if (!res) { return; }
Render.removeRow(APP.proxy, id, function () { Render.removeRow(APP.proxy, id, function () {
change(); change();
}); });
});
} else if (isEdit) { } else if (isEdit) {
unlockRow(id, function () { unlockRow(id, function () {
change(); change();
@ -258,9 +263,12 @@ define([
var isRemove = span.className && span.className.split(' ').indexOf('remove') !== -1; var isRemove = span.className && span.className.split(' ').indexOf('remove') !== -1;
var isEdit = span.className && span.className.split(' ').indexOf('edit') !== -1; var isEdit = span.className && span.className.split(' ').indexOf('edit') !== -1;
if (isRemove) { if (isRemove) {
Cryptpad.confirm(Messages.poll_removeUser, function (res) {
if (!res) { return; }
Render.removeColumn(APP.proxy, id, function () { Render.removeColumn(APP.proxy, id, function () {
change(); change();
}); });
});
} else if (isEdit) { } else if (isEdit) {
unlockColumn(id, function () { unlockColumn(id, function () {
change(); change();
@ -277,9 +285,10 @@ define([
if ($(e.target).is('[type="text"]')) { if ($(e.target).is('[type="text"]')) {
return; return;
} }
$('.lock[data-rt-id!="' + APP.userid + '"]').html('🔒 ');
var $cells = APP.$table.find('thead td:not(.uncommitted), tbody td'); var $cells = APP.$table.find('thead td:not(.uncommitted), tbody td');
$cells.find('[type="text"][data-rt-id!="' + APP.userid + '"]').attr('disabled', true); $cells.find('[type="text"][data-rt-id!="' + APP.userid + '"]').attr('disabled', true);
$cells.find('[data-rt-id!="' + APP.userid + '"] ~ .edit').css('visibility', 'visible'); $('.edit[data-rt-id!="' + APP.userid + '"]').css('visibility', 'visible');
APP.editable.col = [APP.userid]; APP.editable.col = [APP.userid];
APP.editable.row = []; APP.editable.row = [];
}; };
@ -294,14 +303,13 @@ define([
if (isKeyup) { if (isKeyup) {
console.log("Keyup!"); console.log("Keyup!");
return;
} }
if (!target) { return void console.log("NO TARGET"); } if (!target) { return void console.log("NO TARGET"); }
var nodeName = target && target.nodeName; var nodeName = target && target.nodeName;
if (!$(target).parents('#table tbody').length) { if (!$(target).parents('#table tbody').length || $(target).hasClass('edit')) {
hideInputs(e); hideInputs(e);
} }

@ -111,6 +111,12 @@ by maintaining indexes in rowsOrder and colsOrder
.error(new Error("Attempted to remove id which does not exist")); .error(new Error("Attempted to remove id which does not exist"));
} }
Object.keys(obj.table.cells).forEach(function (key) {
if (key.indexOf(id) === 0) {
delete obj.table.cells[key];
}
});
order.splice(idx, 1); order.splice(idx, 1);
if (parent[id]) { delete parent[id]; } if (parent[id]) { delete parent[id]; }
if (typeof(cb) === 'function') { if (typeof(cb) === 'function') {
@ -256,14 +262,23 @@ by maintaining indexes in rowsOrder and colsOrder
}, ['✐']]; }, ['✐']];
}; };
var makeLockElement = Render.makeLockElement = function (id) {
return ['SPAN', {
'data-rt-id': id,
class: 'lock',
}, ['🔒']];
};
var makeHeadingCell = Render.makeHeadingCell = function (cell, readOnly) { var makeHeadingCell = Render.makeHeadingCell = function (cell, readOnly) {
if (!cell) { return ['TD', {}, []]; } if (!cell) { return ['TD', {}, []]; }
if (cell.type === 'text') { if (cell.type === 'text') {
var removeElement = makeRemoveElement(cell['data-rt-id']); var removeElement = makeRemoveElement(cell['data-rt-id']);
var editElement = makeEditElement(cell['data-rt-id']); var editElement = makeEditElement(cell['data-rt-id']);
var lockElement = makeLockElement(cell['data-rt-id']);
var elements = [['INPUT', cell, []]]; var elements = [['INPUT', cell, []]];
if (!readOnly) { if (!readOnly) {
elements.unshift(removeElement); elements.unshift(removeElement);
elements.unshift(lockElement);
elements.unshift(editElement); elements.unshift(editElement);
} }
return ['TD', {}, elements]; return ['TD', {}, elements];

Loading…
Cancel
Save