-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbisharing_aps.js
144 lines (131 loc) · 4.12 KB
/
bisharing_aps.js
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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
(function () {
let tmpl = document.createElement("template");
tmpl.innerHTML = `
<style>
fieldset {
margin-bottom: 10px;
border: 1px solid #afafaf;
border-radius: 3px;
}
table {
width: 100%;
}
input, textarea, select {
font-family: "72",Arial,Helvetica,sans-serif;
width: 100%;
padding: 4px;
box-sizing: border-box;
border: 1px solid #bfbfbf;
}
input[type=checkbox] {
width: inherit;
margin: 6px 3px 6px 0;
vertical-align: middle;
}
</style>
<form id="form" autocomplete="off">
<fieldset>
<legend>General</legend>
<table>
<tr>
<td><label for="serverURL">Server URL</label></td>
<td><input id="serverURL" name="serverURL" type="text"></td>
</tr>
<tr>
<td><label for="licenseKey">License Key</label></td>
<td><input id="licenseKey" name="licenseKey" type="text"></td>
</tr>
</table>
</fieldset>
<fieldset>
<legend>Sharing</legend>
<table>
<tr>
<td><label for="type">Channel</label></td>
<td><input id="channel" name="channel" type="channel"></td>
</tr>
</table>
</fieldset>
<button type="submit" hidden>Submit</button>
</form>
`;
class BiSharingAps extends HTMLElement {
constructor() {
super();
this._shadowRoot = this.attachShadow({ mode: "open" });
this._shadowRoot.appendChild(tmpl.content.cloneNode(true));
let form = this._shadowRoot.getElementById("form");
form.addEventListener("submit", this._submit.bind(this));
form.addEventListener("change", this._change.bind(this));
}
connectedCallback() {
}
_submit(e) {
e.preventDefault();
let properties = {};
for (let name of BiSharingAps.observedAttributes) {
properties[name] = this[name];
}
this._firePropertiesChanged(properties);
return false;
}
_change(e) {
this._changeProperty(e.target.name);
}
_changeProperty(name) {
let properties = {};
properties[name] = this[name];
this._firePropertiesChanged(properties);
}
_firePropertiesChanged(properties) {
this.dispatchEvent(new CustomEvent("propertiesChanged", {
detail: {
properties: properties
}
}));
}
get serverURL() {
return this._getValue("serverURL");
}
set serverURL(value) {
this._setValue("serverURL", value);
}
get licenseKey() {
return this._getValue("licenseKey");
}
set licenseKey(value) {
this._setValue("licenseKey", value);
}
get channel() {
return this._getValue("channel");
}
set channel(value) {
this._setValue("channel", value);
}
_getValue(id) {
return this._shadowRoot.getElementById(id).value;
}
_setValue(id, value) {
this._shadowRoot.getElementById(id).value = value;
}
_getBooleanValue(id) {
return this._shadowRoot.getElementById(id).checked;
}
_setBooleanValue(id, value) {
this._shadowRoot.getElementById(id).checked = value;
}
static get observedAttributes() {
return [
"serverURL",
"licenseKey",
"channel"
];
}
attributeChangedCallback(name, oldValue, newValue) {
if (oldValue != newValue) {
this[name] = newValue;
}
}
}
customElements.define("com-biexcellence-openbi-sap-sac-sharing-aps", BiSharingAps);
})();