-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathmultiTemplateExample.js
More file actions
44 lines (35 loc) · 966 Bytes
/
multiTemplateExample.js
File metadata and controls
44 lines (35 loc) · 966 Bytes
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
import { LightningElement, api } from "lwc";
import { getFormattedPhone } from "c/dataStoringUtils";
import templateEdit from "./multiTemplateExampleEdit.html";
import templateView from "./multiTemplateExampleView.html";
export default class MultiTemplateExample extends LightningElement {
@api mode;
@api set value(newValue) {
this._value = newValue;
}
get value() {
return this._value;
}
@api saveValue() {
this._savedValue = this._value;
}
@api restoreValue() {
this._value = this._savedValue;
}
_value;
_savedValue;
get displayValue() {
return getFormattedPhone(this._value);
}
render() {
if (this.mode === "view") {
return templateView;
} else if (this.mode === "edit") {
return templateEdit;
}
return undefined;
}
handleInputChange(event) {
this._value = event.target.value;
}
}