def __init__(self, inputId, *args, **kwargs): super().__init__(*args, **kwargs) self.holdactive = False self.currentSelection = None self.input = html5.Input() self.input.addClass("input ignt-input") self["style"]["position"] = "relative" self.appendChild(self.input) self._suggestionContainer = html5.Div() self._suggestionContainer["style"]["position"] = "absolute" self._suggestionContainer["style"]["background-color"] = "white" self._suggestionContainer["style"]["width"] = "100%" self._suggestionContainer.hide() self.suggestionList = html5.Ul() self.suggestionList.addClass("list") self._suggestionContainer.appendChild(self.suggestionList) self.moreEntries = Button(translate("mehr laden")) #self._suggestionContainer.appendChild(self.moreEntries) self.appendChild(self._suggestionContainer) DeferredCall(self.updateContainer, _delay=1) self.sinkEvent("onClick") self.sinkEvent("onFocusOut") self.sinkEvent("onInput")
def __init__(self): super(LogButton, self).__init__() self.logsList = [] self["class"] = ["popout-opener", "popout-anchor", "popout--sw"] self.logbtn = Button(icon="icons-time", className="btn btn--topbar btn--log") self.appendChild(self.logbtn) popout = html5.Div() popout["class"] = ["popout"] self.popoutlist = html5.Div() self.popoutlist["class"] = ["list"] popout.appendChild(self.popoutlist) self.appendChild(popout) self.sinkEvent("onClick") aitem = html5.Div() aitem["class"] = ["item", "has-hover", "item--small item--info"] listentry = logEntry({"msg": translate("Das Log ist Leer")}) aitem.appendChild(listentry) self.popoutlist.appendChild(aitem) #load old logs from idb idb = conf["indexeddb"] if "vi_log" not in idb.objectStoreNames: idb.dbAction("createStore", "vi_log", None, {"autoIncrement": True}) data = idb.getList("vi_log") data.addEventListener("dataready", self.idbdata)
def __init__(self, module, structure, item, *args, **kwargs): super(InternalPreview, self).__init__(*args, **kwargs) self.addClass("vi-sb-intprev box-body box--content") 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.ipli = html5.Li() self.ipli["class"] = [ "vi-sb-intprev-item", "vi-sb-intprev--" + module, "vi-sb-intprev--" + bone["type"], "vi-sb-intprev--" + key ] self.ipdl = html5.Dl() self.ipdl.addClass("vi-sb-intprev-content") self.ipdt = html5.Dt() self.ipdt.addClass("vi-sb-intprev-title") self.ipdt.appendChild( html5.TextNode( key if conf["showBoneNames"] else bone.get("descr", key))) self.ipdd = html5.Dd() self.ipdd.addClass("vi-sb-intprev-descr") boneFactory = boneSelector.select(module, key, tmpDict)(module, key, tmpDict) if key == "key": keydiv = html5.Div() keydiv["style"]["display"] = "inline-block" copybtn = Button("Copy", self.onCopyKey) keyvaluediv = boneFactory.viewWidget(item[key]) keyfield = html5.Input() keyfield["value"] = item[key] keyfield["style"]["opacity"] = 0 keyfield["style"]["position"] = "absolute" keyfield["id"] = "keyfield" keydiv.appendChild(keyfield, keyvaluediv, copybtn) self.ipdd.appendChild(keydiv) else: self.ipdd.appendChild(boneFactory.viewWidget(item[key])) self.ipdl.appendChild(self.ipdt) self.ipdl.appendChild(self.ipdd) self.ipli.appendChild(self.ipdl) self.appendChild(self.ipli)
def __init__(self, *args, **kwargs): super(PageFindAction, self).__init__() self["class"].append("input-group") self.searchInput = html5.Input() self.searchInput["class"].append("input ignt-input input--small") self.appendChild(self.searchInput) btn = Button(translate("Find on Page"), callback=self.onClick, icon="icons-search") btn["class"] = "bar-item btn btn--small btn--pagefind" self.appendChild(btn) self.sinkEvent("onKeyPress")
def __init__(self, *args, **kwargs): super(LoadNextBatchAction, self).__init__() self["class"].append("input-group bar-item") self.pages = html5.Select() self.pages["class"].append("select ignt-select select--small") for x in [1, 5, 10]: opt = html5.Option(x) opt["value"] = x self.pages.appendChild(opt) self.appendChild(self.pages) self.btn = Button(translate("load next pages"), callback=self.onClick) self.btn["class"] = "bar-item btn btn--small btn--loadnext" self.appendChild(self.btn) self.sinkEvent("onChange") self.currentLoadedPages = 0
def __init__(self, module, handler, actionName, *args, **kwargs): super(ListPreviewAction, self).__init__(*args, **kwargs) self.urls = conf["defaultPreview"] self.addClass("input-group") self.urlCb = html5.ignite.Select() self.appendChild(self.urlCb) btn = Button(translate("Preview"), callback=self.onClick, icon="icons-preview") btn["class"] = "bar-item btn btn--small btn--preview" self.appendChild(btn) self["disabled"] = True self.isDisabled = True
def __init__(self, *args, **kwargs): super(UserState, self).__init__(*args, **kwargs) self["class"] = ["popout-opener", "popout-anchor", "popout--sw"] self.btn = Button(icon="icons-user", className="btn btn--topbar btn--user") self.appendChild(self.btn) self.sinkEvent("onClick") popout = html5.Div() popout["class"] = ["popout"] self.popoutlist = html5.Div() self.popoutlist["class"] = ["list"] popout.appendChild(self.popoutlist) self.appendChild(popout) self.update()
def __init__(self, *args, **kwargs): super(SetPageRowAmountAction, self).__init__() self["class"].append("input-group") self.pages = html5.Select() self.pages["class"].append("select ignt-select select--small") defaultSizes = [5, 10, 25, 50, 75, 99] if not conf["batchSize"] in defaultSizes: defaultSizes.insert(0, conf["batchSize"]) for x in defaultSizes: opt = html5.Option(x) opt["value"] = x self.pages.appendChild(opt) self.appendChild(self.pages) self.btn = Button(translate("amount"), callback=self.onClick) self.btn["class"] = "bar-item btn btn--small btn--amount" self.appendChild(self.btn) self.sinkEvent("onChange") self.currentLoadedPages = 0
def __init__(self, bone, widgetFactory: callable, **kwargs): # language=HTML super().__init__(""" <div [name]="widgets" class="vi-bone-widgets"></div> <div [name]="actions" class="vi-bone-actions input-group"></div> """) languages = bone.skelStructure[bone.boneName]["languages"] assert languages, "This parameter must not be empty!" self.bone = bone self.languages = languages self._languageWidgets = {} # Create widget for every language for lang in self.languages: assert not any([ch in lang for ch in "<>\"'/" ]), "This is not a valid language identifier!" langBtn = Button(lang, callback=self.onLangBtnClick) langBtn.addClass("btn--lang", "btn--lang-" + lang) if lang == conf["defaultLanguage"]: langBtn.addClass("is-active") self.actions.appendChild(langBtn) kwargs["language"] = lang langWidget = widgetFactory(self.bone, **kwargs) if lang != conf["defaultLanguage"]: langWidget.hide() self.widgets.appendChild(langWidget) self._languageWidgets[lang] = (langBtn, langWidget)
class AutocompleteList(html5.Div): def __init__(self, inputId, *args, **kwargs): super().__init__(*args, **kwargs) self.holdactive = False self.currentSelection = None self.input = html5.Input() self.input.addClass("input ignt-input") self["style"]["position"] = "relative" self.appendChild(self.input) self._suggestionContainer = html5.Div() self._suggestionContainer["style"]["position"] = "absolute" self._suggestionContainer["style"]["background-color"] = "white" self._suggestionContainer["style"]["width"] = "100%" self._suggestionContainer.hide() self.suggestionList = html5.Ul() self.suggestionList.addClass("list") self._suggestionContainer.appendChild(self.suggestionList) self.moreEntries = Button(translate("mehr laden")) #self._suggestionContainer.appendChild(self.moreEntries) self.appendChild(self._suggestionContainer) DeferredCall(self.updateContainer, _delay=1) self.sinkEvent("onClick") self.sinkEvent("onFocusOut") self.sinkEvent("onInput") def onInput(self, event): self.currentSelection = None self.holdactive = True self._suggestionContainer.show() val = self.input["value"] self._dataProvider.setFilter({"search": val}) self.loadData() if not val: self.holdactive = False self._dataProvider.selectionupdate() def setDataProvider(self, obj): assert obj == None or "onNextBatchNeeded" in dir( obj ), \ "The dataProvider must provide a 'onNextBatchNeeded' function" self._dataProvider = obj self.loadData() def loadData(self): if not self._dataProvider: self.emptyList() return 0 self._dataProvider.onNextBatchNeeded() def emptyList(self): self.moreEntries.hide() self.clearSuggestionList() emptyMessage = html5.Li() emptyMessage.addClass("item has-hover item--small") emptyMessage["data"]["value"] = None emptyMessage.appendChild(html5.TextNode(translate("No Item"))) self.suggestionList.appendChild(emptyMessage) def clearSuggestionList(self): self.suggestionList.removeAllChildren() def appendListItem(self, item): self.moreEntries.show() self.suggestionList.appendChild(item) def updateContainer(self): #inputPos = self.input.element.getBoundingClientRect() #self._suggestionContainer[ "style" ][ "width" ] = "%spx" % (inputPos.right - inputPos.left) self._suggestionContainer["style"]["z-index"] = 9999 self._suggestionContainer["style"][ "box-shadow"] = "0 2px 2px 0 rgba(0, 0, 0, 0.14), 0 3px 1px -2px rgba(0, 0, 0, 0.12), 0 1px 5px 0 rgba(0, 0, 0, 0.2)" self._suggestionContainer["style"]["max-height"] = "255px" self._suggestionContainer["style"]["overflow-y"] = "auto" self._suggestionContainer["style"]["overflow"] = "hidden" def setSelection(self, targetElement): entry = [ x for x in self.suggestionList.children() if x.element == targetElement ] if entry: entry = entry[0] else: self.currentSelection = None return 0 if not entry["data"]["value"]: self.currentSelection = None return 0 data = self._dataProvider.dataList[entry["data"]["value"]] self.input["value"] = entry.element.innerHTML self.currentSelection = data self._dataProvider.selectionupdate() def disableSuggestion(self, force=False): if not self.holdactive or force: self._suggestionContainer.hide() def onFocusOut(self, event): DeferredCall(self.disableSuggestion, _delay=200) DeferredCall(self.disableSuggestion, force=True, _delay=10000) def onClick(self, event): if event.target == self.input.element: #click on Input self._suggestionContainer.show() self.holdactive = False elif event.target.parentElement == self.suggestionList.element: #selected list self.setSelection(event.target) self.disableSuggestion() self.holdactive = False elif event.target in [self.suggestionList.element,self.element,self._suggestionContainer.element] or \ event.target.parentElement in [self.suggestionList.element,self.element,self._suggestionContainer.element]: self.holdactive = True else: self.holdactive = False
def __init__(self, widget, *args, **kwargs): super(ExportCsvStarter, self).__init__(title=translate("CSV Export")) self.widget = widget if "viur.defaultlangsvalues" in conf["server"].keys(): self.langSelect = html5.Select() self.langSelect.addClass("select") self.langSelect["id"] = "lang-select" lbl = html5.Label(translate("Language selection")) lbl.addClass("label") lbl["for"] = "lang-select" div = html5.Div() div.appendChild(lbl) div.appendChild(self.langSelect) div.addClass("input-group") self.popupBody.appendChild(div) for key, value in conf["server"]["viur.defaultlangsvalues"].items( ): opt = html5.Option() opt["value"] = key opt.appendChild(html5.TextNode(value)) if key == conf["currentLanguage"]: opt["selected"] = True self.langSelect.appendChild(opt) else: self.langSelect = None # Encoding self.encodingSelect = html5.Select() self.encodingSelect.addClass("select") self.encodingSelect["id"] = "encoding-select" lbl = html5.Label(translate("Encoding")) lbl.addClass("label") lbl["for"] = "encoding-select" div = html5.Div() div.appendChild(lbl) div.appendChild(self.encodingSelect) div.addClass("input-group") self.popupBody.appendChild(div) for i, (k, v) in enumerate([("iso-8859-15", "ISO-8859-15"), ("utf-8", "UTF-8")]): opt = html5.Option() opt["value"] = k if i == 0: opt["selected"] = True opt.appendChild(html5.TextNode(v)) self.encodingSelect.appendChild(opt) self.cancelBtn = Button(translate("Cancel"), self.close, icon="icons-cancel") self.popupFoot.appendChild(self.cancelBtn) self.exportBtn = Button(translate("Export"), self.onExportBtnClick, icon="icons-download-file") self.exportBtn.addClass("btn--edit") self.popupFoot.appendChild(self.exportBtn)
def __init__(self, listWdg, *args, **kwargs): if not listWdg._structure: return super(SelectFieldsPopup, self).__init__(title=translate("Select fields"), *args, **kwargs) self.removeClass("popup--center") self.addClass("popup--n popup--selectfields") self.listWdg = listWdg self.checkboxes = [] ul = html5.Ul() ul.addClass("option-group") self.popupBody.appendChild(ul) for key, bone in self.listWdg._structure: li = html5.Li() li.addClass("check") ul.appendChild(li) chkBox = html5.Input() chkBox.addClass("check-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) lbl.addClass("check-label") li.appendChild(lbl) # Functions for Selection div = html5.Div() div["class"].append("selectiontools input-group") self.popupBody.appendChild(div) self.selectAllBtn = Button(translate("Select all"), callback=self.doSelectAll) self.selectAllBtn["class"].append("btn--selectall") self.unselectAllBtn = Button(translate("Unselect all"), callback=self.doUnselectAll) self.unselectAllBtn["class"].append("btn--unselectall") self.invertSelectionBtn = Button(translate("Invert selection"), callback=self.doInvertSelection) self.invertSelectionBtn["class"].append("btn--selectinvert") div.appendChild(self.selectAllBtn) div.appendChild(self.unselectAllBtn) div.appendChild(self.invertSelectionBtn) # Function for Commit self.cancelBtn = Button(translate("Cancel"), callback=self.doCancel) self.cancelBtn.addClass("btn btn--danger") self.applyBtn = Button(translate("Apply"), callback=self.doApply) self.applyBtn.addClass("btn btn--primary") self.popupFoot.appendChild(self.cancelBtn) self.popupFoot.appendChild(self.applyBtn)
class SelectFieldsPopup(html5.ext.Popup): def __init__(self, listWdg, *args, **kwargs): if not listWdg._structure: return super(SelectFieldsPopup, self).__init__(title=translate("Select fields"), *args, **kwargs) self.removeClass("popup--center") self.addClass("popup--n popup--selectfields") self.listWdg = listWdg self.checkboxes = [] ul = html5.Ul() ul.addClass("option-group") self.popupBody.appendChild(ul) for key, bone in self.listWdg._structure: li = html5.Li() li.addClass("check") ul.appendChild(li) chkBox = html5.Input() chkBox.addClass("check-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) lbl.addClass("check-label") li.appendChild(lbl) # Functions for Selection div = html5.Div() div["class"].append("selectiontools input-group") self.popupBody.appendChild(div) self.selectAllBtn = Button(translate("Select all"), callback=self.doSelectAll) self.selectAllBtn["class"].append("btn--selectall") self.unselectAllBtn = Button(translate("Unselect all"), callback=self.doUnselectAll) self.unselectAllBtn["class"].append("btn--unselectall") self.invertSelectionBtn = Button(translate("Invert selection"), callback=self.doInvertSelection) self.invertSelectionBtn["class"].append("btn--selectinvert") div.appendChild(self.selectAllBtn) div.appendChild(self.unselectAllBtn) div.appendChild(self.invertSelectionBtn) # Function for Commit self.cancelBtn = Button(translate("Cancel"), callback=self.doCancel) self.cancelBtn.addClass("btn btn--danger") self.applyBtn = Button(translate("Apply"), callback=self.doApply) self.applyBtn.addClass("btn btn--primary") self.popupFoot.appendChild(self.cancelBtn) self.popupFoot.appendChild(self.applyBtn) def doApply(self, *args, **kwargs): self.applyBtn.addClass("is-loading") self.applyBtn["icon"] = "icons-loader" self.applyBtn["disabled"] = True res = [] for c in self.checkboxes: if c["checked"]: res.append(c["value"]) if not res: html5.ext.Alert( translate("You have to select at least on field to continue!")) return self.applyBtn["class"].append("is_loading") self.applyBtn["disabled"] = True DeferredCall(self.listWdg.setFields, res, _delay=100, _callback=self.doSetFields) #self.listWdg.setFields( res ) #self.applyBtn.resetIcon() #self.close() def doSetFields(self, *args, **kwargs): self.applyBtn.resetIcon() self.close() def doCancel(self, *args, **kwargs): self.close() def doSelectAll(self, *args, **kwargs): for cb in self.checkboxes: if cb["checked"] == False: cb["checked"] = True def doUnselectAll(self, *args, **kwargs): for cb in self.checkboxes: if cb["checked"] == True: cb["checked"] = False def doInvertSelection(self, *args, **kwargs): for cb in self.checkboxes: if cb["checked"] == False: cb["checked"] = True else: cb["checked"] = False