Exemplo n.º 1
0
			self.widget.disable()
		else:
			self.widget.enable()

	def unserialize(self, value=None):
		self.widget["checked"] = bool(value)

	def serialize(self):
		return self.widget["checked"]


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
	multiEditWidgetFactory = None
	multiViewWidgetFactory = None

	@staticmethod
	def checkFor(moduleName, boneName, skelStructure):
		return skelStructure[boneName]["type"] == "bool" or skelStructure[boneName]["type"].startswith("bool.")


boneSelector.insert(1, BooleanBone.checkFor, BooleanBone)
Exemplo n.º 2
0
	def unserialize(self, value=None):
		if value:
			serverToClient = []

			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.appendChild(html5.TextNode(value or conf["emptyValue"]), replace=True)


class DateBone(BaseBone):
	editWidgetFactory = DateEditWidget
	viewWidgetFactory = DateViewWidget

	@staticmethod
	def checkFor(moduleName, boneName, skelStructure):
		return skelStructure[boneName]["type"] == "date" or skelStructure[boneName]["type"].startswith("date.")


boneSelector.insert(1, DateBone.checkFor, DateBone)
Exemplo n.º 3
0
				self.widget.enable()
			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.appendChild(value or conf["emptyValue"], replace=True)


class TextBone(BaseBone):
	editWidgetFactory = TextEditWidget
	viewWidgetFactory = TextViewWidget

	@staticmethod
	def checkFor(moduleName, boneName, skelStructure):
		return skelStructure[boneName]["type"] == "text" or skelStructure[boneName]["type"].startswith("text.")


boneSelector.insert(1, TextBone.checkFor, TextBone)
Exemplo n.º 4
0
class NumericViewWidget(NumericEditWidget):
    def _createWidget(self):
        pass

    def updateWidget(self):
        pass

    def unserialize(self, value=None):
        self.value = value

        if value is None:
            value = conf["emptyValue"]
        else:
            value = self.setValue(value)

        self.appendChild(html5.TextNode(value), replace=True)


class NumericBone(BaseBone):
    editWidgetFactory = NumericEditWidget
    viewWidgetFactory = NumericViewWidget

    @staticmethod
    def checkFor(moduleName, boneName, skelStructure):
        return skelStructure[boneName]["type"] == "numeric" or skelStructure[
            boneName]["type"].startswith("numeric.")


