diff --git a/cadasta/core/static/css/main.css b/cadasta/core/static/css/main.css index bf2ac4ab7..364adf81a 100644 --- a/cadasta/core/static/css/main.css +++ b/cadasta/core/static/css/main.css @@ -4228,18 +4228,8 @@ ul.resource-actions > li { margin-left: auto; margin-right: auto; } -.content-single .detail .tab-pane .top-btn { - margin-top: 0; - margin-bottom: 0; - width: 100%; - text-align: right; - background: #f2f4f7; - padding: 10px; - position: relative; - top: -20px; } - -.content-single .detail .tab-pane .top-btn .btn-group { - margin-bottom: 0; } +.content-single .detail .top-add { + margin-bottom: -30px; } #project-map h2 { padding-bottom: 0; } @@ -5505,6 +5495,12 @@ main.container-fluid { .content-single .detail ul.list-divider li:last-child { border-bottom: 0; padding-bottom: 6px; } + .content-single .detail .nav-tabs li > a { + font-size: 13px; + padding: 10px; } + .content-single .detail .nav-tabs li.active > a, .content-single .detail .nav-tabs li.active > a:hover, .content-single .detail .nav-tabs li.active > a:focus { + border-color: #e7e8ea; + border-bottom-color: transparent; } .content-single .row-height .detail { padding-top: 0; } .content-single .detail-edit { @@ -5522,6 +5518,8 @@ main.container-fluid { margin-bottom: 10px; padding-bottom: 10px; border-bottom: solid 1px #d9dadb; } + .content-single .panel .panel-body .top-add { + margin-bottom: -30px; } .content-single .panel .panel-buttons { padding: 20px 15px; } .content-single .panel .panel-buttons .btn { @@ -5531,12 +5529,6 @@ main.container-fluid { margin-right: 0; } .content-single .nav-tabs { margin-bottom: 20px; } - .content-single .detail .nav-tabs li > a { - font-size: 13px; - padding: 10px; } - .content-single .detail .nav-tabs li.active > a, .content-single .detail .nav-tabs li.active > a:hover, .content-single .detail .nav-tabs li.active > a:focus { - border-color: #e7e8ea; - border-bottom-color: transparent; } body.map .content-single { overflow-y: hidden; } @@ -5635,7 +5627,7 @@ textarea.form-control { .dataTables_wrapper table.dataTable thead .sorting_desc::after { content: "\e252"; } -.tab-content div.dataTables_wrapper div.dataTables_filter input { +.detail div.dataTables_wrapper div.dataTables_filter input { max-width: 100px; } @media (max-width: 500px) { @@ -5906,6 +5898,13 @@ div.add-btn-btm { padding-bottom: 10px; border-bottom: solid 1px #d9dadb; } +.modal .modal-header .nav-tabs { + position: relative; + top: 16px; + left: 15px; } + .modal .modal-header .nav-tabs li.active a { + background: #fff; } + .modal .modal-body { max-height: calc(100vh - 200px); overflow-y: auto; diff --git a/cadasta/core/static/css/main.scss b/cadasta/core/static/css/main.scss index 52e6c21df..d81d30dbd 100644 --- a/cadasta/core/static/css/main.scss +++ b/cadasta/core/static/css/main.scss @@ -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; @@ -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; @@ -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 { @@ -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; } @@ -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; diff --git a/cadasta/core/static/css/single.scss b/cadasta/core/static/css/single.scss index 94ef753ad..2922248ba 100644 --- a/cadasta/core/static/css/single.scss +++ b/cadasta/core/static/css/single.scss @@ -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; } } diff --git a/cadasta/party/views/default.py b/cadasta/party/views/default.py index 62296abd8..8fd07823a 100644 --- a/cadasta/party/views/default.py +++ b/cadasta/party/views/default.py @@ -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 @@ -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' @@ -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' @@ -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' @@ -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' diff --git a/cadasta/resources/tests/test_views_default.py b/cadasta/resources/tests/test_views_default.py index c74fea8cd..b8ab1708d 100644 --- a/cadasta/resources/tests/test_views_default.py +++ b/cadasta/resources/tests/test_views_default.py @@ -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 diff --git a/cadasta/resources/views/default.py b/cadasta/resources/views/default.py index 7035deca5..335382f11 100644 --- a/cadasta/resources/views/default.py +++ b/cadasta/resources/views/default.py @@ -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' @@ -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' @@ -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' @@ -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' @@ -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' @@ -72,7 +74,7 @@ class ProjectResourcesEdit(LoginPermissionRequiredMixin, class ResourceArchive(LoginPermissionRequiredMixin, ArchiveMixin, - ResourceObjectMixin, + mixins.ResourceObjectMixin, generic.UpdateView): do_archive = True permission_required = 'resource.archive' @@ -81,7 +83,7 @@ class ResourceArchive(LoginPermissionRequiredMixin, class ResourceUnarchive(LoginPermissionRequiredMixin, ArchiveMixin, - ResourceObjectMixin, + mixins.ResourceObjectMixin, generic.UpdateView): do_archive = False permission_required = 'resource.unarchive' diff --git a/cadasta/resources/views/mixins.py b/cadasta/resources/views/mixins.py index 4bf9e24da..d0bf596cb 100644 --- a/cadasta/resources/views/mixins.py +++ b/cadasta/resources/views/mixins.py @@ -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 diff --git a/cadasta/spatial/views/default.py b/cadasta/spatial/views/default.py index 03fccd633..76d39bc09 100644 --- a/cadasta/spatial/views/default.py +++ b/cadasta/spatial/views/default.py @@ -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 @@ -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' @@ -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 @@ -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' diff --git a/cadasta/templates/party/party_detail.html b/cadasta/templates/party/party_detail.html index a0e49dd7b..57504e44d 100644 --- a/cadasta/templates/party/party_detail.html +++ b/cadasta/templates/party/party_detail.html @@ -54,17 +54,25 @@

{% trans "Details" %}

{% trans "Resources" %}

-
-
+ {% if party.resources %} + -
- {% include 'resources/table.html' with object_list=party.resources %} + {% include 'resources/table.html' with object_list=party.resources %} + {% else %} +
+

{% trans "This party does not have any connected resources. To add a resource, select the button below." %}

+
+ {% if project_has_resources %} + + {% else %} + + {% endif %} + {% trans "Add" %} +
+
+ {% endif %}
diff --git a/cadasta/templates/party/relationship_detail.html b/cadasta/templates/party/relationship_detail.html index 24cbe4027..cdfdad18b 100644 --- a/cadasta/templates/party/relationship_detail.html +++ b/cadasta/templates/party/relationship_detail.html @@ -26,7 +26,7 @@

{% trans "Relationship" %}

- +

{% trans "Details" %}

@@ -46,20 +46,28 @@

{% trans "Details" %}

{% endfor %}
- +

{% trans "Resources" %}

-
-
+ {% if relationship.resources %} + -
- {% include 'resources/table_sm.html' with object_list=relationship.resources %} + {% include 'resources/table_sm.html' with object_list=relationship.resources %} + {% else %} +
+

{% trans "This relationship does not have any connected resources. To add a resource, select the button below." %}

+
+ {% if project_has_resources %} + + {% else %} + + {% endif %} + {% trans "Add" %} +
+
+ {% endif %}
diff --git a/cadasta/templates/party/relationship_resources_add.html b/cadasta/templates/party/relationship_resources_add.html index f6f5a5060..e6881a025 100644 --- a/cadasta/templates/party/relationship_resources_add.html +++ b/cadasta/templates/party/relationship_resources_add.html @@ -1,37 +1,10 @@ {% extends "party/relationship_detail.html" %} {% load i18n %} -{% block modals %} - - +{% block page_title %}Add new resource for relationship | {% endblock %} +{% block modals %} +{% url 'parties:relationship_detail' object.organization.slug object.slug relationship.id as cancel_url %} +{% url 'parties:relationship_resource_new' object.organization.slug object.slug relationship.id as upload_url %} +{% include 'resources/modal_add_lib.html' %} {% endblock %} diff --git a/cadasta/templates/party/relationship_resources_new.html b/cadasta/templates/party/relationship_resources_new.html index 32ae14e9a..62ae54c58 100644 --- a/cadasta/templates/party/relationship_resources_new.html +++ b/cadasta/templates/party/relationship_resources_new.html @@ -1,37 +1,15 @@ {% extends "party/relationship_detail.html" %} {% load i18n %} -{% block modals %} - - +{% block extra_script %} + {{ form.media }} + {% include "resources/scripts.html" %} +{% endblock %} +{% block modals %} +{% url 'parties:relationship_detail' object.organization.slug object.slug relationship.id as cancel_url %} +{% url 'parties:relationship_resource_add' object.organization.slug object.slug relationship.id as add_lib_url %} +{% include 'resources/modal_upload.html' %} {% endblock %} diff --git a/cadasta/templates/party/resources_add.html b/cadasta/templates/party/resources_add.html index e43019ae8..60cd0a221 100644 --- a/cadasta/templates/party/resources_add.html +++ b/cadasta/templates/party/resources_add.html @@ -1,37 +1,11 @@ {% extends "party/party_detail.html" %} {% load i18n %} -{% block modals %} - - +{% block page_title %}Add new resource for party | {% endblock %} +{% block modals %} +{% url 'parties:detail' object.organization.slug object.slug party.id as cancel_url %} +{% url 'parties:resource_new' object.organization.slug object.slug party.id as upload_url %} +{% include 'resources/modal_add_lib.html' %} {% endblock %} + diff --git a/cadasta/templates/party/resources_new.html b/cadasta/templates/party/resources_new.html index c321e9bbc..6f62f483a 100644 --- a/cadasta/templates/party/resources_new.html +++ b/cadasta/templates/party/resources_new.html @@ -1,42 +1,15 @@ {% extends "party/party_detail.html" %} {% load i18n %} +{% block page_title %}Upload new resource for party | {% endblock %} + {% block extra_script %} {{ form.media }} {% include "resources/scripts.html" %} {% endblock %} {% block modals %} - - - +{% url 'parties:detail' object.organization.slug object.slug party.id as cancel_url %} +{% url 'parties:resource_add' object.organization.slug object.slug party.id as add_lib_url %} +{% include 'resources/modal_upload.html' %} {% endblock %} diff --git a/cadasta/templates/resources/modal_add_lib.html b/cadasta/templates/resources/modal_add_lib.html new file mode 100644 index 000000000..dfe236f22 --- /dev/null +++ b/cadasta/templates/resources/modal_add_lib.html @@ -0,0 +1,35 @@ +{% load i18n %} + + diff --git a/cadasta/templates/resources/modal_upload.html b/cadasta/templates/resources/modal_upload.html new file mode 100644 index 000000000..8559e75c0 --- /dev/null +++ b/cadasta/templates/resources/modal_upload.html @@ -0,0 +1,37 @@ +{% load i18n %} + + diff --git a/cadasta/templates/resources/project_add_existing.html b/cadasta/templates/resources/project_add_existing.html index 43556e822..17a27cff2 100644 --- a/cadasta/templates/resources/project_add_existing.html +++ b/cadasta/templates/resources/project_add_existing.html @@ -1,39 +1,10 @@ -{% extends "organization/project_wrapper.html" %} +{% extends "resources/project_list.html" %} {% load i18n %} -{% load widget_tweaks %} -{% block page_title %}Add new resource | {% endblock %} -{% block left-nav %}resources{% endblock %} - -{% block content %} - -
-
- -
-
-

{% trans "Resources: Add" %}

-
-
- {% csrf_token %} -
-
- - -

{% trans "Select files from library" %}

-

{% trans "Resources in the library are able to be connected to locations, relationships, parties, and the project. To add a connection, select the checkbox in the left column and select the 'Save' button. If you would like to upload a new resource, select the 'Upload new' tab." %}

- {% include 'resources/table_add_lib.html' %} -
- -
-
-
-
+{% block page_title %}Add new resource for project | {% endblock %} +{% block modals %} +{% url 'resources:project_list' object.organization.slug object.slug as cancel_url %} +{% url 'resources:project_add_new' object.organization.slug object.slug as upload_url %} +{% include 'resources/modal_add_lib.html' %} {% endblock %} diff --git a/cadasta/templates/resources/project_add_new.html b/cadasta/templates/resources/project_add_new.html index e4d07a18b..f271c9de9 100644 --- a/cadasta/templates/resources/project_add_new.html +++ b/cadasta/templates/resources/project_add_new.html @@ -1,43 +1,15 @@ -{% extends "organization/project_wrapper.html" %} +{% extends "resources/project_list.html" %} {% load i18n %} -{% block page_title %}Upload new resource | {% endblock %} -{% block left-nav %}resources{% endblock %} +{% block page_title %}Upload new resource for project | {% endblock %} {% block extra_script %} {{ form.media }} {% include "resources/scripts.html" %} {% endblock %} -{% block content %} - -
-
- -
-
-

{% trans "Resources: Add" %}

-
-
- {% csrf_token %} -
-
- -

{% trans "Upload new file" %}

-

{% trans "To upload a new resource, select the file and provide the name and description below. Once complete, select the 'Save' button" %}.

- {% include "resources/form.html" %} -
- -
-
-
-
-
- -{% endblock %} \ No newline at end of file +{% block modals %} +{% url 'resources:project_list' object.organization.slug object.slug as cancel_url %} +{% url 'resources:project_add_existing' object.organization.slug object.slug as add_lib_url %} +{% include 'resources/modal_upload.html' %} +{% endblock %} diff --git a/cadasta/templates/resources/project_list.html b/cadasta/templates/resources/project_list.html index 3468aae61..6a8cf0a12 100644 --- a/cadasta/templates/resources/project_list.html +++ b/cadasta/templates/resources/project_list.html @@ -12,14 +12,17 @@

{% trans "Resources" %}

-
+
+ {% if project_has_resources %} + + {% else %} + + {% endif %} + {% trans "Add" %} +
{% include 'resources/table.html' %}
diff --git a/cadasta/templates/spatial/location_detail.html b/cadasta/templates/spatial/location_detail.html index 56f4fdf4f..b27a2b86f 100644 --- a/cadasta/templates/spatial/location_detail.html +++ b/cadasta/templates/spatial/location_detail.html @@ -24,13 +24,13 @@

{% trans "Location" %} {{ location.get_type_display }}

- + - +
@@ -50,12 +50,12 @@

{% trans "Location" %} {{ location.get_type_display }}

- +
{% if relationships %} -
- +
+ {% trans "Add" %} @@ -80,7 +80,7 @@

{% trans "Location" %} {{ location.get_type_display }}

{% trans "This location does not have any relationships and is not connected to any parties. To add your first relationship, select the button below." %}

- + {% trans "Add relationship" %} @@ -89,37 +89,25 @@

{% trans "Location" %} {{ location.get_type_display }}

{% endif %}
- +
{% if location.resources %} -
- + {% include 'resources/table_sm.html' with object_list=location.resources %} {% else %}
-

{% trans "This location does not have any connected resources. To add a resource, select from the options below." %}

+

{% trans "This location does not have any connected resources. To add a resource, select the button below." %}

{% endif %} diff --git a/cadasta/templates/spatial/resources_add.html b/cadasta/templates/spatial/resources_add.html index a5f4e1bd6..33349e901 100644 --- a/cadasta/templates/spatial/resources_add.html +++ b/cadasta/templates/spatial/resources_add.html @@ -1,39 +1,10 @@ {% extends "spatial/location_wrapper.html" %} {% load i18n %} -{% load widget_tweaks %} -{% block page_title %}Add new resource | {% endblock %} +{% block page_title %}Add new resource for location | {% endblock %} {% block modals %} - - +{% url 'locations:detail' object.organization.slug object.slug location.id as cancel_url %} +{% url 'locations:resource_new' object.organization.slug object.slug location.id as upload_url %} +{% include 'resources/modal_add_lib.html' with cancel_url_hash="#resources" %} {% endblock %} diff --git a/cadasta/templates/spatial/resources_new.html b/cadasta/templates/spatial/resources_new.html index 7e9dd98c1..3fc0602c0 100644 --- a/cadasta/templates/spatial/resources_new.html +++ b/cadasta/templates/spatial/resources_new.html @@ -1,45 +1,15 @@ {% extends "spatial/location_wrapper.html" %} {% load i18n %} -{% load widget_tweaks %} -{% block page_title %}Upload new resource | {% endblock %} +{% block page_title %}Upload new resource for location | {% endblock %} -{% block form_script %} +{% block extra_script %} {{ form.media }} {% include "resources/scripts.html" %} {% endblock %} {% block modals %} - - - +{% url 'locations:detail' object.organization.slug object.slug location.id as cancel_url %} +{% url 'locations:resource_add' object.organization.slug object.slug location.id as add_lib_url %} +{% include 'resources/modal_upload.html' with cancel_url_hash="#resources" %} {% endblock %}