joomla-projects / gsoc21_frontend-inline-editing

GNU General Public License v2.0
7 stars 2 forks source link

Code Refactoring #9

Open rs4231199 opened 3 years ago

rs4231199 commented 3 years ago

Pull Request for Issue #8.

rs4231199 commented 3 years ago

Controller for the inline editing is working.

Sample Responses Images (click here to expand) ![image](https://user-images.githubusercontent.com/43215292/126072719-01fedada-9678-4dea-9ed5-841fc0c1cee6.png) ![image](https://user-images.githubusercontent.com/43215292/126072735-f2958a9b-dd34-471d-b107-1a66396bf49a.png) ![image](https://user-images.githubusercontent.com/43215292/126072743-9c44e302-86ff-4992-a9fc-8c669fd15f90.png) ![image](https://user-images.githubusercontent.com/43215292/126072747-3c44a488-80a2-4aa8-8972-057d1bc07762.png) ![image](https://user-images.githubusercontent.com/43215292/126072751-94e4ecf1-71ec-4841-b486-865c37317a6d.png)

Code changes highlights

In the Normal save() method, whenever an exception occurs, the user gets redirected to the appropriate page with an informative message. I have made some changes in the CMSApplication to modify the above-mentioned redirect behavior if the request is made for the inline editing.

rs4231199 commented 3 years ago

I have undone the changes in the CMSApplication.

Sample responses from the server (click here to expand) ![image](https://user-images.githubusercontent.com/43215292/126201114-15c10a95-f1e7-433d-9a04-6d683f990ab1.png) ![image](https://user-images.githubusercontent.com/43215292/126201139-5786eaab-f455-40b0-acb9-5bc511871b10.png)
anibalsanchez commented 3 years ago

The JsonResponse message should also have the same JText::_('JINVALID_TOKEN')

In this way, if something goes wrong you can also report the error message.

rs4231199 commented 3 years ago

Added informative messages with the JsonResponse.

Sample responses from the server (click here to expand) ![image](https://user-images.githubusercontent.com/43215292/126211277-f577a8d2-3f20-410a-812f-bcfc1d07d186.png) ![image](https://user-images.githubusercontent.com/43215292/126211123-ef5ab0a2-6be1-41d6-9e68-d1a6b60368c1.png) ![image](https://user-images.githubusercontent.com/43215292/126213322-4f7a8fdb-de95-43cb-8796-446679262d4c.png) ![image](https://user-images.githubusercontent.com/43215292/126211198-c72f070d-e26f-4dfa-8227-5393c70b7d0d.png)
rs4231199 commented 3 years ago

Added Method to get a form field from the server via Ajax request.

Some Screenshots of sample responses ![image](https://user-images.githubusercontent.com/43215292/126739877-ca238cb5-c4e3-4055-aa8b-c06143ae0d34.png) ![image](https://user-images.githubusercontent.com/43215292/126739926-c78d75d9-f9fa-425c-beab-659452a3311b.png) ![image](https://user-images.githubusercontent.com/43215292/126739984-cad113e7-a4d3-46bf-bfed-f758db27b13e.png) ![image](https://user-images.githubusercontent.com/43215292/126740111-a3084e58-dcb2-4406-96e4-b897a23012a2.png) `Empty field` means no field was requested in the Ajax request.
rs4231199 commented 3 years ago

Some screenshots.

Front-end when inline-editing is enabled. ![image](https://user-images.githubusercontent.com/43215292/126911960-f01f2e1d-d01b-418b-8f61-0add1f0ac5df.png)
Front-end when inline-editing is disabled or the user is not authorized. ![image](https://user-images.githubusercontent.com/43215292/126912013-f5c7a58a-fecb-484e-a574-747a835a1a6c.png)
roland-d commented 3 years ago

@rs4231199 I checked out this branch but I am unable to do front-end inline editing. Nothing happens when I click on a title or description. Inline editing is enabled in the Global Configuration. What is missing?

rs4231199 commented 3 years ago

What is missing?

The JavaScript part.

rs4231199 commented 3 years ago
The fields are successfully fetched from the server. https://user-images.githubusercontent.com/43215292/127031421-2da0d34e-cb33-46e8-846c-b6228fa341d3.mp4

Proper rendering needs some more work.

rs4231199 commented 3 years ago
The data is saved successfully. ![Peek 2021-08-01 00-22](https://user-images.githubusercontent.com/43215292/127749818-3fd1818b-772a-4c88-bbdb-0a11c756486e.gif)

Editing experience needs some improvements.

rs4231199 commented 3 years ago

There are two commits.

1) We can never be sure about what got saved in the database. For example, Custom Fields has a filter option that modifies the received value before it gets saved to the database. So, instead of displaying what the user has entered, it now receives the saved value along with the saved status.

2) The aim is to create an inline editable version of each field. We'll define a new layout for each inline editable field. Inline editable fields would require different scripts and styles than the regular fields. We can add those in the new layouts. The renderField() method now accepts an extra parameter to determine what layout to render.

As of now, Custom Text Field and article title can be edited inline. But I haven't modified the layout to inline experience. This commit is more about finalizing the approach. So, wait for a few more commits to experience the final inline editing. 🙂
rs4231199 commented 3 years ago
Gif: Save and Cancel buttons in action ![Peek 2021-08-10 23-27](https://user-images.githubusercontent.com/43215292/128911512-637ca353-61ea-4ec2-a248-4e2b623de6f1.gif)