boneSelector.insert(1, NumericBone.checkFor, NumericBone)
Exemplo n.º 5
0
        widgetFactory = self.viewWidgetFactory

        if self.multiViewWidgetFactory and self.boneStructure.get("multiple"):
            multiWidgetFactory = widgetFactory  # have to make a separate "free" variable
            widgetFactory = lambda bone, **kwargs: self.multiViewWidgetFactory(
                bone, multiWidgetFactory, **kwargs)

        if self.languageViewWidgetFactory and self.boneStructure.get(
                "languages"):
            languageWidgetFactory = widgetFactory  # have to make a separate "free" variable
            widgetFactory = lambda bone, **kwargs: self.languageViewWidgetFactory(
                bone, languageWidgetFactory, **kwargs)

        widget = widgetFactory(self)
        widget.unserialize(value)
        return widget

    '''
	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)
Exemplo n.º 6
0
		if self.bone.readonly:
			self.verify = None
		else:
			# language=HTML
			self.appendChild("""
				<label class="label vi-label vi-label--password is-required">
					{{txt}}
				</label>
				<ignite-input [name]="verify" type="password">
			""",
			vars={"txt": translate("reenter password")})

			self.widget.element.autocomplete="new-password"

	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):
		return skelStructure[boneName]["type"] == "password" or skelStructure[boneName]["type"].startswith("password.")


boneSelector.insert(1, PasswordBone.checkFor, PasswordBone)
Exemplo n.º 7
0
        self.formatString = self.boneStructure["format"]
        self.destModule = self.boneStructure["module"]
        self.destInfo = conf["modules"].get(self.destModule)
        self.destStructure = self.boneStructure["relskel"]
        self.dataStructure = self.boneStructure["using"]

        print(self.destModule, self.destInfo)

    @staticmethod
    def checkFor(moduleName, boneName, skelStructure):
        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):
        return skelStructure[boneName]["type"] == "hierarchy" or skelStructure[
            boneName]["type"].startswith("hierarchy.")


boneSelector.insert(1, HierarchyBone.checkFor, HierarchyBone)
Exemplo n.º 8
0
        super().__init__(bone, **kwargs)
        self.language = language

    def unserialize(self, value=None):
        self.value = value

        if value:
            txt = utils.formatString(self.bone.boneStructure["format"],
                                     value,
                                     self.bone.boneStructure["using"],
                                     language=self.language)

        else:
            txt = None

        self.appendChild(html5.TextNode(txt or conf["emptyValue"]),
                         replace=True)


class RecordBone(BaseBone):
    editWidgetFactory = RecordEditWidget
    viewWidgetFactory = RecordViewWidget

    @staticmethod
    def checkFor(moduleName, boneName, skelStructure):
        return skelStructure[boneName]["type"] == "record" or skelStructure[
            boneName]["type"].startswith("record.")


boneSelector.insert(1, RecordBone.checkFor, RecordBone)
Exemplo n.º 9
0
    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):
        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):
        return (skelStructure[boneName]["type"] == "select" or skelStructure[boneName]["type"].startswith("select.")) \
          and not skelStructure[boneName].get("multiple")


boneSelector.insert(1, SelectSingleBone.checkFor, SelectSingleBone)
Exemplo n.º 10
0
# -*- coding: utf-8 -*-
from vi.priorityqueue import boneSelector
from vi.bones.base import BaseBone, BaseEditWidget, BaseViewWidget


class SpatialEditWidget(BaseEditWidget):
    def createWidget(self):
        # language=HTML
        return self.fromHTML("""
			<ignite-input [name]="latitude" type="number" placeholder="latitude" step="any">
			<ignite-input [name]="longitude" type="number" placeholer="longitute" step="any">
			""")

    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):
        return skelStructure[boneName]["type"] == "spatial" or skelStructure[
            boneName]["type"].startswith("spatial.")


boneSelector.insert(1, SpatialBone.checkFor, SpatialBone)
Exemplo n.º 11
0
        self.widget["value"] = html5.utils.unescape(str(
            value or ""))  # fixme: is html5.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 html5.utils.unescape() is the only difference.

    def unserialize(self, value=None):
        self.value = value
        self.appendChild(html5.TextNode(
            html5.utils.unescape(value or conf["emptyValue"])),
                         replace=True)


class StringBone(BaseBone):
    editWidgetFactory = StringEditWidget
    viewWidgetFactory = StringViewWidget

    @staticmethod
    def checkFor(moduleName, boneName, skelStructure):
        return skelStructure[boneName]["type"] == "str" or skelStructure[
            boneName]["type"].startswith("str.")


boneSelector.insert(1, StringBone.checkFor, StringBone)
Exemplo n.º 12
0
    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):
        return skelStructure[boneName]["type"] == "color" or skelStructure[
            boneName]["type"].startswith("color.")


boneSelector.insert(1, ColorBone.checkFor, ColorBone)
Exemplo n.º 13
0
    style = ["vi-value", "vi-value--email"]

    def _updateWidget(self):
        self.widget["type"] = "email"


class EmailViewWidget(BaseViewWidget):
    def unserialize(self, value=None):
        self.value = value

        if value:
            # language=HTML
            self.appendChild("""<a href="mailto:{{value}}">{{value}}</a>""",
                             value=value,
                             replace=True)
        else:
            self.appendChild(conf["emptyValue"], replace=True)


class EmailBone(BaseBone):
    editWidgetFactory = EmailEditWidget
    viewWidgetFactory = EmailViewWidget

    @staticmethod
    def checkFor(moduleName, boneName, skelStructure):
        return skelStructure[boneName]["type"] == "str.email" or skelStructure[
            boneName]["type"].startswith("str.email.")


boneSelector.insert(2, EmailBone.checkFor, EmailBone)