Skip to content
This repository has been archived by the owner on Jan 22, 2024. It is now read-only.

Commit

Permalink
Merge pull request #104 from TeselaGen/sl_editOnly
Browse files Browse the repository at this point in the history
basic readOnly signals are set up and running
  • Loading branch information
tnrich committed Nov 13, 2015
2 parents 67b5779 + 6364e59 commit 5303216
Show file tree
Hide file tree
Showing 5 changed files with 117 additions and 41 deletions.
12 changes: 11 additions & 1 deletion app/StatusBar.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,14 @@ import styles from './status-bar.css';
selectedSeqMeltingTemp: ['selectedSeqMeltingTemp'],
caretPosition: ['caretPosition'],
selectionLayer: ['selectionLayer'],
readOnly: ['readOnly']
})
@propTypes({
sequenceLength: PropTypes.number.isRequired,
selectedSeqMeltingTemp: PropTypes.number.isRequired,
caretPosition: PropTypes.number.isRequired,
selectionLayer: PropTypes.object.isRequired,
readOnly: PropTypes.bool.isRequired
})
export default class StatusBar extends React.Component {

Expand All @@ -24,7 +26,9 @@ export default class StatusBar extends React.Component {
sequenceLength,
selectedSeqMeltingTemp,
caretPosition,
selectionLayer
selectionLayer,
readOnly,
signals
} = this.props;

var selectionStart = (selectionLayer.start != -1) ? selectionLayer.start : '--';
Expand All @@ -33,6 +37,12 @@ export default class StatusBar extends React.Component {
return (
<div ref="statusBar">
<div className={styles.bar}>
<div>
<button onClick={function () {
signals.setEditState();}}>Set Edit</button>
<button onClick={function () {
signals.testSignal();}}>Test Edit</button>
</div>
<div className={styles.box}>
<div className={styles.label}>Length</div>
<div className={styles.data}>{sequenceLength}</div>
Expand Down
8 changes: 8 additions & 0 deletions app/actions/checkIfEditAllowed.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
export default function checkIfEditAllowed({ selectionLayer }, tree, output) {
if (tree.get('readOnly')) {
output.readOnly();
} else {
output.editAllowed();
}
}
checkIfEditAllowed.outputs = ['editAllowed', 'readOnly'];
8 changes: 8 additions & 0 deletions app/actions/setEditState.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
export default function setEditState(input, tree, output) {
//
console.log("setting edit state to read only");
console.log("readOnly: " + tree.get('readOnly'));
tree.set('readOnly', true);
}

// setEditState.outputs = ['shiftHeld', 'shiftNotHeld'];
49 changes: 48 additions & 1 deletion app/signals.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
//tnr: little webpack trick to require all the action files and add them to the 'a' object
var each = require('lodash/collection/each');
var reqContext = require.context('./actions/', true, /^((?!test).)*$/);
var a = {};
reqContext.keys().forEach(function(key) {
a[key.substring(2)] = reqContext(key)
});

//add all the signals to the cerebral controller here
export default function registerSignals(controller, options) {
export default function registerSignals(controller) {
//tnr: WORKING:
controller.signal('copySelection', [a.getData('selectionLayer', 'sequenceData'), a.copySelection, {
success: a.setData('clipboardData'),
Expand Down Expand Up @@ -87,6 +88,52 @@ export default function registerSignals(controller, options) {
//lower priority
controller.signal('addAnnotations', [a.addAnnotations]);
controller.signal('jumpToRow', [a.jumpToRow]);
// sl: in progress
controller.signal('setEditState', [a.setEditState]);

var editModeOnlySignals = {
'testSignal' :[
function(input, tree, output) {
console.log("test signal");
}
],
'backspacePressed': [
a.getData('selectionLayer', 'sequenceLength', 'sequenceData'),
a.checkLayerIsSelected, {
selected: [a.deleteSequence],
notSelected: [a.getData('caretPosition'), a.prepDeleteOneBack, a.deleteSequence]
}
],
'sequenceDataInserted': [
a.getData('selectionLayer', 'sequenceLength', 'sequenceData'),
a.checkLayerIsSelected, {
selected: [a.deleteSequence],
notSelected: [a.getData('caretPosition')]
},
a.insertSequenceData,
a.setData('caretPosition', 'sequenceData')
]
}
// prepend edit mode check to all edit only mode signals, then instantiate on controller
var processedEditModeSignals = addEditModeOnlyToSignal(editModeOnlySignals);
attachSignalsObjectToController(processedEditModeSignals, controller);
}

function addEditModeOnlyToSignal(signalsObj) {
var newSignalsObj = {};
each(signalsObj, function(actionArray, signalName) {
newSignalsObj[signalName] = [
a.checkIfEditAllowed, {
editAllowed: actionArray,
readOnly: [function (input, tree, output) {console.log('Unable to complete action while in Read Only mode')}]
}
]
})
return newSignalsObj;
}

function attachSignalsObjectToController (signalsObj, controller) {
each(signalsObj, function(actionArray, signalName) {
controller.signal(signalName, actionArray);
})
}
81 changes: 42 additions & 39 deletions app/state.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,41 +12,65 @@ var getCutsitesFromSequence = require('ve-sequence-utils/getCutsitesFromSequence
var enzymeList = require('ve-sequence-utils/enzymeList.json');

module.exports = {
rowToJumpTo: null,
topSpacerHeight: 0,
bottomSpacerHeight: 0,
//sl: begin obsessive alphabetization :p
// simple vars
allowPartialAnnotationsOnCopy: false,
annotationHeight: 15,
averageRowHeight: 100,
bottomSpacerHeight: 0,
caretPosition: 0,
charWidth: 15,
charHeight: 15,
displayLinear: true,
clipboardData: null,
displayCircular: true,
displayLinear: true,
displayRow: true,
annotationHeight: 15,
minimumOrfSize: 20,
tickSpacing: 10,
mapViewTickSpacing: 40,
spaceBetweenAnnotations: 3,
showOrfs: true,
allowPartialAnnotationsOnCopy: false,
minimumOrfSize: 20,
readOnly: false,
rowToJumpTo: null,
showAxis: true,
showCutsites: true,
showParts: true,
showFeatures: true,
showTranslations: true,
showAxis: true,
showSequence: true,
showOrfs: true,
showParts: true,
showReverseSequence: true,
rowViewDimensions: {
showSequence: true,
showTranslations: true,
spaceBetweenAnnotations: 3,
tickSpacing: 10,
topSpacerHeight: 0,
// complex vars
circularViewDimensions: {
height: 500,
width: 500
},
cutsiteLabelSelectionLayer: {
start: -1,
end: -1,
selected: false,
cursorAtEnd: true
},
mapViewDimensions: {
height: 500,
width: 500
},
circularViewDimensions: {
rowViewDimensions: {
height: 500,
width: 500
},
selectionLayer: {
start: -1,
end: -1,
selected: false,
cursorAtEnd: true
},
sequenceData: {//tnr: sequence data gets passed in and overrides this object
sequence: '',
features: [],
translations: [],
parts: [],
},
userEnzymeList: [
'rsplkii',
'bme216i',
Expand All @@ -57,30 +81,11 @@ module.exports = {
height: 500,
width: 500
},
selectionLayer: {
start: -1,
end: -1,
selected: false,
cursorAtEnd: true
},
cutsiteLabelSelectionLayer: {
start: -1,
end: -1,
selected: false,
cursorAtEnd: true
},
caretPosition: 0,
visibleRows: {
start: 0,
end: 0
},
sequenceData: {//tnr: sequence data gets passed in and overrides this object
sequence: '',
features: [],
translations: [],
parts: [],
},
clipboardData: null,
// derived data - can't alphabetize because of dependencies :(
bpsPerRow: deriveData([
['rowViewDimensions',
'width'
Expand All @@ -89,8 +94,7 @@ module.exports = {
function(rowViewDimensionsWidth, charWidth) {
return Math.floor(rowViewDimensionsWidth / charWidth);
}
]),

]),
userEnzymes: deriveData([
['userEnzymeList'],
function(userEnzymeList) {
Expand Down Expand Up @@ -164,7 +168,6 @@ module.exports = {
return selectedSequenceString.length * 10
}
]),

orfData: deriveData([
['sequenceData', 'sequence'],
['sequenceData', 'circular'], //decide on what to call this..
Expand Down

0 comments on commit 5303216

Please sign in to comment.