Commit Graph

130 Commits

Author SHA1 Message Date
jordi fita mas 2e10966ad7 Add the list of features for campsite type 2023-10-13 20:30:31 +02:00
jordi fita mas d784291a04 Create Go functions for PostgreSQL functions for campsite type option
I am going to base these to create the function for campsite type
feature, and since i intend to
2023-10-13 19:05:17 +02:00
jordi fita mas a174837aea Handle errors for Commit and Rollback in campsite/types/option 2023-10-13 18:57:46 +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 59fe8dd131 Add Go functions for campsite_type PostgreSQL functions
I want these because when there are changes in the signature i then have
to find where it is used, and it is easier to do when the compiler tells
you.

For relations it is less necessary because GoLand knows how to validate
SQL strings for them, but it seems to not work with functions,
apparently due to the lack of the “FROM” keyword.

Besides, it tx.FunctionName(ctx, params...) is shorter than
tx.Exec("select functions_name($1, $2…)", params...).
2023-10-13 12:53:30 +02:00
jordi fita mas 0ebbf9613d Check errors for Commit and Rollback in package campsite/types 2023-10-13 12:42:05 +02:00
jordi fita mas 8f5d5cf580 Update CKEditor4 from 39.0.1 to 40.0.0 and switch to the classic editor
Even i had trouble sometimes to know that the “empty space” below
description was the “block editor”, because there was no visual clue.
2023-10-13 10:55:13 +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 ad7126cc92 Fix allowed methods repost for carousel’s root address 2023-10-12 16:23:32 +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 f2b12bdedf Fix Sqitch’s requires for schema_camper in home_carousel and services_carousel
I only messed up the requires; the actual schema for these relations is
correct.
2023-10-12 16:21:32 +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 893876cce4 Fill the actual invoicing data for the company 2023-10-06 19:33:44 +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 15be48b770 Add “bungalows premium” campsite type to demo 2023-10-06 18:53:44 +02:00
jordi fita mas 9293a341ef Add campsite type options, mainly for plots 2023-10-06 13:26:01 +02:00
jordi fita mas 0611e95ea1 Grant execute to guest for function to_price
It is required when showing the prices of campsite types on the public
section of the web.
2023-10-06 13:23:20 +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 0ce1b4bd64 Set the default language of demo users to Catalan
Since i have my browser in English, the automatically detected language
is also set in English, making it harder for me to see if i added all
the translations; when the language is Catalan, i can see the
untranslated strings.
2023-10-03 21:11:10 +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 50cc4c41b3 Fix error unsetting season range that corresponds to existing range 2023-09-28 02:28:33 +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 3768dd5082 Replace serial columns with ‘generated by default as identity’
I just found out that this is a feature introduced in PostgreSQL 10,
back in 2017.

Besides this being the standard way to define an “auto incremental
column” introduced in SQL:2003[0], called “identity columns”, in
PostgreSQL the new syntax has the following pros, according to [1]:

 * No need to explicitly grant usage on the generated sequence.
 * Can restart the sequence with only the name of the table and column;
   no need to know the sequence’s name.
 * An identity column has no default, and the sequence is better
   “linked” to the table, therefore you can not drop the default value
   but leave the sequence around, and, conversely, can not drop the
   sequence if the column is still defined.

Due to this, PostgreSQL’s authors recommendation is to use identity
columns instead of serial, unless there is the need for compatibility
with PostgreSQL older than 10[2], which is not our case.

According to PostgreSQL’s documentation[3], the identity column can be
‘GENERATED BY DEFAULT’ or ‘GENERATED ALWAYS’.  In the latter case, it is
not possible to give a user-specified value when inserting unless
specifying ‘OVERRIDING SYSTEM VALUE’.  I think this would make harder to
write pgTAP tests, and the old behaviour of serial, which is equivalent
to ‘GENERATED BY DEFAULT’, did not bring me any trouble so far.

[0]: https://sigmodrecord.org/publications/sigmodRecord/0403/E.JimAndrew-standard.pdf
[1]: https://www.2ndquadrant.com/en/blog/postgresql-10-identity-columns/
[2]: https://wiki.postgresql.org/wiki/Don't_Do_This#Don.27t_use_serial
[3]: https://www.postgresql.org/docs/15/sql-createtable.html
2023-09-26 19:35:16 +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 75f5410233 Add sample season to demo SQL 2023-09-26 18:54:20 +02:00
jordi fita mas 067ca7a3ee Add function and HTTP handler to delete services 2023-09-26 17:29:49 +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
jordi fita mas cdea3e59de Remove the top position for .has-submenu
The baseline of the arrow down character, changed in 79ade5c029, there
is no need to move it up anymore.
2023-09-26 10:02:31 +02:00
oriol carbonell pujolàs 79ade5c029 Update web/static/public.css
change symbol "has-submenu : after" for "↓"
2023-09-26 06:04:43 +00: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 d79a05a619 Add http.MethodDelete to the list of allowed methods for carousel 2023-09-25 20:03:38 +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