aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHugo Hörnquist <hugo@lysator.liu.se>2021-05-16 22:06:28 +0200
committerHugo Hörnquist <hugo@lysator.liu.se>2021-05-16 22:06:28 +0200
commit1da3c63f34ea30ca35e50cead9edd3bd107bebb4 (patch)
tree14abd7ae3ede69a59d1a7a49128b01e22e926722
parentGenerall callbacks works again. (diff)
downloadcalp-1da3c63f34ea30ca35e50cead9edd3bd107bebb4.tar.gz
calp-1da3c63f34ea30ca35e50cead9edd3bd107bebb4.tar.xz
Calendar setting working again!
-rw-r--r--static/server_connect.js2
-rw-r--r--static/vcal.js61
2 files changed, 32 insertions, 31 deletions
diff --git a/static/server_connect.js b/static/server_connect.js
index 24bf254b..f3fbac1b 100644
--- a/static/server_connect.js
+++ b/static/server_connect.js
@@ -41,7 +41,7 @@ function event_to_jcal (event) {
async function create_event (event) {
// let xml = event.getElementsByTagName("icalendar")[0].outerHTML
- let calendar = event.properties.calendar;
+ let calendar = event.properties.calendar.value;
console.log('calendar=', calendar/*, xml*/);
diff --git a/static/vcal.js b/static/vcal.js
index b8c48f90..366b879a 100644
--- a/static/vcal.js
+++ b/static/vcal.js
@@ -123,25 +123,8 @@ class VComponent {
for (let property of property_names) {
this.ical_properties.add(property)
// console.log("prop", property)
- Object.defineProperty(
- this, property,
- {
- get: function() {
- return this._values[property];
- },
- set: function (value) {
- console.log("set", property, value);
- this._values[property].value = value;
- console.log(this._slots[property].length,
- this._slots[property]);
- /* TODO validate type */
- /* See valid_input_types and all_types */
- for (let [slot,updater] of this._slots[property]) {
- // console.log(updater, slot);
- updater(slot, value);
- }
- },
- });
+
+ this.create_property(property);
}
/* icalendar properties */
@@ -266,14 +249,10 @@ class VComponent {
el.dataset.calendar = "Unknown";
}
- // let calprop = get_property(el, 'calendar', el.dataset.calendar);
- /*
- TODO this is the only location where default_value of
- get_callback_list is used. The option should be removed,
- since we lack type information now that everything is encapsulated
- in VCalParameter objects.
- */
- let calprop = this.get_callback_list('calendar', el.dataset.calendar);
+ let calprop = this.get_callback_list('calendar');
+ this.create_property('calendar');
+ this._values['calendar'] =
+ new VCalParameter('INVALID', el.dataset.calendar);
const rplcs = (s, v) => {
let [_, calclass] = s.classList.find(/^CAL_/);
@@ -286,7 +265,7 @@ class VComponent {
- /* ---------- Calendar ------------------------------ */
+ /* ---------- /Calendar ------------------------------ */
}
@@ -297,11 +276,10 @@ class VComponent {
default_value - default value when creating
bind_to_ical - should this property be added to the icalendar subtree?
*/
- get_callback_list(field, default_value) {
+ get_callback_list(field) {
// let el = this.html_element;
if (! this._slots[field]) {
this._slots[field] = [];
- this._values[field] = default_value;
}
// console.log("get", field);
@@ -325,6 +303,29 @@ class VComponent {
return ['vevent', properties, [/* alarms go here */]]
}
+
+ create_property(property_name) {
+ Object.defineProperty(
+ this, property_name,
+ {
+ get: function() {
+ return this._values[property_name];
+ },
+ set: function (value) {
+ console.log("set", property_name, value);
+ this._values[property_name].value = value;
+ console.log(this._slots[property_name].length,
+ this._slots[property_name]);
+ /* TODO validate type */
+ /* See valid_input_types and all_types */
+ for (let [slot,updater] of this._slots[property_name]) {
+ // console.log(updater, slot);
+ updater(slot, value);
+ }
+ },
+ });
+ }
+
}