Skip to content

041 Upgrade to JCB v2.5.8 and using the new Admin View and Admin Fields

Amigo edited this page Jun 26, 2019 · 22 revisions

UPGRADING TO JCB v2.5.8 AND USING THE NEW ADMIN VIEW AND ADMIN FIELDS

JCB removing Repeatable Fields

Hi. I've got Joomla installed here with JCB Joomla Component Builder 2.5.6 00:00:12 I've got quite a lot of Components that I have imported from another JCB. All of it is working. If we were to look inside of them, it looks the way that it should, and as expected. 00:00:34 Joomla has conveniently decided to get rid of this Repeatable Field, which pops up into a little model. We have systemically been removing this Field 00:00:54 from JCB. We've already done that in other areas of JCB. Like in the Language Translation area. If we would to open any of these Language strings'(a'-ZA.ng-NA)Demo-used in 21', you will see that we already have the Repeatable Field 00:01:19 set up.

Compiler, Other Components in Joomla Can Export And Import IN JCB Packages

This would have been simple as changing the Field Type within JCB to achieve. The only reality is that the Compiler as well as one other feature which is the Joomla Components, can be exported and imported in JCB Packages. These features are mapping into these Component concepts, 00:01:46 the Field structures, how data is stored in a json. The Repeatable Fields are different from how it's being stored in the Sub Form Fields.

Difference Between Repeatable Fields And Sub Form Fields

I'm going to explain what the difference is. There is few tickets open on GitHub about this. We have 00:02:10 taken on the task of supporting all of this. With this next release which is JCB 2.5.8, the whole Admin View area will be moved over to the new Sub Form layout. If I was to open an Admin View - Look, it has the old Repeatable Field concept as you would have learned with all the tutorials we've done. 00:02:43 Your permissions is one of those tabs, the Fields, the Conditions, the Linked Views. Then you have a list of the Fields that are linked to the Admin View. You've got some Custom Buttons you could setup, and it's also a Repeatable Field, as well as linking MySQL, clicking on Table. This is also repeatable Field in a model. 00:03:13

Heads Up - Moving And Changing Of Fields

All of these different Fields are going to be moved to Sub Fields, because of space and statistics. We will move some of these Fields into tabs. I will try and do it in a way that you wouldn't feel lost. Up front this Fields Button are going to be moved to the Fields Tab. 00:03:45 The conditions are going to be moved. There will be in new tab called Settings. Settings tab will be call Details, and a new tab will be Settings. The rest of the Repeatable Fields that are remaining on this side will be placed there.That's just a heads up on what's going to happen. This is going to happen without you doing much. All you need to do is upgrade. 00:04:19

Add Number Of Scripts That Will Convert

We have added a number of scripts that you can go and look at on GitHub if you like. As I'm doing this recording, the Branch: staging is where you will see these changes, if we would to go to the script, this is the script that will convert 00:04:43 the Fields and all the Tables and everything.

Convert Repeatable Function

Let me just go down to that area. We have a function inside of a method. More like an anonymous function. This is what converts the Repeatable Fields. We'll be using this function over and over as you can see we've done it with a upgrade to version 2.5.5 00:05:13 and then there is another upgrade 2.5.7 which was not released because having made this change, we still need to convert the Repeatable Fields. That will continue to run until 2.5.9. The way it does this, 00:05:40 the '$convertRepeatable' function target all these(ajax, custom_button, addtables etc.) fields inside the Admin View, and it passes it over to '$convertRepeatable', which is going to do the work and '$convertRepeatable' function like I said you can look at it over here. If you are uncertain of doing this 00:06:07 you can come and look at '$convertRepeatable' function here. I will also demonstrate that it does work well. The only thing that I have noticed, it's like with this website that we are working on, we talking about thousands of values, even more than thousands.

Model - admin_view.php - Changes Would take Place

I have found that 00:06:32 it sometimes does not convert every single value, and because of that, we did another fix, which goes beyond and ensures that this upgrade will not cause any internal conflicts. That is within the Back end, and within the Model. There are a few places where these new Fields will exist. 00:07:02 One of them is 'admin_field_conditions.php' and the other one is 'admin_view.php'. I'll open this 'admin_view.php'. These are the models in which these Field changes will take place. You'll see that within the 00:07:27 getItem Method at the very end of this method in the Admin View, we added a function which would check if this these Fields were updated during the upgrade. And if it were not updated, while the field is busy loading and you're opening the page. 00:07:52 it'll check whether it's been updated. If it's not updated it will make do the update, and add it to the update object. And then check every Field, all the way down. If it sees that there is been any one of those Fields found to be ready to update, 00:08:14 then we will run the update. After that it will never do it again. The way the array is constructed, this will no longer exist once it's been moved to a Sub Form Storage. The Sub Form array structure is different. 00:08:39 Once you open any of the items, it will automatically convert it and make sure that it's converted.

Checks - Converts Sets Back In Database - Updated Once Never to Do It Again

The other thing that we've done, because you most probably will not open every view or every Admin View. Even in the new admins fields we've done the same. In the admin fields, we are also making sure that that update is there, and the same with the admin field conditions, 00:09:09 it's also there. But there is one more place where we also add these checks and that's in the Compiler. So even if you didn't go and open any of these views and you just went straight to the Compiler, and try to compile any of your Components, the Compiler now been adapted to instead use the new Sub Form Structure within it's compilation. 00:09:38

  • Checking

Within the Get file where most of these sub forms are now needed, we have in the 'getAdminViewclass' method and you will see we are checking whether it's still in a Repeatable Field. If it is, we convert it. 00:10:04 Again store it to the update object while it's getting this one admin view at the very end. Every where it's doing it check, if it's not being converted.

  • Converts

It converts it and sets it back to the data set, and to ensure that we store it back into the database, this little string '$objectUpdate->addpermissions=json_encode($bucket);. So it goes on doing it everywhere where we 00:10:30 expect to find values that still may have been missed.

  • Updates

?? And at the very end of this function, which is big I supposed. If we found that there are any updates we run the update, and after that view is been updated, it will never need to be updated again. These are the kind of 00:10:56 How can I put it Fixes really That we put in place when you already have a JCB with horrendous amount of Data and it is just too big to do just with the normal install Then all these admin views will Be Updated and adapted As you start using JCB And you should not really anywhere at any time experience Any conflicts 00:11:27 In fact if you do the reason for me making this tutorial Is it you can actually get into the code And that you can You know Open an issue on GitHub And give me heads up so I can You know Patch whatever you find And push it out the rest the community Ok so that was just a code side of things now getting back to to our install here 00:11:53 I think what I'll do is I'll just open Maybe this Admin view And then I'm gonna go And Basically Install The The upgrade 00:12:11 I'm just gonna selected it's not been released yet So this is a pre-demostration Just to ensure everything works So if it doesn't you even see that So let's just select this file from my computer Ok there it goes busy installing it It should take a while it's quite a big dataset And you can just wait it out I'd wouldn't shout at you if it missed certain values I don't know why doesn't but 00:12:47 there it goes Your upgrade is been successful And you are now on version 2.5.8 And if we were to open that Admin view Which Basically looked Like this And now just refresh it It should now look like that So you see it's moved 00:13:09 These Fields to the side There's now a settings field And as you can see all the data is just been updated and moved to subform values Same with the taps And if we go to field and conditions There we go That's how the new field and conditions view looks like Now Because of many reasons we couldn't keep the subform fields within the admin View 00:13:38 Especially when you Start having More than 50 admin Fields which in my case I have quite a few of those it's not advisable Because it actually causes the tremendous Slow down on page load I mean imagine each of these lines are actually 1 2 3 4 5 6 7 8 9 10 11 12 13 fields And if you start having a huge a lot of those fields Which you could have up to 800 00:14:09 By the limit we've set it really takes a long time to load that into the page Ok Enough about that how does it work now Well you could either click on this edit button here Or this edit button here to actually go and edit these and change their values If you would like to just edit one specific field You could click on any of these you know pencil editing Links So for example if I click on name 00:14:41 It will ask me whether I've saved all my values in this current View And yes I just click ok And it will now open the name field And I can now come in here do any edits that I'd like And then save and close or just close out again if you wanna only wanna get some information Now Back into This area The same goes with the custom Fields I could click on any of those to edit them Or I could click on this edit here 00:15:12 And it will again ask me if I saved all my work And then if I did click ok And opens Those values right here A nice new tweak with added is that it only loads the fields That are actually linked to this Admin view So that you can only Target The specific fields 00:15:34 Which really makes sense That Those are the fields that needs to be targeted With this conditional option Then you could also create a field but creating a field will not Necessarily add it to the admin View It will just make it available to you If you were to have You know add it By going to admin fields 00:15:57 Oh yes let me just say this this button here And this one here is the same button Just this is a shortcut Because sometimes you might have a lot of fields And it's a way down there to get to conditions So we added some shortcuts up here There's also the tutorial On how to use this but the tutorial still was made when we had the old Fields layout It should still make sense I mean you just need to keep in mind that things change a little So you could click here 00:16:27 On any of these links To actually open That area where the fields are now found And make the changes So that's really the new admin Fields and moving away from repeatable fields To start using subforms for all our Repeatable concepts It's really what This upgrade is all about 00:16:53 There is 1 heads up which I know is little different to how things were done previously Let me just close out of this Admin View Oh yes I could just mention this Here is a shortcut to get to the admin Fields without opening the admin view and then opening the admin fields You can click on this right here and it will automatically take you to the admin fields And you can make changes here 00:17:21 And obviously it's link to the look Area or the look admin view And the same is true when looking at The conditions there the second button here is for conditions The thing that has changed is if you create a new admin View Now You would obviously add the single record name the list record name the short description And the system name And that's really all you need to add 00:17:51 To save the admin view for the first time because The admin view at this stage It cannot be linked to any Fields until it has an ID Now I might still work on this and try and You know Tune it in a way that When you click the button and if the Admin view is not saved it saves it for you But 00:18:15 I haven't done that yet so at this stage Since the admin field doesn't have an ID it's still new because we haven't clicked save Even once You can't link any Fields to them To it so what you would Natural do is just add some Add some name here And And then just save it once And having done that if you now go to Fields and conditions 00:18:57 It basically says create To this button here and that one here is the same button You can click on any of them to create fields So if you would create a field So yes I did save everything And then I You can just click on this plus over here And there's a first field and you can start you know adding fields And tweak them as you would before 00:19:22 And Yep so there you go That's the new subform Fields for admin views And that's what this upgrade is really all about I trust that it all benefit all of us in the future And make it more easier for us to transition into Joomla 4 And thank you for watching.

Clone this wiki locally