Commit Graph

187 Commits

Author SHA1 Message Date
oriol carbonell pujolàs 10e89c16df Add credit card logos to booking page 2024-01-17 13:31:33 +01:00
jordi fita mas 41fd940108 Enable autoplay to cover’s carousel 2024-01-17 13:26:33 +01:00
jordi fita mas 76d94f76f0 Change cover’s carousel to slick, and move arrows of all to top-right
Oriol did not like that this carousel was different from the rest, and
wanted to have it like the rest, but showing only one slide at a time,
like the customer wants.

He also wanted the arrows for **all** carousels to be in the top-right
corner instead of bottom-right, mostly because the customer complains
that she does not see the arrows if they are on the bottom, and Oriol
does not like the arrows to the sides.
2024-01-17 13:22:47 +01:00
jordi fita mas b1e3f5017f Add home’s cover carousel
This is a separate carousel from the one displayed at the bottom with
location info; it is, i suppose, a carousel for the hero image.

For the database, it works exactly as the home carousel, but on the
front had to use AlpineJS instead of Slick because it needs to show a
text popping up from the bottom when the slide is show, something i do
not know how to do in Slick.

It now makes no sense to have the carousel inside the “nature” section,
because the heading is no longer in there, and moved it out into a new
“hero” div.

Since i now have two carousels in home, i had to add additional
attributes to carousel.AdminHandler to know which URL to point to when
POSTing, PUTting, or redirecting.
2024-01-16 21:05:52 +01:00
jordi fita mas 89f8f91a4b Avoid nested forms in admin
I was using a <form> to delete slides and other such elements before
adding the form to sort these same elements with drag and drop, without
realizing that i was wrapping the existing delete <form>s, that now
would not submit properly—they were submitting the sort form instead.
2024-01-16 18:32:02 +01:00
jordi fita mas 0928e78bed Added copyright statement to files modified by Oriol 2024-01-16 17:58:49 +01:00
jordi fita mas a0f9c10193 Add management of surroundings’ highlights (points of interest)
Customer does not want the new “masonry-like” design of the surroundings
page, and wants the same style they already had: a regular list with
text and photo, alternating the photo’s side.

And, of course, they want to be able to add and edit them themselves. It
is like another carousel, but with an additional rich-text description.

The photos that we had in that page are no longer of use.
2024-01-16 01:26:35 +01:00
jordi fita mas 50bcbf012f Allow updating images in CKEditor-“powered” textarea
Had to create a custom build of CKEditor with the following plugins
added-in:

  * Autoformat
  * Block quote
  * Bold
  * General HTML Support
  * Heading
  * Image
  * Image caption
  * Image resize
  * Image style
  * Image toolbar
  * Image upload
  * Indent
  * Italic
  * Link
  * Link image
  * List
  * Media embed
  * Simple upload adapter
  * Source editing
  * Table
  * Table toolbar
  * Text transformation

The important bit is the “Simple uploader adapter”, that i modified to
upload the file as `media` instead of the default `upload` (i.e.,
modified ckeditor.js to replace "upload" with "media").

I also had to add the CSRF header somewhere in the HTML document for
JavaScript to be able to retrieve it and pass it to the uploader
adapter, or i would have to disable CSRF validation in that form, which
i did not like at all.
2024-01-16 01:26:35 +01:00
jordi fita mas 0ed6c1b121 Added note about dogs to the campsite type page
The pets icon is just the same as the notpet but without the diagonal
bar.

The price is hardcoded in the query for now, as there is no field
in the campsite type.
2024-01-15 02:07:32 +01:00
jordi fita mas 0beb0bb315 Add VAT and tourist tax information
Since i need the number of decimals to format the price in the template,
i added them to the company, and used them in the call to price_parse().
2024-01-15 01:45:58 +01:00
jordi fita mas 76456aa9b2 Add check-in and check-out time information to campsite type’s page 2024-01-15 01:02:50 +01:00
jordi fita mas dabd197f02 Add additional information field to campsite types
This is actually just to have a fourth column in order to “balance”
lists for types that have a long descriptions.
2024-01-15 00:28:34 +01:00
jordi fita mas 81b6edbc7b Show campground map using leaflet
It is better for mobile users, as they can zoom and pan the map in their
small screens.

