diff --git a/pillar/web/nodes/custom/posts.py b/pillar/web/nodes/custom/posts.py index 473c5d52..db588711 100644 --- a/pillar/web/nodes/custom/posts.py +++ b/pillar/web/nodes/custom/posts.py @@ -59,6 +59,7 @@ def posts_view(project_id=None, project_url=None, url=None, *, archive=False, pa for post in posts._items: post.picture = get_file(post.picture, api=api) + post.url = url_for_node(node=post) # Use the *_main_project.html template for the main blog is_main_project = project_id == current_app.config['MAIN_PROJECT_ID'] diff --git a/src/scripts/tutti/1_project-navigation.js b/src/scripts/tutti/1_project-navigation.js index c281f0c7..9befe318 100644 --- a/src/scripts/tutti/1_project-navigation.js +++ b/src/scripts/tutti/1_project-navigation.js @@ -1,81 +1,3 @@ -function projectNavCollapse() { - $("#project-side-container").addClass('collapsed'); -}; - -function projectNavExpand() { - $("#project-side-container").removeClass('collapsed'); -}; - -function projectNavCheck(){ - - /* Only run if there is a tree */ - if(document.getElementById("project_tree") !== null) { - - var nav_status = Cookies.getJSON('bcloud_ui'); - - if (nav_status && nav_status.nav_collapsed) { - if (nav_status.nav_collapsed == 'expanded') { - projectNavExpand(); - - } else if ( nav_status.nav_collapsed == 'collapsed' ) { - projectNavCollapse(); - } - } else { - projectNavExpand(); - } - - } -} - -function projectNavToggle(){ - - var nav_status = Cookies.getJSON('bcloud_ui'); - - if (nav_status && nav_status.nav_collapsed) { - if (nav_status.nav_collapsed == 'expanded') { - - projectNavCollapse(); - setJSONCookie('bcloud_ui', 'nav_collapsed', 'collapsed'); - - } else if ( nav_status.nav_collapsed == 'collapsed' ) { - - projectNavExpand(); - setJSONCookie('bcloud_ui', 'nav_collapsed', 'expanded'); - - } - } else { - projectNavCollapse(); - setJSONCookie('bcloud_ui', 'nav_collapsed', 'collapsed'); - } - - $('#project_context-header').width($('#project_context-container').width()); -} - -$(function () { - - /* Check on first load */ - projectNavCheck(); - - $('.project_split, .project_nav-toggle-btn').on('click', function (e) { - projectNavToggle(); - }); - - /* Only run if there is a tree */ - if(document.getElementById("project_tree") !== null) { - - $(document).keypress(function(e) { - var tag = e.target.tagName.toLowerCase(); - - /* Toggle when pressing [T] key */ - if(e.which == 116 && tag != 'input' && tag != 'textarea' && !e.ctrlKey && !e.metaKey && !e.altKey) { - projectNavToggle(); - } - }); - } - -}); - - /* Small utility to enable specific node_types under the Add New dropdown */ /* It takes: * empty: Enable every item diff --git a/src/styles/_organizations.sass b/src/styles/_organizations.sass index c2998c27..c4fcda42 100644 --- a/src/styles/_organizations.sass +++ b/src/styles/_organizations.sass @@ -9,11 +9,11 @@ body.organizations margin-left: auto - #side + .dashboard-secondary .box +container-box padding: 10px 20px - margin: 20px 10px + margin: 0 #item-details .organization @@ -29,7 +29,6 @@ body.organizations input font-size: 1.1em - .org-admin #admin-name padding: 10px 0 diff --git a/src/styles/_project-dashboard.sass b/src/styles/_project-dashboard.sass index 6a4230a1..0df2bd98 100644 --- a/src/styles/_project-dashboard.sass +++ b/src/styles/_project-dashboard.sass @@ -6,8 +6,8 @@ border-bottom-left-radius: 3px border-bottom-right-radius: 3px - section#sub-nav-tabs.home, - section#sub-nav-tabs.projects + nav#sub-nav-tabs.home, + nav#sub-nav-tabs.projects background-color: white border-bottom: thin solid $color-background-dark @@ -17,7 +17,7 @@ section#home background-color: $color-background-dark - section.nav-tabs__tab + nav.nav-tabs__tab display: none background-color: $color-background-light diff --git a/src/styles/_project.sass b/src/styles/_project.sass index aaecff63..49f76e10 100644 --- a/src/styles/_project.sass +++ b/src/styles/_project.sass @@ -41,10 +41,6 @@ body.blog width: 100% left: 0 -#project-side-container.collapsed+#project_context-header - span#status-bar - left: $project-sidebar-width - #project_context-header span#status-bar text-align: left @@ -316,10 +312,6 @@ span#project-edit-title weight: 400 white-space: nowrap -.project_split.collapsed+#project_context-header - span#project-edit-title - left: 0 - /* Edit Asset buttons */ .project-mode-view, @@ -702,41 +694,6 @@ ul.project_nav-edit-list min-height: 800px border: none -#project-side-container - &.collapsed - .project_nav-toggle-btn i:before - content: '\e827' - - .project_split - background-color: $project-sidebar-background - cursor: e-resize - right: 0 - left: 8px - width: 5px - - #project_nav - width: 5px - +media-xs - width: initial - - #project_nav-container - width: 5px - +media-xs - display: block - width: initial - position: relative - - #project_nav-header, - #project_context-header, - #project_tree - display: none - visibility: hidden - - +media-xs - display: block - visibility: visible - position: relative - /* The actual navigation tree container */ #project_tree @@ -753,20 +710,6 @@ ul.project_nav-edit-list &.edit margin-top: 0 -/* Clickable bar between navtree and context view, to collapse tree */ -.project_split - float: right - position: absolute - width: 15px - margin-left: -8px - top: 0 - right: -15px - bottom: 0 - cursor: w-resize - user-select: none - - +media-xs - display: none /* Node Context */ =project-node-title diff --git a/src/styles/blog.sass b/src/styles/blog.sass index 06799b31..05fc1ec3 100644 --- a/src/styles/blog.sass +++ b/src/styles/blog.sass @@ -239,22 +239,18 @@ font: family: $font-body size: 1.8em - padding-bottom: 10px - padding-top: 20px - .item-info - color: $color-text-dark-secondary - font-size: 1em + padding: 10px 25px 10px - a - color: $color-text-dark-secondary - &:hover - color: $color-primary + ul.meta + +list-meta + font-size: .9em + padding: 15px 25px 5px .item-content +node-details-description - padding: 35px 25px font-size: 1.3em + padding: 15px 25px 25px +media-xs padding: diff --git a/src/templates/_macros/_navigation.pug b/src/templates/_macros/_navigation.pug index 866f78ca..fd08e94a 100644 --- a/src/templates/_macros/_navigation.pug +++ b/src/templates/_macros/_navigation.pug @@ -1,6 +1,6 @@ | {% macro navigation_tabs(title) %} -section#nav-tabs +nav#nav-tabs ul#nav-tabs__list li.nav-tabs__list-tab( class="{% if title == 'homepage' %}active{% endif %}") diff --git a/src/templates/nodes/custom/_scripts.pug b/src/templates/nodes/custom/_scripts.pug index 437ed567..8b010ba0 100644 --- a/src/templates/nodes/custom/_scripts.pug +++ b/src/templates/nodes/custom/_scripts.pug @@ -1,17 +1,5 @@ script(type="text/javascript"). - /* Convert Markdown */ - var convert_fields = '.node-details-description, .blog_index-item .item-content'; - var convert = new Markdown.getSanitizingConverter(); - Markdown.Extra.init(convert); - convert = convert.makeHtml; - - - /* Parse description/content fields to convert markdown */ - $(convert_fields).each(function(i){ - $(convert_fields).eq(i).html(convert($(convert_fields).eq(i).text())); - }); - ProjectUtils.setProjectAttributes({isProject: false}); // Click anywhere in the page to hide the overlay diff --git a/src/templates/nodes/custom/asset/file/view_embed.pug b/src/templates/nodes/custom/asset/file/view_embed.pug index 72a56321..1100ae57 100644 --- a/src/templates/nodes/custom/asset/file/view_embed.pug +++ b/src/templates/nodes/custom/asset/file/view_embed.pug @@ -18,7 +18,7 @@ | {% if node.description %} .node-details-description#node-description - | {{node.description}} + | {{ node.description | markdown }} | {% endif %} include ../../_node_details diff --git a/src/templates/nodes/custom/asset/image/view_embed.pug b/src/templates/nodes/custom/asset/image/view_embed.pug index d92b5392..ccb6cb53 100644 --- a/src/templates/nodes/custom/asset/image/view_embed.pug +++ b/src/templates/nodes/custom/asset/image/view_embed.pug @@ -18,7 +18,7 @@ | {% if node.description %} .node-details-description#node-description - | {{node.description}} + | {{ node.description | markdown }} | {% endif %} include ../../_node_details diff --git a/src/templates/nodes/custom/asset/video/view_embed.pug b/src/templates/nodes/custom/asset/video/view_embed.pug index 2e192957..528ef3b5 100644 --- a/src/templates/nodes/custom/asset/video/view_embed.pug +++ b/src/templates/nodes/custom/asset/video/view_embed.pug @@ -40,7 +40,7 @@ | {% if node.description %} .node-details-description#node-description - | {{node.description}} + | {{ node.description | markdown }} | {% endif %} include ../../_node_details diff --git a/src/templates/nodes/custom/blog/_macros.pug b/src/templates/nodes/custom/blog/_macros.pug index 2e775f45..e583186d 100644 --- a/src/templates/nodes/custom/blog/_macros.pug +++ b/src/templates/nodes/custom/blog/_macros.pug @@ -1,27 +1,31 @@ //- ******************************************************* -// | {% macro render_blog_post(node) %} | {% if node.picture %} -a.blog_index-header(href="{{ url_for_node(node=node) }}") +a.blog_index-header(href="{{ node.url }}") img(src="{{ node.picture.thumbnail('l', api=api) }}") | {% endif %} .blog_index-item - a.item-title( - href="{{ url_for_node(node=node) }}") - | {{node.name}} + ul.meta + | {% if node.project.name %} + li {{ node.project.name }} + | {% endif %} - .item-info. - #[span(title="{{node._created}}") {{node._created | pretty_date }}] - {% if node._created != node._updated %} - #[span(title="{{node._updated}}") (updated {{node._updated | pretty_date }})] - {% endif %} - {% if node.properties.category %}| {{node.properties.category}}{% endif %} - · {{node.user.full_name}} - · #[a(href="{{ url_for_node(node=node) }}#comments") comment] - {% if node.properties.status != 'published' %} | {{ node.properties.status}} {% endif %} + li.when + a(href="{{ node.url }}", + title="Updated {{ node._updated | pretty_date }}") + | {{ node._created | pretty_date }} + + li + a(href="{{ node.url }}#comments") + | comment + + a.item-title( + href="{{ node.url }}") + | {{ node.name }} .item-content - | {{ node.properties.content }} + | {{ node.properties.content | markdown }} | {% endmacro %} @@ -30,15 +34,15 @@ a.blog_index-header(href="{{ url_for_node(node=node) }}") .blog_index-item.list | {% if node.picture %} - a.item-header(href="{{ url_for_node(node=node) }}") + a.item-header(href="{{ node.url }}") img.image(src="{{ node.picture.thumbnail('s', api=api) }}") | {% else %} - a.item-header.nothumb(href="{{ url_for_node(node=node) }}") + a.item-header.nothumb(href="{{ node.url }}") i.pi-document-text | {% endif %} a.item-title( - href="{{ url_for_node(node=node) }}") + href="{{ node.url }}") | {{node.name}} .item-info. diff --git a/src/templates/nodes/custom/blog/index.pug b/src/templates/nodes/custom/blog/index.pug index 946bb9c6..71c8dccc 100644 --- a/src/templates/nodes/custom/blog/index.pug +++ b/src/templates/nodes/custom/blog/index.pug @@ -29,7 +29,7 @@ link(href="{{ url_for('static_pillar', filename='assets/css/blog.css', v=1732017 | {% for post in posts %} li.jstree-node a.jstree-anchor.tree-item.post( - href="{{ url_for_node(node=post) }}") + href="{{ node.url }}") .tree-item-thumbnail | {% if post.picture %} img(src="{{ post.picture.thumbnail('s', api=api) }}") diff --git a/src/templates/nodes/custom/comment/list_embed.pug b/src/templates/nodes/custom/comment/list_embed.pug index aac1bd0e..79b167c2 100644 --- a/src/templates/nodes/custom/comment/list_embed.pug +++ b/src/templates/nodes/custom/comment/list_embed.pug @@ -73,32 +73,6 @@ | {% block comment_scripts %} script. - // If there's a comment link in the URL, scroll there - function scrollToLinkedComment() { - var scrollToId = location.hash; - if (scrollToId.length <= 1) return; - - $(scrollToId) - .addClass('comment-linked') - .scrollHere(); - } - $(scrollToLinkedComment); - - - $('#comment_field').autoResize(); - - // Initialize Markdown to later convert comment as we type - var convert = new Markdown.getSanitizingConverter(); - Markdown.Extra.init(convert); - convert = convert.makeHtml; - - // Submit new comment - $(document) - .off('click','body .comment-action-submit') - .on( 'click','body .comment-action-submit', function(e){ - post_comment($(this)); - }); - {% if show_comments %} $('body') .off('pillar:comment-posted') @@ -111,9 +85,37 @@ script. $('#' + comment_node_id).scrollHere(); }); }); + + // If there's a comment link in the URL, scroll there + function scrollToLinkedComment() { + var scrollToId = location.hash; + if (scrollToId.length <= 1) return; + + $(scrollToId) + .addClass('comment-linked') + .scrollHere(); + } + $(scrollToLinkedComment); + {% endif %} + {% if can_post_comments %} + + // If we can actually comment, load the tools to do it + + // Initialize Markdown to later convert comment as we type + var convert = new Markdown.getSanitizingConverter(); + Markdown.Extra.init(convert); + convert = convert.makeHtml; + + // Submit new comment + $(document) + .off('click','body .comment-action-submit') + .on( 'click','body .comment-action-submit', function(e){ + post_comment($(this)); + }); + // Writing comment // Markdown convert as we type in the textarea $(document) @@ -142,6 +144,9 @@ script. } }); + // Autoresize the textarea as we type + $('#comment_field').autoResize(); + // Edit comment // Enter edit mode @@ -218,4 +223,6 @@ script. }); }); + {% endif %} + | {% endblock %} diff --git a/src/templates/nodes/custom/group/view_embed.pug b/src/templates/nodes/custom/group/view_embed.pug index 1507e8fd..a39b62e1 100644 --- a/src/templates/nodes/custom/group/view_embed.pug +++ b/src/templates/nodes/custom/group/view_embed.pug @@ -15,7 +15,7 @@ | {% if node.description %} .node-details-description - | {{node.description}} + | {{ node.description | markdown }} | {% endif %} section.node-children.group diff --git a/src/templates/nodes/custom/group_hdri/view_embed.pug b/src/templates/nodes/custom/group_hdri/view_embed.pug index ab2abe2d..bf2f4239 100644 --- a/src/templates/nodes/custom/group_hdri/view_embed.pug +++ b/src/templates/nodes/custom/group_hdri/view_embed.pug @@ -12,7 +12,7 @@ | {% if node.description %} section.node-row .node-details-description - | {{node.description}} + | {{ node.description | markdown }} | {% endif %} | {% if children %} diff --git a/src/templates/nodes/custom/group_texture/view_embed.pug b/src/templates/nodes/custom/group_texture/view_embed.pug index d9900830..a52e7bd8 100644 --- a/src/templates/nodes/custom/group_texture/view_embed.pug +++ b/src/templates/nodes/custom/group_texture/view_embed.pug @@ -12,7 +12,7 @@ | {% if node.description %} section.node-row .node-details-description - | {{node.description}} + | {{ node.description | markdown }} | {% endif %} | {% if children %} diff --git a/src/templates/nodes/custom/hdri/view_embed.pug b/src/templates/nodes/custom/hdri/view_embed.pug index db73f3d9..9a6f02ff 100644 --- a/src/templates/nodes/custom/hdri/view_embed.pug +++ b/src/templates/nodes/custom/hdri/view_embed.pug @@ -93,7 +93,7 @@ | {% if node.description %} .node-details-description#node-description - | {{node.description}} + | {{ node.description | markdown }} | {% endif %} | {% if node.properties.license_notes %} diff --git a/src/templates/nodes/custom/page/view_embed.pug b/src/templates/nodes/custom/page/view_embed.pug index 3709a03d..1f11571b 100644 --- a/src/templates/nodes/custom/page/view_embed.pug +++ b/src/templates/nodes/custom/page/view_embed.pug @@ -17,7 +17,7 @@ | {% if node.description %} .node-details-description#node-description - | {{node.description}} + | {{ node.description | markdown }} | {% endif %} .node-details-meta.footer @@ -32,7 +32,7 @@ script. // Push the correct URL onto the history. This push happens after the id has // been pushed to the history already. We should probably keep only this and // skip the project-level displayNode push. - + var url = '{{ node.properties.url }}' var replace_state = {nodeId: '{{node._id}}', url: url}; window.history.replaceState( diff --git a/src/templates/organizations/index.pug b/src/templates/organizations/index.pug index 3b6891f6..6138a51c 100644 --- a/src/templates/organizations/index.pug +++ b/src/templates/organizations/index.pug @@ -17,13 +17,13 @@ meta(name="twitter:image", content="{{ url_for('static', filename='assets/img/ba | {% block body %} .dashboard-container - section#main + section.dashboard-main | {{ navigation_tabs(title) }} section#projects | {% if can_create_organization %} - section#sub-nav-tabs.projects + nav#sub-nav-tabs.projects ul#sub-nav-tabs__list li.result#create_organization_result_panel li.create @@ -32,7 +32,7 @@ meta(name="twitter:image", content="{{ url_for('static', filename='assets/img/ba | Create Organization | {% endif %} - section.nav-tabs__tab.active#own_projects + nav.nav-tabs__tab.active#own_projects ul.projects__list | {% if organizations %} | {% for organization in organizations['_items'] %} @@ -65,7 +65,7 @@ meta(name="twitter:image", content="{{ url_for('static', filename='assets/img/ba span Create an Organization to get started! | {% endif %} - section#side + section.dashboard-secondary section.box #item-details diff --git a/src/templates/projects/home_layout.pug b/src/templates/projects/home_layout.pug index d4a66dac..733f6ae7 100644 --- a/src/templates/projects/home_layout.pug +++ b/src/templates/projects/home_layout.pug @@ -20,23 +20,23 @@ meta(name="twitter:image", content="{{ url_for('static', filename='assets/img/ba | {% block body %} .dashboard-container - section#main + section.dashboard-main | {{ navigation_tabs(title) }} section#projects - section#sub-nav-tabs.home + nav#sub-nav-tabs.home ul#sub-nav-tabs__list - li.nav-tabs__list-tab#subtab-blender_sync(data-tab-url='.') + li.nav-tabs__list-tab#subtab-blender_sync(data-tab-url="{{ url_for('projects.home_project')}}") i.pi-blender | Blender Sync - li.nav-tabs__list-tab#subtab-images(data-tab-url='images') + li.nav-tabs__list-tab#subtab-images(data-tab-url="{{ url_for('projects.home_project_shared_images')}}") i.pi-picture | Images | {% block currenttab %}{% endblock %} - section#side + section.dashboard-secondary section.announcement img.header( src="{{ url_for('static', filename='assets/img/blender_sync_header.jpg') }}") diff --git a/src/templates/projects/index_dashboard.pug b/src/templates/projects/index_dashboard.pug index 540ff0c9..67b313c8 100644 --- a/src/templates/projects/index_dashboard.pug +++ b/src/templates/projects/index_dashboard.pug @@ -20,12 +20,12 @@ meta(name="twitter:image", content="{{ url_for('static', filename='assets/img/ba | {% block body %} .dashboard-container - section#main + section.dashboard-main | {{ navigation_tabs(title) }} section#projects - section#sub-nav-tabs.projects + nav#sub-nav-tabs.projects ul#sub-nav-tabs__list li.nav-tabs__list-tab.active(data-tab-toggle='own_projects') | Own Projects @@ -48,7 +48,7 @@ meta(name="twitter:image", content="{{ url_for('static', filename='assets/img/ba | Create Project | {% endif %} - section.nav-tabs__tab.active#own_projects + nav.nav-tabs__tab.active#own_projects ul.projects__list | {% for project in projects_user %} li.projects__list-item( @@ -148,7 +148,7 @@ meta(name="twitter:image", content="{{ url_for('static', filename='assets/img/ba | No projects shared with you... yet! | {% endif %} - section#side + section.dashboard-secondary section.announcement img.header( src="{{ url_for('static', filename='assets/img/backgrounds/services_projects.jpg')}}") diff --git a/src/templates/projects/view.pug b/src/templates/projects/view.pug index f80280f1..540a8efb 100644 --- a/src/templates/projects/view.pug +++ b/src/templates/projects/view.pug @@ -131,11 +131,6 @@ link(href="{{ url_for('static_pillar', filename='assets/css/project-main.css', v i.pi-cog | {% endif %} - .project_nav-toggle-btn( - title="Toggle navigation [T]", - data-toggle="tooltip", - data-placement="right") - i.pi-angle-double-left #project_nav(class="{{ title }}") #project_nav-container @@ -150,7 +145,6 @@ link(href="{{ url_for('static_pillar', filename='assets/css/project-main.css', v | {% endblock project_tree %} | {% endif %} - .project_split(title="Toggle Navigation [T]") #project_context-container | {% if project.has_method('PUT') %} diff --git a/src/templates/projects/view_embed.pug b/src/templates/projects/view_embed.pug index 0b6ddb03..6ba828f5 100644 --- a/src/templates/projects/view_embed.pug +++ b/src/templates/projects/view_embed.pug @@ -39,7 +39,7 @@ | {% if project.description %} .node-details-description - | {{ project.description }} + | {{ project.description | markdown }} | {% endif %} | {# Until we implement urls for pages diff --git a/src/templates/users/edit_embed.pug b/src/templates/users/edit_embed.pug index 0c76e544..52b38881 100644 --- a/src/templates/users/edit_embed.pug +++ b/src/templates/users/edit_embed.pug @@ -1,115 +1 @@ -| {% block body %} - -#user-edit-container - - #user-edit-header - .user-edit-name(title="Full Name") {{user.full_name}} - .user-edit-username(title="Username") - i.pi-users - | {{user.username}} - .user-edit-email(title="E-mail") - i.pi-email - | {{user.email}} - .user-edit-id(title="User ID") - i.pi-vcard - | {{user.user_id}}   - - a.copy-to-clipboard( - style="margin-left: auto", - name="Copy to Clipboard", - type="button", - href="javascript:void(0)", - data-clipboard-text="{{ user.user_id }}", - title="Copy ID to clipboard") - | (copy to clipboard) - p This user on: - =' ' - a(href="https://store.blender.org/wp-admin/users.php?s={{ user.email | urlencode }}") Blender Store - =' | ' - a(href="https://www.blender.org/id/admin/users/?flt1_4={{ user.email | urlencode }}") Blender ID - - form( - id="user-edit-form", - method="POST", - enctype="multipart/form-data", - action="{{url_for('users.users_edit', user_id=user.user_id)}}") - - | {% for field in form %} - - | {% if field.name == 'csrf_token' %} - | {{ field }} - - | {% else %} - - | {% if field.type == 'HiddenField' %} - | {{ field }} - - | {% else %} - - .form-group(class="{{field.name}}{% if field.errors %} error{% endif %}") - | {{ field.label }} - | {{ field(class='form-control') }} - - | {% if field.errors %} - ul.error - | {% for error in field.errors %} - li {{ error }} - | {% endfor %} - | {% endif %} - span.field-description {{ field.description }} - - | {% endif %} - - | {% endif %} - - | {% endfor %} - - .form-group.capabilities - label Capabilities - | {% if user.capabilities %} - ul - | {% for cap in user.capabilities|sort %} - li {{ cap }} - | {% endfor %} - | {% else %} - p - i.pi-cancel - | none - | {% endif %} - - a#button-cancel.btn.btn-default(href="#", data-user-id='{{user.user_id}}') Cancel - - input#submit_edit_user.btn.btn-default( - data-user-id="{{user.user_id}}", - type="submit" value="Submit") - - #user-edit-notification - -script(src="{{ url_for('static_pillar', filename='assets/js/vendor/clipboard.min.js')}}") -script(type="text/javascript"). - $('#roles').select2(); - - $('#user-edit-form').submit(function(e){ - e.preventDefault(); - //- console.log($(this).serialize()); - $.post($(this).attr('action'), $(this).serialize()) - .done(function(data){ - // This function is defined in index.pug. - displayUser('{{ user.user_id }}') - .done(function() { - $('#user-edit-notification').addClass('success').html('Success!'); - }); - }) - .fail(function(data){ - $('#user-edit-notification').addClass('fail').html('Houston!'); - }); - //- $("#user-edit-form").submit(); - }); - - $('#button-cancel').click(function(e){ - $('#user-container').html('') - }); - - new Clipboard('.copy-to-clipboard'); - -| {% endblock %} +| {% extends "users/edit_embed_base.html" %} diff --git a/src/templates/users/edit_embed_base.pug b/src/templates/users/edit_embed_base.pug new file mode 100644 index 00000000..db6344c0 --- /dev/null +++ b/src/templates/users/edit_embed_base.pug @@ -0,0 +1,110 @@ +| {% block body %} + +#user-edit-container + + #user-edit-header + .user-edit-name(title="Full Name") {{user.full_name}} + .user-edit-username(title="Username") + i.pi-users + | {{user.username}} + .user-edit-email(title="E-mail") + i.pi-email + | {{user.email}} + .user-edit-id(title="User ID") + i.pi-vcard + | {{user.user_id}}   + + a.copy-to-clipboard( + style="margin-left: auto", + name="Copy to Clipboard", + type="button", + href="javascript:void(0)", + data-clipboard-text="{{ user.user_id }}", + title="Copy ID to clipboard") + | (copy to clipboard) + | {% block user_links %}{% endblock %} + form( + id="user-edit-form", + method="POST", + enctype="multipart/form-data", + action="{{url_for('users.users_edit', user_id=user.user_id)}}") + + | {% for field in form %} + + | {% if field.name == 'csrf_token' %} + | {{ field }} + + | {% else %} + + | {% if field.type == 'HiddenField' %} + | {{ field }} + + | {% else %} + + .form-group(class="{{field.name}}{% if field.errors %} error{% endif %}") + | {{ field.label }} + | {{ field(class='form-control') }} + + | {% if field.errors %} + ul.error + | {% for error in field.errors %} + li {{ error }} + | {% endfor %} + | {% endif %} + span.field-description {{ field.description }} + + | {% endif %} + + | {% endif %} + + | {% endfor %} + + .form-group.capabilities + label Capabilities + | {% if user.capabilities %} + ul + | {% for cap in user.capabilities|sort %} + li {{ cap }} + | {% endfor %} + | {% else %} + p + i.pi-cancel + | none + | {% endif %} + + a#button-cancel.btn.btn-default(href="#", data-user-id='{{user.user_id}}') Cancel + + input#submit_edit_user.btn.btn-default( + data-user-id="{{user.user_id}}", + type="submit" value="Submit") + + #user-edit-notification + +script(src="{{ url_for('static_pillar', filename='assets/js/vendor/clipboard.min.js')}}") +script(type="text/javascript"). + $('#roles').select2(); + + $('#user-edit-form').submit(function(e){ + e.preventDefault(); + //- console.log($(this).serialize()); + $.post($(this).attr('action'), $(this).serialize()) + .done(function(data){ + // This function is defined in index.pug. + displayUser('{{ user.user_id }}') + .done(function() { + $('#user-edit-notification').addClass('success').html('Success!'); + }); + }) + .fail(function(data){ + $('#user-edit-notification').addClass('fail').html('Houston!'); + }); + //- $("#user-edit-form").submit(); + }); + + $('#button-cancel').click(function(e){ + $('#user-container').html('') + }); + + new Clipboard('.copy-to-clipboard'); + +| {% endblock %}