Fix pinned column not always stored in polls

pull/1/head
yflory 7 years ago
parent 88e7f9a218
commit 7bc2f81852

@ -838,12 +838,9 @@ define([
prepareProxy(uncommitted, copyObject(Render.Example)); prepareProxy(uncommitted, copyObject(Render.Example));
if (!APP.readOnly) { if (!APP.readOnly) {
var coluid = Render.coluid(); var coluid = Render.coluid();
if (proxy.content.colsOrder.indexOf(userid) === -1 && if (userid) {
uncommitted.content.colsOrder.indexOf(userid) === -1) { // If userid exists, it means the user already has a pinned column
// The user doesn't have his own column: the new one should be his // and we should unlock it
coluid = userid;
} else {
// The user already has his own column: unlock it
unlockColumn(userid); unlockColumn(userid);
} }
uncommitted.content.colsOrder.push(coluid); uncommitted.content.colsOrder.push(coluid);
@ -968,10 +965,10 @@ define([
}); });
// If the user's column is not committed, add his username // If the user's column is not committed, add his username
var $userInput = $('.cp-app-poll-table-uncommitted > input[data-rt-id^='+ APP.userid +']'); var $userInput = $('.cp-app-poll-table-uncommitted > input');
if ($userInput.val() === '') { if (!APP.userid) {
var uname = metadataMgr.getUserData().name; var uname = metadataMgr.getUserData().name;
APP.uncommitted.content.cols[APP.userid] = uname; APP.uncommitted.content.cols[APP.uncommitted.content.colsOrder[0]] = uname;
$userInput.val(uname); $userInput.val(uname);
} }
@ -1164,7 +1161,6 @@ define([
.on('ready', function (info) { .on('ready', function (info) {
common.getPadAttribute('userid', function (e, userid) { common.getPadAttribute('userid', function (e, userid) {
if (e) { console.error(e); } if (e) { console.error(e); }
if (!userid) { userid = Render.coluid(); }
APP.userid = userid; APP.userid = userid;
onReady(info, userid); onReady(info, userid);
}); });

Loading…
Cancel
Save