Had to increase header’s z-index or the zoom controls would be on top
of it.
2024-01-14 22:31:13 +01:00
oriol carbonell pujolàs 3dbcc076d2 Merge branch 'master' of ssh://dev.tandem.ws:2222/tandem/camper 2024-01-14 21:36:16 +01:00
oriol carbonell pujolàs cb97151264 Update campground map 2024-01-14 21:36:03 +01:00
jordi fita mas 79df1736f2 Add tourist tax to company
Not used anywhere yet, but i will need it when computing the booking’s
total.
2024-01-14 02:09:17 +01:00
jordi fita mas 9b96a355a4 Automatically select the departure date when arrival changes
By default, it selects the next day, unless the new arrival date is
before the current departure, in which case is left as is, because the
idea is to help people avoid useless calendar selections when booking
for next three or four months: they would need to change the month
twice, and now only at most one.
2024-01-13 02:03:27 +01:00
jordi fita mas a226d17aa7 Add the campsite type’s name in front of price if it has options
Customer wants to explicitly show that the first price, the one on top
of the options, is for the campsite type.
2024-01-13 01:37:11 +01:00
jordi fita mas 976b2bcbcf Add position to services to be able to manually sort by admins 2024-01-13 01:15:24 +01:00
jordi fita mas 4e126237a0 Replace L10nInput with I18nInput in service
locale.Translation and form.L10nInput are no longer used.

The translation type in Postgres is now also useless, and i believe it
was never used, but i keep it because I already have a tag and i can not
just remove it, meaning that dropping it is more trouble that worth it.
2024-01-12 21:06:12 +01:00
jordi fita mas 58c3b607a1 Replace L10nInput with I18nInput in season 2024-01-12 20:26:45 +01:00
jordi fita mas 2b702d6632 Add golang template to initialize x-data for translation in admin
Had to add the DefaultLang to legal and location forms in order to use
the same template for all.
2024-01-12 19:51:12 +01:00
jordi fita mas b6cd2f7693 Use I18nInput instead of L10nInput to translate carousels 2024-01-12 19:33:44 +01:00
jordi fita mas 4d0d7a44ab Add slides to show parameter to carouselInit template
Customer wants four slides in home’s carousel, while keeping three in
the rest of the carousels.

In mobile screen, Oriol told me to always have a single slide, but in
tablet it is the given number minus one.
2024-01-11 21:04:32 +01:00
jordi fita mas 2f1895b71a Show international phone number with 00 instead of +
Customer wants it that way.
2024-01-11 20:56:35 +01:00
jordi fita mas f28664acce Replace use of L10NInput with I18nInput for campsite 2024-01-10 21:52:49 +01:00
jordi fita mas 3f46ea3a9a Add “Menu” next to the trigram symbol (“hamburger”) 2024-01-10 19:41:57 +01:00
jordi fita mas 07223f64d2 Merge remote-tracking branch 'origin/upcoming' 2023-12-22 10:41:59 +01:00
oriol carbonell pujolàs 15761a370d Change home image background 2023-12-22 10:41:27 +01:00
jordi fita mas 4d0123def7 Bring back the whole list of options in type page, but in accordion
This is how the customer wants it.
2023-12-22 03:27:49 +01:00
jordi fita mas 12d5356455 Add the link to the reservation conditions to the booking form
This text must be created in the administration interface, but whatever.
2023-12-22 02:29:06 +01:00
jordi fita mas 03c20fec88 Add management of legal texts 2023-12-22 02:23:18 +01:00
jordi fita mas bda3507b62 Merge remote-tracking branch 'origin/upcoming' 2023-12-22 00:22:06 +01:00
oriol carbonell pujolàs 8cfa3b1c77 Add bottom border to heading and add camping association images 2023-12-22 00:20:53 +01:00
jordi fita mas adf87fce94 Add the language switch on the header’s top most in desktop sizes
Customer wants the language switch at the same level as the email and
phone links, because that’s what they have on the old website.
2023-12-21 22:39:58 +01:00
jordi fita mas 8b9f3438a0 Merge remote-tracking branch 'origin/upcoming' 2023-12-21 21:19:18 +01:00
oriol carbonell pujolàs b2b0f035b5 Add style for booking menu item and operture footer section 2023-12-21 21:18:22 +01:00
jordi fita mas ff6e9497b5 Replace contact page with location
Customer does not want a contact page, but a page where they can write
the direction on how to reach the campground, with a Google map embed
instead of using Leaflet, because Google Maps shows the reviews right
in the map.

