atk4 / data

Data Access PHP Framework for SQL & high-latency databases
https://atk4-data.readthedocs.io
MIT License
270 stars 46 forks source link

Default UserAction 'delete' should have a confirmation message #1082

Open mkrecek234 opened 1 year ago

mkrecek234 commented 1 year ago

Steps to reproduce:

Expected behaviour: By default, there should be a confirmation required before deletion

So adding 'confirmation' = 'Do you really want to delete this record?'here

https://github.com/atk4/data/blob/448e3085699c9a1b2591a777129b4f9bbf317704/src/Model/UserActionsTrait.php#L135

mvorisek commented 1 year ago

Completely agree, about two years ago it was removed when the actions were migrated to UA and since then I always patched in localy like:

abstract class MyModel extends Model
{
    protected function init(): void
    {
        parent::init();

        // ask user for confirmation when delete button is pressed
        $this->getUserAction('delete')->confirmation = 'Do you want to delete this record?';
    }
}
mvorisek commented 1 year ago

If we add any text here in atk4/data, how is it supposed to work with translation in the future? We cannot import/support anything about translations in atk4/data.

mkrecek234 commented 1 year ago

I would propose to add the possibility in atk4/data to add a (localised) text handling function. If not added, it uses its own hard-wired system texts. If it is defined, you can then set any localistion _t function - as extensively discussed with the community, the texts should have unique identifiers like model.delete.confirmation.

This is a separate topic, and not related to this PR: We have plenty of system texts in atk4/data that cannot be localised. As long as we do not have a localisation interface for atk4/data, we should continue implementing texts in hard-wired English in atk4/data.

mvorisek commented 1 year ago

Feel free to send a PR for this, I fully agree the confirmation for delete should be in opt-out fashion.