diff options
| author | Alon Levy <alon@pobox.com> | 2015-03-07 08:39:18 +0200 |
|---|---|---|
| committer | Alon Levy <alon@pobox.com> | 2015-03-07 15:02:42 +0200 |
| commit | 2746c5d10ca67fdfd31ead979d0ccd3ee03ebed6 (patch) | |
| tree | 4044b1091d95b6d294ee5741ec6ecaf10993f4bc /src | |
| parent | 0e51a475db95fe410ca43c03710b75ab389bd6d5 (diff) | |
client: move nodetypes from consts to model/types
Diffstat (limited to 'src')
| -rw-r--r-- | src/client/consts.js | 3 | ||||
| -rw-r--r-- | src/client/model/types.js | 12 | ||||
| -rw-r--r-- | src/client/textanalysis.js | 6 | ||||
| -rw-r--r-- | src/client/view/graph_view.js | 8 |
4 files changed, 16 insertions, 13 deletions
diff --git a/src/client/consts.js b/src/client/consts.js index 4a66b811..670b92b7 100644 --- a/src/client/consts.js +++ b/src/client/consts.js @@ -2,8 +2,6 @@ define(function() { - var nodetypes = ["person", "club", "skill", "interest", "third-internship-proposal", "internship"]; - var description = { person: 'A person in CRI - student or teacher', club: 'A shared club or project within the CRI', @@ -19,7 +17,6 @@ define(function() { KEYSTROKE_WHERE_DOCUMENT: 'keystroke_where_document', KEYSTROKE_WHERE_TEXTANALYSIS: 'keystroke_where_textanalysis', INPUT_WHERE_TEXTANALYSIS: 'input_where_textanalysis', - nodetypes: nodetypes, description: description, NEW_NODE_NAME: 'new node', }; diff --git a/src/client/model/types.js b/src/client/model/types.js index fac37cbe..990c3b02 100644 --- a/src/client/model/types.js +++ b/src/client/model/types.js @@ -2,14 +2,19 @@ define(['underscore', 'util'], function(_, util) { -var type_attributes = { - 'third-internship-proposal': ['status', 'startdate', 'enddate', 'description', 'url'], +var nodetypes, + type_attributes = { + 'internship': ['status', 'startdate', 'enddate', 'description', 'url'], 'skill': ['description', 'url'], 'interest': ['description', 'url'], - '_defaults': ['description', 'url'], + 'person': ['description', 'url'], }, all_attributes; +nodetypes = _.keys(type_attributes); + +type_attributes['_defaults'] = ['description', 'url']; + _.values(type_attributes).map(function (attributes) { attributes.push('name'); attributes.push('type'); @@ -20,6 +25,7 @@ all_attributes = _.union(_.flatten(_.map(type_attributes, _.values))).sort(); return ( { + nodetypes: nodetypes, type_attributes: function (type) { util.assert(type[0] !== '_', 'invalid type name'); return type_attributes[type_attributes.hasOwnProperty(type) ? type : '_defaults']; diff --git a/src/client/textanalysis.js b/src/client/textanalysis.js index 1ab58497..3a89e51c 100644 --- a/src/client/textanalysis.js +++ b/src/client/textanalysis.js @@ -1,5 +1,5 @@ -define(['rz_core', 'model/core', 'model/util', 'model/diff', 'consts', 'util'], -function(rz_core, model_core, model_util, model_diff, consts, util) { +define(['rz_core', 'model/core', 'model/util', 'model/diff', 'model/types', 'consts', 'util'], +function(rz_core, model_core, model_util, model_diff, model_types, consts, util) { "use strict"; // Aliases @@ -10,7 +10,7 @@ var node_edge_separator = rz_config.node_edge_separator; var separator_string = rz_config.separator_string; var typeindex = 0, - nodetypes = consts.nodetypes, + nodetypes = model_types.nodetypes, node_name_to_type = {}; var _get_lastnode, diff --git a/src/client/view/graph_view.js b/src/client/view/graph_view.js index ff7de845..b6372307 100644 --- a/src/client/view/graph_view.js +++ b/src/client/view/graph_view.js @@ -25,8 +25,8 @@ * which resulted in overly complex (read: undefined/buggy) code. */ -define(['d3', 'Bacon_wrapper', 'util', 'view/selection', 'view/helpers', 'model/diff', 'view/view', 'view/bubble'], -function(d3 , Bacon , util , selection , view_helpers, model_diff , view, view_bubble) { +define(['d3', 'Bacon_wrapper', 'util', 'view/selection', 'view/helpers', 'model/diff', 'view/view', 'view/bubble', 'model/types'], +function(d3 , Bacon , util , selection , view_helpers, model_diff , view, view_bubble, model_types) { var obj_take = util.obj_take; @@ -96,8 +96,8 @@ function GraphView(spec) { cx, cy, // FIXME take filter names from index.html or both from graph db - filter_states = {'interest':null, 'skill':null, 'club':null, 'person':null, 'third-internship-proposal':null}, - filter_state_names = ['interest', 'skill', 'club', 'person', 'third-internship-proposal']; + filter_states = _.object(_.map(model_types.nodetypes, function (type) { return [type, null]; })), + filter_state_names = model_types.nodetypes; util.assert(parent_element !== undefined && graph_name !== undefined && graph !== undefined && zoom_property !== undefined && |