That means i had to replace the GPS locations with XML fields for the
customer to write.  In all four languages.

This time i tried a translation approach inspired by PrestaShop: instead
of opening a new page for each language, i have all languages in the
same page and use AlpineJS to show just a single language.  It is far
easier to write the translations, even though you do not have the source
text visible, specially in this section that there is no place for me
to put the language links.
2023-12-21 21:17:04 +01:00
jordi fita mas 38d07fb662 Add a class to the booking menu item, and move it second to last
Oriol needs to give it style, and customer wants it there.
2023-12-21 19:13:10 +01:00
jordi fita mas c9a6df658f Add position to campsite type features 2023-12-21 17:33:01 +01:00
jordi fita mas d21b34ab40 Merge remote-tracking branch 'origin/upcoming' 2023-12-21 16:22:33 +01:00
oriol carbonell pujolàs c555ecd432 Update campground map 2023-12-21 11:59:01 +01:00
jordi fita mas 7b6bae5062 Add the email and phone numbers at the very top
Requested by the customer
2023-12-20 20:39:26 +01:00
jordi fita mas 34081a50f4 Move home carousel to the page’s bottom
Customer requested it
2023-12-20 20:24:06 +01:00
jordi fita mas b6c4eb790f Add the country name to the footer’s address
Customer requested it
2023-12-20 20:22:47 +01:00
jordi fita mas 907d9844d3 Add the booking link to the menu
Customer requested it
2023-12-20 20:19:05 +01:00
jordi fita mas b4b7584c14 Show “full slides in the carousels, 3 slides in the biggest breakpoint
Customer does not want the next slide to show partially; either it shows
theo whole slide, or not at all.

Had to remove the min-width for campsite type’s spiel, or it would make
the whole thing fall over, i do not know why; possibly because slick
could not reduce the width to its expected value.
2023-12-20 20:11:39 +01:00
jordi fita mas 678b5cc523 Add user-defined order to campsite types, options, seasons and carousels
I use Sortable, exactly like HTMx’s sorting example does[0].  Had to
export the slug or ID of some entries to be able to add it in the hidden
input.

For forms that use ID instead of slug, had to use an input name other
than “id” because otherwise the swap would fail due to bug #1496[1].  It
is apparently fixed in a recent version of HTMx, but i did not want to
update for fear of behaviour changes.

[0]: https://htmx.org/examples/sortable/
[1]: https://github.com/bigskysoftware/htmx/issues/1496
2023-12-20 19:52:14 +01:00
oriol carbonell pujolàs b8029cd131 Update styles 2023-12-20 13:02:56 +01:00
oriol carbonell pujolàs ed099ad19f Update campground map 2023-12-20 13:02:41 +01:00
jordi fita mas 66a7ae3d27 Fix typo in Accommodation, and fix its translations 2023-12-13 23:45:36 +01:00
jordi fita mas 20d32d6a6d Keep campsite type and date when going to booking form from type page 2023-12-13 23:42:18 +01:00
oriol carbonell pujolàs 6e1d5b14bc Style changes 2023-12-13 23:23:28 +01:00
jordi fita mas cfd5d5675c Remove “Party Details” from booking form, and stylize it a bit 2023-12-12 23:16:04 +01:00
jordi fita mas ac09fd77da Use redsys_environment to choose the correct URL to send the payment to 2023-10-27 17:03:50 +02:00
jordi fita mas 0cbf973cbb Add the payment form to admin
Had to change setup_redsys because admins can not read the current
encrypt key, thus it is not possible to `set encrypt_key =
coalesce(…, encrypt_key)`.

Not that it did much sense, anyway, as i was already inside the branch
of the if when encrpty_key is null.

However, it seems that this also affects in the `on conflict` update. I
assume this is because `excluded` is some kind of row of the relation
and has the same restrictions.
2023-10-27 16:08:13 +02:00
jordi fita mas 57b4360dfb Add error messages to the booking form
I forgot _all_ of them….
2023-10-27 12:37:09 +02:00
jordi fita mas 048b7cbf90 Add the slug to the form in the campsite type public page
The idea is that the booking form will be prefilled with the values
passed from that other mini-form, and the campsite type is implicit
due to the page where the form is located at, but i need to give it to
the booking page.

