Skip to content

Commit

Permalink
Allow create project from data browser just with a view (unicef-drp#262)
Browse files Browse the repository at this point in the history
  • Loading branch information
meomancer authored Apr 5, 2024
1 parent 7423cca commit a69fd51
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 5 deletions.
7 changes: 7 additions & 0 deletions django_project/frontend/src/app/form.scss
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,13 @@

&.ClickedReadOnly {
cursor: pointer;
background-color: white;
color: unset;
border: 1px solid rgba(0, 0, 0, 0.23) !important;

&:hover {
border: 1px solid rgba(0, 0, 0, 0.87) !important;
}
}
}

Expand Down
10 changes: 7 additions & 3 deletions django_project/frontend/src/pages/Admin/Dataset/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export default function DatasetAdmin() {
// Other attributes
const defaultFilters = urlParams()
const [filters, setFilters] = useState({
groupAdminLevel: defaultFilters.groupAdminLevel === 'true',
groupAdminLevel: defaultFilters.groupAdminLevel ? defaultFilters.groupAdminLevel === 'true' : true,
indicators: defaultFilters.indicators ? splitParams(defaultFilters.indicators) : [],
datasets: defaultFilters.datasets ? splitParams(defaultFilters.datasets, false) : [],
levels: defaultFilters.levels ? splitParams(defaultFilters.levels) : [],
Expand Down Expand Up @@ -225,9 +225,13 @@ export default function DatasetAdmin() {
<div className='Separator'/>
<ThemeButton
variant='primary'
disabled={!(filters.datasets.length === 1 && filters.indicators.length >= 1)}
disabled={!(filters.datasets.length === 1)}
onClick={() => {
window.location.href = `/admin/project/create?dataset=${filters.datasets[0]}&indicators=${filters.indicators.join(',')}`;
let url = `/admin/project/create?dataset=${filters.datasets[0]}`
if (filters.indicators.length) {
url += `&indicators=${filters.indicators.join(',')}`
}
window.location.href = url;
}}
>
<AddIcon/> Add to New Project
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ export default function Filter(
<input
disabled={!fields || onLoading}
type="text"
className='ClickedReadOnly'
placeholder={onLoading ? "Loading" : "SQL Filter"}
readOnly={true}
value={data}
Expand Down
4 changes: 3 additions & 1 deletion django_project/geosight/data/api/dashboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,11 +150,13 @@ def get(self, request, slug):
dashboard_indicators = []
dashboard_indicator_layers = []
indicator_layers_structure_children = []
if dataset and indicators:
if dataset:
view, _ = ReferenceLayerView.objects.get_or_create(
identifier=dataset
)
dashboard.reference_layer = view

if indicators:
for idx, indicator in enumerate(
Indicator.objects.filter(id__in=indicators.split(','))
):
Expand Down
2 changes: 1 addition & 1 deletion django_project/version/version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.40.2
1.40.3

0 comments on commit a69fd51

Please sign in to comment.