From 5a91457a5b8595969957cd6676afc2fff858251e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hugo=20H=C3=B6rnquist?= Date: Tue, 11 Aug 2020 17:19:37 +0200 Subject: HTML Created events now have a description. Unfortunately they ALWAYS have a description. --- static/script.js | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'static') diff --git a/static/script.js b/static/script.js index 32bc3b4b..c2ea07c1 100644 --- a/static/script.js +++ b/static/script.js @@ -471,6 +471,28 @@ function place_in_edit_mode (event) { summary.replaceWith(input); + /* ---------------------------------------- */ + + let descs = popup.getElementsByClassName("description"); + if (descs.length === 1) { + let description = descs[0]; + let textarea = makeElement('textarea', { + name: "description", + placeholder: description.innerText, + required: false, + }); + + textarea.oninput = function () { + event.properties["description"] = this.value; + } + + let slot = event.properties["_slot_description"] + let idx = slot.findIndex(e => e[0] === description); + slot.splice(idx, 1, [input, (s, v) => s.innerHTML = v]) + + description.replaceWith(textarea); + } + /* ---------------------------------------- */ let submit = makeElement( 'input', { -- cgit v1.2.3 From ad78b193271abb6df486d3acfd7ab94f51cd101c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hugo=20H=C3=B6rnquist?= Date: Tue, 11 Aug 2020 19:39:37 +0200 Subject: Can create events without descriptions again. --- static/script.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'static') diff --git a/static/script.js b/static/script.js index c2ea07c1..be19dc13 100644 --- a/static/script.js +++ b/static/script.js @@ -478,7 +478,8 @@ function place_in_edit_mode (event) { let description = descs[0]; let textarea = makeElement('textarea', { name: "description", - placeholder: description.innerText, + placeholder: "Description (optional)", + innerHTML: description.innerText, required: false, }); -- cgit v1.2.3 From 2e684fd427097965834bd5f1f22196be99b82757 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hugo=20H=C3=B6rnquist?= Date: Tue, 11 Aug 2020 19:49:28 +0200 Subject: Allow events to enter edit mode after creation. --- static/script.js | 1 + static/style.css | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) (limited to 'static') diff --git a/static/script.js b/static/script.js index be19dc13..37f86549 100644 --- a/static/script.js +++ b/static/script.js @@ -428,6 +428,7 @@ function place_in_edit_mode (event) { let input = makeElement ('input', { type: "time", required: true, + value: field.innerText, onchange: function (e) { /* Only update datetime when the input is filled out */ diff --git a/static/style.css b/static/style.css index 193cc1fb..3a2a8c5d 100644 --- a/static/style.css +++ b/static/style.css @@ -509,7 +509,7 @@ along with their colors. overflow: visible; } -.event input { +.popup input { white-space: initial; border: 1px solid gray; max-width: 100%; -- cgit v1.2.3 From 7c914d16b60fb72aa25aa469b60b85f06fb3a518 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hugo=20H=C3=B6rnquist?= Date: Tue, 11 Aug 2020 20:05:40 +0200 Subject: Keep summary when editing existing elements. --- static/script.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'static') diff --git a/static/script.js b/static/script.js index 37f86549..7f9291d7 100644 --- a/static/script.js +++ b/static/script.js @@ -457,8 +457,9 @@ function place_in_edit_mode (event) { let summary = popup.getElementsByClassName("summary")[0]; let input = makeElement('input', { - name: "dtstart", - placeholder: summary.innerText, + name: "summary", + value: summary.innerText, + placeholder: "Sammanfattning", required: true, }); @@ -539,7 +540,7 @@ window.onload = function () { let popupElement = document.getElementById("popup" + event.id); open_popup(popupElement); - popupElement.querySelector("input[name='dtstart']").focus(); + popupElement.querySelector("input[name='summary']").focus(); }); } @@ -557,7 +558,7 @@ window.onload = function () { let popupElement = document.getElementById("popup" + event.id); open_popup(popupElement); - popupElement.querySelector("input[name='dtstart']").focus(); + popupElement.querySelector("input[name='summary']").focus(); }); } -- cgit v1.2.3 From aa18e57dfdf2bd0f626d7101ab712e6a0ff6dbf3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hugo=20H=C3=B6rnquist?= Date: Tue, 11 Aug 2020 20:05:56 +0200 Subject: Focus summary when editing existing. --- static/script.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'static') diff --git a/static/script.js b/static/script.js index 7f9291d7..5b6f561a 100644 --- a/static/script.js +++ b/static/script.js @@ -475,6 +475,10 @@ function place_in_edit_mode (event) { /* ---------------------------------------- */ + /* TODO add elements if the arent't already there + * Almost all should be direct children of '.event-body'. + * Biggest problem is generated fields relative order. + */ let descs = popup.getElementsByClassName("description"); if (descs.length === 1) { let description = descs[0]; @@ -515,6 +519,11 @@ function place_in_edit_mode (event) { article.replaceWith(wrappingForm); wrappingForm.appendChild(article); + /* this is for existing events. + * Newly created events aren't in the DOM tree yet, and can + * therefore not yet be focused */ + input.focus(); + } window.onload = function () { @@ -558,7 +567,7 @@ window.onload = function () { let popupElement = document.getElementById("popup" + event.id); open_popup(popupElement); - popupElement.querySelector("input[name='summary']").focus(); + popupElement.querySelector("input[name='summary']").focus(); }); } -- cgit v1.2.3 From e65184faa90ccc7760c90659e92080984afc0b3c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hugo=20H=C3=B6rnquist?= Date: Tue, 11 Aug 2020 20:16:02 +0200 Subject: Expand whitespace. --- static/script.js | 52 +++++++++++++++++++++++++++------------------------- 1 file changed, 27 insertions(+), 25 deletions(-) (limited to 'static') diff --git a/static/script.js b/static/script.js index 5b6f561a..cc647b77 100644 --- a/static/script.js +++ b/static/script.js @@ -459,7 +459,7 @@ function place_in_edit_mode (event) { let input = makeElement('input', { name: "summary", value: summary.innerText, - placeholder: "Sammanfattning", + placeholder: "Sammanfattning", required: true, }); @@ -475,30 +475,32 @@ function place_in_edit_mode (event) { /* ---------------------------------------- */ - /* TODO add elements if the arent't already there - * Almost all should be direct children of '.event-body'. - * Biggest problem is generated fields relative order. - */ - let descs = popup.getElementsByClassName("description"); - if (descs.length === 1) { - let description = descs[0]; - let textarea = makeElement('textarea', { - name: "description", - placeholder: "Description (optional)", - innerHTML: description.innerText, - required: false, - }); - - textarea.oninput = function () { - event.properties["description"] = this.value; - } - - let slot = event.properties["_slot_description"] - let idx = slot.findIndex(e => e[0] === description); - slot.splice(idx, 1, [input, (s, v) => s.innerHTML = v]) - - description.replaceWith(textarea); - } + /* TODO add elements if the arent't already there + * Almost all should be direct children of '.event-body' (or + * '.eventtext'?). + * Biggest problem is generated fields relative order. + */ + let descs = popup.getElementsByClassName("description"); + if (descs.length === 1) { + let description = descs[0]; + let textarea = makeElement('textarea', { + name: "description", + placeholder: "Description (optional)", + innerHTML: description.innerText, + required: false, + }); + + textarea.oninput = function () { + event.properties["description"] = this.value; + } + + let slot = event.properties["_slot_description"] + let idx = slot.findIndex(e => e[0] === description); + slot.splice(idx, 1, [input, (s, v) => s.innerHTML = v]) + + description.replaceWith(textarea); + } + /* ---------------------------------------- */ -- cgit v1.2.3 From 70dd50111a339fd9fcf54cc2f9670c1313a154a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hugo=20H=C3=B6rnquist?= Date: Tue, 11 Aug 2020 20:25:56 +0200 Subject: Mercge CAL and CAL_bg css classes. --- static/style.css | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'static') diff --git a/static/style.css b/static/style.css index 3a2a8c5d..28901c8d 100644 --- a/static/style.css +++ b/static/style.css @@ -300,6 +300,7 @@ along with their colors. list-style-type: none; border-left-width: 1em; border-left-style: solid; + border-color: var(--color); padding-left: 1ex; /* force to single line */ @@ -507,6 +508,8 @@ along with their colors. transition: 0.3s; font-size: var(--event-font-size); overflow: visible; + background-color: var(--color); + color: var(--complement); } .popup input { @@ -607,6 +610,10 @@ along with their colors. padding-right: 1em; } +.eventlist .eventtext { + border-color: var(--color); +} + .eventlist .eventtext.tentative { border-left-style: dashed; } -- cgit v1.2.3 From 54c613f48caa01f05fac2774dc2d2253568b552e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hugo=20H=C3=B6rnquist?= Date: Tue, 11 Aug 2020 20:17:25 +0200 Subject: Add dropdown editing event. --- static/script.js | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'static') diff --git a/static/script.js b/static/script.js index cc647b77..0385ac5a 100644 --- a/static/script.js +++ b/static/script.js @@ -501,6 +501,11 @@ function place_in_edit_mode (event) { description.replaceWith(textarea); } + /* ---------------------------------------- */ + + let evtext = popup.getElementsByClassName('eventtext')[0] + let calendar_dropdown = document.getElementById('calendar-dropdown-template').firstChild.cloneNode(true); + evtext.prepend(calendar_dropdown); /* ---------------------------------------- */ -- cgit v1.2.3 From 7deb6aac6d5af730f564a9f238c8feaf77f0e167 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hugo=20H=C3=B6rnquist?= Date: Tue, 11 Aug 2020 20:35:12 +0200 Subject: Fix color in popups. --- static/style.css | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'static') diff --git a/static/style.css b/static/style.css index 28901c8d..1a7b2f14 100644 --- a/static/style.css +++ b/static/style.css @@ -300,7 +300,7 @@ along with their colors. list-style-type: none; border-left-width: 1em; border-left-style: solid; - border-color: var(--color); + border-color: var(--color); padding-left: 1ex; /* force to single line */ @@ -508,8 +508,8 @@ along with their colors. transition: 0.3s; font-size: var(--event-font-size); overflow: visible; - background-color: var(--color); - color: var(--complement); + background-color: var(--color); + color: var(--complement); } .popup input { @@ -611,7 +611,7 @@ along with their colors. } .eventlist .eventtext { - border-color: var(--color); + border-color: var(--color); } .eventlist .eventtext.tentative { @@ -741,6 +741,7 @@ along with their colors. user-select: none; cursor: grab; + background-color: var(--color); } .popup-control .btn { -- cgit v1.2.3 From 263e64dfe8549e6c726fb06dd5cdc03fa6a90298 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hugo=20H=C3=B6rnquist?= Date: Tue, 11 Aug 2020 20:41:28 +0200 Subject: Limit CAL_ class to once per 'thing'. --- static/style.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'static') diff --git a/static/style.css b/static/style.css index 1a7b2f14..719cca1c 100644 --- a/static/style.css +++ b/static/style.css @@ -818,7 +818,7 @@ along with their colors. } .tab [type=radio]:checked ~ label ~ .content { - z-index: 1; + z-index: 1; } /* Other -- cgit v1.2.3 From e360d3566eb878a944dada510a0c7e8437a5554b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hugo=20H=C3=B6rnquist?= Date: Tue, 11 Aug 2020 21:31:52 +0200 Subject: Fix frontend for calendar choosing. --- static/script.js | 38 ++++++++++++++++++++++++++++++++++++++ static/style.css | 4 ++++ 2 files changed, 42 insertions(+) (limited to 'static') diff --git a/static/script.js b/static/script.js index 0385ac5a..ed133a2d 100644 --- a/static/script.js +++ b/static/script.js @@ -122,6 +122,21 @@ function bind_popup_control (nav) { }); } +/* + * Finds the first element of the DOMTokenList whichs value matches + * the supplied regexp. Returns a pair of the index and the value. + */ +DOMTokenList.prototype.find = function (regexp) { + console.log(this); + let entries = this.entries(); + let entry; + while (! (entry = entries.next()).done) { + if (entry.value[1].match(regexp)) { + return entry.value; + } + } +} + class EventCreator { /* dynamicly created event when dragging */ @@ -505,6 +520,29 @@ function place_in_edit_mode (event) { let evtext = popup.getElementsByClassName('eventtext')[0] let calendar_dropdown = document.getElementById('calendar-dropdown-template').firstChild.cloneNode(true); + + let [_, calclass] = popup.classList.find(/^CAL_/); + for (let [i, option] of calendar_dropdown.childNodes.entries()) { + if (option.value === calclass.substr(4)) { + calendar_dropdown.selectedIndex = i; + break; + } + } + + /* Instant change while user is stepping through would be + * preferable. But I believe that