The booking page does not yet use that information.
2023-10-19 21:38:44 +02:00
jordi fita mas 302ce29e4a Add the first draft of the booking and payment forms
The form is based on the one in the current website, but in a single
page instead of split into many pages; possibly each <fieldset> should
be in a separate page/view.  The idea is for Oriol to check the design
and decide how it would be presented to the user, so i needed something
to show him first.

I hardcoded the **test** data for the customer’s Redsys account.  Is
this bad? I hope not, but i am not really, really sure.

The data sent to Redsys is just a placeholder because there are booking
details that i do not know, like what i have to do with the “teenagers”
field or the area preferences, thus i can not yet have a booking
relation.  Nevertheless, had to generate a random order number up to
12-chars in length or Redsys would refuse the payment, claiming that
the order is duplicated.

The Redsys package is based on the PHP code provided by Redsys
themselves, plus some hints at the implementations from various Go
packages that did not know why they were so complicated.

Had to grant select on table country to guest in order to show the
select with the country options.

I have changed the “Postal code” input in taxDetails for “Postcode”
because this is the spell that it is used in the current web, i did not
see a reason to change it—it is an accepted form—, and i did not want to
have inconsistencies between forms.
2023-10-19 21:37:34 +02:00
jordi fita mas 96fb253354 Show the campsite type’s calendar in an “infinite scroll” carousel
Oriol does not want to waste so much vertical space for the calendar,
and wants it to show in a carousel, initially with only 6 months, and
loading the next three each time the user scrolls past the last.

I now use HTMx in the public page too for this auto-loading behavior,
based on their “infinite scroll” example[0].

Had to put the /calendar URI inside campsites because in the
calendar.gohtml i do not know the current type’s UUID, and can not use
a relative URL to “add subdirectories”, because the type does not end
with a slash.

Had to change season.CollectCalendar to expect the first month and a
number of months to show, to be able to load only 6 or 3 months after
the current, for the initial carousel content, or after the last month
of the carousel.

[0]: https://htmx.org/examples/infinite-scroll/
2023-10-18 21:06:41 +02:00
jordi fita mas 852acaccc3 Add the calendar to the public campsite type page
I had to export the Calendar type from Season to use it from
campsite/types, and also renamed them because season.SeasonCalendar is
a bit redundant compared to just season.Calendar.

I still have not added the HTMx code to switch year because i am not
sure whether Oriol will want to show a whole year or just half a year.

The calculation for the text color taking into account the contrast with
the background is from [0].

[0]: https://www.smashingmagazine.com/2020/07/css-techniques-legibility/#foreground-contrast
2023-10-14 23:14:23 +02:00
jordi fita mas 27af39b296 Add the Catalonia’s Tourism Registry number to company
It is required to be displayed on the website of tourism companies of
Catalonia.
2023-10-14 21:59:36 +02:00
jordi fita mas 2002f0e959 Fix the font size and weight of campsite type headings
These are according to the design
2023-10-13 22:10:44 +02:00
jordi fita mas 9b240cf8c2 Add the booking form to type, and style page according to design 2023-10-13 21:59:45 +02:00
jordi fita mas d1b43e5062 Show “Starting from” price with campsite types that have options
In the old website, the prices where show with all the options, but in
the new design only a single price is show, that in the case of
campsites with options is the price per night of the “base” plus the
minimum options selected.
2023-10-13 20:44:24 +02:00
jordi fita mas 2e10966ad7 Add the list of features for campsite type 2023-10-13 20:30:31 +02:00
jordi fita mas 7fc87b5cb5 Add the info and facilities fields to campsite type
I wish CKEditor would have support for <dl>, but it is unlikely that
they will add any time soon[0], specially when in 2018 they already
“forgotten”[1] that this was requested back in 2007[2].

Therefore, in the demo i did it more or less like in the original
design, with “extra” <h4>, although i added them under a <h3>, to avoid
“gaps” in the outline.

[0]: https://github.com/ckeditor/ckeditor5/issues/775
[1]: https://github.com/ckeditor/ckeditor5/issues/775#issuecomment-358591747
[2]: https://dev.ckeditor.com/ticket/1333
2023-10-13 18:09:28 +02:00
jordi fita mas ebf47b5d75 Add the “spiel” for campsite types
This is the text that introduces the carousel; it is not a spiel, but
this is what i call it.

