-
Notifications
You must be signed in to change notification settings - Fork 25
/
Copy pathcodelist.js
82 lines (74 loc) · 1.87 KB
/
codelist.js
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
import { computed } from '@ember/object';
import Service, { inject as service } from '@ember/service';
import codes from 'mdcodes/resources/js/mdcodes.js';
export default Service.extend({
/**
* Codelist Service
*
* This service provides controlled value lists for use in the editor. The
* service may be customized by modifing the object in init. The existing
* property names should be maintained.
*
* @module mdeditor
* @submodule service
* @class codelist
*/
init() {
this._super(...arguments);
let codelist = this;
//remap codelist names to be more generic
Object.keys(codes)
.forEach(function (key) {
if(key === 'default') {
return;
}
const list = codes[key];
const name = key.replace(/^iso_|adiwg_/, '');
codelist[name] = list;
//remove deprecated codes
codelist[name]['codelist'] = list.codelist.rejectBy('deprecated');
});
},
/**
* Custom Profiles service
*
* @property customProfiles
*/
customProfiles: service('custom-profile'),
/**
* The profiles codelist, updates when number of Custom Profiles change.
*
* @property profile
* @type {Object}
* @category computed
* @required customProfiles.profiles{[],@each.title}
*/
profile: computed(
'customProfiles.profiles.{[],@each.title}',
function () {
return {
codelist: this.customProfiles.profiles.map((itm) => {
return {
code: itm.id,
codeName: itm.title,
description: itm.description
};
})
};
}),
/**
* Codelist item title overrides
*
* @property codeOverrides
* @type {Object}
* @category computed
* @required profile
*/
codeOverrides: computed('profile', function () {
return {
scope: {
dataset: "geographicDataset"
}
}
})
});