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

Resolve #295 and #407: Improve the UI/UX in adding/uploading resources #516

Merged
merged 1 commit into from
Jul 29, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 18 additions & 19 deletions cadasta/core/static/css/main.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

35 changes: 23 additions & 12 deletions cadasta/core/static/css/main.scss
Original file line number Diff line number Diff line change
Expand Up @@ -735,7 +735,17 @@ main.container-fluid {
border-bottom: 0;
padding-bottom: 6px;
}
}
}
.nav-tabs {
li > a {
font-size: 13px;
padding: 10px;
}
li.active > a, li.active > a:hover, li.active > a:focus {
border-color: $table-border-color;
border-bottom-color: transparent;
}
}
}
.row-height .detail { // columns fixed to match heights like org overview
padding-top: 0;
Expand All @@ -761,6 +771,9 @@ main.container-fluid {
padding-bottom: 10px;
border-bottom: solid 1px $gray-light;
}
.top-add {
margin-bottom: -30px;
}
}
.panel-buttons { // buttons at bottom of panels containing forms
padding: 20px 15px;
Expand All @@ -776,16 +789,6 @@ main.container-fluid {
.nav-tabs {
margin-bottom: 20px;
}
.detail .nav-tabs {
li > a {
font-size: 13px;
padding: 10px;
}
li.active > a, li.active > a:hover, li.active > a:focus {
border-color: $table-border-color;
border-bottom-color: transparent;
}
}
}

body.map .content-single {
Expand Down Expand Up @@ -924,7 +927,7 @@ textarea.form-control {
}
}

.tab-content div.dataTables_wrapper div.dataTables_filter input {
.detail div.dataTables_wrapper div.dataTables_filter input {
max-width: 100px;
}

Expand Down Expand Up @@ -1265,6 +1268,14 @@ div.add-btn-btm { // add party link at bottom of table
padding-bottom: 10px;
border-bottom: solid 1px #d9dadb;
}
.modal-header .nav-tabs {
position: relative;
top: $modal-title-padding + 1px;
left: 30px - $modal-title-padding;
li.active a {
background: $modal-content-bg;
}
}
.modal-body {
max-height: calc(100vh - 200px);
overflow-y: auto;
Expand Down
14 changes: 2 additions & 12 deletions cadasta/core/static/css/single.scss
Original file line number Diff line number Diff line change
Expand Up @@ -231,18 +231,8 @@
margin-left: auto;
margin-right: auto;
}
.tab-pane .top-btn {
margin-top: 0;
margin-bottom: 0;
width: 100%;
text-align: right;
background: $body-bg;
padding: 10px;
position: relative;
top: -20px;
}
.tab-pane .top-btn .btn-group {
margin-bottom: 0;
.top-add {
margin-bottom: -30px;
}
}

Expand Down
5 changes: 5 additions & 0 deletions cadasta/party/views/default.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from core.mixins import LoginPermissionRequiredMixin

from resources.forms import AddResourceFromLibraryForm
from resources.views.mixins import ProjectHasResourcesMixin
from . import mixins
from .. import forms
from .. import messages as error_messages
Expand Down Expand Up @@ -39,6 +40,7 @@ def get_form_kwargs(self, *args, **kwargs):
class PartiesDetail(LoginPermissionRequiredMixin,
JsonAttrsMixin,
mixins.PartyObjectMixin,
ProjectHasResourcesMixin,
generic.DetailView):
template_name = 'party/party_detail.html'
permission_required = 'party.view'
Expand Down Expand Up @@ -87,6 +89,7 @@ def post(self, request, *args, **kwargs):

class PartyResourcesNew(LoginPermissionRequiredMixin,
mixins.PartyResourceMixin,
ProjectHasResourcesMixin,
generic.CreateView):
template_name = 'party/resources_new.html'
permission_required = 'party.resources.add'
Expand All @@ -96,6 +99,7 @@ class PartyResourcesNew(LoginPermissionRequiredMixin,
class PartyRelationshipDetail(LoginPermissionRequiredMixin,
JsonAttrsMixin,
mixins.PartyRelationshipObjectMixin,
ProjectHasResourcesMixin,
generic.DetailView):
template_name = 'party/relationship_detail.html'
permission_required = 'tenure_rel.view'
Expand Down Expand Up @@ -130,6 +134,7 @@ def get_success_url(self):

class PartyRelationshipResourceNew(LoginPermissionRequiredMixin,
mixins.PartyRelationshipResourceMixin,
ProjectHasResourcesMixin,
generic.CreateView):
template_name = 'party/relationship_resources_new.html'
permission_required = 'tenure_rel.resources.add'
Expand Down
8 changes: 6 additions & 2 deletions cadasta/resources/tests/test_views_default.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,12 @@ def _get(self, user=None, status=None, resources=None):
content = response.render().content.decode('utf-8')
expected = render_to_string(
'resources/project_list.html',
{'object_list': resources,
'object': self.project},
{
'object_list': resources,
'object': self.project,
'project_has_resources': (
self.project.resource_set.exists()),
},
request=self.request
)
assert expected == content
Expand Down
18 changes: 10 additions & 8 deletions cadasta/resources/views/default.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@

from core.mixins import LoginPermissionRequiredMixin

from .mixins import ProjectResourceMixin, ResourceObjectMixin
from . import mixins
from ..forms import AddResourceFromLibraryForm
from .. import messages as error_messages


class ProjectResources(LoginPermissionRequiredMixin,
ProjectResourceMixin,
mixins.ProjectResourceMixin,
mixins.ProjectHasResourcesMixin,
generic.ListView):
template_name = 'resources/project_list.html'
permission_required = 'resource.list'
Expand All @@ -19,7 +20,7 @@ class ProjectResources(LoginPermissionRequiredMixin,


class ProjectResourcesAdd(LoginPermissionRequiredMixin,
ProjectResourceMixin,
mixins.ProjectResourceMixin,
base_generic.edit.FormMixin,
generic.DetailView):
template_name = 'resources/project_add_existing.html'
Expand All @@ -39,7 +40,8 @@ def post(self, request, *args, **kwargs):


class ProjectResourcesNew(LoginPermissionRequiredMixin,
ProjectResourceMixin,
mixins.ProjectResourceMixin,
mixins.ProjectHasResourcesMixin,
generic.CreateView):
template_name = 'resources/project_add_new.html'
permission_required = 'resource.add'
Expand All @@ -50,7 +52,7 @@ def get_perms_objects(self):


class ProjectResourcesDetail(LoginPermissionRequiredMixin,
ResourceObjectMixin,
mixins.ResourceObjectMixin,
generic.DetailView):
template_name = 'resources/project_detail.html'
permission_required = 'resource.view'
Expand All @@ -63,7 +65,7 @@ def get_context_data(self, *args, **kwargs):


class ProjectResourcesEdit(LoginPermissionRequiredMixin,
ResourceObjectMixin,
mixins.ResourceObjectMixin,
generic.UpdateView):
template_name = 'resources/edit.html'
permission_required = 'resource.edit'
Expand All @@ -72,7 +74,7 @@ class ProjectResourcesEdit(LoginPermissionRequiredMixin,

class ResourceArchive(LoginPermissionRequiredMixin,
ArchiveMixin,
ResourceObjectMixin,
mixins.ResourceObjectMixin,
generic.UpdateView):
do_archive = True
permission_required = 'resource.archive'
Expand All @@ -81,7 +83,7 @@ class ResourceArchive(LoginPermissionRequiredMixin,

class ResourceUnarchive(LoginPermissionRequiredMixin,
ArchiveMixin,
ResourceObjectMixin,
mixins.ResourceObjectMixin,
generic.UpdateView):
do_archive = False
permission_required = 'resource.unarchive'
Expand Down
9 changes: 9 additions & 0 deletions cadasta/resources/views/mixins.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,3 +82,12 @@ def get_context_data(self, *args, **kwargs):
context = super().get_context_data(*args, **kwargs)
context['resource'] = self.get_object()
return context


class ProjectHasResourcesMixin(ProjectMixin):
def get_context_data(self, *args, **kwargs):
context = super().get_context_data(*args, **kwargs)
context['project_has_resources'] = (
self.get_project().resource_set.exists()
)
return context
7 changes: 4 additions & 3 deletions cadasta/spatial/views/default.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from core.mixins import LoginPermissionRequiredMixin

from resources.forms import AddResourceFromLibraryForm
from resources.views.mixins import ProjectHasResourcesMixin
from party.messages import TENURE_REL_CREATE
from . import mixins
from .. import forms
Expand Down Expand Up @@ -58,6 +59,7 @@ def get_form_kwargs(self):
class LocationDetail(LoginPermissionRequiredMixin,
JsonAttrsMixin,
mixins.SpatialUnitObjectMixin,
ProjectHasResourcesMixin,
generic.DetailView):
template_name = 'spatial/location_detail.html'
permission_required = 'spatial.view'
Expand All @@ -66,9 +68,7 @@ class LocationDetail(LoginPermissionRequiredMixin,

def get_context_data(self, *args, **kwargs):
context = super().get_context_data(*args, **kwargs)
context['relationships'] = (
context['location'].tenurerelationship_set.all()
)
context['relationships'] = self.object.tenurerelationship_set.all()
return context


Expand Down Expand Up @@ -113,6 +113,7 @@ def post(self, request, *args, **kwargs):

class LocationResourceNew(LoginPermissionRequiredMixin,
mixins.SpatialUnitResourceMixin,
ProjectHasResourcesMixin,
generic.CreateView):
template_name = 'spatial/resources_new.html'
permission_required = 'spatial.resources.add'
Expand Down
26 changes: 17 additions & 9 deletions cadasta/templates/party/party_detail.html
Original file line number Diff line number Diff line change
Expand Up @@ -54,17 +54,25 @@ <h3>{% trans "Details" %}</h3>
<!-- /party information -->
<!-- Party resources -->
<h3>{% trans "Resources" %}</h3>
<div class="top-btn pull-right">
<div class="btn-group">
{% if party.resources %}
<div class="top-btn pull-right top-add">
<a class="btn btn-primary btn-sm" href="{% url 'parties:resource_add' object.organization.slug object.slug party.id %}">
<span class="glyphicon glyphicon-plus" aria-hidden="true"></span>
{% trans "Add from library" %}</a>
<a class="btn btn-primary btn-sm" href="{% url 'parties:resource_new' object.organization.slug object.slug party.id %}">
<span class="glyphicon glyphicon-upload" aria-hidden="true"></span>
{% trans "Upload new" %}</a>
<span class="glyphicon glyphicon-plus" aria-hidden="true"></span> {% trans "Add" %}</a>
</div>
</div>
{% include 'resources/table.html' with object_list=party.resources %}
{% include 'resources/table.html' with object_list=party.resources %}
{% else %}
<div>
<p>{% trans "This party does not have any connected resources. To add a resource, select the button below." %}</p>
<div class="btn-full">
{% if project_has_resources %}
<a class="btn btn-primary" href="{% url 'parties:resource_add' object.organization.slug object.slug party.id %}">
{% else %}
<a class="btn btn-primary" href="{% url 'parties:resource_new' object.organization.slug object.slug party.id %}">
{% endif %}
<span class="glyphicon glyphicon-plus" aria-hidden="true"></span> {% trans "Add" %}</a>
</div>
</div>
{% endif %}
<!-- /party resources -->
</div>
</div>
Expand Down
Loading