studio_xblock_wrapper.html 6.47 KB
Newer Older
1 2 3
<%!
from django.utils.translation import ugettext as _
from contentstore.views.helpers import xblock_studio_url
4
from contentstore.utils import is_visible_to_specific_content_groups
5
import json
6 7 8 9 10 11
%>
<%
xblock_url = xblock_studio_url(xblock)
show_inline = xblock.has_children and not xblock_url
section_class = "level-nesting" if show_inline else "level-element"
collapsible_class = "is-collapsible" if xblock.has_children else ""
12
label = xblock.display_name_with_default or xblock.scope_ids.block_type
13
messages = json.dumps(xblock.validate().to_json())
14
%>
15

16 17 18 19 20 21 22 23
<%namespace name='static' file='static_content.html'/>

<%block name="header_extras">
<script type="text/template" id="xblock-validation-messages-tpl">
    <%static:include path="js/xblock-validation-messages.underscore" />
</script>
</%block>

24 25 26 27
<script>
    require(["jquery", "js/factories/xblock_validation"], function($, XBlockValidationFactory) {
        XBlockValidationFactory(
            ${messages},
28 29
            $.parseJSON("${bool(xblock_url)}".toLowerCase()),  // xblock_url will be None or a string
            $.parseJSON("${bool(is_root)}".toLowerCase()),  // is_root will be None or a boolean
30 31 32
            $('div.xblock-validation-messages[data-locator="${xblock.location | h}"]')
        );
    });
33 34
</script>

35 36
% if not is_root:
    % if is_reorderable:
37
    <li class="studio-xblock-wrapper is-draggable" data-locator="${xblock.location | h}" data-course-key="${xblock.location.course_key | h}">
38
    % else:
39
    <div class="studio-xblock-wrapper" data-locator="${xblock.location | h}" data-course-key="${xblock.location.course_key | h}">
40 41
    % endif

42 43 44 45 46
    <section class="wrapper-xblock ${section_class} ${collapsible_class}
    % if is_visible_to_specific_content_groups(xblock):
        has-group-visibility-set
    % endif
    ">
47
% endif
48

49
<header class="xblock-header xblock-header-${xblock.category}">
50 51 52 53 54
    <div class="xblock-header-primary
    % if not show_preview:
        is-collapsed
    % endif
    ">
55
        <div class="header-details">
56
            % if show_inline:
57
            <a href="#" data-tooltip="${_('Expand or Collapse')}" class="action expand-collapse collapse">
58
                <i class="icon fa fa-caret-down ui-toggle-expansion"></i>
59 60 61
                <span class="sr">${_('Expand or Collapse')}</span>
            </a>
            % endif
62
            <span class="xblock-display-name">${label | h}</span>
63 64 65
        </div>
        <div class="header-actions">
            <ul class="actions-list">
66
                % if not is_root:
67 68 69 70 71 72 73 74
                    % if can_edit:
                        % if not show_inline:
                            <li class="action-item action-edit">
                                <a href="#" class="edit-button action-button">
                                    <i class="icon fa fa-pencil"></i>
                                    <span class="action-button-text">${_("Edit")}</span>
                                </a>
                            </li>
75 76 77 78 79 80 81 82
                            % if can_edit_visibility:
                                <li class="action-item action-visibility">
                                    <a href="#" data-tooltip="${_("Visibility Settings")}" class="visibility-button action-button">
                                        <i class="icon fa fa-eye" aria-hidden="true"></i>
                                        <span class="sr">${_("Visibility")}</span>
                                    </a>
                                </li>
                            % endif
83 84 85 86 87 88 89 90 91 92 93 94 95 96 97
                            % if can_add:
                                <li class="action-item action-duplicate">
                                    <a href="#" data-tooltip="${_("Duplicate")}" class="duplicate-button action-button">
                                    <i class="icon fa fa-copy"></i>
                                    <span class="sr">${_("Duplicate")}</span>
                                    </a>
                                </li>
                            % endif
                        % endif
                        % if can_add:
                            <!-- If we can add, we can delete. -->
                            <li class="action-item action-delete">
                                <a href="#" data-tooltip="${_("Delete")}" class="delete-button action-button">
                                <i class="icon fa fa-trash-o"></i>
                                <span class="sr">${_("Delete")}</span>
98 99 100 101 102 103 104 105 106 107 108 109
                                </a>
                            </li>
                        % endif
                        % if is_reorderable:
                            <li class="action-item action-drag">
                                <span data-tooltip="${_('Drag to reorder')}" class="drag-handle action"></span>
                            </li>
                        % endif
                    % elif not show_inline:
                        <li class="action-item action-edit action-edit-view-only">
                            <a href="#" class="edit-button action-button">
                                <span class="action-button-text">${_("Details")}</span>
110 111
                            </a>
                        </li>
112
                    % endif
113 114 115
                % endif
            </ul>
        </div>
116
    </div>
117 118 119 120 121 122 123 124 125 126
    % if not is_root:
        <div class="wrapper-xblock-message xblock-validation-messages" data-locator="${xblock.location | h}"/>
        % if xblock_url:
        <div class="xblock-header-secondary">
            <div class="meta-info">${_('This block contains multiple components.')}</div>
            <ul class="actions-list">
                <li class="action-item action-view">
                    <a href="${xblock_url}" class="action-button">
                        ## Translators: this is a verb describing the action of viewing more details
                        <span class="action-button-text">${_('View')}</span>
127
                        <i class="icon fa fa-arrow-right"></i>
128 129 130 131 132
                    </a>
                </li>
            </ul>
        </div>
        % endif
133 134
    % endif
 </header>
135 136 137 138 139

% if is_root:
    <div class="wrapper-xblock-message xblock-validation-messages" data-locator="${xblock.location | h}"/>
% endif

140 141 142 143 144 145 146 147 148 149 150
% if show_preview:
    % if is_root or not xblock_url:
        <article class="xblock-render">
        ${content}
        </article>
    % else:
        <div class="xblock-message-area">
        ${content}
        </div>
    % endif
 % endif   
151

152 153 154 155 156 157 158
% if not is_root:
    </section>
    % if is_reorderable:
        </li>
    % else:
        </div>
    % endif
159
% endif