It turns out that this text needs to have paragraphs and headings, much
like home’s slider, rather than the one in services page, thus no need
to change its font size or to align all items in the carousel in the
middle.
2023-10-12 18:47:08 +02:00
jordi fita mas 471ed9e870 Add the carousel for campsite types
I can not reuse the carousel package because these carousels need the
campsite site’s slug as a first parameters: i can not have a relation
per campsite type, as i do in home and services pages, because the
campsite types are added by administration types; even if i had a
single relation for slides of home and services pages, these would go
in a different relation due to the foreign key to campsite type.

What i could reuse, however, is the Slide and SlideEntry types from
that package, although i had to export carousel.Translation to be usable
from the types package.  I should change that to use locale.Translation,
but this was the easier option, or i would need to change the queries
and templates for carousel package too.

Besides that, they work exactly like the slides in home and services
pages.
2023-10-12 17:43:23 +02:00
jordi fita mas eeb1904b5e Fix type comment for carousel/l10n.gohtml template
It was using the home package, where it belonged before, instead of
carousel.
2023-10-12 16:22:43 +02:00
jordi fita mas caab52a274 Add the campground page
For now, this page only shows the map, that i had to create a new
“files” template function to include it as an extra template file.
2023-10-06 22:14:11 +02:00
jordi fita mas ae29726fa2 Add the footer site map
I created a common template to show the company address in the footer
and the contact page, and then i realized Go did not like to output my
phone URL in the anchor without having the tel: schema in the template.
I then removed that variable and now the URL is created with tel: and
the phone number with its spaces removed.
2023-10-06 22:02:59 +02:00
jordi fita mas d5905a2277 Add the contact page, containing a map with the company location
I was not sure whether to use PostGIS to store the GPS location of the
company, as i am sure i will only use that point just to show the map.
However, just in case, it is not a big deal.

There is no way to change that from the administration pages for now,
because of time constraints, and it is very unlikely that they will
change the campgrounds’ location in the near future.

The location is in a separate table because i did not want to have to
change every test file, to be honest, but this also makes the map
“optional” without the need for NULL values.

I added the contact address to every public page because the new design
adds it to the footer, so i will be needing it everywhere, just like the
menu.
2023-10-06 21:21:00 +02:00
jordi fita mas b73c70c347 Change “singular lodges” menu item to just “campsites” 2023-10-06 18:58:24 +02:00
jordi fita mas 9293a341ef Add campsite type options, mainly for plots 2023-10-06 13:26:01 +02:00
jordi fita mas 60a488b7a0 Add the services and surroundings menu items to the public layout 2023-10-06 11:37:25 +02:00
jordi fita mas 5f38ab8fd3 Add internationalization and localization to seasons 2023-10-03 21:14:37 +02:00
jordi fita mas ef6a8f5aee Add the campsite type cost per season 2023-10-01 21:14:39 +02:00
jordi fita mas 680d51e704 Add max campers and dogs allowed fields to campsite types 2023-09-29 20:17:39 +02:00
jordi fita mas 6939670dfc Add a year navigator to the seasons’ calendar 2023-09-29 18:20:16 +02:00
jordi fita mas 47ec317010 Put calendar’s season selector form in a dialog 2023-09-29 01:35:05 +02:00
jordi fita mas 2d209c8128 Add the minimal CSS for the admin section from Numerus
Basically: menus, tables, snack bar, and input fields.
2023-09-28 02:23:25 +02:00
jordi fita mas e584e29f46 Make seasons’ calendar dynamic and allow to set/unset ranges
The CSS is not very good, but for testing purposes it will work.
2023-09-27 14:21:27 +02:00
jordi fita mas ea2fe8848b Add the season_calendar relation and table on the admin section
This calendar is supposed to be edited by admin users, but do not yet
have the complete JavaScript code to do so, thus for now i have made it
read-only.
2023-09-27 02:23:09 +02:00
jordi fita mas 1621a95fb1 Add a border around season’s color icon
This is because the public design, not yet implemented here, does it
too.
2023-09-26 18:54:53 +02:00
jordi fita mas 650d3bff7b Add a confirmation message for delete actions, except for session
I do not like confirmation messages: they question user’s actions, and
in general it is better to offer an undo option afterward. However, undo
is harder to implement, and currently i do not have time to do this.

