Skip to content

Commit 88d2aef

Browse files
lucyqfrederickjansen
authored andcommitted
Unmask UI enhancements (#82)
* session page working with requirejs * track page working * handsontable loading * track page working with bootstrap * all pages working with requirejs * code cleanup and reorganizing dependencies * cleaning up code * reorganized to separate views and controllers * added local copy of bootstrap * Saving file in correct rows. Headers for demographic data are still in form of keys * removed .idea * properly sorted columns and sheets * grabbing data from hot for csv * event listeners * drag and drop, unmask button * basic table saving * full table with correct labels * rendering tables * redoing table rendering... * titles render * table showing on click * cleaning the lint * added an alert msg for POST /get_masks * drag functioning again for unmask * drag and drop restored for client * removed extraneous textarea box on unmask page * removed placeholder values * removed unnecessary unmask button * Remove merge conflict leftover * fixed gender labels on unmasked csv * removed placeholder session key and password in unmasking page * moved updating table widths to tableController * error messages for 500 get masks post * fixed string parsing error in saving questions * table headers on unmask page * linting * Fix formatting
1 parent 097bb83 commit 88d2aef

File tree

17 files changed

+1711
-838
lines changed

17 files changed

+1711
-838
lines changed

.eslintignore

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
client/app/helper/sheetjsw.js
2-
3-
2+
client/app/data/*
43
client/app/vendor/*

.eslintrc.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
"extends": "eslint:recommended",
33
"rules": {
44
"indent": [2, 2, { "SwitchCase": 1 }],
5+
"keyword-spacing": [2, { "before": true, "after": true }],
56
"object-shorthand": [2, "consistent"],
67
"no-unused-vars": [1, {"vars": "local", "args": "none"}],
78
"quote-props": [1, "consistent-as-needed"],

client/app/common.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@ require.config({
1313
alertify_defaults: 'helper/alertify_defaults',
1414
DropSheet: 'helper/drop_sheet',
1515
mpc: 'helper/mpc',
16-
ResizeSensor: 'vendor/ResizeSensor'
16+
ResizeSensor: 'vendor/ResizeSensor',
17+
table_template: 'data/tables'
18+
1719
},
1820
shim: {
1921
bootstrap: {

client/app/controllers/analystController.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -225,9 +225,10 @@ define(['filesaver'], function (filesaver) {
225225
},
226226
error: function (err) {
227227
/* global errmsg */
228-
var errmsg = 'Error Connecting: Reconnect Attempt #' + counter.toString();
228+
// NOTE: commented out because errmsg is assigned a value but never used
229+
// var errmsg = 'Error Connecting: Reconnect Attempt #' + counter.toString();
229230
if (err && err.hasOwnProperty('responseText') && err.responseText !== undefined) {
230-
errmsg = err.responseText;
231+
// errmsg = err.responseText;
231232
}
232233

233234
//document.getElementById(status).className = 'alert alert-error';

client/app/controllers/clientController.js

Lines changed: 12 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* global alertify, $ */
22

3-
define(['jquery', 'helper/sail_HOT', 'helper/mpc', 'alertify', 'alertify_defaults'], function ($, sailHOT, mpc, alertify) {
3+
define(['jquery', 'controllers/tableController', 'helper/mpc', 'alertify', 'alertify_defaults'], function ($, tableController, mpc, alertify) {
44

55
var client = (function () {
66
var SESSION_KEY_ERROR = 'Invalid session number';
@@ -24,6 +24,7 @@ define(['jquery', 'helper/sail_HOT', 'helper/mpc', 'alertify', 'alertify_default
2424
discrepancies: SEMANTIC_CELLS
2525
};
2626

27+
// TODO: create new view for alerts
2728
function error(msg) {
2829
alertify.alert('<img src="/images/cancel.png" alt="Error">Error!', msg);
2930
}
@@ -77,11 +78,6 @@ define(['jquery', 'helper/sail_HOT', 'helper/mpc', 'alertify', 'alertify_default
7778
dataType: 'text'
7879
}).then(function (response) {
7980
response = JSON.parse(response);
80-
var title = response.title;
81-
var description = response.description;
82-
83-
//$("#session-title").html(title);
84-
//$("#session-description").html(description);
8581

8682
var $parent = $('#session, #participation-code').parent();
8783
$parent.removeClass('has-error').addClass('has-success has-feedback');
@@ -116,11 +112,8 @@ define(['jquery', 'helper/sail_HOT', 'helper/mpc', 'alertify', 'alertify_default
116112
function updateWidth(tables, reset) {
117113

118114
if (reset) {
119-
var $instructions = $('#instructions');
120-
$instructions.css('width', '');
121-
$instructions.css('max-width', '');
122-
$instructions.css('margin-left', '');
123-
$('header, #shadow').css('right', 0);
115+
tableController.resetTableWidth();
116+
124117
tableWidthsOld = [];
125118
return;
126119
}
@@ -149,24 +142,7 @@ define(['jquery', 'helper/sail_HOT', 'helper/mpc', 'alertify', 'alertify_default
149142

150143
var maxWidth = Math.max.apply(null, tableWidths);
151144

152-
// Reset width of instructions.
153-
$('#instructions').css('width', maxWidth);
154-
$('#instructions').css('max-width', maxWidth);
155-
var documentWidth = $(window).width();
156-
var containerWidth = parseFloat($('.container').first().width());
157-
var offset = (containerWidth - maxWidth) / 2;
158-
159-
if (offset < (containerWidth - documentWidth) / 2) {
160-
offset = (containerWidth - documentWidth) / 2;
161-
}
162-
163-
if (maxWidth > documentWidth) {
164-
$('header, #shadow').css('right', documentWidth - maxWidth);
165-
}
166-
167-
// Bootstrap row has margin-left: -15px, add this back to offset to keep card centered
168-
$('#instructions').css('margin-left', offset + 15);
169-
145+
tableController.updateTableWidth(maxWidth);
170146
tableWidthsOld = tableWidths.concat();
171147
}
172148

@@ -240,8 +216,8 @@ define(['jquery', 'helper/sail_HOT', 'helper/mpc', 'alertify', 'alertify_default
240216
}
241217

242218
// Register semantic discrepancies validator.
243-
// console.log("VALIDATE?", register_validator)
244-
sailHOT.register_validator('discrepancies', function (table, cell, value, callback) {
219+
// console.log("VALIDATE?", registerValidator)
220+
tableController.registerValidator('discrepancies', function (table, cell, value, callback) {
245221
checkSemanticDiscrepancies(tables, table, cell, value, callback);
246222
});
247223

@@ -258,19 +234,18 @@ define(['jquery', 'helper/sail_HOT', 'helper/mpc', 'alertify', 'alertify_default
258234
errorMsg = GENERIC_TABLE_ERR;
259235
errorMsg = errorMsg.replace('%s', table_name);
260236
}
261-
262237
if (errors.indexOf(errorMsg) === -1) {
263238
errors = errors.concat(errorMsg);
264239
}
265240
};
266-
sailHOT.register_error_handler(errorHandler);
241+
tableController.registerErrorHandler(errorHandler);
267242

268243
// Validate tables (callback chaining)
269244
(function validate_callback(i) {
270245
if (i >= tables.length) {
271246
// Remove the semantic discrepancies validator.
272-
sailHOT.remove_validator('discrepancies');
273-
sailHOT.remove_error_handler(0);
247+
tableController.removeValidator('discrepancies');
248+
tableController.removeErrorHandler(0);
274249
for (i = 0; i < tables.length; i++) {
275250
tables[i].render();
276251
}
@@ -336,7 +311,7 @@ define(['jquery', 'helper/sail_HOT', 'helper/mpc', 'alertify', 'alertify_default
336311

337312
// Handle table data, tables are represented as 2D associative arrays
338313
// with the first index being the row key, and the second being the column key
339-
var tables_data = sailHOT.construct_data_tables(tables);
314+
var tables_data = tableController.constructDataTables(tables);
340315
for (var i = 0; i < tables_data.length; i++) {
341316
data_submission[tables_data[i].name] = tables_data[i].data;
342317
}
@@ -443,7 +418,7 @@ define(['jquery', 'helper/sail_HOT', 'helper/mpc', 'alertify', 'alertify_default
443418
* 2. For the bonus table (3rd table), it can only be non-zero if the other tables are non-zero.
444419
*/
445420
function checkSemanticDiscrepancies(tables, table, cell, value, callback) {
446-
var num_regex = /$[0-9]+^/; // no need to worry about empty spaces, hot removes them for number types.
421+
// var num_regex = /$[0-9]+^/; // no need to worry about empty spaces, hot removes them for number types.
447422
var bonus_table = tables[2];
448423
var name = table._sail_meta.name;
449424
var r = cell.row_index;

0 commit comments

Comments
 (0)