• Hello Fabrik Community

    Fabrik is now in the hands of the development team that brought you Fabrik for Joomla 4. We have recently transitioned the Fabrik site over to a new server and are busy trying to clean it up. We have upgraded the site to Joomla 4 and are running the latest version of Fabrik 4. We have also upgraded the Xenforo forum software to the latest version. Many of the widgets you might have been used to on the forum are no longer operational, many abandoned by the developers. We hope to bring back some of the important ones as we have time.

    Exciting times to be sure.

    The Fabrik 4.0 Official release is now available. In addition, the Fabrik codebase is now available in a public repository. See the notices about these in the announcements section

    We wish to shout out a very big Thank You to all of you who have made donations. They have really helped. But we can always use more...wink..wink..

    Also a big Thank You to those of you who have been assisting others in the forum. This takes a very big burden off of us as we work on bugs, the website and the future of Fabrik.

Update calc field and hide fields- Complex setup

jo-ka

Member
Hello.
Sorry for this long post, but I need to explain my setup in order to be understandable.

I'm developping a system to manage referees game prize money. I don't manage games and nominations on Joomla, I just import the games from an API and then I run some PHP scripts in order to populate Fabrik tables.

So, in order to do this, my script imports games to fab_games and nominations to fab_nominations.
Then, I run a script that fills the fab_game_prizes, based on some criteria.

All of this is working by now.

So, I have a list join between fab_games and fab_nominations (repeatable, merge rows and reduce data), joined on gameID field.

This way, the referee can view the Game details on one tab, and Game nominations on another one. View only, there's no Edit permissions on form, like this:

upload_2021-3-2_9-5-27.png

So, when they enter to view, they get this:
upload_2021-3-2_9-9-19.png

upload_2021-3-2_9-15-28.png

Now:

I need the referees to fill the values for their prize money, BUT, so they can only edit their own record.
So, I followed a @juuser suggestion made on this post https://fabrikar.com/forums/index.php?threads/list-join-table-template.52326/, and used the Fabrik Content plugin, with the correct filters, on a new manual created Group, like this:

upload_2021-3-2_9-50-40.png

This way, I have full control, with the right permissions, and allow just the logged in user, to edit his own values. When the user click on edit, a popup form comes and the user fills the values, and the list is automatically updated. Great! (Ajaxify links active on list).

So, 2 questions:

1 - Is there a way to have the lower calc filed (Total prémios), which is on the Games form, to run the calc after the popup form close, or whe the content list updates?
I've been playing around with redirect form plugin, but with now avail. Also tried the watch element on calc plugin, but also with now avail.

2 - I know I can use custom.css to hide buttons from the list, based on field values but, is there a way to hide this buttons based on the logged in user?

I've used this method, as with the list join method I can only edit the values IF, I allow the user to edit the full initial record.

I hope I've been clear enough with this long post.

Is there a way to accomplish this?

Thanks in advance.
 
First one seems tricky.

You said you already tried redirect plugin. What happens when you redirect the form (which list is embed to the form with content plugin) to your main form. In that case the form should reload and therefore the calc element updated? Calc element should be set "Only calc on save" = "No". If you need the calc element's value in database, you can create a duplicate hidden calc element with the same code and set "Only calc on save" = "Yes".

If that doesn't work, I would try something like this:
1) In main form add a "dummy" element which is accessible to all users (Access level = Public).
2) Hide it with element javascript on form load.
3) Set the calc elements "Ajax observe fields" to that dummy field.

Now add the following to your form's form_XX.js file (the form which is added in your main list with content plugin):
Code:
requirejs(['fab/fabrik'], function() {
    Fabrik.addEvent('fabrik.form.submit.end', function(form) {
        jQuery('#tablename_dummyelementname').trigger('change'); 
    })
});
and see if this triggers change on your dummy element which then should trigger the calc element update. Of course change the XX in the form_XX.js to your form id and the dummy element id to match yours.

I haven't tested this approach in any way, so no guarantees it will work.

About the second issue. You should be able to use list caneditrow plugin and in Advanced tab "PHP eval" add something like this:
Code:
return '{tablename___userid_element_name_raw}' == '{$my-id}';
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top