From f26cdb1a216ff2264047f03a10831be3f1633cd8 Mon Sep 17 00:00:00 2001 From: yflory Date: Wed, 7 Dec 2016 11:44:09 +0100 Subject: [PATCH] Fix UI issues, unclickable user column, add confirm dialog --- customize.dist/main.css | 1 + customize.dist/src/cryptpad.less | 1 + www/poll/test/main.js | 24 ++++++++++++++++-------- www/poll/test/render.js | 15 +++++++++++++++ 4 files changed, 33 insertions(+), 8 deletions(-) diff --git a/customize.dist/main.css b/customize.dist/main.css index 99b5eea7f..62208fa1b 100644 --- a/customize.dist/main.css +++ b/customize.dist/main.css @@ -434,6 +434,7 @@ div.realtime table thead td { padding: 0px 5px; background: #4c443f; border-radius: 20px 20px 0 0; + text-align: center; } form.realtime table thead td input[type="text"], div.realtime table thead td input[type="text"] { diff --git a/customize.dist/src/cryptpad.less b/customize.dist/src/cryptpad.less index d0a783f3e..d681e3c50 100644 --- a/customize.dist/src/cryptpad.less +++ b/customize.dist/src/cryptpad.less @@ -480,6 +480,7 @@ form.realtime, div.realtime { padding: 0px 5px; background: @less-light-base; border-radius: 20px 20px 0 0; + text-align: center; input { &[type="text"] { width: 100%; diff --git a/www/poll/test/main.js b/www/poll/test/main.js index 3e9b3d5ee..63df28926 100644 --- a/www/poll/test/main.js +++ b/www/poll/test/main.js @@ -91,6 +91,7 @@ define([ $('input[disabled="disabled"][data-rt-id^="' + id + '"]').removeAttr('disabled'); $('input[type="checkbox"][data-rt-id^="' + id + '"]').addClass('enabled'); $('[data-rt-id="' + id + '"] ~ .edit').css('visibility', 'hidden'); + $('.lock[data-rt-id="' + id + '"]').html('🔓'); if (isOwnColumnCommitted()) { return; } $('[data-rt-id^="' + id + '"]').closest('td').addClass("uncommitted"); @@ -108,11 +109,12 @@ define([ $('input[disabled="disabled"][data-rt-id^="' + id + '"]').removeAttr('disabled'); $('input[type="checkbox"][data-rt-id^="' + id + '"]').addClass('enabled'); $('span.edit[data-rt-id="' + id + '"]').css('visibility', 'hidden'); + $('.lock[data-rt-id="' + id + '"]').html('🔓'); }); }; var updateTableButtons = function () { - if ($('.checkbox-cell').length && !isOwnColumnCommitted()) { + if (!isOwnColumnCommitted()) { $('#commit').show(); } @@ -246,8 +248,11 @@ define([ var isRemove = span.className && span.className.split(' ').indexOf('remove') !== -1; var isEdit = span.className && span.className.split(' ').indexOf('edit') !== -1; if (isRemove) { - Render.removeRow(APP.proxy, id, function () { - change(); + Cryptpad.confirm(Messages.poll_removeOption, function (res) { + if (!res) { return; } + Render.removeRow(APP.proxy, id, function () { + change(); + }); }); } else if (isEdit) { unlockRow(id, function () { @@ -258,8 +263,11 @@ define([ var isRemove = span.className && span.className.split(' ').indexOf('remove') !== -1; var isEdit = span.className && span.className.split(' ').indexOf('edit') !== -1; if (isRemove) { - Render.removeColumn(APP.proxy, id, function () { - change(); + Cryptpad.confirm(Messages.poll_removeUser, function (res) { + if (!res) { return; } + Render.removeColumn(APP.proxy, id, function () { + change(); + }); }); } else if (isEdit) { unlockColumn(id, function () { @@ -277,9 +285,10 @@ define([ if ($(e.target).is('[type="text"]')) { return; } + $('.lock[data-rt-id!="' + APP.userid + '"]').html('🔒 '); 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('[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.row = []; }; @@ -294,14 +303,13 @@ define([ if (isKeyup) { console.log("Keyup!"); - return; } if (!target) { return void console.log("NO TARGET"); } var nodeName = target && target.nodeName; - if (!$(target).parents('#table tbody').length) { + if (!$(target).parents('#table tbody').length || $(target).hasClass('edit')) { hideInputs(e); } diff --git a/www/poll/test/render.js b/www/poll/test/render.js index 826a867a9..b0b41369d 100644 --- a/www/poll/test/render.js +++ b/www/poll/test/render.js @@ -111,6 +111,12 @@ by maintaining indexes in rowsOrder and colsOrder .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); if (parent[id]) { delete parent[id]; } 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) { if (!cell) { return ['TD', {}, []]; } if (cell.type === 'text') { var removeElement = makeRemoveElement(cell['data-rt-id']); var editElement = makeEditElement(cell['data-rt-id']); + var lockElement = makeLockElement(cell['data-rt-id']); var elements = [['INPUT', cell, []]]; if (!readOnly) { elements.unshift(removeElement); + elements.unshift(lockElement); elements.unshift(editElement); } return ['TD', {}, elements];