forked from isaacsc/kurriculum-generator
-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathkurriculum-generator.js
More file actions
111 lines (97 loc) · 2.57 KB
/
Copy pathkurriculum-generator.js
File metadata and controls
111 lines (97 loc) · 2.57 KB
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
102
103
104
105
106
107
108
109
110
111
'use strict';
class KurriculumGenerator extends Polymer.Element {
static get is() { return 'kurriculum-generator'; }
static get properties() {
return {
loading: {
type: Boolean,
reflectToAttribute: true,
value: false
},
blind: {
type: Boolean,
value: false
},
cvItem: {
type: Object,
value: () => {return {}}
},
index: {
type: Number
},
section:{
type: String,
value: ''
},
user:{
type: Object
},
_computeName: {
type: String,
computed: '_generateName(user.name, user.surname, blind)'
},
isAdmin: {
type: Boolean,
value: true
},
_userId: String
};
}
connectedCallback() {
super.connectedCallback();
}
_linkAddButton(e) {
this.$.modal.open();
this.set('cvItem', { });
this.set('index', null);
this.set('section', e.currentTarget.dataset.field);
}
_linkEditButton(e) {
this.$.modal.open();
let dataset = e.currentTarget.dataset;
this.cvItem = Object.assign({}, dataset.index ? this.user[dataset.field][dataset.index] : this.user[dataset.field]);
this.set('index', dataset.index);
this.set('section', dataset.field);
}
_getLocaleDate(d) {
var date = new Date(d);
return date && date.toLocaleDateString(navigator.language, {
year: 'numeric',
month: 'numeric'
});
}
deleteItem () {
this.splice(`user.${this.section}`, this.index, 1);
this.$.modal.close();
}
editItem(e) {
let obj = (!this.index) ? `user.${this.section}` : `user.${this.section}.${this.index}`;
this.user[this.section] instanceof Array && !this.index ? this.push(`user.${this.section}`, this.cvItem) : this.set(obj, this.cvItem);
this.$.modal.close();
}
getBlindCV() {
this.blind = !this.blind;
this.$.blindIcon.setAttribute('icon', (this.blind) ? 'visibility-off' : 'visibility');
}
_generateName(name, surname, blind) {
if(name && surname){
return (this.blind) ? `${this.user.name.slice(0,1)}. ${this.user.surname.slice(0,1)}.` : `${this.user.name} ${this.user.surname}`;
}
}
_computeFieldPeriod(sect) {
return ['experience', 'studies'].includes(sect);
}
_computeFieldTitle(sect) {
return sect !== 'aptitudes';
}
_computeFieldDescription(sect) {
return sect !== 'studies';
}
_computeFieldPercent(sect) {
return sect === 'skills';
}
print() {
window.print();
}
}
window.customElements.define(KurriculumGenerator.is, KurriculumGenerator);