forked from cardstack/boxel
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcontact-card.gts
80 lines (71 loc) · 1.92 KB
/
contact-card.gts
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
import StringField from 'https://cardstack.com/base/string';
import {
Component,
CardDef,
FieldDef,
field,
contains,
containsMany,
linksToMany,
} from 'https://cardstack.com/base/card-api';
import { PhoneField } from './phone-number';
class Alias extends CardDef {
static displayName = 'Alias';
@field name = contains(StringField);
@field title = contains(StringField, {
computeVia: function (this: Alias) {
return this.name;
},
});
static embedded = class Embedded extends Component<typeof this> {
<template>
<@fields.name />
</template>
};
}
export class EmergencyContactField extends FieldDef {
static displayName = 'Emergency Contact';
@field name = contains(StringField);
@field phoneNumber = contains(PhoneField);
@field email = contains(StringField);
static embedded = class Embedded extends Component<typeof this> {
<template>
<@fields.name />
<@fields.phoneNumber />
<@fields.email />
</template>
};
}
class Name extends StringField {
static displayName = 'Name';
}
class Guest extends FieldDef {
static displayName = 'Guest';
@field name = contains(StringField);
@field additionalNames = containsMany(Name);
static embedded = class Embedded extends Component<typeof this> {
<template>
<@fields.name />
</template>
};
}
export class ContactCard extends CardDef {
static displayName = 'Contact';
@field name = contains(StringField);
@field phone = contains(PhoneField);
@field emergencyContact = contains(EmergencyContactField);
@field guestNames = containsMany(Name);
@field guest = contains(Guest);
@field aliases = linksToMany(Alias);
@field title = contains(StringField, {
computeVia: function (this: ContactCard) {
return this.name;
},
});
static embedded = class Embedded extends Component<typeof this> {
<template>
<@fields.name />
<@fields.phone />
</template>
};
}