-
Notifications
You must be signed in to change notification settings - Fork 1
/
fs-person-gender.html
90 lines (78 loc) · 2.33 KB
/
fs-person-gender.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
<link rel="import" href="../polymer/polymer-element.html">
<link rel="import" href="../polymer/lib/elements/dom-if.html">
<link rel="import" href="../fs-person-mixin/fs-person-mixin.html">
<link rel="import" href="../paper-radio-group/paper-radio-group.html">
<link rel="import" href="../fs-conclusion-mixin/fs-conclusion-mixin.html">
<link rel="import" href="fs-person-gender-selector.html">
<dom-module id="fs-person-gender">
<template>
<template is="dom-if" if="[[editable]]">
<div hidden$="[[!edit]]">
<fs-person-gender-selector gender="[[gender.type]]" on-gender-changed="_selectionChanged"></fs-person-gender-selector>
</div>
</template>
<div hidden$="[[edit]]">{{_genderDisplay(gender.type)}}</div>
</template>
<script>
/**
* `fs-person-gender`
*
*
* @customElement
* @polymer
* @demo demo/index.html
*/
class FsPersonGender extends FSPersonMixin(FsConclusionMixin(Polymer.Element)) {
static get is() { return 'fs-person-gender'; }
static get properties() {
return {
gender: {
type: Object,
notify: true,
observer: '_conclusionSync'
},
saveUrl: {
computed: '_computeSaveUrl(personId)'
}
};
}
static get template() {
return super.conclusionTemplate(this.is);
}
_personChanged() {
if(this.person && this.person.gender) {
this.gender = this.person.gender;
} else {
this.gender = undefined;
}
}
_conclusionSync(gender) {
this.conclusion = gender;
}
_conclusionBody() {
return {
persons: [{
gender: this.gender
}]
};
}
_computeSaveUrl(personId) {
return `/platform/tree/persons/${personId}`;
}
_genderDisplay(type) {
switch(type) {
case 'http://gedcomx.org/Male':
return 'Male';
case 'http://gedcomx.org/Female':
return 'Female';
default:
return 'Unknown';
}
}
_selectionChanged(e) {
this.gender = {type: e.detail.value};
}
}
window.customElements.define(FsPersonGender.is, FsPersonGender);
</script>
</dom-module>