Skip to content

Commit

Permalink
Merge branch 'feature/viurDepends' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
phorward committed May 30, 2017
2 parents faacd4e + 6218b96 commit 849f6f1
Show file tree
Hide file tree
Showing 32 changed files with 592 additions and 269 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Expand Up @@ -7,6 +7,10 @@ public/vi.css
output
.idea
*.bak
*.pyc
*.iml
public/vi_custom.less

pynetree/.hg
pynetree/.hgignore

3 changes: 3 additions & 0 deletions .gitmodules
@@ -1,6 +1,9 @@
[submodule "public/icons"]
path = public/icons
url = https://bitbucket.org/viur/icons.git
[submodule "logics"]
path = logics
url = git@bitbucket.org:viur/logics.git
[submodule "html5"]
path = html5
url = git@bitbucket.org:viur/html5.git
21 changes: 20 additions & 1 deletion actions/edit.py
Expand Up @@ -32,7 +32,7 @@ def __init__(self, *args, **kwargs):

@staticmethod
def isSuitableFor(module, handler, actionName):
return actionName == "save.singleton"
return actionName == "save.singleton" and module != "_tasks"

def onClick(self, sender=None):
self["class"].append("is_loading")
Expand All @@ -44,6 +44,25 @@ def resetLoadingState(self):

actionDelegateSelector.insert(1, SaveSingleton.isSuitableFor, SaveSingleton)

class ExecuteSingleton(html5.ext.Button):
def __init__(self, *args, **kwargs):
super(ExecuteSingleton, self).__init__(translate("Execute"), *args, **kwargs)
self["class"] = "icon save close"

@staticmethod
def isSuitableFor(module, handler, actionName):
return actionName == "save.singleton" and module == "_tasks"

def onClick(self, sender=None):
self["class"].append("is_loading")
self.parent().parent().doSave(closeOnSuccess=True)

def resetLoadingState(self):
if "is_loading" in self["class"]:
self["class"].remove("is_loading")

actionDelegateSelector.insert(1, ExecuteSingleton.isSuitableFor, ExecuteSingleton)

class SaveClose( html5.ext.Button ):
def __init__(self, *args, **kwargs):
super( SaveClose, self ).__init__( translate("Save-Close"), *args, **kwargs )
Expand Down
4 changes: 2 additions & 2 deletions admin.py
Expand Up @@ -188,7 +188,7 @@ def startup(self):

# Finalizing!
viInitializedEvent.fire()
DeferredCall( self.checkInitialHash )
DeferredCall(self.checkInitialHash)
self.unlock()

def remove(self):
Expand All @@ -200,7 +200,7 @@ def log(self, type, msg ):
self.logWdg.log( type, msg )

def checkInitialHash(self, *args, **kwargs):
urlHash = eval("window.top.location.hash")
urlHash = conf["startupHash"]
if not urlHash:
return

Expand Down
59 changes: 25 additions & 34 deletions bones/base.py
@@ -1,11 +1,13 @@
#!/usr/bin/env python2
# -*- coding: utf-8 -*-

import html5

from priorityqueue import editBoneSelector, viewDelegateSelector, extractorDelegateSelector
from config import conf

