Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Display a list of forms after a user has logged on #227

Closed
wcj365 opened this issue May 29, 2024 · 4 comments
Closed

Display a list of forms after a user has logged on #227

wcj365 opened this issue May 29, 2024 · 4 comments

Comments

@wcj365
Copy link

wcj365 commented May 29, 2024

After a user logs on.
Display a list of all forms that the user has saved/submitted.
Show key fields including date created, last modified, status)
Include a link to the form so user can directly access the form and make updates.

@signebedi
Copy link
Owner

signebedi commented Jun 16, 2024

This sounds something like a "recent activity" feature. It's reasonable and straightforward to implement. Not all admins may want it, so we can make it a config like RECENT_ACTIVITY_ENABLED, which should default to False. https://github.com/signebedi/libreforms-fastapi/blob/master/libreforms_fastapi/utils/config.py.

Then, we want to modify the home jinja2 template. Currently, the template is very straightforward, and to add this we will need to add some javascript. https://github.com/signebedi/libreforms-fastapi/blob/master/libreforms_fastapi/app/templates/home.html.jinja. The template has access to the config object, so you can access the config we set above as config['RECENT_ACTIVITY_ENABLED'].

Then, we want to pull the API data using Ajax (the endpoint will be /api/form/read_all) and render ~5 of the most recent changes in a data table, see eg. below.

$('#recentActivityTable').DataTable({
    "ordering": false,
    "info": false,
    "paging": false,
    "searching": false 
});

You will want to pass the sort_by_last_edited param as True to the API call, so we get the most recent changes at the top. In fact, you will want to set most bool params to True, see your options in the docstring that begins on the following line:

Retrieves all documents of a specified form type, identified by the form name in the URL.
It verifies the form's existence, checks user permissions, retrieves documents from the
database, and logs the query. You can pass flatten=true to return data in a flat format.
You can pass escape=true to escape output. You can pass simple_response=true to receive
just the data as a response. You can pass exclude_journal=true to exclude the document
journal, which can sometimes complicate data handling because of its nested nature. You
can pass stringify_output=true if you would like output types coerced into string format.
You can pass sort_by_last_edited=True if you want to sort by most recent changes.

@wcj365 Want to take a stab at a PR for this feature?

@signebedi
Copy link
Owner

[api] Allow sorting of read_all by last_edited date
If we want to see recent activity, we should add a param to this API endpoint to sort results by last edited date, with most recent edits going to the top of the results.

@signebedi
Copy link
Owner

We'll leave in pagination to the datatable for now, but it may make sense to remove that option from the UI datatable down the road. The broader question is whether we should be able to set the length read_all API call as a param.

@signebedi
Copy link
Owner

[api] [form] Add set_length int param to read_all API endpoint
We may want to limit responses this way. But then we want to make it easier to orderBy some field to enable appropriate control over the data returned...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants