-
Notifications
You must be signed in to change notification settings - Fork 8
GitHub Issue #899: App save grid view in subfolder overrides inherited default #7974
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
base: develop
Are you sure you want to change the base?
Changes from all commits
d94807a
b8cde4a
5d1f784
fa0b8ed
ce135ce
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2534,7 +2534,7 @@ public void addNavTrail(NavTree root) | |
| // Uck. Supports the old and new view designer. | ||
| protected JSONObject saveCustomView(Container container, QueryDefinition queryDef, | ||
| String regionName, String viewName, boolean replaceExisting, | ||
| boolean share, boolean inherit, | ||
| boolean share, boolean inherit, boolean inheritToTargetContainer, | ||
| boolean session, boolean saveFilter, | ||
| boolean hidden, JSONObject jsonView, | ||
| ActionURL returnUrl, | ||
|
|
@@ -2558,8 +2558,19 @@ protected JSONObject saveCustomView(Container container, QueryDefinition queryDe | |
| else | ||
| view = queryDef.getCustomView(owner, getViewContext().getRequest(), name); | ||
|
|
||
| // GitHub Issue #899: the lookups above also resolve views inherited from ancestor folders. Absent an explicit | ||
| // target folder, shadow that view with a new local one rather than editing (and relocating) the ancestor's. | ||
| CustomView inheritedView = null; | ||
| if (view != null && !inheritToTargetContainer && view.getContainer() != null && !container.equals(view.getContainer())) | ||
| { | ||
| inheritedView = view; | ||
| view = null; | ||
| } | ||
|
|
||
| if (view != null && !replaceExisting && !StringUtils.isEmpty(name)) | ||
| errors.reject(ERROR_MSG, "A saved view by the name \"" + viewName + "\" already exists. "); | ||
| if (inheritedView != null && !replaceExisting && !StringUtils.isEmpty(name)) | ||
| errors.reject(ERROR_MSG, "A saved view by the name \"" + viewName + "\" is already inherited from folder \"" + inheritedView.getContainer().getPath() + "\". "); | ||
|
|
||
| // 11179: Allow editing the view if we're saving to session. | ||
| // NOTE: Check for session flag first otherwise the call to canEdit() will add errors to the errors collection. | ||
|
|
@@ -2625,7 +2636,7 @@ else if (session != view.isSession()) | |
| try | ||
| { | ||
| view.delete(getUser(), getViewContext().getRequest()); | ||
| JSONObject ret = saveCustomView(container, queryDef, regionName, viewName, replaceExisting, share, inherit, session, saveFilter, hidden, jsonView, returnUrl, errors); | ||
| JSONObject ret = saveCustomView(container, queryDef, regionName, viewName, replaceExisting, share, inherit, inheritToTargetContainer, session, saveFilter, hidden, jsonView, returnUrl, errors); | ||
| success = !errors.hasErrors() && ret != null; | ||
| return success ? ret : null; | ||
| } | ||
|
|
@@ -2770,9 +2781,10 @@ public ApiResponse execute(SimpleApiJsonForm form, BindException errors) | |
| boolean session = jsonView.optBoolean("session", false); | ||
| boolean hidden = jsonView.optBoolean("hidden", false); | ||
| // Users may save views to a location other than the current container | ||
| String containerPath = jsonView.optString("containerPath", getContainer().getPath()); | ||
| String containerPath = jsonView.optString("containerPath", null); | ||
| boolean inheritToTargetContainer = inherit && containerPath != null; | ||
| Container container; | ||
| if (inherit) | ||
| if (inheritToTargetContainer) | ||
| { | ||
| // Only respect this request if it's a view that is inheritable in subfolders | ||
| container = ContainerManager.getForPath(containerPath); | ||
|
|
@@ -2788,9 +2800,12 @@ public ApiResponse execute(SimpleApiJsonForm form, BindException errors) | |
| throw new NotFoundException("No such container: " + containerPath); | ||
| } | ||
|
|
||
| if (inheritToTargetContainer && !container.hasPermission(getUser(), EditSharedViewPermission.class)) | ||
| throw new UnauthorizedException(); | ||
|
|
||
| JSONObject savedView = saveCustomView( | ||
| container, queryDef, QueryView.DATAREGIONNAME_DEFAULT, viewName, replace, | ||
| shared, inherit, session, true, hidden, jsonView, null, errors); | ||
| shared, inherit, inheritToTargetContainer, session, true, hidden, jsonView, null, errors); | ||
|
|
||
| if (savedView != null) | ||
| { | ||
|
|
@@ -6220,8 +6235,9 @@ public ApiResponse execute(SaveSessionViewForm form, BindException errors) | |
|
|
||
| // Users may save views to a location other than the current container | ||
| String containerPath = form.getContainerPath(); | ||
| boolean inheritToTargetContainer = form.isInherit() && containerPath != null; | ||
| Container container; | ||
| if (form.isInherit() && containerPath != null) | ||
| if (inheritToTargetContainer) | ||
| { | ||
| // Only respect this request if it's a view that is inheritable in subfolders | ||
| container = ContainerManager.getForPath(containerPath); | ||
|
|
@@ -6265,6 +6281,19 @@ public ApiResponse execute(SaveSessionViewForm form, BindException errors) | |
| existingView = null; | ||
| } | ||
|
|
||
| // GitHub Issue #899: getCustomView() also resolves views inherited from ancestor folders. Absent an explicit | ||
| // target folder, shadow that view with a new local one instead of rewriting (and un-inheriting) the ancestor's. | ||
| CustomView inheritedView = null; | ||
| if (existingView != null && !inheritToTargetContainer && existingView.getContainer() != null | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: Seems like some logical consolidation is in order with aligned logic in |
||
| && !container.equals(existingView.getContainer())) | ||
| { | ||
| inheritedView = existingView; | ||
| existingView = null; | ||
| } | ||
|
|
||
| if (inheritedView != null && !form.isReplace() && !StringUtils.isEmpty(form.getNewName())) | ||
| throw new IllegalArgumentException("A saved view by the name \"" + form.getNewName() + "\" is already inherited from folder \"" + inheritedView.getContainer().getPath() + "\". "); | ||
|
|
||
| if (existingView != null && !form.isReplace() && !StringUtils.isEmpty(form.getNewName())) | ||
| throw new IllegalArgumentException("A saved view by the name \"" + form.getNewName() + "\" already exists. "); | ||
|
|
||
|
|
@@ -6278,8 +6307,7 @@ public ApiResponse execute(SaveSessionViewForm form, BindException errors) | |
| viewCopy.setFilterAndSort(view.getFilterAndSort()); | ||
| viewCopy.setColumnProperties(view.getColumnProperties()); | ||
| viewCopy.setIsHidden(form.isHidden()); | ||
| if (form.isInherit()) | ||
| viewCopy.setContainer(container); | ||
| viewCopy.setContainer(container); | ||
|
|
||
| viewCopy.save(getUser(), getViewContext().getRequest()); | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comment at the top of this function is right. "Uck.".