Development
This commit is contained in:
parent
450c0081f7
commit
6e36b692dc
3 changed files with 19 additions and 6 deletions
|
|
@ -359,7 +359,7 @@ def collect_form_specs(items):
|
||||||
t = item.get('type', '')
|
t = item.get('type', '')
|
||||||
if t == 'field':
|
if t == 'field':
|
||||||
itype = item.get('input_type', 'text')
|
itype = item.get('input_type', 'text')
|
||||||
if item.get('validate') or itype == 'checkbox' or itype == 'number':
|
if item.get('validate') or itype in ('checkbox', 'number', 'password'):
|
||||||
fields.append(item)
|
fields.append(item)
|
||||||
elif t == 'subnet_row':
|
elif t == 'subnet_row':
|
||||||
fields.append(item)
|
fields.append(item)
|
||||||
|
|
@ -386,6 +386,7 @@ def build_form_script(field_specs, submit_sel):
|
||||||
subnet_items = []
|
subnet_items = []
|
||||||
validate_items = []
|
validate_items = []
|
||||||
checkbox_only = []
|
checkbox_only = []
|
||||||
|
password_items = []
|
||||||
gate_vars = []
|
gate_vars = []
|
||||||
|
|
||||||
for spec in field_specs:
|
for spec in field_specs:
|
||||||
|
|
@ -414,6 +415,9 @@ def build_form_script(field_specs, submit_sel):
|
||||||
gate_vars.append(f'{vn} && {vn}._valid')
|
gate_vars.append(f'{vn} && {vn}._valid')
|
||||||
else:
|
else:
|
||||||
checkbox_only.append(vn)
|
checkbox_only.append(vn)
|
||||||
|
elif itype == 'password':
|
||||||
|
password_items.append(vn)
|
||||||
|
gate_vars.append(f'{vn} && {vn}.value.trim()')
|
||||||
else:
|
else:
|
||||||
validate_items.append((vn, nm))
|
validate_items.append((vn, nm))
|
||||||
if spec.get('optional'):
|
if spec.get('optional'):
|
||||||
|
|
@ -450,6 +454,9 @@ def build_form_script(field_specs, submit_sel):
|
||||||
for vn in checkbox_only:
|
for vn in checkbox_only:
|
||||||
lines.append(f" if ({vn}) {vn}.addEventListener('change', _upd);")
|
lines.append(f" if ({vn}) {vn}.addEventListener('change', _upd);")
|
||||||
|
|
||||||
|
for vn in password_items:
|
||||||
|
lines.append(f" if ({vn}) {vn}.addEventListener('input', _upd);")
|
||||||
|
|
||||||
lines.append('}());')
|
lines.append('}());')
|
||||||
return '<script>' + '\n'.join(lines) + '</script>'
|
return '<script>' + '\n'.join(lines) + '</script>'
|
||||||
|
|
||||||
|
|
@ -1134,6 +1141,8 @@ def build_items(items, tokens, inherited_req=None):
|
||||||
level = client_level()
|
level = client_level()
|
||||||
parts = []
|
parts = []
|
||||||
for item in items:
|
for item in items:
|
||||||
|
if item.get('multi_user_only') and settings.is_single_user():
|
||||||
|
continue
|
||||||
req = item.get('client_requirement', inherited_req)
|
req = item.get('client_requirement', inherited_req)
|
||||||
if not passes(req, level):
|
if not passes(req, level):
|
||||||
continue
|
continue
|
||||||
|
|
@ -1544,7 +1553,7 @@ def build_item(item, tokens, inherited_req=None):
|
||||||
|
|
||||||
def render_layout(view_id, content_html, tokens, page_name=None, suppress_pending_bar=False):
|
def render_layout(view_id, content_html, tokens, page_name=None, suppress_pending_bar=False):
|
||||||
level = client_level()
|
level = client_level()
|
||||||
has_pending_alert = not config_utils._apply_changes_immediately() and bool(config_utils.get_dashboard_pending())
|
has_pending_alert = level != 'nothing' and not config_utils._apply_changes_immediately() and bool(config_utils.get_dashboard_pending())
|
||||||
titlebar_html = f'<div class="titlebar"><span class="titlebar-brand">{config_utils.WEB_APP_DISPLAY_NAME}</span></div>'
|
titlebar_html = f'<div class="titlebar"><span class="titlebar-brand">{config_utils.WEB_APP_DISPLAY_NAME}</span></div>'
|
||||||
navbar_html = build_navbar(view_id, level, tokens, pending_alert=has_pending_alert)
|
navbar_html = build_navbar(view_id, level, tokens, pending_alert=has_pending_alert)
|
||||||
footer_html = f'<footer class="footer">{config_utils.WEB_APP_DISPLAY_NAME}</footer>'
|
footer_html = f'<footer class="footer">{config_utils.WEB_APP_DISPLAY_NAME}</footer>'
|
||||||
|
|
@ -1712,6 +1721,8 @@ def build_navbar(active_view, level, tokens, pending_alert=False):
|
||||||
|
|
||||||
|
|
||||||
def build_nav_item(item, active_view, level, in_dropdown=False, inherited_req=None, pending_alert=False):
|
def build_nav_item(item, active_view, level, in_dropdown=False, inherited_req=None, pending_alert=False):
|
||||||
|
if item.get('multi_user_only') and settings.is_single_user():
|
||||||
|
return ''
|
||||||
req = item.get('client_requirement', inherited_req)
|
req = item.get('client_requirement', inherited_req)
|
||||||
t = item.get('type', '')
|
t = item.get('type', '')
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -42,8 +42,8 @@
|
||||||
"client_requirement": "client_is_viewer+",
|
"client_requirement": "client_is_viewer+",
|
||||||
"items": [
|
"items": [
|
||||||
{ "type": "nav_item", "label": "Preferences", "map_to": "preferences" },
|
{ "type": "nav_item", "label": "Preferences", "map_to": "preferences" },
|
||||||
{ "type": "nav_item", "label": "Manage Accounts", "map_to": "accountmanage", "client_requirement": "client_is_manager+" },
|
{ "type": "nav_item", "label": "Manage Accounts", "map_to": "accountmanage", "client_requirement": "client_is_manager+", "multi_user_only": true },
|
||||||
{ "type": "nav_action", "label": "Log Out", "action": "log_out" }
|
{ "type": "nav_action", "label": "Log Out", "action": "accountlogout/logout" }
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
@ -58,7 +58,8 @@
|
||||||
"label": "Create Account",
|
"label": "Create Account",
|
||||||
"map_to": "accountcreate",
|
"map_to": "accountcreate",
|
||||||
"align": "right",
|
"align": "right",
|
||||||
"client_requirement": "client_is_nothing="
|
"client_requirement": "client_is_nothing=",
|
||||||
|
"multi_user_only": true
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -54,7 +54,8 @@
|
||||||
"link": {
|
"link": {
|
||||||
"action": "/accountcreate",
|
"action": "/accountcreate",
|
||||||
"text": "Create Account"
|
"text": "Create Account"
|
||||||
}
|
},
|
||||||
|
"multi_user_only": true
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue