Example #1
0
    def setPayedSucceeded(self, response):
        self.done += 1

        if self.done + self.failed == self.total:
            conf["mainWindow"].log("success",
                                   translate(self.txtSuccess, count=self.done))
            NetworkService.notifyChange(self.parent().parent().module)
Example #2
0
    def setPageAmount(self):
        self.addClass("is-loading")
        currentModule = self.parent().parent()

        amount = int(self.pages["options"].item(
            self.pages["selectedIndex"]).value)
        currentModule.setAmount(amount)
        NetworkService.notifyChange(currentModule.module)
Example #3
0
 def fetchSucceeded(self, req):
     if self.pendingFetches:
         self.fetchNext()
     else:
         conf["mainWindow"].log("success", "Done :)")
         from vi.network import NetworkService  # Circular import otherwise
         self.removeClass("is-loading")
         NetworkService.notifyChange(self.parent().parent().module)
Example #4
0
	def onSuccess(self, *args, **kwargs):
		"""
			Internal callback - The upload succeeded.
		"""
		if isinstance(self.responseValue["values"], list):
			for v in self.responseValue["values"]:
				self.uploadSuccess.fire(self, v)

		else:
			self.uploadSuccess.fire(self, self.responseValue["values"])

		NetworkService.notifyChange("file")
		self.replaceWithMessage("Upload complete", isSuccess=True)
Example #5
0
	def closeOrContinue(self, sender=None ):
		NetworkService.notifyChange(self.module, key=self.key, action=self.mode)

		if self.closeOnSuccess:
			if self.module == "_tasks":
				self.parent().close()
				return

			conf["mainWindow"].removeWidget(self)
			return

		self.clear()
		self.bones = {}

		if self.mode == "add":
			self.key = 0

		self.reloadData()
Example #6
0
 def onClick(self, sender=None):
     self.addClass("is-loading")
     NetworkService.notifyChange(self.parent().parent().module)
Example #7
0
    def setData(self, request=None, data=None, ignoreMissing=False):
        """
		Rebuilds the UI according to the skeleton received from server

		:param request: A finished NetworkService request
		:type request: NetworkService
		:type data: dict
		:param data: The data received
		"""
        assert (request or data)
        if request:
            data = NetworkService.decode(request)

        try:
            skelStructure = {k: v for k, v in data["structure"]}

        except AttributeError:
            NetworkService.notifyChange(self.module)
            conf["mainWindow"].removeWidget(self)
            return

        print
        print("data", data)
        print("action", data["action"])
        if "action" in data and (data["action"]
                                 in ["addSuccess", "editSuccess"]):
            NetworkService.notifyChange(self.module)
            logDiv = html5.Div()
            logDiv["class"].append("msg")
            spanMsg = html5.Span()
            spanMsg.appendChild(html5.TextNode(translate("Entry saved!")))
            spanMsg["class"].append("msgspan")
            logDiv.appendChild(spanMsg)
            if self.module in conf["modules"].keys():
                spanMsg = html5.Span()
                spanMsg.appendChild(
                    html5.TextNode(conf["modules"][self.module]["name"]))
                spanMsg["class"].append("modulspan")
                logDiv.appendChild(spanMsg)
            if "values" in data.keys() and "name" in data["values"].keys():
                spanMsg = html5.Span()
                spanMsg.appendChild(html5.TextNode(str(
                    data["values"]["name"])))
                spanMsg["class"].append("namespan")
                logDiv.appendChild(spanMsg)
            conf["mainWindow"].log("success", logDiv)
            if self.closeOnSuccess:
                conf["mainWindow"].removeWidget(self)
                return
            self.clear()
            # self.bones = {}
            self.reloadData()
            return

        self.clear()
        self.actionbar.resetLoadingState()
        self.dataCache = data

        fieldSets = {}
        cat = "byweek"

        fieldSets[cat] = EditWidgetFieldset(cat)
        fieldSets[cat].addClass("active")

        self.dtstart = data["values"]["startdate"]
        startdateLabel = html5.Label("Termin")
        startdateLabel["class"].append("termin")
        startdateLabel["class"].append("date")
        startdate_id = "vi_%s_%s_edit_bn_%s" % (self.editIdx, self.module,
                                                "repeatdate")
        startdateLabel["for"] = startdate_id
        startdate = date.DateViewBoneDelegate("termin", "startdate",
                                              skelStructure).render(
                                                  data["values"], "startdate")
        startdate["id"] = startdate_id
        containerDiv = html5.Div()
        containerDiv.appendChild(startdateLabel)
        containerDiv.appendChild(startdate)
        containerDiv["class"].append("bone")
        containerDiv["class"].append("bone_startdate")
        containerDiv["class"].append("date")
        fieldSets[cat]._section.appendChild(containerDiv)

        countLabel = html5.Label("Wiederholungen")
        countLabel["class"].append("count")
        countLabel["class"].append("numeric")
        count_id = "vi_%s_%s_edit_bn_%s" % (self.editIdx, self.module, "count")
        countLabel["for"] = count_id

        self.count = html5.Input()
        self.count["id"] = count_id
        containerDiv2 = html5.Div()
        containerDiv2["class"].append("bone")
        containerDiv2["class"].append("bone_count")
        containerDiv2["class"].append("date")
        containerDiv2.appendChild(countLabel)
        containerDiv2.appendChild(self.count)

        # containerDiv3 = html5.Div()
        # self.byweekday = list()
        # for key, value in [["MO", "Mo"], ["TU", "Di"], ["TH", "Mi"], ["WE", "Do"], ["FR", "Fr"], ["SA", "Sa"], ["SU", "So"]]:
        # 	alabel=html5.Label()
        # 	acheckbox=html5.Input()
        # 	acheckbox["type"]="checkbox"
        # 	acheckbox["name"]=key
        # 	alabel.appendChild(acheckbox)
        # 	aspan=html5.Span()
        # 	aspan.element.innerHTML=value
        # 	alabel.appendChild(aspan)
        # 	containerDiv3.appendChild(alabel)
        # 	containerDiv2["class"].append("bone")
        # 	containerDiv2["class"].append("bone_count")
        # 	containerDiv2["class"].append("byweekday")
        # 	self.byweekday.append(acheckbox)

        fieldSets[cat]._section.appendChild(containerDiv2)
        # fieldSets[ cat ]._section.appendChild(containerDiv3)
        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
Example #8
0
 def loadAllRows(self):
     NetworkService.notifyChange(self.parent().parent().module)