From b671dee016e8b545791d13a31381e359f7c45f18 Mon Sep 17 00:00:00 2001 From: Amigo <49749100+aamigo@users.noreply.github.com> Date: Thu, 31 Oct 2019 08:57:07 +0200 Subject: [PATCH] Updated 073 JCB Fields Type Extended (markdown) --- 073-JCB-Fields-Type-Extended.md | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/073-JCB-Fields-Type-Extended.md b/073-JCB-Fields-Type-Extended.md index b7b31ce..407f59b 100644 --- a/073-JCB-Fields-Type-Extended.md +++ b/073-JCB-Fields-Type-Extended.md @@ -51,17 +51,19 @@ Then the 'button' feature is one of the features that are quite exciting. Let me [00:12:29](https://www.youtube.com/watch?v=91iIAuHZj38&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h12m29s) -If we now go back to the code, we see a new set of a script called `getinput`. That's how the button gets added. It asks `getAttribute('button')`, it checks if `button` is `true`. If button is `true`, then it already have the parent `HTML` (the whole field is in this HTML). If you have a button and someone clicks on it, you might want them to [00:13:07](https://www.youtube.com/watch?v=91iIAuHZj38&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h13m07s) be redirected back to this page where the field is, once they are done on the other page. This is what it does, it checks if there is a 'Referral'. We are building a return value as well. We come down here and we start to build the button. There is the button being built(See Video). [00:13:44](https://www.youtube.com/watch?v=91iIAuHZj38&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h13m44s) That is to create. This is called preachers, and down here we have a view called 'Preacher' and 'Preachers'. That is the Single View, the Single View name of the place, the field is added. This is the 'Listview'. We are grabbing the field data from the Preacher View, and it's List name is 'Preachers'. It is the table where the data is being captured from. Not the table where you are going to show the field but the table where you are taking the information from. +If we now go back to the code, we see a new set of a script called `getinput`. That's how the button gets added. It asks `getAttribute('button')`, it checks if `button` is `true`. If button is `true`, then it already have the parent `HTML` (the whole field is in this HTML). If you have a button and someone clicks on it, you might want them to [00:13:07](https://www.youtube.com/watch?v=91iIAuHZj38&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h13m07s) be redirected back to this page where the field is, once they are done on the other page. This is what it does, it checks if there is a 'Referral'. We are building a return value as well. We come down here and we start to build the button. There is the button being built(See Video). [00:13:44](https://www.youtube.com/watch?v=91iIAuHZj38&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h13m44s) That is to create. This is called preachers, and down here we have a view called 'Preacher' and 'Preachers'. That is the Single View, the Single View name of the place, the field is added. This is the 'Listview'. We are grabbing the field data from the Preacher View, and it's List name is 'Preachers'. It is the table where the data is being captured from. Not the table where you are going to show the field but the table where you are taking the information from.[00:14:55](https://www.youtube.com/watchv=91iIAuHZj38&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h14m55s) If you take it from multiple tables, then you must choose a dominant table. The one that you want to be always available. That's what this is as well as this as you can see. It is usually the case that preachers and preacher values are the same. I decided to give the option to change the table name. + +We will get to these again. Just wanted to [00:15:28](https://www.youtube.com/watch?v=91iIAuHZj38&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h15m28s) show you that if those two(preacher and preachers) line-up, the button name lines up with those two. It checks whether this current user has authority to edit buttons. We can go down and create and edit button. We can also write JavaScript to [00:16:01](https://www.youtube.com/watch?v=91iIAuHZj38&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h16m01s) give that button behavior. When you click change the field, it checks: Is that value? and then it updates. You can check out if this is JavaScript. This one up here is used to generate the create button and it also validates whether this user has create options, [00:16:30](https://www.youtube.com/watch?v=91iIAuHZj38&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h16m30s) and is the user in the admin area. Currently this feature is not available to the site area and it's because of many conventions in the site area, so is custom. It'll probably break this button. We'll have to work at this but this is where we are at. + +### Able To Target The Admin Area With This Kind Of Button + +[00:16:50](https://www.youtube.com/watch?v=91iIAuHZj38&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h16m50s) + +We are able to target the admin area with this kind of button. If we have a button, we add the button declaration to the document. Then we add the buttons to the field with this input append. This class here, is a Joomla class. Which means we are falling back on their implementation on how to add a little tweak to the field. That is how the button gets added and how it works. You can go through this, I mean it is quite simple. It's very easy code. This implementation is to make sure that the button name follows the convention and naming convention. [00:17:46](https://www.youtube.com/watch?v=91iIAuHZj38&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h17m46s) That's the HTML and JavaScript that sets up the button. The reason why you would sometimes see the edit button there and sometimes not, is about the relationship here. The buttonName must match one of these(preacher and preachers). If it doesn't, it won't add it. That is if you want to have a [00:18:18](https://www.youtube.com/watch?v=91iIAuHZj38&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h18m18s) button that already knows where we are going. How can I know those values? At the moment the only values we have, are these values it's come up here. These values(see video). We don't have other values. This is the values we have, the view ID. That's what we have to work with. If there's no relationship then how can we set the edit button? The relationship must be set. This is the way we set a relationship. That's quite simple. You must make sure that the name of the [00:18:58](https://www.youtube.com/watch?v=91iIAuHZj38&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h18m58s) button, this one won't work. Although we said the button to be true, it will check the name and see this doesn't match and it won't add a button. That's good because we don't want a button here. We want a button to show up in Sermon Preacher. When it loads this(preacher) button it will check the name, it'll say this one matches and it will add a button. That's the right behavior, that's what we want. If we compile it. [00:19:36](https://www.youtube.com/watch?v=91iIAuHZj38&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h19m36s) Go to sermons, click Behold he prayeth. We'll see it has an edit option. If we select none it has a create option, select Leonard Ravenhill it has a edit option. That is how that relationship comes together. We go back to the field. [00:20:07](https://www.youtube.com/watch?v=91iIAuHZj38&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h20m07s) We have the buttons set. That's really the whole discussion. If you don't want the button set, but you want the button on the page, set this to false or just leave it out. It will take the button away completely. ???? -[00:14:55](https://www.youtube.com/watchv=91iIAuHZj38&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h14m55s) - -Now you take it from multiple tables then he must choose a dominant table The one that you want to be Always available So that's what this is as well as this as you can see It is obviously usually the case that this and this values the same But I decided to just give us The option to change the table name anyway Ok so we Will get to these again Just wanted you to see you [00:15:28](https://www.youtube.com/watch?v=91iIAuHZj38&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h15m28s) Sorry show you that if those two Actually line-up The button name lines up with those two Then it checks whether this is current user has authority to actually edit buttons We come down here And we create and edit button So And we also write JavaScript to [00:16:01](https://www.youtube.com/watch?v=91iIAuHZj38&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h16m01s) Give that Button behavior when you click Change the field it checks ok Is that value and then it Updates that you can check out this JavaScript here. This one up here is used to generate the create button and it also validates Whether This user Has create Options [00:16:30](https://www.youtube.com/watch?v=91iIAuHZj38&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h16m30s) And is there is a user in the admin area currently this feature is Is not available to the site area and It's because of many conventions in the site area is so custom it'll probably Break this button so We'll have to work at this but this is where we are at we were able to Target the admin area with this kind of button And then if we have a button We actually add the button declaration To the document And then we add the buttons To the field with this [00:17:10](https://www.youtube.com/watch?v=91iIAuHZj38&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h17m10s) Input append this class here Is a Joomla Class Which means we falling back on their implementation on how to add a little tweak to the button sorry to the field So we just add this and that is how the button gets added and how it works You mean you can come through this I mean this is quite simple It's very easy code here This this implementation here is just to make sure that the button name follows the convention And naming convention And [00:17:46](https://www.youtube.com/watch?v=91iIAuHZj38&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h17m46s) Yeah so that's that's the HTML and JavaScript that sets up the button and The reason why you would sometimes see the edit button there and sometimes not is about this relationship here The Button name Must match one of these So if it doesn't It won't add it It's sort of It's necessary for that to be like that because of You wanna have a [00:18:18](https://www.youtube.com/watch?v=91iIAuHZj38&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h18m18s) Button that already knows where we going right And how can I know those values at the moment the only values we have here Are these values it's come up here These values We don't have Other values This is the values we have the view ID So That's what we have to work with and so if there's no relationship Then how can we How can we set the edit button the relationship must be set so this is the way we Set a relationship that's quite simple right you just make sure that the name of the [00:18:58](https://www.youtube.com/watch?v=91iIAuHZj38&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h18m58s) The button this one won't work So although we said the button here to be true It will check the name and see how this doesn't match and it won't add a button and that's good because we don't want that Actually a button here we want a button to show up in this one And so when it loads this button It will check the name it'll say ah yeah this one matches and it will add a button So That's the right behavior That's what we want so if we compile it now &&&&&&&&&&&@@@ We can just come here [00:19:36](https://www.youtube.com/watch?v=91iIAuHZj38&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h19m36s) And go to sermons Click here We'll see it now has an edit option If we select none and has a great option Select this it has a edit option That is sort of how that relationship comes together So were are we go back To the field [00:20:07](https://www.youtube.com/watch?v=91iIAuHZj38&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h20m07s) Ok So Oh this is a wrong one So now we have the buttons set That's really the whole discussion And you could if you don't want the button set But you want the button on the page Set this to false Or just leave it out yeah it will take the button away completely Now this table value is a mandatory value [00:20:40](https://www.youtube.com/watch? - - - -v=91iIAuHZj38&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h20m40s) Because it gives us a dynamic value which we can use in In many places including here You see a list button gets added to a page as well if we If we look back here at this implementation we see that here is a list Again But this isn't even in the view This is in the list View So you can Have a filter Dynamically in place for this again in the batch as well if you if you select batch [00:21:16](https://www.youtube.com/watch?v=91iIAuHZj38&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h21m16s) There is also one available to select so all of these fields Are still using the information that we give here +This table value is a mandatory value. [00:20:40](https://www.youtube.com/watch?v=91iIAuHZj38&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h20m40s) Because it gives us a dynamic value which we can use in In many places including here You see a list button gets added to a page as well if we If we look back here at this implementation we see that here is a list Again But this isn't even in the view This is in the list View So you can Have a filter Dynamically in place for this again in the batch as well if you if you select batch [00:21:16](https://www.youtube.com/watch?v=91iIAuHZj38&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h21m16s) There is also one available to select so all of these fields Are still using the information that we give here So if you don't have this information then some of these Fields functions will just Disappear It will Most probably not break But it will not be there so if you to see the fields filtering option is not working then it's because of these settings that are not right