The delete for the session is different because the only repercussion
would be to log in again; the user is not in danger of losing any data
whatsoever.
2023-09-26 17:00:22 +02:00
jordi fita mas d4cabce7f5 Add the new service form 2023-09-26 16:51:35 +02:00
oriol carbonell pujolàs 97dc93d06d Update web/templates/campground_map.svg 2023-09-26 05:50:00 +00:00
jordi fita mas 44526b1efb Add the edit form for services
This one has an input to select the icon.  It makes no sense to choose
an icon only by name, thus a <select> is not appropriate, and had to
use a hidden input with a row of button to choose the icon from.  This
works now only because there are very few icons; we’ll need to choose
a different approach when there are many more icons.

Since now the icons have to be defined in CSS for both the public and
admin sections, i had to split it into a separate file that both sites
can use.  I considered the option to “include” that CSS with m4, like
i do for images in demo.sql, but it made everything too complicated
(e.g., having to call make for each change in the CSS), and decided to
load that CSS in a separate <link>.
2023-09-25 20:10:33 +02:00
jordi fita mas 9dfa210708 Replace gradient image for trees in SVG with an actual SVG gradient 2023-09-25 18:03:05 +02:00
jordi fita mas 5697ad27fe Move admin-only links inside the user’s menu
We discussed with Oriol how to show these “extra” menu items, as they
can’t be in the horizontal menu we have intended for employees, because
there is not enough horizontal space.

Oriol suggested to move these into the user menu.  In fact, the company
settings was already there, which means that i already wanted to do that
from the very beginning, i believe, but i must have forgotten it along
the way….  Or maybe it was because this is where Numerus has the company
settings menu item, too, and i did not see the relation with the rest;
i do not know.
2023-09-25 13:13:19 +02:00
jordi fita mas 819c0412d2 Add missing campsites and mark them on the SVG map 2023-09-25 12:51:11 +02:00
jordi fita mas bba555be10 Replace SVG’s foreign attribute with a specific prefix for IDs
I decided to use a custom attribute for the campsite label in the SVG
because i was a bit wary of reusing ‘id’ for that, specially given that
most labels are number only and XML can not have IDs starting with a
number.

In fact, at least Inkscape and Affinity solve the problem by having an
additional foreign attribute to keep the “group label” in without that
restriction (‘inkscape:label’ and ‘serif:id’, respectively), thus i
thought of doing the same, but with a namespace that i control and be
independent of the design program.

However, it seems that Affinity does not have a way of editing the XML
attributes like Inkscape does[0], thus there is no way of adding or
editing that value from there; i can not ask Oriol to edit the SVG file
in a text editor each time.

We have agreed to reuse the ‘id’ attribute to contain the campsite’s
label by using a specific prefix, that we checked is editable without
issue in Affinity’s UI.

[0]: https://forum.affinity.serif.com/index.php?/topic/24318-xml-data/&do=findComment&comment=115609
2023-09-25 12:44:47 +02:00
jordi fita mas 6d84b8baad Fix campground and campsite nomenclature for SVG map
I am using the US terms for campground and campsite, that’s why the
relation is called ‘campsite’ instead of ‘pitch’, but i used the wrong
terminology in the SVG map because the customer uses the UK term and
call themselves campsite, so i mixed things.

It is now the campground map and each individual area is a campsite,
as i have been using all along.
2023-09-25 12:34:05 +02:00
jordi fita mas 233aacc2de Export camperUploadForm function
I did not remember that the file was loaded as a module, so i have
to export it in order to use from the <script> in media.  That <script>
needs to be also a module and explicitly import the function; since it
is already loaded, the browser does not load the file again.
2023-09-24 03:19:46 +02:00
jordi fita mas 4aa74c0768 Add the “normal” link to campsite administration
This link is supposed to be for employees, to see the map and check
on campsites’ availability.  Currently, it shows the same for employees
and admins, but it will need to change.
2023-09-24 03:18:39 +02:00
jordi fita mas e3503187d3 Add campsite map in SVG
I intend to use the same SVG file for customers and employees, so i had
to change Oriol’s design to add a class to layers that are supposed to
be only for customers, like trees.  These are hidden in the admin area.

