-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathal-edge-editor.tsx
77 lines (71 loc) · 2.15 KB
/
al-edge-editor.tsx
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
import { Component, Event, EventEmitter, h, Prop } from "@stencil/core";
import MinusIcon from "../../assets/svg/minus.svg";
import TickIcon from "../../assets/svg/tick.svg";
import { AlEdge } from "../../interfaces";
import i18n from "./al-edge-editor.i18n.en.json";
import { ContentStrings } from "./ContentStrings";
@Component({
tag: "al-edge-editor",
styleUrl: "al-edge-editor.css",
shadow: true
})
export class AlEdgeEditor {
private _contentStrings: ContentStrings = i18n;
@Event() public deleteEdge: EventEmitter;
@Event() public saveEdge: EventEmitter;
@Prop({ mutable: true }) public edge: [string, AlEdge];
public render() {
if (this.edge) {
const [edgeId, edge] = this.edge;
return (
<form onSubmit={e => e.preventDefault()}>
<ion-item>
<ion-input
id="title"
value={edge.title}
placeholder={this._contentStrings.title}
required
onIonChange={e => (edge.title = e.detail.value)}
maxlength={20}
/>
</ion-item>
<ion-item>
<ion-textarea
id="description"
value={edge.description}
placeholder={this._contentStrings.description}
rows={5}
onIonChange={e => (edge.description = e.detail.value)}
maxlength={280}
/>
</ion-item>
<ion-item>
<ion-button
size="small"
onClick={() => {
this.deleteEdge.emit(edgeId);
this.edge = null;
}}
>
<ion-icon src={MinusIcon} />
{this._contentStrings.delete}
</ion-button>
<ion-button
size="small"
type="submit"
onClick={() => {
if (edge.title) {
this.saveEdge.emit([edgeId, edge]);
}
}}
>
<ion-icon src={TickIcon} />
{this._contentStrings.update}
</ion-button>
</ion-item>
</form>
);
}
return null;
}
}