* Added "required" to choice fields that needs it

* Fixed jquery-validate not validating select (because of being hidden 
due to selectpicker)
This commit is contained in:
Adolfo Gómez García 2014-11-25 20:31:55 +01:00
parent 44e6a3b50c
commit eb844a0c88
8 changed files with 19 additions and 12 deletions

View File

@ -103,7 +103,8 @@ class ServicesPools(ModelHandler):
'comments': item.comments,
'state': item.state,
'thumb': item.image.thumb64 if item.image is not None else DEFAULT_THUMB_BASE64,
'service_id': item.service.uuid
'service_id': item.service.uuid,
'restrained': item.isRestrained(),
}
# Gui related

View File

@ -85,7 +85,7 @@ class ServiceCacheUpdater(Job):
for ds in whichNeedsCaching:
ds.userServices.update() # Cleans cached queries
# If this deployedService don't have a publication active and needs it, ignore it
if ds.activePublication() == None and ds.service.getInstance().publicationType is not None:
if ds.activePublication() is None and ds.service.getInstance().publicationType is not None:
logger.debug('Needs publication but do not have one, cache test ignored')
continue
# If it has any running publication, do not generate cache anymore

View File

@ -33,7 +33,7 @@
from __future__ import unicode_literals
__updated__ = '2014-11-05'
__updated__ = '2014-11-25'
from django.db import models
from django.db.models import signals
@ -160,7 +160,6 @@ class DeployedService(UUIDModel):
return False # Do not perform any restraint check if we set the globalconfig to 0 (or less)
date = getSqlDatetime() - timedelta(seconds=GlobalConfig.RESTRAINT_TIME.getInt())
if self.userServices.filter(state=State.ERROR, state_date__gt=date).count() >= GlobalConfig.RESTRAINT_COUNT.getInt():
return True

View File

@ -52,7 +52,7 @@
name: f.name
css: "modal_field_data"
)
# if this field has a filler (callback to get data)
if f.gui.fills
gui.doLog "This field has a filler"
@ -96,7 +96,7 @@
$.extend originalValues, h.originalValues
form += "</form>"
gui.doLog "Original values: ", originalValues
# Init function for callbacks.
# Callbacks can only be attached to "Selects", but it's parameters can be got from any field
# This needs the "form selector" as base for setting callbacks, etc..
@ -226,8 +226,11 @@
gui.tools.applyCustoms id
# Validation
$form.validate
debug: true
ignore: ':hidden:not("select")'
errorClass: "text-danger"
validClass: "has-success"
highlight: (element) ->
@ -239,6 +242,10 @@
$(element).remove()
return
# Generate rules for required select fields
for s in $($form.selector + " select[multiple][required]")
gui.doLog "Rules ", $(s).rules()
# And catch "accept" (default is "Save" in fact) button click
$("#{id} .button-accept").click ->

View File

@ -36,7 +36,7 @@
# If Mousedown registers a temporal mouseUp event on parent, to lauch button click
$this.mousedown (event) ->
$("body").mouseup (e) ->
# Remove temporal mouseup handler
$(this).unbind "mouseup"

View File

@ -14,9 +14,9 @@
{% for message in messages %}
<div class="alert alert-danger alert-dismissable">
<button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button>
{{ message }}
{{ message }}
</div>
{% endfor %}
{% endfor %}
</div>
</div>
{% endif %}
@ -29,7 +29,7 @@
<li {{# if first }}class="active" {{/ if }}><a href="#section_{{ key }}" data-toggle="tab">{{ key }}</a>
{{/ eachKey }}
</ul>
<div class="row">
<div class="row">
<div class="tab-content col-md-12 col-md-offset-0 col-lg-8 col-lg-offset-2">
{{# eachKey config }}
<div class="tab-pane {{# if first }}active{{/ if }}" id="section_{{ key }}">

View File

@ -3,7 +3,7 @@
{% comment %}The choice item MUST be a Select{% endcomment %}
{% block field %}
{% verbatim %}
<select class="selectpicker show-menu-arrow show-tick {{ css }}" name="{{ name }}" data-style="btn-default" data-width="100%" id="{{ name }}_field" {{# if readonly }} disabled{{/ if }}>
<select class="selectpicker show-menu-arrow show-tick {{ css }}" name="{{ name }}" data-style="btn-default" data-width="100%" id="{{ name }}_field" {{# if readonly }} disabled{{/ if }}{{# if required }} required{{/ if }}>
{{#each values }}
<option value="{{ id }}"{{# ifequals id ../value }}selected{{/ ifequals }}>{{ text }}</option>
{{/each}}

View File

@ -3,7 +3,7 @@
{% comment %}The choice item MUST be a Select.{% endcomment %}
{% block field %}
{% verbatim %}
<select class="selectpicker show-menu-arrow {{ css }}" multiple data-style="btn-default" data-selected-text-format="count>3" data-width="100%" name="{{ name }}" id="{{ name }}_field" {{# if readonly }} disabled{{/ if }}>
<select class="selectpicker show-menu-arrow {{ css }}" multiple data-style="btn-default" data-selected-text-format="count>3" data-width="100%" name="{{ name }}" id="{{ name }}_field" {{# if readonly }} disabled{{/ if }}{{# if required }} required{{/ if }}>
{{#each values }}
<option value="{{ id }}"{{# ifbelongs id ../value }}selected{{/ ifbelongs }}>{{ text }}</option>
{{/each}}