phrasing icon indicating copy to clipboard operation
phrasing copied to clipboard

Feature/default phrase

Open dkNorth opened this issue 4 years ago • 2 comments

Adds a default option for normal phrases.

If you want to change the default later on, but keep the already set up phrases intact.

In my case... I create multiple versions of the same phrase, with a default phrase that may be changed later on. I can't use the key as a default, because if I change it, it resets all other versions back to default, because the key is different. With a default phrase I can change it as often as I like without touching the key.

dkNorth avatar Nov 25 '20 14:11 dkNorth

@dkNorth thanks for opening the pull request for this.

Can you please give me an example of your default phrase value? I think it might clear up the reason for why this behaviour is beneficial. Is your goal adding new phrases with a different default value, or performing shotgun surgery on all your views that have a default value?

Also, I'd rather go with setting the default value via configuration:

config.white_list = ["Post.title", "Post.body"] # already exists
# config.default_phrase = nil => would be the gem default
config.default_phrase = 'Please enter phrase here'

This way you wouldn't have to define default on every phrase if it's the same.

cilim avatar Nov 30 '20 11:11 cilim

I needed the default phrase, because in my App an Editor is allowed to create personalized Pages for specific Visitors. In short they create a page and the visitor who the site is for, receives a link only to that specific page.

This page always starts out the exact same with text passages at predetermined locations. The Editor of course should be able to edit these and should also get an Idea how it looks like with default text. Now, I got many different text passages, some are long, some are just titles and so on and all of them should be filled with dummy text (the default phrase).

The way I did this before was that I put the dummy text into the key parameter, which worked fine, but there were 2 problems:

  1. The "Edit All" List was very chaotic. It wasn't really possible to see where each phrase belonged, because the keys were so long and unspecific.
  2. If me or the Editor wants to change the default phrase for new pages later on, we can't, because changing the key value (default phrase) means changing back all previous set phrases on the other pages to the new default, because the key is different now.

I can't use the default phrase in the config either, because the dummy texts should be different for different phrases.

I realize it probably is a very specific problem, but I wrote the update so that it was optional to use it like this.

dkNorth avatar Dec 01 '20 16:12 dkNorth