I understood that customers and employees have to click on a campsite to
select it, and then they can book or whatever they need to do to them.
Since customers and employees most certainly will need to have different
listeners on campsites, i decided to add the link with JavaScript.  To
do so, i need a custom XML attribute with the campsite’s identifier.

Since i have seen that all campsites have a label, i changed the
“identifier” to the unique combination (company_id, label).  The
company_id is there because different companies could have the same
label; i left the campsite_id primary key for foreign constraints.

In this case, as a test, i add an <a> element to the campsite with a
link to edit it; we’ll discuss with Oriol what exactly it needs to do.

However, the original design had the labels in a different layer, that
interfered with the link, as the numbers must be above the path and
the link must wrap the path in order to “inherit” its shape.  I had no
other recourse than to move the labels in the same layer as the paths’.
2023-09-24 03:17:13 +02:00
jordi fita mas 5a16fa44a6 Change media picker from <div> to <dialog> and make it modal
Have to call Dialog.showModal when HTMx loaded the dialog in the DOM,
so had to add a onLoad event listened that checks whether the loaded
element is actually a DIALOG.

Had to restrict the margin: 0 for all elements (*) to exclude dialog,
because the browser sets it to auto, and i did not want to set it again
just because i was too overzealous with my “reset”.

The rest of the CSS is just to have a sticky header and footer, and see
the cancel button, that works as a “close”, all the time.

Finally, i realized that if i add the dialog at the end of the fieldset
and let HTMx inherit its hx-target and hx-swap, i no longer need to set
them in the dialog, as HTMx will always replace the fieldset, and i can
have the dialog side by side the current content of the fieldset, that
it was very confusing seeing it disappear when trying to select a new
media.

The cancel button could now just remove the dialog instead of making the
POST, but in local it makes no difference; we’lls see what happens on
production.
2023-09-22 02:11:03 +02:00
jordi fita mas b5d40cc262 Add the upload form to the media picker
It makes easier to upload new images from the place where we need it,
instead of having to go to the media section each time.

It was a little messy, this one.

First of all, I realized that POSTint to /admin/media/picker to get the
new media field was wrong: i was not asking the server to “accept an
entity”, but only requesting a new HTML value, just like a GET to
/admin/media/upload requests the form to upload a new media, thus here
i should do the same, except i needed the query parameters to change the
field, which is fine—it is actually a different resource, thus a
different URL.

Then, i thought that i could not POST the upload to /admin/media,
because i returned a different HTML —the media field—, so i reused the
recently unused POST to /admin/media/picker to upload that file and
return the HTML for the field.  It was wrong, because i was not
requesting the server to put the file as a subordinate of
/admin/media/picker, only /admin/media, but i did not come up with any
other solution.

Since i had two different upload functions now, i created uploadForm’s
Handle method to refactorize the duplicated logic to a single place.
Unfortunately, i did not work as i expected because uploadForm’s and
mediaPicker’s MustRender methods are different, and mediaPicker has to
embed uploadForm to render the form in the picker.  That made me change
Handle’s output to a boolean and error in order for the HTTP handler
function know when to render the form with the error messages with the
proper MustRender handler.

However, I saw the opportunity of reusing that Handler method for
editMedia, that was doing mostly the same job, but had to call a
different Validate than uploadForm’s, because editMedia does not require
the uploaded file.  That’s when i realized that i could use an interface
and that this interface could be reused not only within media but
throughout the application, and added HandleMultipart in form.

Had to create a different interface for multipart forms because they
need different parameters in Parse that non-multipart form, when i add
that interface, hence had to also change Parse to ParseForm to account
for the difference in signature; not a big deal.

After all that, i realized that i **could** POST to /admin/media in both
cases, because i always return “an HTML entity”, it just happens that
for the media section it is empty with a redirect, and for the picker is
the field.  That made the whole Handle method a bit redundant, but i
left it nevertheless, as i find it slightly easier to read the
uploadMedia function now.
2023-09-22 01:40:22 +02:00
jordi fita mas 7e748bcaa5 Add empty settings-tabs to htmx layout
This is required if requesting an admin page via HTMx; i do not think it
is done as of now, except for the media picker, that has no layout
because i do not want to update the title.
2023-09-21 01:58:29 +02:00