Przeglądaj źródła

Add User templates

jmontoyaa 8 lat temu
rodzic
commit
2e204dc7bf

+ 62 - 0
src/Chamilo/CoreBundle/Resources/views/User/Form/_attributes.html.twig

@@ -0,0 +1,62 @@
+<script>
+
+    ;
+    (function ($) {
+        'use strict';
+
+        $(document).ready(function () {
+            $(document).on('click', 'a[data-collection-button="add"]', function (e) {
+                e.preventDefault();
+                var collectionContainer = $('#' + $(this).data('collection'));
+                var isArray = collectionContainer.data('is-php-array');
+                var prototype = $('#' + $(this).data('prototype')).data('prototype');
+                var item = prototype.replace(/__name__/g, collectionContainer.children().length + (undefined == isArray ? 0 : 1));
+                collectionContainer.append(item);
+            });
+
+            $(document).on('click', 'a[data-collection-button="delete"]', function (e) {
+                e.preventDefault();
+                var item = $(this).closest('.' + $(this).data('collection') + '-' + $(this).data('collection-item'));
+                item.remove();
+            });
+        });
+    })(jQuery);
+
+</script>
+
+<div class="tab-pane" id="attributes">
+    <div
+            id="sylius-assortment-product-attributes"
+            class="collection-container"
+            data-prototype="{{ ('<div id="sylius_product_attributes___name__">' ~ form_row(form.extraFields.vars.prototype.extraField, {'attr': {'class': 'attribute-chooser'}}))|e }}{{ (form_row(form.extraFields.vars.prototype.value) ~ '</div>')|e }}">
+
+        {% for attributeForm in form.extraFields %}
+            <div class="sylius-assortment-product-attributes-attribute row">
+                <div class="col-md-10">
+                    {{ form_widget(attributeForm) }}
+                </div>
+                <div class="col-md-2">
+                    <a href="#" class="btn btn-danger"
+                       data-collection-button="delete"
+                       data-collection="sylius-assortment-product-attributes"
+                       data-collection-item="attribute">
+                        <i class="glyphicon glyphicon-trash"></i>&nbsp;{{ 'sylius.product.remove_attribute'|trans }}
+                    </a>
+                </div>
+            </div>
+        {% endfor %}
+        {% for key, prototype in form.extraFields.vars.prototype.vars.prototypes %}
+            <div id="attribute-prototype_{{ key }}" class="attribute-prototypes"
+                 data-prototype="{{ form_widget(prototype)|e }}"></div>
+        {% endfor %}
+        {#</div>#}
+
+        <a href="#"
+           class="btn btn-success btn-block"
+           data-collection-button="add"
+           data-prototype="sylius-assortment-product-attributes"
+           data-collection="sylius-assortment-product-attributes"
+        >
+            {{ 'sylius.product.add_attribute'|trans }}
+        </a>
+    </div>

+ 32 - 0
src/Chamilo/CoreBundle/Resources/views/User/Form/_main.html.twig

@@ -0,0 +1,32 @@
+<div class="tab-pane active" id="main">
+    <div class="box-body">
+        <div class="row">
+            <div class="col-md-6">
+                {{ form_row(form.official_code) }}
+                {{ form_row(form.firstname) }}
+                {{ form_row(form.lastname) }}
+                {{ form_row(form.phone) }}
+
+                {{ form_row(form.timezone) }}
+                {{ form_row(form.locale) }}
+                {{ form_row(form.picture_uri) }}
+            </div>
+            <div class="col-md-6">
+                {{ form_row(form.username) }}
+                {{ form_row(form.email) }}
+                {{ form_row(form.password) }}
+                {{ form_row(form.groups) }}
+            </div>
+        </div>
+        <hr/>
+    </div>
+    <div class="row">
+        <div class="col-md-6">
+            <hr/>
+
+        </div>
+        <div class="col-md-6">
+
+        </div>
+    </div>
+</div>

+ 6 - 0
src/Chamilo/CoreBundle/Resources/views/User/Form/_tabs.html.twig

@@ -0,0 +1,6 @@
+<ul class="nav nav-tabs">
+    <li class="active"><a href="#main" data-toggle="tab">{{ 'User'|trans }}</a>
+    </li>
+    <li><a href="#attributes" data-toggle="tab">{{ 'Extra fields'|trans }}</a>
+    </li>
+</ul>

+ 12 - 0
src/Chamilo/CoreBundle/Resources/views/User/_form.html.twig

@@ -0,0 +1,12 @@
+{% form_theme form '@ChamiloCore/User/forms.html.twig' %}
+
+{{ form_errors(form) }}
+{% include '@ChamiloCore/User/Form/_tabs.html.twig' %}
+<br>
+<div class="tab-content">
+    {% include '@ChamiloCore/User/Form/_main.html.twig' %}
+    {% include '@ChamiloCore/User/Form/_attributes.html.twig' %}
+</div>
+<hr>
+
+{{ form_widget(form._token) }}

+ 9 - 0
src/Chamilo/CoreBundle/Resources/views/User/create.html.twig

@@ -0,0 +1,9 @@
+{% from '@ChamiloTheme/Macros/actions.html.twig' import create %}
+
+{{ form_errors(form) }}
+
+<form action="{{ url }}" method="post"
+      class="form-horizontal" {{ form_enctype(form) }} novalidate>
+    {% include '@ChamiloCore/User/_form.html.twig' %}
+    {{ create(url) }}
+</form>

+ 138 - 0
src/Chamilo/CoreBundle/Resources/views/User/forms.html.twig

@@ -0,0 +1,138 @@
+{% extends 'form_div_layout.html.twig' %}
+
+{% block choice_widget_collapsed %}
+    {% set attr = attr|merge({'class': attr.class|default('') ~ ' form-control'}) %}
+    {{ parent() }}
+{% endblock choice_widget_collapsed %}
+
+{% block textarea_widget %}
+    {% set attr = attr|merge({'class': attr.class|default('') ~ ' form-control'}) %}
+    {{ parent() }}
+{% endblock textarea_widget %}
+
+{% block form_widget_simple %}
+    {% spaceless %}
+        {% set attr = attr|merge({'class': attr.class|default('') ~ ' form-control'}) %}
+        {% set type = type|default('text') %}
+
+        {% if 'file' == type %}
+            <span class="btn-primary btn-lg file-overlay"><i
+                        class="icon-folder-open"></i> {{ 'sylius.form.choose_file'|trans }}</span>
+        {% endif %}
+        {{ parent() }}
+    {% endspaceless %}
+{% endblock form_widget_simple %}
+
+{% block form_label %}
+    {% spaceless %}
+        {% set label_attr = label_attr|merge({'class': label_attr.class|default('col-lg-2') ~ ' control-label'}) %}
+        {{ parent() }}
+    {% endspaceless %}
+{% endblock form_label %}
+
+{% block money_widget %}
+    {% spaceless %}
+        <div class="input-group">
+            <span class="input-group-addon">{{ money_pattern|replace({'{{ widget }}': ''}) }}</span>
+            {{ block('form_widget_simple') }}
+        </div>
+    {% endspaceless %}
+{% endblock money_widget %}
+
+{% block percent_widget %}
+    {% spaceless %}
+        <div class="input-group">
+            <span class="input-group-addon">%</span>
+            {{ block('form_widget_simple') }}
+        </div>
+    {% endspaceless %}
+{% endblock percent_widget %}
+
+{% block datetime_widget %}
+    {% spaceless %}
+        {% if widget == 'single_text' %}
+            {{ block('form_widget_simple') }}
+        {% else %}
+            <div class="form-group">
+                {{ form_widget(form.date) }}
+                {{ form_widget(form.time) }}
+            </div>
+        {% endif %}
+    {% endspaceless %}
+{% endblock datetime_widget %}
+
+{% block date_widget %}
+    {% spaceless %}
+        {% if widget == 'single_text' %}
+            {{ block('form_widget_simple') }}
+        {% else %}
+            {{ '{{ year }} / {{ month }} / {{ day }}'|replace({
+                '{{ year }}':  form_widget(form.year, {'attr': {'style': 'display: inline; width: 100px;'}}),
+                '{{ month }}': form_widget(form.month, {'attr': {'style': 'display: inline; width: 100px;'}}),
+                '{{ day }}':   form_widget(form.day, {'attr': {'style': 'display: inline; width: 100px;'}}),
+            })|raw }}
+        {% endif %}
+    {% endspaceless %}
+{% endblock date_widget %}
+
+{% block time_widget %}
+    {% spaceless %}
+        {% if widget == 'single_text' %}
+            {{ block('form_widget_simple') }}
+        {% else %}
+            {% set vars = widget == 'text' ? { 'attr': { 'size': 1, 'style': 'width: 60px; display: inline;' }} : {} %}
+            &nbsp;{{ form_widget(form.hour, vars) }}{% if with_minutes %}:{{ form_widget(form.minute, vars) }}{% endif %}{% if with_seconds %} {{ form_widget(form.second, vars) }}{% endif %}
+        {% endif %}
+    {% endspaceless %}
+{% endblock time_widget %}
+
+{% block form_row %}
+    {% spaceless %}
+        <div class="form-group{% if errors|length > 0 %} has-error{% endif %}">
+            {{ form_label(form) }}
+            <div class="col-lg-10">
+                {{ form_widget(form) }}
+                {% for error in errors %}
+                    <span class="help-block form-error">
+                {{ error.messagePluralization is null
+                ? error.messageTemplate|trans(error.messageParameters, 'validators')
+                : error.messageTemplate|transchoice(error.messagePluralization, error.messageParameters, 'validators') }}
+            </span>
+                {% endfor %}
+            </div>
+        </div>
+    {% endspaceless %}
+{% endblock form_row %}
+
+{% block sonata_media_type_widget %}
+    <div class="col-xs-3 pull-left">
+        {% if value is not empty and value.providerReference %}
+            <div class="pull-left" style="margin-right: 5px">
+                {% thumbnail value, 'admin' with {'class': 'img-polaroid media-object'} %}
+            </div>
+
+            {% if sonata_admin_enabled is defined and sonata_admin_enabled %}
+                <a href="{{ url('admin_sonata_media_media_edit', {id: value.id}) }}"><strong>{{ value.name }}</strong></a>
+            {% else %}
+                <strong>{{ value.name }}</strong>
+            {% endif %}
+            <br/>
+            <span type="label">{{ value.providerName|trans({}, 'SonataMediaBundle') }}</span> ~ {{ value.context }}
+        {% else %}
+            <div class="pull-left" style="margin-right: 5px">
+                <img src="{{ asset('bundles/sonatamedia/grey.png') }}"
+                     class="img-polaroid media-object"
+                     style="width: 85px; height: 85px"/>
+            </div>
+            <strong>{{ 'no_linked_media'|trans({}, 'SonataMediaBundle') }}</strong>
+            <br/>
+            <span type="label">{{ form.vars['provider']|trans({}, 'SonataMediaBundle') }}
+                ~ {{ form.vars['context']|trans({}, 'SonataMediaBundle') }}</span>
+        {% endif %}
+    </div>
+
+    <div class="span3 pull-left">
+        {{ 'link_media'|trans({}, 'SonataMediaBundle') }}
+        {{ block('form_widget') }}
+    </div>
+{% endblock sonata_media_type_widget %}