Пример #1
0
    def __init__(self, loginScreen, *args, **kwargs):
        super(UserPasswordLoginHandler, self).__init__(loginScreen, *args,
                                                       **kwargs)

        # Standard Login Form
        self.pwform = html5.Form()
        self.mask.appendChild(self.pwform)

        self.username = LoginInputField(self)
        self.username["name"] = "username"
        self.username["placeholder"] = translate("Username")
        self.pwform.appendChild(self.username)

        self.password = LoginInputField(self)
        self.password["type"] = "password"
        self.password["name"] = "password"
        self.password["placeholder"] = translate("Password")
        self.pwform.appendChild(self.password)

        self.loginBtn = html5.ext.Button(translate("Login"),
                                         callback=self.onLoginClick)
        self.loginBtn.addClass("vi-login-btn")
        self.pwform.appendChild(self.loginBtn)

        # One Time Password
        self.otpform = html5.Form()
        self.otpform.hide()
        self.mask.appendChild(self.otpform)

        self.otp = LoginInputField(self)
        self.otp["name"] = "otp"
        self.otp["placeholder"] = translate("One Time Password")
        self.otpform.appendChild(self.otp)

        self.verifyBtn = html5.ext.Button(translate("Verify"),
                                          callback=self.onVerifyClick)
        self.otpform.appendChild(self.verifyBtn)

        # Universal edit widget
        self.editform = html5.Div()
        self.editform.hide()
        self.mask.appendChild(self.editform)

        self.edit = html5.Div()
        self.editform.appendChild(self.edit)

        self.editskey = self.editaction = self.editwidget = None

        self.sendBtn = html5.ext.Button(translate("Send"),
                                        callback=self.onSendClick)
        self.editform.appendChild(self.sendBtn)
Пример #2
0
	def __init__(self, modul, key):
		super(RepeatDatePopup, self).__init__()
		self.module = modul
		self.editIdx = RepeatDatePopup.__editIdx_ #Iternal counter to ensure unique ids
		RepeatDatePopup.__editIdx_ += 1
		self.key = key
		self._lastData = {} #Dict of structure and values received
		self.closeOnSuccess = False

		h3 = html5.H3()
		h3["class"].append("modul_%s" % self.module)
		h3["class"].append("apptype_list")

		h3.appendChild(html5.TextNode(translate("create recurrent dates")))

		self.wasInitialRequest = True
		self.actionbar = ActionBar( self.module, "list", "repeatdate")
		self.appendChild( self.actionbar )
		self.form = html5.Form()
		self.appendChild(self.form)
		self.actionbar.setActions(["create.recurrent"])
		self.reloadData()
Пример #3
0
	def renderStructure(self, readOnly = False):
		self.bones = {}
		self.containers = {}

		tmpDict = {k: v for k, v in self.skelStructure}
		fieldSets = {}
		currRow = 0

		defaultCat = self.defaultCat
		firstCat = True

		for key, bone in self.skelStructure:

			#Enforcing readOnly mode
			if readOnly:
				tmpDict[key]["readonly"] = True

			cat = defaultCat

			if ("params" in bone.keys()
			    and isinstance(bone["params"],dict)
			    and "category" in bone["params"].keys()):
				cat = bone["params"]["category"]

			if cat is not None and not cat in fieldSets.keys():
				fs = html5.Fieldset()
				fs["class"] = cat

				if firstCat:
					fs["class"].append("active")
					firstCat = False

					if self.form is self:
						self.form = html5.Form()
						self.appendChild(self.form)

				fieldSets[cat] = EditWidgetFieldset(cat)

			wdgGen = editBoneSelector.select(self.module, key, tmpDict)
			widget = wdgGen.fromSkelStructure(self.module, key, tmpDict)
			widget["id"] = "vi_%s_%s_%s_%s_bn_%s" % (self.editIdx, None, "internal", cat or "empty", key)

			descrLbl = html5.Label(bone["descr"])
			descrLbl["class"].append(key)
			descrLbl["class"].append(bone["type"].replace(".","_"))
			descrLbl["for"] = "vi_%s_%s_%s_%s_bn_%s" % ( self.editIdx, None, "internal", cat or "empty", key)

			if bone["required"]:
				descrLbl["class"].append("is_required")

			if (bone["required"]
			    and (bone["error"] is not None
			            or (self.errorInformation and key in self.errorInformation.keys()))):
				descrLbl["class"].append("is_invalid")
				if bone["error"]:
					descrLbl["title"] = bone["error"]
				else:
					descrLbl["title"] = self.errorInformation[ key ]

				if fieldSets and cat in fieldSets:
					fieldSets[cat]["class"].append("is_incomplete")

			if bone["required"] and not (bone["error"] is not None or (self.errorInformation and key in self.errorInformation.keys())):
				descrLbl["class"].append("is_valid")

			if "params" in bone.keys() and isinstance(bone["params"], dict) and "tooltip" in bone["params"].keys():
				tmp = html5.Span()
				tmp.appendChild(descrLbl)
				tmp.appendChild( ToolTip(longText=bone["params"]["tooltip"]) )
				descrLbl = tmp

			self.containers[key] = html5.Div()
			self.containers[key].appendChild(descrLbl)
			self.containers[key].appendChild(widget)
			self.containers[key].addClass("bone", "bone_%s" % key, bone["type"].replace(".","_"))

			if "." in bone["type"]:
				for t in bone["type"].split("."):
					self.containers[key].addClass(t)

			if cat is not None:
				fieldSets[cat]._section.appendChild(self.containers[key])
			else:
				self.form.appendChild(self.containers[key])

			currRow += 1
			self.bones[key] = widget

			#Hide invisible bones
			if not bone["visible"]:
				self.containers[key].hide()

		if len(fieldSets)==1:
			for (k,v) in fieldSets.items():
				if not "active" in v["class"]:
					v["class"].append("active")

		tmpList = [(k,v) for (k,v) in fieldSets.items()]
		tmpList.sort( key=lambda x:x[0])

		for k,v in tmpList:
			self.form.appendChild( v )
			v._section = None
