Updated 069 Join Fields in the admin list view with field relations (markdown)

Amigo 2019-10-02 14:41:06 +02:00
parent ca6f911667
commit 8bddb26d20

@ -83,8 +83,6 @@ If we go into the Preacher fields area, you'll see we have two fields the Name(t
[00:22:15](https://www.youtube.com/watch?v=hh4IIPmYIY8&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h22m15s)
In the Sermons area we will see that we have a Preacher table and a Name table. We have these two links 'Ten shekels and a shirt and Paris Reidhead', this 'Paris Reidhead' will open the Preacher, the same as opening it from the Preacher list view and then this 'Ten shekels and a shirt' is going to open the Sermon. This is going to be easy because [00:22:45](https://www.youtube.com/watch?v=hh4IIPmYIY8&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h22m45s) we can decide we have so many rows, let's combine the Preacher with the Name row. Yet we want to retain the link as it is working. We want to retain the option to filter by the Preacher. Let's show you how easy it is to do that. We'll go to the Sermons list View or admin view and then again to the fields, click on create fields relations, before we are going to do that, [00:23:20](https://www.youtube.com/watch?v=hh4IIPmYIY8&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h23m20s) I first need to remove the Preacher from the list. We are first going to go to where we selected the fields. That needs to be linked to the admin list view.
In the Sermons area we will see that we have a Preacher table and a Name table. We have these two links 'Ten shekels and a shirt and Paris Reidhead', this 'Paris Reidhead' will open the Preacher, the same as opening it from the Preacher list view and then this 'Ten shekels and a shirt' is going to open the Sermon. This is going to be easy because [00:22:45](https://www.youtube.com/watch?v=hh4IIPmYIY8&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h22m45s) we can decide we have so many rows, let's combine the Preacher with the Name row. Yet we want to retain the link as it is working. We want to retain the option to filter by the Preacher. Let's show you how easy it is to do that. We'll go to the Sermons list View or admin view and then again to the fields, click on create fields relations, before we are going to do that, [00:23:20](https://www.youtube.com/watch?v=hh4IIPmYIY8&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h23m20s) I first need to remove the Preacher from the list. We are first going to go to where we selected the fields. That needs to be linked to the admin list view. The one we want to remove is the Preacher value. [00:23:42](https://www.youtube.com/watch?v=hh4IIPmYIY8&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h23m42s) Sermon Preacher. We are going to say no, don't add it. When you are going to do that, it is going to wipe out all the links that usually should not been selected if it's not a listview. But since we still want it to be a link, we still want it to be a filter, we are going to leave those checked and click save and close. Going back to Editing The Admin View page, going to Fields. We'll see that [00:24:10](https://www.youtube.com/watch?v=hh4IIPmYIY8&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h24m10s) the Sermon Preacher is no longer going to show in the list view. But it's still going to be a filter and a link. If you compile, it won't show up at all. You will still need to go and select the Relations area. Click on New. Then select Name in List Field. [00:24:33](https://www.youtube.com/watch?v=hh4IIPmYIY8&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h24m33s) In Join Field you would need to select the Sermon Preacher, And then View in Area row, we could either say we want to do this ourselves, or [00:24:50](https://www.youtube.com/watch?v=hh4IIPmYIY8&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h24m50s) we could use Glue. Which in this case I'm going to use a space just an empty space, and save and close. Then compile, install. Refresh the Sermon page we will see that there are [00:25:21](https://www.youtube.com/watch?v=hh4IIPmYIY8&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h25m21s) two links. The one is to open Sermon and the other one is opening the Preacher. If we click on it, it still behaves as before. The Preacher opens, we close it again. We are back and we still have the Preacher filter at the bottom of our page as we had it before. [00:25:48](https://www.youtube.com/watch?v=hh4IIPmYIY8&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h25m48s) This is really great! We can also then open 'Ten shekels and a shirt and Paris Reidhead'. All is working as expected.
????
And the one we want to remove Is the preacher value So it's this one [00:23:42](https://www.youtube.com/watch?v=hh4IIPmYIY8&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h23m42s) Sermon preacher we gonna say no Don't add it and when you do that is gonna wipe out all the links that usually Should not be selected if it's not a listview But since we still wanted to be a link And we still wanted to be a filter We gonna leave those checked And then click save and close So now Getting back to this page And going to Fields we'll see that [00:24:10](https://www.youtube.com/watch?v=hh4IIPmYIY8&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h24m10s) The the preacher now Is No longer going to show the list View But it's still Going to be A filter in a link And if you compile now it won't show up at all You still need to now go and select the relations area click on new And then select name [00:24:33](https://www.youtube.com/watch?v=hh4IIPmYIY8&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h24m33s) Here You would now Need to select The sermon preacher And then View And then Well we could either say We wanna do this ourselves Or [00:24:50](https://www.youtube.com/watch?v=hh4IIPmYIY8&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h24m50s) We could Use glue Which in this case I'm just gonna use a space just an empty space like that And save and close And then we compile Install And then refresh the sermon page we see that now They are [00:25:21](https://www.youtube.com/watch?v=hh4IIPmYIY8&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h25m21s) Two links here The one is to open the Actual Sermon and the other one is opening the It's going to open the preacher So if we click on it it still behaves as before the preacher gets opened we closed again And we back here and we still have the preacher filter Here at the bottom of our page As we had it before [00:25:48](https://www.youtube.com/watch?v=hh4IIPmYIY8&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h25m48s) And so This is really Great We can also then open here And All is working as expected Now as easy as it was To combine these two values into one column While still retaining the actual links and everything surrounding this value having a Dynamically get the name [00:26:16](https://www.youtube.com/watch?v=hh4IIPmYIY8&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h26m16s) Because obviously in the table it's taught the ID only And now showing it here it means it's actually remapped it in the database so let me show you that So we open the sermons Model and we scroll down We'll see here in the the list query It's still Maps the preacher table in And Builds the connection on the ID in the preacher And still selects [00:26:49](https://www.youtube.com/watch?v=hh4IIPmYIY8&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h26m49s) The preacher name Then going to the view of that Sermons We see if you scroll down Here It has Produced this chunk Of code For the for the preachers name And this chunk of code [00:27:14](https://www.youtube.com/watch?v=hh4IIPmYIY8&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h27m14s) For the Sermon name So it still does all the Producing of the HTML code and all the permissional checking whether Does this user actually have The edit permission to To change this value Of the specific preacher [00:27:37](https://www.youtube.com/watch?v=hh4IIPmYIY8&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h27m37s) So yes and yet it's showing the preacher name As the linking up in the database was done So it's quite exciting I really Hope that you would find it as useful as I am already doing And like I said if you discover anything not to work as expected Please do contact me and on GitHub open up a issue And we will Take it from there. Thanks for watching.
Now as easy as it was to combine these two values into one column while still retaining the links and everything surrounding this value having it dynamically have the Name. [00:26:16](https://www.youtube.com/watch?v=hh4IIPmYIY8&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h26m16s) Because in the table it's the ID only. Showing it here it means it's remapped in the database. We open the sermons model and we scroll down. We'll see in the getListQuery it still maps the preacher table in, builds the connection on the ID, and the preacher. It still selects [00:26:49](https://www.youtube.com/watch?v=hh4IIPmYIY8&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h26m49s) the preacher name. Then going to the view of that sermons. We will see if you scroll down, it has produced this potion of code for the preachers name(see video). This portion of code [00:27:14](https://www.youtube.com/watch?v=hh4IIPmYIY8&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h27m14s) for the sermon name. It still does all the producing of the HTML code and all the permissions checking whether does this user have the edit permission to change this value of the specific preacher. [00:27:37](https://www.youtube.com/watch?v=hh4IIPmYIY8&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h27m37s) Yet it's showing the preacher name as the linking up in the database was done. It's quite exciting. I really hope that you would find it as useful as I am. Like I said if you discover anything not to work as expected, please do contact me and on GitHub open up a issue. We will take it from there.