walkasjesus / walkasjesus_framework

This is the Jesus Commandments Application which is build in a Python Framework
GNU General Public License v3.0
1 stars 0 forks source link

Make the settings working again #70

Closed walkasjesus closed 4 years ago

walkasjesus commented 4 years ago

In the branch improve_user_experience we moved all the select boxes to a Settings on the right top. This broke some of the functionality. @guidogast gave the idea to dynamically load the content of the bible translations and not refresh the whole page. Also the media items selectbox functionality should be fixed.

@guidogast , can you explain further to @Ikbengeenrobot how it should work?

guido-visser commented 4 years ago

Web applications nowadays often use an API together with AJAX (Asynchronous Javascript XMLHTTPRequest) to fetch data and then dynamically load information on the page. This has a couple of advantages:

The server should have a REST API that can return all kinds of data (preferably JSON). For example:

A GET request with the URL https://jesuscommandments.org/api/getLanguages could return something like:

{
    "results": [
        {
            "id": "nl",
            "language": "Nederlands"
        },
        {
            "id": "en",
            "language": "English"
        },
        {
            "id": "de",
            "language": "Deutsch"
        },
        {
            "id": "fr",
            "language": "Français"
        }
    ]
}

This data can then be used to fill the select box dynamically with Javascript. The same thing can be done for the bible translations, but the API should then be able to accept parameters, for example:

GET https://jesuscommandments.org/api/getBibleTranslations?id=nl could return

{
    "results":[
        {
            "id": "hsv",
            "translation": "Herziene Staten Vertaling"
        },
        {
            "id": "ead7b4cc5007389c-01",
            "translation": "De Heilige Schrift, Petrus Canisiusvertaling, 1939"
        },
    ]
}

I hope this is clear for you @Ikbengeenrobot , it would be amazing if an API like this can be implemented since it enhances the user experience a whole lot.

Ikbengeenrobot commented 4 years ago

I understand, it will give a better separation between, frontend and backend. However building an API in a clean/nice way will take some effort. So if we want this we should figure out the priority related to other items.

We can also hack something in, but most of the times you will get to regret the 'hack it in' method :)

guido-visser commented 4 years ago

Agreed, @jesuscommandments what do you think.

walkasjesus commented 4 years ago

I wasn't sure if there already was an integrated API in django, but if it takes quite some effort, I think it is best to look at this later. So we need to adjust the way of the settings in this branch. @guidogast, can it still reload the whole page and stay in the settings screen until you save or close it? Since when you change a language now, it will refresh the page and leave the settings.

guido-visser commented 4 years ago

I have an idea on how to make that work. Will take look at it soon

walkasjesus commented 4 years ago

Thanks to @guidogast , it works!