diff --git a/app/project-static/content.css b/app/project-static/content.css index 80f5de1e..e1827120 100644 --- a/app/project-static/content.css +++ b/app/project-static/content.css @@ -65,6 +65,119 @@ input[type=submit] { height: 30px; margin: 10px; } + + + + +/* Style the navigation tabs at the top of a content page */ +.content-navigation-tabs { + display: block; + overflow: hidden; + border-bottom: 1px solid #ccc; + /* background-color: #f1f1f1; */ + width: 100%; + text-align: left; + padding: 0px; + margin: 0px +} + + +.content-navigation-tabs-link { + border: 0px; + margin: none; + padding: none; +} + +/* Style the buttons that are used to open the tab content */ +.content-navigation-tabs button { + display: inline; + background-color: inherit; + float: left; + border: none; + outline: none; + cursor: pointer; + margin: 0px; + padding: 0px; + padding: 14px 16px; + transition: 0.3s; + font-size: inherit; + color: #6a6e73; +} + + +/* Change background color of buttons on hover */ +.content-navigation-tabs button:hover { + /* background-color: #ddd; */ + border-bottom: 3px solid #ccc; +} + + +/* Create an active/current tablink class */ +.content-navigation-tabs button.active { + /* background-color: #ccc; */ + border-bottom: 3px solid #177ee6; +} + + + +/* Style content for each tab */ +.content-tab { + width: 100%; + display: none; + padding-bottom: 0px; + border: none; + border-top: none; +} + +.content-tab hr { + border: none; + border-top: 1px solid #ccc; +} + +.content-tab pre { + word-wrap: break-word; + white-space: pre-wrap; +} + +/* Style for section fields on details page */ +.detail-view-field { + display: unset; + height: 30px; + line-height: 30px; + padding: 0px 20px 40px 20px; + +} + +.detail-view-field label { + display: inline-block; + font-weight: bold; + width: 200px; + margin: 10px; + height: 30px; + line-height: 30px; + +} + +.detail-view-field span { + display: inline-block; + width: 340px; + margin: 10px; + border-bottom: 1px solid #ccc; + height: 30px; + line-height: 30px; + +} + + + + + + + + + + + /******************************************************************************* EoF refactored @@ -124,61 +237,6 @@ input[type=checkbox]:checked::after { -/* Style the tab */ -.tab { - display: block; - overflow: hidden; - border-bottom: 1px solid #ccc; - /* background-color: #f1f1f1; */ - width: 100%; - text-align: left; - padding: 0px; - margin: 0px -} - -.tablinks { - border: 0px; - margin: none; - padding: none; -} - -/* Style the buttons that are used to open the tab content */ -.tab button { - display: inline; - background-color: inherit; - float: left; - border: none; - outline: none; - cursor: pointer; - margin: 0px; - padding: 0px; - padding: 14px 16px; - transition: 0.3s; - font-size: inherit; - color: #6a6e73; -} - -/* Change background color of buttons on hover */ -.tab button:hover { - /* background-color: #ddd; */ - border-bottom: 3px solid #ccc; -} - -/* Create an active/current tablink class */ -.tab button.active { - /* background-color: #ccc; */ - border-bottom: 3px solid #177ee6; -} - -/* Style the tab content */ -.tabcontent { - width: 100%; - display: none; - /* padding: 6px 12px; */ - padding-bottom: 0px; - border: none; - border-top: none; -} table { width: 100%; diff --git a/app/project-static/functions.js b/app/project-static/functions.js new file mode 100644 index 00000000..cf2c74f1 --- /dev/null +++ b/app/project-static/functions.js @@ -0,0 +1,16 @@ +function openContentNavigationTab(evt, TabName) { + var i, tabcontent, tablinks; + + tabcontent = document.getElementsByClassName("content-tab"); + for (i = 0; i < tabcontent.length; i++) { + tabcontent[i].style.display = "none"; + } + + tablinks = document.getElementsByClassName("content-navigation-tabs-link"); + for (i = 0; i < tablinks.length; i++) { + tablinks[i].className = tablinks[i].className.replace(" active", ""); + } + + document.getElementById(TabName).style.display = "block"; + evt.currentTarget.className += " active"; +} diff --git a/app/templates/base.html.j2 b/app/templates/base.html.j2 index 585c648c..712f2e90 100644 --- a/app/templates/base.html.j2 +++ b/app/templates/base.html.j2 @@ -14,6 +14,7 @@ + {% endif %} diff --git a/app/templates/content/field.html.j2 b/app/templates/content/field.html.j2 new file mode 100644 index 00000000..76b77f85 --- /dev/null +++ b/app/templates/content/field.html.j2 @@ -0,0 +1,72 @@ +{% load json %} +{% load markdown %} + +{% if field.widget_type == 'textarea' or field.label == 'Notes' %} + + {% if field.name in section.json and field.value %} + +
{{ field.value.strip | json_pretty | safe }}
+ + {% elif field.name in section.markdown or field.label == 'Notes' %} + + {% if field.label == 'Notes' %} + +
+ + +
+ {% if field.value %} + {{ field.value | markdown | safe }} + {% else %} +   + {% endif %} +
+
+ + {% else %} + + {% if field.value %} + + {{ field.value | markdown | safe }} + + {% else %} + +   + + {% endif %} + + {% endif %} + + {% elif not field.value %} + +   + + {% endif %} + + +{% else %} + + +
+ + + {% if field.field.choices %} {# Display the selected choice text value #} + {% for id, value in field.field.choices %} + + {% if field.value == id %} + + {{ value }} + + {% endif %} + + {%endfor%} + + {% else %} + {{ field.value }} + {% endif %} + +
+ +{% endif %} diff --git a/app/templates/content/section.html.j2 b/app/templates/content/section.html.j2 new file mode 100644 index 00000000..c6c18bd1 --- /dev/null +++ b/app/templates/content/section.html.j2 @@ -0,0 +1,93 @@ +{% load json %} +{% load markdown %} + +{% for section in tab.sections %} + + + {% if forloop.first %} + +

{{ tab.name }}

+ + {% else %} + +
+

{{ section.name }}

+ + {% endif %} + +
+ + {% if section.layout == 'single' %} + + {% for section_field in section.fields %} + {% for field in form %} + + {% if field.name in section_field %} + + {% include 'content/field.html.j2' %} + + {% endif %} + + {% endfor %} + {% endfor %} + + {% elif section.layout == 'double' %} + + {% if section.left %} + +
+ + {% for section_field in section.left %} + {% for field in form %} + + {% if field.name in section_field %} + + {% include 'content/field.html.j2' %} + + {% endif %} + + {% endfor %} + {% endfor %} + +
+ + {% endif %} + + + {% if section.right %} + +
+ + {% for section_field in section.right %} + {% for field in form %} + + {% if field.name in section_field %} + + {% include 'content/field.html.j2' %} + + {% endif %} + + {% endfor %} + {% endfor %} + +
+ + {% endif %} + + {% endif %} + + {% if forloop.first %} + + {% if tab.edit_url %} + +
+ +
+ + {% endif %} + + {% endif %} + +
+ +{% endfor %} diff --git a/app/templates/detail.html.j2 b/app/templates/detail.html.j2 new file mode 100644 index 00000000..35d54ee2 --- /dev/null +++ b/app/templates/detail.html.j2 @@ -0,0 +1,33 @@ +{% extends 'base.html.j2' %} + +{% block content %} + +
+ + + + {% for key, tab in form.tabs.items %} + + {% if forloop.first %} + + + + {% else %} + + + + {% endif %} + + {% endfor %} + +
+ +{% block tabs %}{% endblock %} + +{% endblock %} \ No newline at end of file diff --git a/docs/projects/centurion_erp/development/media/layout-template-view-base.png b/docs/projects/centurion_erp/development/media/layout-template-view-base.png new file mode 100644 index 00000000..f5668551 Binary files /dev/null and b/docs/projects/centurion_erp/development/media/layout-template-view-base.png differ diff --git a/docs/projects/centurion_erp/development/media/layout-template-view-detail.drawio b/docs/projects/centurion_erp/development/media/layout-template-view-detail.drawio new file mode 100644 index 00000000..189d742c --- /dev/null +++ b/docs/projects/centurion_erp/development/media/layout-template-view-detail.drawio @@ -0,0 +1,46 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/docs/projects/centurion_erp/development/media/layout-template-view-detail.png b/docs/projects/centurion_erp/development/media/layout-template-view-detail.png new file mode 100644 index 00000000..ef245ff6 Binary files /dev/null and b/docs/projects/centurion_erp/development/media/layout-template-view-detail.png differ diff --git a/docs/projects/centurion_erp/development/templates.md b/docs/projects/centurion_erp/development/templates.md index 5758fc9b..36d5cf04 100644 --- a/docs/projects/centurion_erp/development/templates.md +++ b/docs/projects/centurion_erp/development/templates.md @@ -7,3 +7,51 @@ about: https://gitlab.com/nofusscomputing/infrastructure/configuration-managemen --- This section of the documentation contains the details related to the templates used within Centurion ERP for rendering data for the end user to view. +The base template is common to all templates and is responsible for the rendering of the common layout. Each subsequent template includes this template. This enables **ALL** pages within the site to share the same layout. + +![Base template layout](./media/layout-template-view-base.png) + +Point of note is that the orange area of the template is what each template is "filling out." + +This view contains the following areas: + +- Page Header +- Navigation +- Page Title +- Content Area +- Page footer + +!!! note + This template should not be included directly as it is incomplete and requires subsequent templates to populate the contents of the orange area. + + +## Detail + +This template is intended to be used to render the details of a single model. The layout of the detail view is as follows: + +![detail layout](./media/layout-template-view-detail.png) + +This view contains the following areas: + +- Section navigation tabs +- Section Content + +The page title represents the "what" to the contents of the page. i.e. for a device this would be the device name. A detail page contains navigation tabs to aid in displaying multiple facets of an item, with each "tabbed" page containing one or more sections. Point of note is that the tabs are only rendered within the top section of each "tabbed" page. + +Base definition for defining a detail page is as follows: + +``` jinja + +{% extends 'detail.html.j2' %} + +{% load json %} +{% load markdown %} + + +{% block tabs %} + + your tabs content here + +{% endblock %} + +```