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

feat: read-only geolocation (GDE-86) #16561

Merged
merged 16 commits into from
Jun 5, 2023

Conversation

barredterra
Copy link
Collaborator

@barredterra barredterra commented Apr 10, 2022

Continues work from #16513

Depends on #21055

  • Render the map into the control's display_area
  • Hide draw controls if the map is read-only
  • Remove the useless refresh button
  • Separate get_leaflet_controls and point_to_layer into separate methods that can be more easily overwritten with a custom script

Before

Read-Write

before-rw

Read only

before-r

After

Read-Write

after-rw

Read only

after-r

Todo

Scenarios to test

Does the map render nicely in all of the following scenarios?

  • Map in collapsible and normal section
  • Refresh, hard-refresh, or page through records
  • Editable and read-only map
  • With and without data/drawings

no-docs

Internal reference: LAN-756

- render map into display_area
- hide draw controls if read-only
- remove useless refresh_button
@stale
Copy link

stale bot commented Apr 17, 2022

This pull request has been automatically marked as stale because it has not had recent activity. It will be closed within 3 days if no further activity occurs, but it only takes a comment to keep a contribution alive :) Also, even if it is closed, you can always reopen the PR when you're ready. Thank you for contributing.

@stale stale bot added the inactive label Apr 17, 2022
@barredterra barredterra marked this pull request as ready for review April 17, 2022 16:38
@barredterra barredterra requested review from a team and surajshetty3416 and removed request for a team April 17, 2022 16:38
@shariquerik
Copy link
Member

@barredterra Are you working on the Todo part you mentioned?

@barredterra
Copy link
Collaborator Author

@shariquerik I'm currently out of ideas / don't know where to start searching 😅. Do you have any ideas?

@barredterra barredterra requested a review from hrwX April 25, 2022 18:43
@shariquerik
Copy link
Member

shariquerik commented Apr 27, 2022

@shariquerik I'm currently out of ideas / don't know where to start searching 😅. Do you have any ideas?

I will have to look into it.
Btw hide draw controls if read-only is not working.

@barredterra
Copy link
Collaborator Author

Btw hide draw controls if read-only is not working.

Are you sure you're loading the most recent code? Tested this several times and using it in production v13 already.

@stale
Copy link

stale bot commented May 4, 2022

This pull request has been automatically marked as stale because it has not had recent activity. It will be closed within 3 days if no further activity occurs, but it only takes a comment to keep a contribution alive :) Also, even if it is closed, you can always reopen the PR when you're ready. Thank you for contributing.

@stale stale bot added the inactive label May 4, 2022
@codecov
Copy link

codecov bot commented May 11, 2022

Codecov Report

❗ No coverage uploaded for pull request base (develop@a049b7f). Click here to learn what that means.
The diff coverage is 0.00%.

❗ Current head c9eb03f differs from pull request most recent head 64d1e64. Consider uploading reports for the commit 64d1e64 to get more accurate results

Additional details and impacted files
@@            Coverage Diff             @@
##             develop   #16561   +/-   ##
==========================================
  Coverage           ?   58.78%           
==========================================
  Files              ?      769           
  Lines              ?    68989           
  Branches           ?     6005           
==========================================
  Hits               ?    40554           
  Misses             ?    24949           
  Partials           ?     3486           
Flag Coverage Δ
ui-tests 49.74% <0.00%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

@hrwX
Copy link
Contributor

hrwX commented May 11, 2022

@barredterra Am I missing something here ? When I make this field read_only, the field disappears

Screencast.from.05-11-2022.03_43_24.PM.mp4

@hrwX
Copy link
Contributor

hrwX commented May 11, 2022

@barredterra the refresh_input in base_control.js is not triggered => set_input in data.js is not triggered => set_disp_area in data.js is not triggered and hence we cannot see the map on CMD + SHIFT + R press

@stale
Copy link

stale bot commented May 24, 2022

This pull request has been automatically marked as stale because it has not had recent activity. It will be closed within 3 days if no further activity occurs, but it only takes a comment to keep a contribution alive :) Also, even if it is closed, you can always reopen the PR when you're ready. Thank you for contributing.

@stale stale bot added the inactive label May 24, 2022
@barredterra barredterra marked this pull request as draft May 24, 2022 11:21
marination and others added 3 commits May 22, 2023 14:53
…olocation render

- When gelocation control is built, it awaits loading of libraries
- Withi the control everything is await but a layer above where multiple controls are sequentially built this breaks
- Form render goes ahead without waiting for the gelocation control
- The `onload_post_render` in `Location` cannot find the map wrapper as the control is still being built
- Therefore, on a hard load, the control does not show up and appears on soft reload.
@blaggacao
Copy link
Collaborator

blaggacao commented May 28, 2023

@barredterra Looks like this would need a rebase after #21055 is merged, now.

As I needed the patch, I've done a rebase here.

On this occasion: Whats the rationale of using set_disp_area(value) over format_for_input(value)?

@barredterra
Copy link
Collaborator Author

barredterra commented May 30, 2023

Whats the rationale of using set_disp_area(value) over format_for_input(value)? – @blaggacao

Long time since i wrote this... 🤔 From the naming, I guess format_for_input was not getting called for read-only fields.

@barredterra
Copy link
Collaborator Author

@marination could you review this PR?

@marination
Copy link
Collaborator

@barredterra Replicated the this.map.invalidateSize() issue. It occurs on geolocation controls that are inside collapsible sections. This is the only pending issue in this PR. Code looks fine and functions fine.

What happens is:

  • invalidateSize() essentially tries to find the width and height of the map wrapper so that it can make the map occupy the entire wrapper space.
  • If the control is in a collapsed section, the wrapper is hidden and therefore invalidateSize() gets a width and height of 0 and thus it essentially does nothing.
  • When you expand the section, some grey tiles are visible due to this invalidateSize() being ineffective

So the "right" time to invoke invalidateSize() is when the map control is not hidden anymore i.e. on the collapse() event of the section

This way, the logic can stay in the control itself. Each control can
decide what it needs to do on section collapse/expand.
@barredterra
Copy link
Collaborator Author

@marination thanks a lot for your investigation and the suggested fix. Everything seems to be working fine now. 👍🏼

@marination
Copy link
Collaborator

@barredterra tested all scenarios. LGTM. @surajshetty3416 can you give it a final look and merge ?

@surajshetty3416
Copy link
Member

LGTM. Merging.

@surajshetty3416 surajshetty3416 merged commit e5524ba into frappe:develop Jun 5, 2023
@barredterra barredterra deleted the map-read-only branch June 5, 2023 12:52
@ankush ankush mentioned this pull request Jun 5, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 20, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
backport version-14-hotfix backport to version 14
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants