Updated 038 Setup Site Edit View in JCB (markdown)

Amigo 2019-10-07 15:26:49 +02:00
parent 8428a02555
commit c2f7b5ad8d

@ -29,10 +29,12 @@ In JCB there is a switch that can be flipped for JCB to write the code for the s
[00:06:05](https://www.youtube.com/watch?v=tmB22d9dQ4M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h06m05s) [00:06:05](https://www.youtube.com/watch?v=tmB22d9dQ4M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h06m05s)
Looking at the demo websites folder structure in the code, there is a com_demo folder under components. [00:06:19](https://www.youtube.com/watch?v=tmB22d9dQ4M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h06m19s) There are the Models as well as the Controllers and the Views. This is the View that was dynamically generated by JCB. The View, the Model, and the Controller are called 'Look'. Open (controller look.php) to see what was the code that was written. [00:06:49](https://www.youtube.com/watch?v=tmB22d9dQ4M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h06m49s) It looks very similar to the Admin Area except that it has been slightly modified for the front end and its requirements. As you can see we were adding some CSS classes and JavaScript from the back end. Here is the 'model','getItem', 'getForm', and the Controller.[00:07:16](https://www.youtube.com/watch?v=tmB22d9dQ4M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h07m16s) It shows the code that has been created. The fact that this was created, does not mean that there is a set of links that you can click and edit the forms which was submitted or that there is a link to create any. These things should be done manually. [00:07:51](https://www.youtube.com/watch?v=tmB22d9dQ4M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h07m51s) Looking at the demo websites folder structure in the code, there is a com_demo folder under components. [00:06:19](https://www.youtube.com/watch?v=tmB22d9dQ4M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h06m19s) There are the Models as well as the Controllers and the Views. This is the View that was dynamically generated by JCB. The View, the Model, and the Controller are called 'Look'. Open (controller look.php) to see what was the code that was written. [00:06:49](https://www.youtube.com/watch?v=tmB22d9dQ4M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h06m49s) It looks very similar to the Admin Area except that it has been slightly modified for the front end and its requirements. As you can see we were adding some CSS classes and JavaScript from the back end. Here is the 'model','getItem', 'getForm', and the Controller.[00:07:16](https://www.youtube.com/watch?v=tmB22d9dQ4M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h07m16s) It shows the code that has been created. The fact that this was created, does not mean that there is a set of links that you can click and edit the forms which was submitted or that there is a link to create any. These things should be done manually.
### Manually Add Links ### Manually Add Links
[00:07:51](https://www.youtube.com/watch?v=tmB22d9dQ4M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h07m51s)
Under site views there are two views, one is called 'Looks' and another one is called 'Looking'. As you can remember the one we looked at here, which I set was automatically generated is called 'Look', so that one is not showing because it was a tick box that created this whole View model and Controller. It is not necessary to build the 'Look' view again but you need to get links to it. [00:08:21](https://www.youtube.com/watch?v=tmB22d9dQ4M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h08m21s) In 'Looks' a Dynamic Gets is used, as well as in 'Looking'. Open the Dynamic Get page. There is one called 'Looks' and 'Looking'. Go to the Looks Dynamic Get. It got a custom script area were it is asked whether the items are set or whether there are items. [00:09:10](https://www.youtube.com/watch?v=tmB22d9dQ4M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h09m10s) Then loop through them('$cando')(See video), it may be seen in the Helper Class there is a 'getAction' function. Under site views there are two views, one is called 'Looks' and another one is called 'Looking'. As you can remember the one we looked at here, which I set was automatically generated is called 'Look', so that one is not showing because it was a tick box that created this whole View model and Controller. It is not necessary to build the 'Look' view again but you need to get links to it. [00:08:21](https://www.youtube.com/watch?v=tmB22d9dQ4M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h08m21s) In 'Looks' a Dynamic Gets is used, as well as in 'Looking'. Open the Dynamic Get page. There is one called 'Looks' and 'Looking'. Go to the Looks Dynamic Get. It got a custom script area were it is asked whether the items are set or whether there are items. [00:09:10](https://www.youtube.com/watch?v=tmB22d9dQ4M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h09m10s) Then loop through them('$cando')(See video), it may be seen in the Helper Class there is a 'getAction' function.
The 'getAction' function inquires whether the current user has the edit option to the specific 'look' item. If it does, it builds in this little script an edit 'look' button and dynamically adds that to the edit link, which is coupled to the item, and then continues on. It dynamically generates the button for 'edit' in the dynamic get. [00:09:48](https://www.youtube.com/watch?v=tmB22d9dQ4M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h09m48s) It could have been done anywhere. I decided to do it here because then it gets added to the model, which is more where your logic, for lots of the data structure, should be placed. Go back to the Site Views, open the 'Looks' Site View. It may be seen that the 'Main Get' is set as 'Looks'. If you scroll down, in this area(See video) we are looping through the 'Look' items, and echoing the edit link after the description.[00:10:25](https://www.youtube.com/watch?v=tmB22d9dQ4M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h10m25s) That means the link that has been built in the Dynamic Get which is the button, it will either be empty and therefore show nothing. If the user does not have the permission to edit it, or it will show a button. [00:11:04](https://www.youtube.com/watch?v=tmB22d9dQ4M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h11m04s) A link has not been added for creating 'New Looks' and the same would be required to do that. The 'getAction' function inquires whether the current user has the edit option to the specific 'look' item. If it does, it builds in this little script an edit 'look' button and dynamically adds that to the edit link, which is coupled to the item, and then continues on. It dynamically generates the button for 'edit' in the dynamic get. [00:09:48](https://www.youtube.com/watch?v=tmB22d9dQ4M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h09m48s) It could have been done anywhere. I decided to do it here because then it gets added to the model, which is more where your logic, for lots of the data structure, should be placed. Go back to the Site Views, open the 'Looks' Site View. It may be seen that the 'Main Get' is set as 'Looks'. If you scroll down, in this area(See video) we are looping through the 'Look' items, and echoing the edit link after the description.[00:10:25](https://www.youtube.com/watch?v=tmB22d9dQ4M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h10m25s) That means the link that has been built in the Dynamic Get which is the button, it will either be empty and therefore show nothing. If the user does not have the permission to edit it, or it will show a button. [00:11:04](https://www.youtube.com/watch?v=tmB22d9dQ4M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h11m04s) A link has not been added for creating 'New Looks' and the same would be required to do that.