New to tiddlywiki - need some help [with validating tags when user saves tiddler, then preventing (re)edits]

Dear all,

I am new to tiddlywiki so sorry if I ask beginner questions, my previous question might have been not clear enough.

I would like to close a bit the wiki so that users that create new tiddlers have to choose among tags :

  • there are 5 tags corresponding to the people (person1 person2 … person5)
  • there are 3 tags corresponding to the types of note (type1 type2 type3)
    and of course the text that can be formatted.

So basically each new tiddler must have exactly 2 tags (e.g. person2 type3)

How would you achieve that ?

Users should not be able to edit the tiddler later : is there a way ?

Thanks for any help.

1 Like

Hello brunoc68!

I haven’t ever tried to implement either of these kinds of restrictions. But since nobody else has chimed in, I’ll offer a couple thoughts:

The first challenge is akin to what we call field-value “validation” in database circles. For TiddlyWiki, I think you would need an “on-save” action: A Modular Action Mechanism For Tiddler Save Button

I think it may still be worth asking a bit about whether you’re committed to tags here, rather than to having a person field and a note-type field.

Tags are convenient, but when you have consistent field-like structure to your real-world task, separate fields are often the wiser choice. Having such dedicated “lanes” of information may really make things easier as your solution grows.

(For example, suppose you later decide that it should be possible for a tiddler/note to correspond to two people, or to two types, but only under certain conditions… Or you discover a good reason to add an additional tag to some tiddlers (“on hold” or “done” or “urgent”, whatever), but now your on-save validation process (making sure there are exactly two tags, one from each of two categories) would need to be reworked to allow this further kind of helpful tag. If your data is in dedicated fields, meanwhile, your solutions can be more precise and less fragile.)

The second idea is not as easy to address without more details.
Do you want tiddler edits in general to be impossible — like forever, and for everyone? So, if someone hits the check-mark in edit mode by accident, that tiddler is forever engraved in stone? :grimacing:

I’m guessing (hoping?) things are a bit more specific. How to achieve what you want depends on how “securely” (and for whom) you want to prevent revisions to (some category of) tiddlers (once they are generated and the first editing session is complete).

The easiest (but least secure) way is just to HIDE the edit button on tiddlers that meet a certain condition. This is an easy task with a custom stylesheet.

A smart person who understands tiddlywiki (including you :wink: ) can still find ways to modify the contents of tiddlers whose edit button is hidden. Is that a problem for your project?

Can you say more about why you want to prevent editing (for whom, when, and with what level of lockdown)?

1 Like

Along with @Springer’s advice I totaly support. Consider cloning the current edit button and hiding it. Then make the remaining button display conditionally, you could also add a config tiddler such that the condition changes according to its setting.

The ultimate security is not if you can edit a tiddler but if you can save to the file or server.

Tell us more about your wiki and how more than one user will use it.

1 Like

Dear both,

First of all thank you so much @TW_Tones @Springer for taking care of my question.

I tell you a bit more about the project.

I volunteer in a non-profit association that takes care of children from child welfare service.
There is a lot of administrative work to do: everything must be listed and documented (we are in France…)
First of all there are educators who write the notes. These notes concern one or more children.
These notes are:

  • daily reports
  • medical reports
  • incident notes
  • etc…

A practical example: the educator Paul took the children Pierre, Anne and Mickaël for a walk in the mountains today. During this walk, Mickaël insulted Anne and will be punished for that. The sanction will be discussed with the educational team upon returning from the walk. The same day, the educator Sylvie took the child Johan to the psychiatrist.
At the end of the day, we have to write down everything:

  • Paul fills out the “daily note” which concerns Pierre, Anne and Mickaël: he describes the mountain walk
  • Paul also filled out an incident note: Mickaël insulted Anne
  • Paul and Sylvie have decided on a sanction for Mickaël: one of the two or both fills out a sanction note
  • Sylvie fills in the daily medical report of Johan

At this stage everything is documented. Each quarter, the association must provide detailed reports for each child:

  • incident notes
  • medical follow-ups
  • school monitoring
  • etc…

We must also take into account that there are regular changes:

  • educators resign for various reasons, others are hired
  • children arrive, others leave

Hence my original idea of ​​labels separated into different categories, but I am open to using fields if it is more suitable.

Concerning the modifications: it is more about preventing possible human errors (creation of new label) than completely locking the database. Indeed, simply hiding the button is sufficient, especially since in the event of an error someone will have to be able to make a modification.

An important point also : notes will have to be classified by date, and should not have any title.

So far, the default tiddlywiki would work fine with the tags for this project, providing the writers are well educated : they have to choose educator(s), child(ren), type(s) of note, and we can easily sort all of that in reports based on tags.
Unfortunately, I can not count on educator well educated to IT : they already have so much dedication and work with the children…

Here’s something like a proof of concept:

It shows how you can use drop-down lists, checkboxes, and text fields to assemble temporary data. Then have a button that creates a tiddler (named by username plus date, for now) with those field values. (EDIT: This version doesn’t have data validation in the strict sense, but it does hide the “create” button until there are values in certain key fields.)

There are many ways in which this is rough and needs improvement. But I hope that by quickly sketching something out, I can put you on the path toward what you want. Edit the proof-of-concept to see what kinds of widgets and buttons, etc., make the input-form work.

As always, documentation — such as https://tiddlywiki.com/#EditTextWidget — will get you much further, once you know the kinds of things you’re looking for.

1 Like

You’ll probably want a tiddler-maker tiddler that users use to populate fields. The “Save” button is hidden until all fields are complete.

If you’re new to database interfaces, know that having people type things in ad-hoc is very unreliable. Whenever possible, people should populate fields using selection from a list. The items in the drop-down can be populated from a known list of items or derived from the items used so far.

Also, identifying people by first name/last name is highly unreliable. If there is some identification number associated with people, then that’s what should be actually stored in the fields, with the displayed name derived from the number.

This applies both to the kids and to the educators. This may mean that you have to do administrative work to routinely update tiddlers, for instance, that have the names and ID of the people for reference.

Any dates should use some sort of date-picker, so all the dates are formatted properly.

The reason all this matters, is because at some point you’re going to want to make reports. Making reports will be impossible if there are 6 different spellings of a name, or a field for “condition” has comments about the weather.

2 Likes

That’s exactly what I set up a rudimentary demo of, at link above. (Except it’s the “create” button that’s hidden, until temp tiddler fields are filled in.)

And yes, @Mark_S is right about all the big-data-related reasons to build your form carefully!

@brunoc68 thanks for sharing your project. I can see a number of ways the community can help you so make sure you start new topics to discuss things as you go an link back to this summary New to tiddlywiki - need some help [with validating tags when user saves tiddler, then preventing (re)edits] - #4 by brunoc68

This suggests my earlier suggestion of a “conditional edit button” is the way to go.

This has an interesting correspondence to Idea a very short title field VST

Thank you all for your support. I have to diggest what you gave me so far and I’ll come back to you with new questions for sure.

3 Likes