Skip to content

Commit

Permalink
fix:jans-cli reviced all array type in properties (ref: #3062)
Browse files Browse the repository at this point in the history
  • Loading branch information
AbdelwahabAdam committed Nov 24, 2022
1 parent 1f06d7c commit 03c25de
Showing 1 changed file with 32 additions and 10 deletions.
42 changes: 32 additions & 10 deletions jans-cli-tui/cli_tui/plugins/010_oxauth/view_property.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,15 @@ def save(self) -> None:
prop_type = self.get_item_data(wid)
data = prop_type['value']

elif (type(self.value)==list and type(self.value[0]) not in [dict,list]):
elif (type(self.value)==list and (type(self.value[0]) not in [dict,list])):

for wid in self.value_content.children:
prop_type = self.get_item_data(wid)
data = prop_type['value'].split('\n')

if self.get_type(prop_type['key']) != 'checkboxlist':
data = prop_type['value'].split('\n')
else:
data = prop_type['value']

elif type(self.value) == dict :
for wid in self.value_content.children:
Expand Down Expand Up @@ -140,34 +145,42 @@ async def coroutine():

def get_type(self,prop):
try :
if self.schema.get('properties', {})[prop]['type'] == 'string':
proper = self.schema.get('properties', {})[prop]

if proper['type'] == 'string':
prop_type= 'TitledText'

elif self.schema.get('properties', {})[prop]['type'] == 'integer':
elif proper['type'] == 'integer':
prop_type= 'int-TitledText'

elif self.schema.get('properties', {})[prop]['type'] == 'boolean':
elif proper['type'] == 'boolean':
prop_type= 'TitledCheckBox'

elif self.schema.get('properties', {})[prop]['type'] == 'object':
elif proper['type'] == 'object':
prop_type= 'dict'

elif self.schema.get('properties', {})[prop]['type'] == 'array':
if 'enum' in self.schema.get('properties', {})[prop]:
elif proper['type'] == 'array':
if 'enum' in proper or ('enum' in proper['items']):
prop_type= 'checkboxlist'
else:
if type(self.value[0]) == dict:
prop_type= 'list-dict'
elif type(self.value[0]) == list:
prop_type= 'list-list'
else:
prop_type= 'long-TitledText'
except:
prop_type = None

return prop_type

def get_listValues(self,prop):
def get_listValues(self,prop,type=None):
try :
list_values= self.schema.get('properties', {})[prop]['enum']
if type !='nasted':
list_values= self.schema.get('properties', {})[prop]['items']['enum']
else:
list_values= self.schema.get('properties', {})[prop]['items']['items']['enum']

except:
list_values = []

Expand Down Expand Up @@ -206,6 +219,15 @@ def prepare_properties(self):
),
],width=D())

elif prop_type == 'list-list':
self.value_content= HSplit([
self.app.getTitledCheckBoxList(
self.property,
name=self.property,
values=self.get_listValues(self.property,'nasted'),
style='class:outh-client-checkboxlist'),
],width=D())

elif prop_type == 'checkboxlist':
self.value_content= HSplit([
self.app.getTitledCheckBoxList(
Expand Down

0 comments on commit 03c25de

Please sign in to comment.