Пример #4
0
	def __init__(self, module, applicationType, key=0, node=None, skelType=None, clone=False,
	                hashArgs=None, context=None, logaction = "Entry saved!", *args, **kwargs):
		"""
			Initialize a new Edit or Add-Widget for the given module.
			:param module: Name of the module
			:type module: str
			:param applicationType: Defines for what application this Add / Edit should be created. This hides additional complexity introduced by the hierarchy / tree-application
			:type applicationType: Any of EditWidget.appList, EditWidget.appHierarchy, EditWidget.appTree or EditWidget.appSingleton
			:param id: ID of the entry. If none, it will add a new Entry.
			:type id: Number
			:param rootNode: If applicationType==EditWidget.appHierarchy, the new entry will be added under this node, if applicationType==EditWidget,appTree the final node is derived from this and the path-parameter.
			Has no effect if applicationType is not appHierarchy or appTree or if an id have been set.
			:type rootNode: str
			:param path: Specifies the path from the rootNode for new entries in a treeApplication
			:type path: str
			:param clone: If true, it will load the values from the given id, but will save a new entry (i.e. allows "cloning" an existing entry)
			:type clone: bool
			:param hashArgs: Dictionary of parameters (usually supplied by the window.hash property) which should prefill values.
			:type hashArgs: dict
		"""
		if not module in conf["modules"].keys():
			conf["mainWindow"].log("error", translate("The module '{module}' does not exist.", module=module))
			assert module in conf["modules"].keys()

		super(EditWidget, self ).__init__(*args, **kwargs)
		self.module = module

		# A Bunch of santy-checks, as there is a great chance to mess around with this widget
		assert applicationType in [ EditWidget.appList, EditWidget.appHierarchy, EditWidget.appTree, EditWidget.appSingleton ] #Invalid Application-Type?

		if applicationType==EditWidget.appHierarchy or applicationType==EditWidget.appTree:
			assert key is not None or node is not None #Need either an id or an node

		if clone:
			assert key is not None #Need an id if we should clone an entry
			assert not applicationType==EditWidget.appSingleton # We cant clone a singleton
			if applicationType==EditWidget.appHierarchy or applicationType==EditWidget.appTree:
				assert node is not None #We still need a rootNode for cloning
			if applicationType==EditWidget.appTree:
				assert node is not None #We still need a path for cloning #FIXME

			self.clone_of = key
		else:
			self.clone_of = None

		# End santy-checks
		self.editIdx = EditWidget.__editIdx_ #Internal counter to ensure unique ids
		EditWidget.__editIdx_ += 1
		self.applicationType = applicationType
		self.key = key
		self.mode = "edit" if self.key or applicationType == EditWidget.appSingleton else "add"
		self.modified = False
		self.node = node
		self.skelType = skelType
		self.clone = clone
		self.bones = {}
		self.closeOnSuccess = False
		self.logaction = logaction
		self.sinkEvent("onChange")

		self.context = context
		self.views = {}

		self._lastData = {} #Dict of structure and values received

		if hashArgs:
			self._hashArgs = parseHashParameters(hashArgs)
		else:
			self._hashArgs = None

		self.editTaskID = None
		self.wasInitialRequest = True #Wherever the last request attempted to save data or just fetched the form

		# Action bar
		self.actionbar = ActionBar(self.module, self.applicationType, (self.mode if not clone else "clone"))
		self.appendChild(self.actionbar)

		editActions = []

		if self.mode == "edit":
			editActions.append("refresh")

		if module in conf["modules"] and conf["modules"][module]:
			editActions.extend(conf["modules"][module].get("editActions", []))

		if applicationType == EditWidget.appSingleton:
			self.actionbar.setActions(["save.singleton"] + editActions)
		else:
			self.actionbar.setActions(["save.close", "save.continue"] + editActions)

		# Set path
		if applicationType == EditWidget.appSingleton:
			conf["theApp"].setPath(module + "/" + self.mode)
		elif self.mode == "edit":
			conf["theApp"].setPath(module + "/" + (self.mode if not clone else "clone") + "/" + self.key)
		else:
			conf["theApp"].setPath(module + "/" + self.mode)

		# Input form
		self.form = html5.Form()
		self.appendChild(self.form)

		# Engage
		self.reloadData()