-
Notifications
You must be signed in to change notification settings - Fork 0
/
ee-app-settings.html
101 lines (80 loc) · 2.42 KB
/
ee-app-settings.html
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
<link rel="import" href="../polymer/polymer.html">
<!-- Iron -->
<!-- Paper -->
<!-- Shared -->
<link rel="import" href="../js-data-behaviors/js-data-collection-behavior.html">
<link rel="import" href="../ee-helper-behavior/ee-helper-behavior.html">
<!-- My -->
<dom-module id="ee-app-settings">
<script>
Polymer({
is: 'ee-app-settings',
JSData: {
collectionName: 'settings'
},
behaviors: [
Elfy.JSDataCollectionBehavior,
Elfy.EEHelperBehavior,
],
properties: {
settings: {
type: Array,
value() { return [] },
notify: true,
},
serviceTypes: {
type: Array,
value() { return [] },
notify: true,
computed: '_aliasKeyArr(settings, "serviceTypes", settings.*)'
},
conditionalSkills: {
type: Array,
value() { return [] },
notify: true,
computed: '_aliasKeyArr(settings, "conditionalSkills", settings.*)'
},
standardMedicalConditions: {
type: Array,
value() { return [] },
notify: true,
computed: '_aliasKeyArr(settings, "standardMedicalConditions", settings.*)'
},
// otherwise standardMedicalConditionRecords gets changed
// if the record gets changed somewhere else. readOnly doesn't help in this case.
recordsResetTrigger: {
type: Object,
value () { return {} }
},
standardMedicalConditionRecords: {
type: Array,
value() { return [] },
notify: true,
readOnly: true,
},
},
observers: [
'_createMcRecords(standardMedicalConditions, recordsResetTrigger.*)'
],
_createMcRecords(standardMedicalConditions) {
if (!standardMedicalConditions) return []
var records = []
standardMedicalConditions.forEach((e) => {
var r = App.MedicalCondition.createRecord()
for(var k in e) r[k]=e[k];
records.push(r)
})
this._setStandardMedicalConditionRecords(records)
},
_aliasKeyArr(settings, key) {
let s = settings.find(s => s.key === key)
return s ? s.value : []
},
serviceTypeNameForKey(key) {
if (!key) return ''
var st = this.serviceTypes.find(s => s.key === key)
return st.name
}
});
</script>
</dom-module>