Skip to content

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

Amigo edited this page Aug 5, 2019 · 22 revisions

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

JCB removing Repeatable Fields

00:00:00

For example, Joomla is installed here with JCB Joomla Component Builder 2.5.6. Here is quite a lot of Components that has been imported from another JCB and all of them is functioning. For convenience sake Joomla has decided to get rid of this Repeatable Field, which pops up into a little model. It is being systemically removed from JCB.00:00:54 It has already been done in other areas of JCB. Like in the Language Translation area. If any of these Language strings is opened(a'-ZA.ng-NA)Demo-used in 21), it may be seen that we already have the Repeatable Field set up.

00:01:21 This would have been as simple as changing the Field Type within JCB. The 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, the Field structures, how data is stored in a 'json' by the Repeatable Fields, are different from how it is stored in the Sub Form Fields.

JCB 2.5.8, Whole Admin View Moved To Sub Form Layout

00:01:59

There is few issues open on GitHub concerning this. 00:02:10 We have taken on the task of supporting it all. 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 an Admin View - 'Look' is opened, it has the old Repeatable Field concept as could be seen in all the tutorials that had been given. 00:02:43 Permissions is one of those tabs, the Fields, the Conditions, the Linked Views. Then there is a list of the Fields that are linked to the Admin View and some Custom Buttons that can be set up, and it is also a Repeatable Field, as well as linking MySQL(select 'Table'). This is also a repeatable Field in a model.

Heads Up - Moving And Changing Of Fields

00:03:13

All of these different Fields are going to be moved to Sub Fields, because of space and statistics, some of these Fields will be moved into tabs. It will be done in a way that you will not feel lost. Up front this Fields Button are going to be moved to the Fields Tab and so are the Conditions going to be moved there.00:03:45 There will be a new tab called 'Settings'. <<<<<<<<

Settings tab will be called 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

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 Fixes that we put in place when you already have a JCB with horrendous amount of data. It is just too big to do the normal install, then all these admin views will be updated and adapted as you start using JCB. And you should not anywhere at any time experience any conflicts. 00:11:27 In fact if you do, the reason for me making this tutorial, is that you can get into the code. Open an issue on GitHub, and give me heads up so that I can patch whatever you find, and push it out to the rest of the Community. That was just a code side of things.

Installing The Upgrade v2.5.8

Getting back to our install. 00:11:53 I think what I'll do is I'll just open this Admin View - Look, and then I'm going to go and install the upgrade. 00:12:11 I'm just going to select it, it's not been released yet, so this is a pre-demostration. Just to ensure everything works, if it doesn't, you even see that. Let's just select this file from my computer. There it goes, busy installing it. It should take a while, it's quite a big data set. You can just wait it out. 00:12:47 Your upgrade is been successful. You are now on version 2.5.8.

New Field And Conditions View

If we were to open that Admin View which looked like this(see video) and now refresh it, it should look like that(see video). 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 Sub Form values. Same with the tabs. If we go to Field and Conditions, that's how the new Field and Conditions View looks like. Because of many reasons we couldn't keep the Sub Form 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 causes a tremendous slow down on page load. I mean imagine each of these lines are 1 - 13 Fields. If you start having 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.

How The Field And Conditions View Works?

How does it work? Well you could either click on the Edit button - Linked Fields, or the Edit button - Field Conditions to 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 pencil editing links. 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'. It will 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 want to get some information. Back into Editing the Admin View area.

How To Edit Custom Fields

The same goes with the Custom Fields. I could click on any of those to edit them. Or I could click on this Edit button. 00:15:12 It will again ask me if I saved all my work, then if I did click 'OK'. Opens those values right here. A nice new tweak we added, is that it only loads the Fields that are linked to this Admin View(Match Field) that you can target the specific Fields 00:15:34 which makes sense. That Those are the fields that needs to be targeted with this conditional option.

Creating Field - Available

Then you could also create a field. Creating a field will not necessarily add it to the Admin View, it will just make it available to you, if you were to add it by going to Admin Fields .00:15:57 The Edit (Linked Fields)button is the same as 'Edit admin fields conditions for this admin view' but it is a shortcut, because sometimes you might have a lot of fields, and it's a way down there to get to conditions. 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. You just need to keep in mind that things change a little. You could click 00:16:27 on any of these links to open that area where the fields are now found and make the changes. That's the new Admin Fields. Moving away from Repeatable Fields to start using Sub Forms for all our Repeatable concepts. It's what this upgrade is all about. 00:16:53

Shortcut Buttons - First Button, Admin Fields - Second Button, Conditions

There is one heads up which I know is a little different to how things were done previously. Let me close out of this Admin View. I could just mention this, here(buttons underneath a view) is a shortcut to get to the Admin Fields without opening the Admin View and then opening the Admin Fields. You can click on the right button and it will automatically take you to the Admin Fields. You can make changes 00:17:21 and it's link to the Look Area or the Look Admin View. The same is true when looking at the Conditions. The second button is for conditions.

Create New Admin View: Adding - Single Record Name, List Record Name, Short Description, System Name

The thing that has changed is, if you create a new Admin View, you would add the Single Record Name, the List Record Name, the Short Description, the System Name. That's all you need to add 00:17:51 to save the Admin View for the first time. The Admin View at this stage, cannot be linked to any fields until it has an ID. I might still work on this and try and tune it in a way that when you click the button, and if the Admin View is not saved, it saves it for you. 00:18:15 I haven't done that yet. 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 it. What you would naturally do is, add some Name(test) here, then just save it once. Having done that if you go to Fields and Conditions 00:18:57 it says 'Create'. This button here 'Create' and that one here 'Create admin fields for this admin views' is the same button. You can click on any of them to Create Fields. If you would Create a field, yes I did save everything. You can click on the plus+. There's the first field and you can start adding fields, and tweak them as you would before. 00:19:22 That's the new Sub Form Fields for Admin Views. That's what this upgrade is all about. I trust that it benefit all of us in the future, and make it more easier for us to transition into Joomla 4.

Clone this wiki locally