summaryrefslogtreecommitdiff
path: root/src/client/model/types.js
blob: fac37cbeae8e5bddd10f32039d59a8b13abae2e1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
define(['underscore', 'util'],
function(_,            util)
{

var type_attributes = {
        'third-internship-proposal': ['status', 'startdate', 'enddate', 'description', 'url'],
        'skill': ['description', 'url'],
        'interest': ['description', 'url'],
        '_defaults': ['description', 'url'],
    },
    all_attributes;

_.values(type_attributes).map(function (attributes) {
        attributes.push('name');
        attributes.push('type');
        attributes.sort();
    });

all_attributes = _.union(_.flatten(_.map(type_attributes, _.values))).sort();

return (
    {
        type_attributes: function (type) {
            util.assert(type[0] !== '_', 'invalid type name');
            return type_attributes[type_attributes.hasOwnProperty(type) ? type : '_defaults'];
        },
        all_attributes: all_attributes,
    });
}
)