class BaseBoneExtractor(object):
"""
Base "Catch-All" extractor for everything not handled separately.
"""
def __init__(self, moduleName, boneName, skelStructure, *args, **kwargs):
super(BaseBoneExtractor, self).__init__()
self.skelStructure = skelStructure
Expand All @@ -32,7 +34,7 @@ class BaseViewBoneDelegate( object ):
Base "Catch-All" delegate for everything not handled separately.
"""
def __init__(self, moduleName, boneName, skelStructure, *args, **kwargs ):
super( BaseViewBoneDelegate, self ).__init__()
super(BaseViewBoneDelegate, self).__init__()
self.skelStructure = skelStructure
self.boneName = boneName
self.moduleName=moduleName
Expand All @@ -44,51 +46,40 @@ def render(self, data, field):
return html5.Label(conf[ "empty_value" ])


class BaseEditBone( html5.Input ):
class BaseEditBone(html5.Input):
"""
Base edit widget for everything not handled separately.
"""
def setParams(self):
if self.readOnly:
self["disabled"] = True

def __init__(self, moduleName, boneName, readOnly, *args, **kwargs ):
super( BaseEditBone, self ).__init__( *args, **kwargs )
def __init__(self, moduleName, boneName, readOnly, *args, **kwargs):
super(BaseEditBone, self).__init__(*args, **kwargs)
self.boneName = boneName
self.readOnly = readOnly
self.setParams()

@staticmethod
def fromSkelStructure( moduleName, boneName, skelStructure ):
readOnly = "readonly" in skelStructure[ boneName ].keys() and skelStructure[ boneName ]["readonly"]
return( BaseEditBone( moduleName, boneName, readOnly ) )
def fromSkelStructure(moduleName, boneName, skelStructure, *args, **kwargs):
return BaseEditBone(moduleName, boneName, skelStructure[boneName].get("readonly", False))

def unserialize(self, data, extendedErrorInformation=None):
def setParams(self):
if self.readOnly:
self["disabled"] = True

def unserialize(self, data, extendedErrorInformation = None):
if self.boneName in data.keys():
self["value"] = data[ self.boneName ] if data[ self.boneName ] else ""
#self.lineEdit.setText( str( data[ self.boneName ] ) if data[ self.boneName ] else "" )
self["value"] = data.get(self.boneName, "")

def serializeForPost(self):
return( { self.boneName: self["value"] } )
return {
self.boneName: self["value"]
}

def serializeForDocument(self):
return( self.serialize( ) )
return self.serializeForPost()

def setExtendedErrorInformation(self, errorInfo ):
def setExtendedErrorInformation(self, errorInfo):
pass




def CheckForBaseBone(moduleName, boneName, skelStucture, *args, **kwargs):
res = str(skelStucture[boneName]["type"]).startswith("hidden")
print("checking basebone", str(skelStucture[boneName]["type"]), res)
return res


#Register this Bone in the global queue
editBoneSelector.insert( 0, lambda *args, **kwargs: True, BaseEditBone)


viewDelegateSelector.insert( 0, lambda *args, **kwargs: True, BaseViewBoneDelegate)
extractorDelegateSelector.insert(0, CheckForBaseBone, BaseBoneExtractor)
# Register this Bone in the global queue as generic fallback.
editBoneSelector.insert(0, lambda *args, **kwargs: True, BaseEditBone)
viewDelegateSelector.insert(0, lambda *args, **kwargs: True, BaseViewBoneDelegate)
extractorDelegateSelector.insert(0, lambda *args, **kwargs: True, BaseBoneExtractor)
16 changes: 8 additions & 8 deletions bones/boolean.py
Expand Up @@ -14,8 +14,8 @@ def __init__(self, moduleName, boneName, skelStructure, *args, **kwargs ):

def render( self, data, field ):
if field in data.keys():
return( html5.Label(str( data[field])))
return( html5.Label(conf[ "empty_value" ]) )
return html5.Label(translate(str(data[field])))
return html5.Label(conf["empty_value"])

class BooleanEditBone( html5.Input ):

Expand All @@ -29,9 +29,9 @@ def __init__(self, moduleName, boneName,readOnly, *args, **kwargs ):


@staticmethod
def fromSkelStructure( moduleName, boneName, skelStructure ):
def fromSkelStructure(moduleName, boneName, skelStructure, *args, **kwargs):
readOnly = "readonly" in skelStructure[ boneName ].keys() and skelStructure[ boneName ]["readonly"]
return( BooleanEditBone( moduleName, boneName, readOnly ) )
return BooleanEditBone(moduleName, boneName, readOnly)

##read
def unserialize(self, data, extendedErrorInformation=None):
Expand All @@ -40,11 +40,11 @@ def unserialize(self, data, extendedErrorInformation=None):

##save
def serializeForPost(self):
return ( { self.boneName: str(self._getChecked())} )
return {self.boneName: str(self._getChecked())}

##UNUSED
def serializeForDocument(self):
return( self.serialize( ) )
return self.serializeForPost()


class ExtendedBooleanSearch( html5.Div ):
Expand Down Expand Up @@ -91,8 +91,8 @@ def canHandleExtension( extension, view, modul ):



def CheckForBooleanBone( moduleName, boneName, skelStucture, *args, **kwargs ):
return( skelStucture[boneName]["type"]=="bool" )
def CheckForBooleanBone(moduleName, boneName, skelStucture, *args, **kwargs):
return skelStucture[boneName]["type"] == "bool"

#Register this Bone in the global queue
editBoneSelector.insert( 3, CheckForBooleanBone, BooleanEditBone)
Expand Down
12 changes: 6 additions & 6 deletions bones/color.py
Expand Up @@ -40,9 +40,9 @@ def __init__(self, moduleName, boneName,readOnly, *args, **kwargs ):


@staticmethod
def fromSkelStructure( moduleName, boneName, skelStructure ):
def fromSkelStructure(moduleName, boneName, skelStructure, *args, **kwargs):
readOnly = "readonly" in skelStructure[ boneName ].keys() and skelStructure[ boneName ]["readonly"]
return( ColorEditBone( moduleName, boneName, readOnly ) )
return ColorEditBone(moduleName, boneName, readOnly)

##read
def unserialize(self, data, extendedErrorInformation=None):
Expand All @@ -51,14 +51,14 @@ def unserialize(self, data, extendedErrorInformation=None):

##save
def serializeForPost(self):
return ( { self.boneName: str(self._getValue())} )
return { self.boneName: str(self._getValue())}

##UNUSED
def serializeForDocument(self):
return( self.serialize( ) )
return self.serializeForPost()

def CheckForColorBone( moduleName, boneName, skelStucture, *args, **kwargs ):
return( skelStucture[boneName]["type"]=="color" )
def CheckForColorBone(moduleName, boneName, skelStucture, *args, **kwargs):
return skelStucture[boneName]["type"] == "color"

#Register this Bone in the global queue
editBoneSelector.insert( 3, CheckForColorBone, ColorEditBone)
Expand Down
4 changes: 2 additions & 2 deletions bones/date.py
Expand Up @@ -147,7 +147,7 @@ def __init__(self, moduleName, boneName, readOnly, date=True, time=True, *args,
self.timeinput["readonly"] = True

@staticmethod
def fromSkelStructure(moduleName, boneName, skelStructure):
def fromSkelStructure(moduleName, boneName, skelStructure, *args, **kwargs):
readOnly = "readonly" in skelStructure[ boneName ].keys() and skelStructure[ boneName ]["readonly"]
date = skelStructure[ boneName ]["date"] if "date" in skelStructure[ boneName ].keys() else True
time = skelStructure[ boneName ]["time"] if "time" in skelStructure[ boneName ].keys() else True
Expand Down Expand Up @@ -200,7 +200,7 @@ def serializeForPost(self):
return {self.boneName: returnvalue}

def serializeForDocument(self):
return self.serialize()
return self.serializeForPost()

def CheckForDateBone(moduleName, boneName, skelStucture, *args, **kwargs):
return skelStucture[boneName]["type"] == "date"
Expand Down
5 changes: 2 additions & 3 deletions bones/email.py
Expand Up @@ -32,9 +32,9 @@ def __init__(self, moduleName, boneName,readOnly,*args, **kwargs ):
super( EmailEditBone, self ).__init__( moduleName, boneName,readOnly, *args, **kwargs )

@staticmethod
def fromSkelStructure( moduleName, boneName, skelStructure ):
def fromSkelStructure(moduleName, boneName, skelStructure, *args, **kwargs):
readOnly = "readonly" in skelStructure[ boneName ].keys() and skelStructure[ boneName ]["readonly"]
return( EmailEditBone( moduleName, boneName, readOnly ) )
return EmailEditBone(moduleName, boneName, readOnly)

def unserialize(self, data):
if self.boneName in data.keys():
Expand All @@ -45,7 +45,6 @@ def serializeForPost(self):
return( { self.boneName: self.input["value"] } )
raise InvalidBoneValueException()


def setSpecialType(self):
self.input["type"]="email"

Expand Down

0 comments on commit 849f6f1

Please sign in to comment.