Skip to content

Commit

Permalink
Updated template to BS5 styles
Browse files Browse the repository at this point in the history
  • Loading branch information
trollfot committed Nov 21, 2023
1 parent fdc43d5 commit 37f4324
Show file tree
Hide file tree
Showing 8 changed files with 48 additions and 53 deletions.
40 changes: 19 additions & 21 deletions deform/templates/checkbox.pt
Original file line number Diff line number Diff line change
@@ -1,23 +1,21 @@
<div class="checkbox">
<label for="${field.oid}">
<input tal:define="name name|field.name;
true_val true_val|field.widget.true_val;
css_class css_class|field.widget.css_class;
style style|field.widget.style;
oid oid|field.oid;
autofocus autofocus|field.autofocus|None"
type="checkbox"
name="${name}" value="${true_val}"
id="${oid}"
tal:attributes="checked cstruct == true_val;
class css_class;
style style;
autofocus autofocus;
attributes|field.widget.attributes|{};" />
<div class="form-check">
<input tal:define="name name|field.name;
true_val true_val|field.widget.true_val;
css_class css_class|field.widget.css_class;
style style|field.widget.style;
oid oid|field.oid;
autofocus autofocus|field.autofocus|None"
type="checkbox"
name="${name}" value="${true_val}"
id="${oid}"
tal:attributes="checked cstruct == true_val;
class string:form-check-input ${css_class};
style style;
autofocus autofocus;
attributes|field.widget.attributes|{};" />

<span tal:condition="hasattr(field, 'schema') and hasattr(field.schema, 'label')"
tal:replace="field.schema.label" class="checkbox-label" >
</span>

</label>
<label for="${field.oid}"
tal:condition="hasattr(field, 'schema') and hasattr(field.schema, 'label')"
tal:content="field.schema.label"
class="form-check-label"></label>
</div>
18 changes: 8 additions & 10 deletions deform/templates/checkbox_choice.pt
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,24 @@
style style|field.widget.style;
oid oid|field.oid;
inline getattr(field.widget, 'inline', False);
autofocus autofocus|field.autofocus"
tal:omit-tag="not inline">
autofocus autofocus|field.autofocus">
${field.start_sequence()}
<div tal:repeat="choice values | field.widget.values"
tal:omit-tag="inline"
class="checkbox">
<label for="${oid}-${repeat.choice.index}"
tal:define="(value, title) choice"
tal:attributes="class inline and 'checkbox-inline'">
tal:attributes="class string:form-check ${inline and 'form-check-inline' or ''}">
<tal:choice tal:define="(value, title) choice">
<input tal:attributes="checked value in cstruct;
class css_class;
class string:form-check-input css_class;
style style;
autofocus not repeat.choice.index and autofocus;
attributes|field.widget.attributes|{};"
type="checkbox"
name="checkbox"
value="${value}"
id="${oid}-${repeat.choice.index}"/>
${title}
</label>
<label class="form-check-label" for="${oid}-${repeat.choice.index}">
${title}
</label>
</tal:choice>
</div>
${field.end_sequence()}
</div>
4 changes: 2 additions & 2 deletions deform/templates/mapping_item.pt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
i18n:domain="deform">

<label for="${oid}"
class="control-label ${required and 'required' or ''}"
class="form-label ${required and 'required' or ''}"
tal:condition="not structural"
id="req-${oid}"
>
Expand All @@ -31,7 +31,7 @@
tal:condition="input_append">${input_append}</span>
</div>

<p class="form-text text-danger"
<p class="invalid-feedback"
tal:define="errstr 'error-%s' % field.oid"
tal:repeat="msg field.error.messages()"
i18n:translate=""
Expand Down
23 changes: 11 additions & 12 deletions deform/templates/radio_choice.pt
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,28 @@
css_class css_class|field.widget.css_class;
style style|field.widget.style;
inline getattr(field.widget, 'inline', False);
autofocus autofocus|field.autofocus"
tal:omit-tag="not inline">
autofocus autofocus|field.autofocus">
${field.start_rename()}
<div tal:repeat="choice values | field.widget.values"
tal:omit-tag="inline"
class="radio">
<label for="${oid}-${repeat.choice.index}"
tal:define="(value, title) choice"
tal:attributes="class inline and 'radio-inline'">
tal:attributes="class string:form-check ${inline and 'form-check-inline' or ''}">
<tal:choice tal:define="(value, title) choice">
<input tal:attributes="checked value == cstruct;
class css_class;
class string:form-check-input ${css_class};
style style;
autofocus not repeat.choice.index and autofocus;
readonly 'readonly' in getattr(field.widget, 'attributes', {}) and value == cstruct;
disabled 'readonly' in getattr(field.widget, 'attributes', {}) and value != cstruct;
attributes|field.widget.attributes|{};
"
attributes|field.widget.attributes|{};"
type="radio"
name="${oid}"
value="${value}"
id="${oid}-${repeat.choice.index}"/>
${title}
</label>

<label for="${oid}-${repeat.choice.index}"
class="form-check-label">
${title}
</label>
</tal:choice>
</div>
${field.end_rename()}
</div>
10 changes: 5 additions & 5 deletions deform/templates/richtext.pt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
tinymce_options tinymce_options|field.widget.tinymce_options;
oid oid|field.oid;
name name|field.name;"
xmlns:i18n="http://xml.zope.org/namespaces/i18n"
xmlns:i18n="http://xml.zope.org/namespaces/i18n"
i18n:domain="deform"
tal:omit-tag="">

Expand All @@ -12,15 +12,15 @@
height: 240px;
display: block;
}
</style>
<textarea id="${oid}" name="${name}"
</style>
<textarea id="${oid}" name="${name}"
class="tinymce form-control" tal:content="cstruct" />
<!--!
NB: disable delayed_load on error redisplay of form, since
that might result in non-HTML-escaped interpolation of
user input.
-->
<span id="${oid}-preload" class="tinymce-preload"
<span id="${oid}-preload" class="tinymce-preload"
tal:condition="delayed_load and not field.error"
tal:content="structure cstruct" />
<script type="text/javascript">
Expand All @@ -30,7 +30,7 @@
language: '<tal:block i18n:translate="language-code">en</tal:block>',
body_class: 'form-control',
<tal:block condition="tinymce_options">${tinymce_options},</tal:block>
elements: oid
selector: '#' + oid
};
var jqoid = $('#' + oid);
var jqoid_preload = $('#' + oid + '-preload');
Expand Down
2 changes: 1 addition & 1 deletion deform/templates/select.pt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<select tal:attributes="
name name;
id oid;
class string: form-control ${css_class or ''};
class string: form-select ${css_class or ''};
multiple multiple;
size size;
style style;
Expand Down
2 changes: 1 addition & 1 deletion deform/templates/select2.pt
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
<select tal:attributes="
name name;
id oid;
class string: form-control ${css_class or ''};
class string: form-select ${css_class or ''};
data-placeholder field.widget.placeholder|None;
multiple multiple;
style style;
Expand Down
2 changes: 1 addition & 1 deletion deform/templates/selectize.pt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<select tal:attributes="
name name;
id oid;
class string: form-control ${css_class or ''};
class string: form-select ${css_class or ''};
data-placeholder field.widget.placeholder|None;
multiple multiple;
style style;
Expand Down

0 comments on commit 37f4324

Please sign in to comment.