<flare-input [name]="latitude" type="number" placeholder="latitude" step="any"> <flare-input [name]="longitude" type="number" placeholer="longitute" step="any"> """)) return tpl def updateWidget(self): if self.bone.readonly: self.latitude.disable() self.longitude.disable() else: self.latitude.enable() self.longitude.enable() def unserialize(self, value=None): self.latitude["value"], self.longitude["value"] = value or (0, 0) def serialize(self): return {"lat": self.latitude["value"], "lng": self.longitude["value"]} class SpatialBone(BaseBone): editWidgetFactory = SpatialEditWidget @staticmethod def checkFor(moduleName, boneName, skelStructure, *args, **kwargs): return skelStructure[boneName]["type"] == "spatial" or skelStructure[ boneName]["type"].startswith("spatial.") boneSelector.insert(1, SpatialBone.checkFor, SpatialBone)
self.widget.addClass("input-group-item") if self.bone.readonly: self.widget.disable() else: self.widget.enable() class EmailViewWidget(BaseViewWidget): def unserialize(self, value=None): self.value = value if value: #"""<a href="mailto:{{value}}">{{value}}</a>""", #fixme style parameter to activate mailTo link self.replaceChild("""{{value}}""", value=value) else: self.replaceChild(conf["emptyValue"]) class EmailBone(BaseBone): editWidgetFactory = EmailEditWidget viewWidgetFactory = EmailViewWidget @staticmethod def checkFor(moduleName, boneName, skelStructure, *args, **kwargs): return skelStructure[boneName]["type"] == "str.email" or skelStructure[ boneName]["type"].startswith("str.email.") boneSelector.insert(2, EmailBone.checkFor, EmailBone)
def unserialize(self, value=None): self.widget["value"] = utils.unescape(str( value or "")) # fixme: is utils.unescape() still required? self.updateLength() def serialize(self): return self.widget["value"] class StringViewWidget(BaseViewWidget): # fixme: Do we really need this? BaseViewWidget should satisfy, # the call to utils.unescape() is the only difference. def unserialize(self, value=None): self.value = value self.replaceChild( html5.TextNode(utils.unescape(value or conf["emptyValue"]))) class StringBone(BaseBone): editWidgetFactory = StringEditWidget viewWidgetFactory = StringViewWidget @staticmethod def checkFor(moduleName, boneName, skelStructure, *args, **kwargs): return skelStructure[boneName]["type"] == "str" or skelStructure[ boneName]["type"].startswith("str.") boneSelector.insert(1, StringBone.checkFor, StringBone)
self.widget[ "value" ] = self.setValue( self.widget[ "value" ] ) def unserialize( self, value = None ): self.widget[ "value" ] = self.setValue( value ) def serialize( self ): return self.value or 0 class NumericViewWidget( BaseViewWidget ): def unserialize( self, value = None ): if value is None: value = conf[ "emptyValue" ] self.value = value self.replaceChild( html5.TextNode( self.value )) class NumericBone( BaseBone ): editWidgetFactory = NumericEditWidget viewWidgetFactory = NumericViewWidget @staticmethod def checkFor( moduleName, boneName, skelStructure, *args, **kwargs ): return skelStructure[ boneName ][ "type" ] == "numeric" or skelStructure[ boneName ][ "type" ].startswith( "numeric." ) boneSelector.insert( 1, NumericBone.checkFor, NumericBone )
self.widget.element.autocomplete = "new-password" return self.widget def updateWidget(self): if self.bone.readonly: self.widget.disable() if self.verify: self.verify.disable() else: self.widget.enable() if self.verify: self.verify.enable() def serialize(self): if not self.verify or self.widget["value"] == self.verify["value"]: return self.widget["value"] raise InvalidBoneValueException() class PasswordBone(BaseBone): editWidgetFactory = PasswordEditWidget @staticmethod def checkFor(moduleName, boneName, skelStructure, *args, **kwargs): return skelStructure[boneName]["type"] == "password" or skelStructure[ boneName]["type"].startswith("password.") boneSelector.insert(1, PasswordBone.checkFor, PasswordBone)
def serialize(self): value = self.widget["value"] return value if value else None class ColorViewWidget(BaseViewWidget): def unserialize(self, value=None): self.value = value if value: self["style"]["background-color"] = value self.appendChild(value) else: self.appendChild(conf["emptyValue"]) class ColorBone(BaseBone): editWidgetFactory = ColorEditWidget viewWidgetFactory = ColorViewWidget multiEditWidgetFactory = None multiViewWidgetFactory = None @staticmethod def checkFor(moduleName, boneName, skelStructure, *args, **kwargs): return skelStructure[boneName]["type"] == "color" or skelStructure[ boneName]["type"].startswith("color.") boneSelector.insert(1, ColorBone.checkFor, ColorBone)
else: self.widget["readonly"] = False # fixme: required? def _setDisabled(self, disable): super()._setDisabled(disable) if not disable and not self._disabledState and self.parent( ) and self.parent().hasClass("is-active"): self.parent().removeClass("is-active") class TextViewWidget(BaseViewWidget): def unserialize(self, value=None): self.value = value self.replaceChild(value or conf["emptyValue"]) class TextBone(BaseBone): editWidgetFactory = TextEditWidget viewWidgetFactory = TextViewWidget @staticmethod def checkFor(moduleName, boneName, skelStructure, *args, **kwargs): return skelStructure[boneName]["type"] == "text" or skelStructure[ boneName]["type"].startswith("text.") boneSelector.insert(1, TextBone.checkFor, TextBone)
super().__init__(*args, **kwargs) self.formatString = self.boneStructure["format"] self.destModule = self.boneStructure["module"] self.destInfo = conf["modules"].get(self.destModule, {"handler":"list"}) self.destStructure = self.boneStructure["relskel"] self.dataStructure = self.boneStructure["using"] #logging.debug("RelationalBone: %r, %r", self.destModule, self.destInfo) @staticmethod def checkFor(moduleName, boneName, skelStructure, *args, **kwargs): return skelStructure[boneName]["type"] == "relational" or skelStructure[boneName]["type"].startswith("relational.") boneSelector.insert(1, RelationalBone.checkFor, RelationalBone) # --- hierarchyBone --- class HierarchyBone(RelationalBone): # fixme: this bone is obsolete! It behaves exactly as relational. @staticmethod def checkFor(moduleName, boneName, skelStructure, *args, **kwargs): return skelStructure[boneName]["type"] == "hierarchy" or skelStructure[boneName]["type"].startswith("hierarchy.") boneSelector.insert(1, HierarchyBone.checkFor, HierarchyBone) # --- treeItemBone --- class TreeItemBone(RelationalBone): selectorAllow = TreeLeafWidget
containerDiv.appendChild(label) valueDiv = html5.Div() valueDiv.addClass("flr-value-wrapper") valueDiv.appendChild(widget) if tooltip: valueDiv.appendChild(tooltip) if error: valueDiv.appendChild(error) containerDiv.appendChild(valueDiv) #containerDiv.appendChild( fieldErrors ) return (containerDiv, label, widget, error) ''' def toString(self, value): return value or conf["emptyValue"] def toJSON(self, value): if isinstance(value, list): return [str(i) for i in value] return value ''' boneSelector.insert(0, lambda *args, **kwargs: True, BaseBone)
viewWidgetFactory = SelectViewWidget """ Base "Catch-All" delegate for everything not handled separately. """ def __init__(self, moduleName, boneName, skelStructure): super().__init__(moduleName, boneName, skelStructure) self.valuesDict = { k: v for k, v in self.boneStructure["values"] } # fixme this could be obsolete when core renders dict... @staticmethod def checkFor(moduleName, boneName, skelStructure, *args, **kwargs): return (skelStructure[ boneName ][ "type" ] == "select" or skelStructure[ boneName ][ "type" ].startswith( "select." )) \ and skelStructure[ boneName ].get( "multiple" ) boneSelector.insert(1, SelectMultipleBone.checkFor, SelectMultipleBone) class SelectSingleBone(SelectMultipleBone): editWidgetFactory = SelectSingleEditWidget @staticmethod def checkFor(moduleName, boneName, skelStructure, *args, **kwargs): return (skelStructure[ boneName ][ "type" ] == "select" or skelStructure[ boneName ][ "type" ].startswith( "select." )) \ and not skelStructure[ boneName ].get( "multiple" ) boneSelector.insert(1, SelectSingleBone.checkFor, SelectSingleBone)
if self.bone.boneStructure.get("date", True): serverToClient.append( "%d.%m.%Y") # fixme: Again german format?? if self.bone.boneStructure.get("time", True): serverToClient.append("%H:%M:%S") try: self.value = datetime.datetime.strptime( value or "", " ".join(serverToClient)) value = self.value.strftime( translate("vi.bone.date.at").join( serverToClient)) # fixme: hmm... except: value = "Invalid Datetime Format" self.replaceChild(html5.TextNode(value or conf["emptyValue"])) class DateBone(BaseBone): editWidgetFactory = DateEditWidget viewWidgetFactory = DateViewWidget @staticmethod def checkFor(moduleName, boneName, skelStructure, *args, **kwargs): return skelStructure[boneName]["type"] == "date" or skelStructure[ boneName]["type"].startswith("date.") boneSelector.insert(1, DateBone.checkFor, DateBone)
self.value = value if value: txt = formatString( self.bone.boneStructure["format"], value, self.bone.boneStructure["using"], language=self.language, prefix=[ 'dest' ] #use dest prefix! < rel and record use the same format dest.XXX ) else: txt = None self.replaceChild(html5.TextNode(txt or conf["emptyValue"])) class RecordBone(BaseBone): editWidgetFactory = RecordEditWidget viewWidgetFactory = RecordViewWidget @staticmethod def checkFor(moduleName, boneName, skelStructure, *args, **kwargs): return skelStructure[boneName]["type"] == "record" or skelStructure[ boneName]["type"].startswith("record.") boneSelector.insert(1, RecordBone.checkFor, RecordBone)
def updateWidget( self ): if self.bone.readonly: self.widget.disable() else: self.widget.enable() def unserialize( self, value = None ): self.widget[ "checked" ] = bool( value ) def serialize( self ): return "yes" if self.widget[ "checked" ] else "no" class BooleanViewWidget( BaseViewWidget ): def unserialize( self, value = None ): self.value = value self.appendChild( html5.TextNode( translate( str( bool( value ) ) ) ), replace = True ) class BooleanBone( BaseBone ): editWidgetFactory = BooleanEditWidget viewWidgetFactory = BooleanViewWidget @staticmethod def checkFor( moduleName, boneName, skelStructure, *args, **kwargs ): return skelStructure[ boneName ][ "type" ] == "bool" or skelStructure[ boneName ][ "type" ].startswith( "bool." ) boneSelector.insert( 1, BooleanBone.checkFor, BooleanBone )