Skip to content

Commit

Permalink
Added Control simple label
Browse files Browse the repository at this point in the history
  • Loading branch information
UmSenhorQualquer committed Aug 3, 2018
1 parent 386c69f commit cef9d4e
Show file tree
Hide file tree
Showing 7 changed files with 75 additions and 7 deletions.
18 changes: 14 additions & 4 deletions docs/source/api-reference/python/controls.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@
:synopsis: Pyforms Controls


Enumerates Bpod board supported operations.



ControlBase
----------------------------

Expand Down Expand Up @@ -276,6 +272,20 @@ ControlLabel
:show-inheritance:
:exclude-members: init_form, serialize, deserialize


----------------------------

ControlSimpleLabel
----------------------------

.. autoclass:: pyforms_web.controls.control_simplelabel.ControlSimpleLabel
:members:
:undoc-members:
:show-inheritance:
:exclude-members: init_form, serialize, deserialize



----------------------------

ControlMenu
Expand Down
2 changes: 0 additions & 2 deletions docs/source/api-reference/python/widgets/django.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
***************************


Enumerates Bpod board supported operations.


ModelAdminWidget
----------------------------
Expand Down
2 changes: 1 addition & 1 deletion pyforms_web/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
__author__ = "Ricardo Ribeiro"
__credits__ = ["Ricardo Ribeiro"]
__license__ = "MIT"
__version__ = "4.0"
__version__ = "4.0.1"
__maintainer__ = "Ricardo Ribeiro"
__email__ = "ricardojvr@gmail.com"
__status__ = "Development"
Expand Down
1 change: 1 addition & 0 deletions pyforms_web/allcontrols.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
from .controls.control_integer import ControlInteger
from .controls.control_itemslist import ControlItemsList
from .controls.control_label import ControlLabel
from .controls.control_simplelabel import ControlSimpleLabel
from .controls.control_list import ControlList
from .controls.control_menu import ControlMenu
from .controls.control_multiplechecks import ControlMultipleChecks
Expand Down
21 changes: 21 additions & 0 deletions pyforms_web/controls/control_simplelabel.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
from pyforms_web.controls.control_base import ControlBase
import simplejson

class ControlSimpleLabel(ControlBase):
def __init__(self, *args, **kwargs):
self._css = ''
super().__init__(*args, **kwargs)

def init_form(self):
return """new ControlSimpleLabel('{0}', {1})""".format(
self._name,
simplejson.dumps(self.serialize())
)

def deserialize(self, properties): pass

def serialize(self):
res = super().serialize()
if self.value:
res.update({'value': "<br />".join(self.value.split("\n"))})
return res
37 changes: 37 additions & 0 deletions pyforms_web/web/static/pyformsjs/ControlSimpleLabel.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
class ControlSimpleLabel extends ControlBase{

////////////////////////////////////////////////////////////////////////////////

get_value(){
return this.properties.value;
};

////////////////////////////////////////////////////////////////////////////////

init_control(){
var html = '<div class="ui field '+this.properties.css+' control ControlSimpleLabel" id="'+this.place_id()+'" >';
if(this.properties.label){
html += '<div class="header">';
html += this.properties.label;
html += '</div>';
};

html += '<p id="'+this.control_id()+'" >';
if(this.properties.value!=null || this.properties.value!=undefined)
html += this.properties.value;
html += '</p>';
html += '</div>';
this.jquery_place().replaceWith(html);


};

////////////////////////////////////////////////////////////////////////////////

set_value(value){
this.init_control();
};

////////////////////////////////////////////////////////////////////////////////

}
1 change: 1 addition & 0 deletions pyforms_web/web/static/pyformsjs/pyforms.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ class PyformsManager{
$.getScript("/static/pyformsjs/ControlBoundingSlider.js");
$.getScript("/static/pyformsjs/ControlVisVis.js");
$.getScript("/static/pyformsjs/ControlLabel.js");
$.getScript("/static/pyformsjs/ControlSimpleLabel.js");
$.getScript("/static/pyformsjs/ControlTimeout.js");
$.getScript("/static/pyformsjs/ControlEmptyWidget.js");
$.getScript("/static/pyformsjs/ControlMenu.js");
Expand Down

0 comments on commit cef9d4e

Please sign in to comment.