Skip to content

Commit

Permalink
Review: make setting for finer grained review colors persistent
Browse files Browse the repository at this point in the history
  • Loading branch information
tomka committed Apr 21, 2017
1 parent a54058e commit e56ce64
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 9 deletions.
16 changes: 13 additions & 3 deletions django/applications/catmaid/static/js/widgets/review.js
Original file line number Diff line number Diff line change
Expand Up @@ -1347,8 +1347,6 @@
'#ffd87a', '#ffe777', '#fff774', '#e6ff6e', '#d4ff6b'
];

CATMAID.ReviewSystem.useDetailedStatusColors = false;

/**
* Support function for selecting a background color based on review state.
*/
Expand All @@ -1358,7 +1356,7 @@
} else if (0 === reviewed) {
return CATMAID.ReviewSystem.STATUS_COLOR_NONE;
} else {
if (CATMAID.ReviewSystem.useDetailedStatusColors) {
if (CATMAID.ReviewSystem.Settings.session.detailed_review_colors) {
// Get a color index in [0,9], mapping to review percentages 1 to 99
var colorIndex = Math.max(0, Math.min(9, Math.floor(reviewed / 10)));
return CATMAID.ReviewSystem.STATUS_COLOR_PARTIAL_8[colorIndex];
Expand Down Expand Up @@ -1458,6 +1456,18 @@
};
})();

CATMAID.ReviewSystem.Settings = new CATMAID.Settings(
'review',
{
version: 0,
entries: {
detailed_review_colors: {
default: false
}
},
migrations: {}
});

CATMAID.Init.on(CATMAID.Init.EVENT_PROJECT_CHANGED, CATMAID.ReviewSystem.Whitelist.refresh);
CATMAID.Init.on(CATMAID.Init.EVENT_USER_CHANGED, CATMAID.ReviewSystem.Whitelist.refresh);

Expand Down
17 changes: 11 additions & 6 deletions django/applications/catmaid/static/js/widgets/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -1290,12 +1290,17 @@
}));

// Review status coloring
ds.append(CATMAID.DOM.createCheckboxSetting('Use detailed review color status',
CATMAID.ReviewSystem.useDetailedStatusColors,
'If true, review status is displayed in nine different colors between ' +
'the regular 0% and 100% colors.', function() {
CATMAID.ReviewSystem.useDetailedStatusColors = this.checked;
}));
ds.append(wrapSettingsControl(
CATMAID.DOM.createCheckboxSetting('Use detailed review color status',
CATMAID.ReviewSystem.Settings[SETTINGS_SCOPE].detailed_review_colors,
'If true, review status is displayed in nine different colors between ' +
'the regular 0% and 100% colors.', function() {
CATMAID.ReviewSystem.Settings
.set('detailed_review_colors', this.checked, SETTINGS_SCOPE);
}),
CATMAID.ReviewSystem.Settings,
'detailed_review_colors',
SETTINGS_SCOPE));

var dsTracingWarnings = CATMAID.DOM.addSettingsContainer(ds,
"Warnings", true);
Expand Down

0 comments on commit e56ce64

Please sign in to comment.