Skip to content

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

Amigo edited this page May 15, 2019 · 22 revisions

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 day JCB And Basically all of it is working If we were to look Inside of them It really looks the way that it should And it's expected 00:00:34 Now Joomla has Conveniently Decided to Get rid of this repeatable Field Which pops up into a little Model And So we have systemically been removing this field 00:00:54 From JCB Just to show you We've already done that in other areas of JCB Like in the language area If we would to Open Any of these Language strings You see that we already have the repeatable field 00:01:19 Set up here Now This would have been a simple as changing the field type Within JCB to achieve Only Reality is that the compiler As well as one other feature which is the Joomla components Can be exported in JCB packages and imported And so These features are mapping into these component concepts 00:01:46 You know the Field structures really how data stored In a json By the repeatable fields Are different from how it's being stored in the subform fields Are gonna go into explaining what the difference is There is actually Few tickets been open on GitHub about this And so We have 00:02:10 Taken on the task of just Sporting all of this With this next release which is JCB 2.5.8 The whole admin View area Will now be moved over to this new form Subform layout So if I was to open an admin View now It basically has The old Repeatable field concept As you would have learned with all the tutorials we've done 00:02:43 So your permissions is one of those taps the fields The conditions the linked fields And then you have a list of the fields that are linked to the admin View And you've got some custom buttons you could Setup and it's also A Repeatable field As well as linking a sequel Clicking on table this is also repeatable field In a model 00:03:13 So all of these different fields are now gonna be moved to subfields Because of space and statistics We will Move some of these Fields into taps I will try and do it in a way that seems obvious and that he wouldn't feel lost So just up front The fields This Fields button Are going to be moved To the fields tab 00:03:45 And so does The conditions move there There will be in new tab called settings so basically this tab will stay there And will call that details and a new tab with settings And the rest of the repeatable fields that are remaining On this side will be placed there Ok so that's just a heads up on what's gonna happen But this is gonna happen really without you doing much Basically all you need to do is upgrade And 00:04:19 We have added a number of scripts That you can actually go and look at On GitHub if you like As I'm doing this recording The staging branch Is where you will see these changes So Basically 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 So let me just go down to that area So here we have a function Inside of a method More like an anonymous function And Basically this is what converts the repeatable fields So I'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.7 which was not really released because having made this This change We still need to to convert the repeatable fields And that will continue to run until 2.5.9 Now The way it does this Is it really Targets The various 00:05:40 Up here There's to convert repeatable function it Target all these fields as you can see Inside the admin View And it passes it over to this Convert repeatable Which is really going to do the work and this 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 this function here And I will now also demonstrate that it actually does work well The only thing that I have actually noticed It's like with this website that we are working on here We talking about thousands of values Well Even more than thousands And I have found that 00:06:32 It sometimes does not convert every single value And so because of that We actually did another fix Which Goes beyond and ensures that this upgrade will not cause any Internal conflicts And that is within the Backend And within the model There are a few places where these New fields will now exist 00:07:02 One of them is conditions Field conditions and the other one is admin Fields so I'll open that one Open this one And obviously in a Oh not Not that one It's this admin View These are the models in which these field changes will take place And you'll see that within the 00:07:27 Get item Method at the very end Of this method In the admin View We added a function Which would basically check If this These Fields were updated during the upgrade And if it were not updated That is 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 actually make Do the update And add it to the update object And then basically check every field All the way down Till here And then if it sees that there is been any one of those fields Found to be You know ready to update 00:08:14 Then we will run the update And after that it will never Do it again Because you see the way the A the array is constructed This Will no longer exist once it's been moved to a subform Storage The subform array structure is different So 00:08:39 Once you open any of the items it will automatically convert it and make sure that it's Converted The other thing that we've done Because you most probably will not all open every view or every Admin View Is Even when the new admins Fields we've done the same So you can see here 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 then there is one more place where we also add these Checks and that's actually 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 obviously now been adapted to instead Actually Use the new subform structure Within it's compilation 00:09:38 To within the get file where most of these subforms are now needed We have In the get admin Function let me just get there So here is the get admin View Method of function class method And you see we are checking Whether it's still in a repeatable field And if it is We convert it 00:10:04 And we again store it to the update object That While it's getting this one Admin view at the very end So every where it's doing it check If it's not being converted converts it's sets it back to the data set And also to ensure that we store it back into the database Little String And So It Goes On Doing it everywhere Where we 00:10:30 You know expect To find values that still You know me I've been missed And then here it very end of this function Which is a little big I supposed If we found that there are any updates we run the update And after that that view is been updated and it will never need to be updated again so these are the Kind of Switches 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