Beispiel #1
0
    def render(self, data, field):
        if field in data.keys():
            result = html5.Ul()
            options = {k: v for k, v in self.skelStructure[field]["values"]}

            for i, fieldKey in enumerate(data[field]):
                if conf["maxMultiBoneEntries"] and i + 1 > conf[
                        "maxMultiBoneEntries"]:
                    ali = html5.Li()
                    ali.appendChild(
                        html5.TextNode(
                            translate("and {count} more",
                                      count=len(data[field]) -
                                      conf["maxMultiBoneEntries"])))
                    ali["class"].append("selectmulti_more_li")

                    result.appendChild(ali)
                    break

                ali = html5.Li()
                ali.appendChild(html5.TextNode(options.get(fieldKey,
                                                           fieldKey)))
                ali["Title"] = fieldKey

                result.appendChild(ali)

            return result

        return html5.Label(conf["empty_value"])
Beispiel #2
0
	def __init__(self, modul, structure, item, *args, **kwargs):
		super( InternalPreview, self ).__init__( *args, **kwargs )

		self["class"].append("internalpreview")

		tmpDict = {key: bone for key, bone in structure}

		for key, bone in structure:
			if "params" in bone.keys() and bone[ "params" ] \
					and "previewBone" in bone[ "params" ].keys() \
						and bone[ "params" ][ "previewBone" ] == False:
				continue

			self.ali= html5.Li()
			self.ali["class"]=[ modul,"type_"+bone["type"],"bone_"+key]
			self.adl= html5.Dl()

			self.adt=html5.Dt()
			self.adt.appendChild(html5.TextNode(key if conf["showBoneNames"] else bone.get("descr", key)))

			self.aadd=html5.Dd()
			delegateFactory = viewDelegateSelector.select( modul, key, tmpDict )( modul, key, tmpDict )
			self.aadd.appendChild(delegateFactory.render( item, key ))

			self.adl.appendChild(self.adt)
			self.adl.appendChild(self.aadd)
			self.ali.appendChild(self.adl)

			self.appendChild(self.ali)
Beispiel #3
0
	def __init__(self, listWdg, *args, **kwargs):
		if not listWdg._structure:
			return

		super( SelectFieldsPopup, self ).__init__( title=translate("Select fields"), *args, **kwargs )

		self["class"].append("selectfields")
		self.listWdg = listWdg
		self.checkboxes = []

		ul = html5.Ul()
		self.appendChild( ul )

		for key, bone in self.listWdg._structure:
			li = html5.Li()
			ul.appendChild( li )

			chkBox = html5.Input()
			chkBox["type"] = "checkbox"
			chkBox["value"] = key

			li.appendChild(chkBox)
			self.checkboxes.append( chkBox )

			if key in self.listWdg.getFields():
				chkBox["checked"] = True
			lbl = html5.Label(bone["descr"],forElem=chkBox)
			li.appendChild(lbl)

		# Functions for Selection
		div = html5.Div()
		div[ "class" ].append( "selectiontools" )

		self.appendChild( div )

		self.selectAllBtn =  html5.ext.Button( translate( "Select all" ), callback=self.doSelectAll )
		self.selectAllBtn[ "class" ].append( "icon" )
		self.selectAllBtn[ "class" ].append( "selectall" )
		self.unselectAllBtn =  html5.ext.Button( translate( "Unselect all" ), callback=self.doUnselectAll )
		self.unselectAllBtn[ "class" ].append( "icon" )
		self.unselectAllBtn[ "class" ].append( "unselectall" )
		self.invertSelectionBtn =  html5.ext.Button( translate( "Invert selection" ), callback=self.doInvertSelection )
		self.invertSelectionBtn[ "class" ].append( "icon" )
		self.invertSelectionBtn[ "class" ].append( "selectinvert" )

		div.appendChild(self.selectAllBtn)
		div.appendChild(self.unselectAllBtn)
		div.appendChild(self.invertSelectionBtn)

		# Function for Commit
		self.cancelBtn = html5.ext.Button( translate( "Cancel" ), callback=self.doCancel)
		self.cancelBtn["class"].append("btn_no")

		self.applyBtn = html5.ext.Button( translate( "Apply" ), callback=self.doApply)
		self.applyBtn["class"].append("btn_yes")

		self.appendChild(self.applyBtn)
		self.appendChild(self.cancelBtn)
Beispiel #4
0
    def log(self, type, msg):
        """
			Adds a message to the log
			:param type: The type of the message.
			:type type: "success", "error", "warning", "info", "progress"
			:param msg: The message to append
			:type msg: str
		"""
        assert type in ["success", "error", "warning", "info", "progress"]

        liwrap = html5.Li()
        liwrap["class"].append("log_" + type)
        liwrap["class"].append("is_new")

        spanDate = html5.Span()
        spanDate.appendChild(
            html5.TextNode(datetime.now().strftime("%H:%M:%S")))
        spanDate["class"].append("date")
        liwrap.appendChild(spanDate)

        if isinstance(msg, html5.Widget):
            #Append that widget directly
            liwrap.appendChild(msg)

        else:
            #Create a span element for that message
            spanMsg = html5.Span()
            spanMsg.appendChild(html5.TextNode(html5.utils.unescape(msg)))
            spanMsg["class"].append("msg")
            liwrap.appendChild(spanMsg)

        DeferredCall(self.removeNewCls, liwrap, _delay=2500)
        self.logUL.appendChild(liwrap)

        if len(self.logUL._children) > 1:
            self.logUL.element.removeChild(liwrap.element)
            self.logUL.element.insertBefore(
                liwrap.element, self.logUL.element.children.item(0))
Beispiel #5
0
    def __init__(self, moduleName, boneName, readOnly, values, *args,
                 **kwargs):
        super(AccessMultiSelectBone, self).__init__(*args, **kwargs)
        self.boneName = boneName
        self.moduleName = moduleName
        self.readOnly = readOnly
        print(values)
        self.values = {k: v for k, v in values}

        self.modules = {}
        self.modulesbox = {}
        self.flags = {}

        self.sinkEvent("onClick")

        for value in self.values:
            module = self.parseskelaccess(value)

            if not module:
                self.flags[value] = None
            elif not module[0] in self.modules.keys():
                self.modules[module[0]] = {}

        # Render static / singleton flags first
        for flag in sorted(self.flags.keys()):
            label = html5.Label()

            checkbox = html5.Input()
            checkbox["type"] = "checkbox"
            checkbox["name"] = flag
            label.appendChild(checkbox)

            self.flags[flag] = checkbox

            span = html5.Span()
            span.appendChild(html5.TextNode(flag))
            label.appendChild(span)

            self.appendChild(label)

        # Render module access flags then
        for module in sorted(self.modules.keys()):
            label = html5.Label()

            span = html5.Span()
            span.appendChild(html5.TextNode(module))
            label.appendChild(span)

            ul = html5.Ul()

            checkbox = html5.Input()
            checkbox["type"] = "checkbox"
            checkbox["name"] = module
            self.modulesbox[module] = checkbox

            li = html5.Li()
            li.appendChild(checkbox)
            ul.appendChild(li)

            for state in self.states:
                li = html5.Li()
                li["class"] = ["access-state", state]

                # Some modules may not support all states
                if ("%s-%s" % (module, state)) not in self.values:
                    li["class"].append("disabled")

                ul.appendChild(li)

                self.modules[module][state] = li

            label.appendChild(ul)

            self.appendChild(label)