Let providers add extra views, options for includes config
This commit is contained in:
parent
c4e872c94c
commit
d18bade951
|
@ -7,21 +7,14 @@
|
||||||
NB. Any changes made here will require an app restart!
|
NB. Any changes made here will require an app restart!
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<h3 class="block is-size-3">Tailbone Views</h3>
|
% for topkey, topgroup in sorted(view_settings.items(), key=lambda itm: 'aaaa' if itm[0] == 'rattail' else itm[0]):
|
||||||
|
<h3 class="block is-size-3">Views for: ${topkey}</h3>
|
||||||
<h4 class="block is-size-4">People</h4>
|
% for group_key, group in six.iteritems(topgroup):
|
||||||
% for key, label in view_settings['people']:
|
<h4 class="block is-size-4">${group_key.capitalize()}</h4>
|
||||||
${self.simple_flag(key, label)}
|
% for key, label in group:
|
||||||
% endfor
|
${self.simple_flag(key, label)}
|
||||||
|
% endfor
|
||||||
<h4 class="block is-size-4">Products</h4>
|
% endfor
|
||||||
% for key, label in view_settings['products']:
|
|
||||||
${self.simple_flag(key, label)}
|
|
||||||
% endfor
|
|
||||||
|
|
||||||
<h4 class="block is-size-4">Other</h4>
|
|
||||||
% for key, label in view_settings['other']:
|
|
||||||
${self.simple_flag(key, label)}
|
|
||||||
% endfor
|
% endfor
|
||||||
|
|
||||||
</%def>
|
</%def>
|
||||||
|
@ -32,7 +25,9 @@
|
||||||
v-model="simpleSettings['tailbone.includes.${key}']"
|
v-model="simpleSettings['tailbone.includes.${key}']"
|
||||||
@input="settingsNeedSaved = true">
|
@input="settingsNeedSaved = true">
|
||||||
<option :value="null">(disabled)</option>
|
<option :value="null">(disabled)</option>
|
||||||
<option value="${key}">${key}</option>
|
% for option in view_options[key]:
|
||||||
|
<option value="${option}">${option}</option>
|
||||||
|
% endfor
|
||||||
</b-select>
|
</b-select>
|
||||||
</b-field>
|
</b-field>
|
||||||
</%def>
|
</%def>
|
||||||
|
|
|
@ -31,6 +31,7 @@ import six
|
||||||
import colander
|
import colander
|
||||||
|
|
||||||
from .master import PoserMasterView
|
from .master import PoserMasterView
|
||||||
|
from tailbone.providers import get_all_providers
|
||||||
|
|
||||||
|
|
||||||
class PoserViewView(PoserMasterView):
|
class PoserViewView(PoserMasterView):
|
||||||
|
@ -94,7 +95,7 @@ class PoserViewView(PoserMasterView):
|
||||||
# TODO: this probably should be more dynamic? definitely need
|
# TODO: this probably should be more dynamic? definitely need
|
||||||
# to let integration packages register some more options...
|
# to let integration packages register some more options...
|
||||||
|
|
||||||
return {
|
everything = {'rattail': {
|
||||||
|
|
||||||
'people': {
|
'people': {
|
||||||
|
|
||||||
|
@ -181,16 +182,59 @@ class PoserViewView(PoserMasterView):
|
||||||
'label': "Taxes",
|
'label': "Taxes",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}}
|
||||||
|
|
||||||
|
for key, views in six.iteritems(everything['rattail']):
|
||||||
|
for vkey, view in six.iteritems(views):
|
||||||
|
view['options'] = [vkey]
|
||||||
|
|
||||||
|
providers = get_all_providers(self.rattail_config)
|
||||||
|
for provider in six.itervalues(providers):
|
||||||
|
|
||||||
|
# loop thru provider top-level groups
|
||||||
|
for topkey, groups in six.iteritems(provider.get_provided_views()):
|
||||||
|
|
||||||
|
# get or create top group
|
||||||
|
topgroup = everything.setdefault(topkey, {})
|
||||||
|
|
||||||
|
# loop thru provider view groups
|
||||||
|
for key, views in six.iteritems(groups):
|
||||||
|
|
||||||
|
# add group to top group, if it's new
|
||||||
|
if key not in topgroup:
|
||||||
|
topgroup[key] = views
|
||||||
|
|
||||||
|
# also must init the options for group
|
||||||
|
for vkey, view in six.iteritems(views):
|
||||||
|
view['options'] = [vkey]
|
||||||
|
|
||||||
|
else: # otherwise must "update" existing group
|
||||||
|
|
||||||
|
# get ref to existing ("standard") group
|
||||||
|
stdgroup = topgroup[key]
|
||||||
|
|
||||||
|
# loop thru views within provider group
|
||||||
|
for vkey, view in six.iteritems(views):
|
||||||
|
|
||||||
|
# add view to group if it's new
|
||||||
|
if vkey not in stdgroup:
|
||||||
|
view['options'] = [vkey]
|
||||||
|
stdgroup[vkey] = view
|
||||||
|
|
||||||
|
else: # otherwise "update" existing view
|
||||||
|
stdgroup[vkey]['options'].append(view['spec'])
|
||||||
|
|
||||||
|
return everything
|
||||||
|
|
||||||
def configure_get_simple_settings(self):
|
def configure_get_simple_settings(self):
|
||||||
settings = []
|
settings = []
|
||||||
|
|
||||||
view_settings = self.collect_available_view_settings()
|
view_settings = self.collect_available_view_settings()
|
||||||
for view_section, section_settings in six.iteritems(view_settings):
|
for topgroup in six.itervalues(view_settings):
|
||||||
for key in section_settings:
|
for view_section, section_settings in six.iteritems(topgroup):
|
||||||
settings.append({'section': 'tailbone.includes',
|
for key in section_settings:
|
||||||
'option': key})
|
settings.append({'section': 'tailbone.includes',
|
||||||
|
'option': key})
|
||||||
|
|
||||||
return settings
|
return settings
|
||||||
|
|
||||||
|
@ -202,14 +246,23 @@ class PoserViewView(PoserMasterView):
|
||||||
simple_settings=simple_settings,
|
simple_settings=simple_settings,
|
||||||
input_file_templates=input_file_templates)
|
input_file_templates=input_file_templates)
|
||||||
|
|
||||||
# add available settings as sorted (key, label) options
|
# first add available options
|
||||||
view_settings = self.collect_available_view_settings()
|
view_settings = self.collect_available_view_settings()
|
||||||
for key in list(view_settings):
|
view_options = {}
|
||||||
settings = view_settings[key]
|
for topgroup in six.itervalues(view_settings):
|
||||||
settings = [(key, setting['label'])
|
for key, views in six.iteritems(topgroup):
|
||||||
for key, setting in six.iteritems(settings)]
|
for vkey, view in six.iteritems(views):
|
||||||
settings.sort(key=lambda itm: itm[1])
|
view_options[vkey] = view['options']
|
||||||
view_settings[key] = settings
|
context['view_options'] = view_options
|
||||||
|
|
||||||
|
# then add all available settings as sorted (key, label) options
|
||||||
|
for topkey, topgroup in six.iteritems(view_settings):
|
||||||
|
for key in list(topgroup):
|
||||||
|
settings = topgroup[key]
|
||||||
|
settings = [(key, setting['label'])
|
||||||
|
for key, setting in six.iteritems(settings)]
|
||||||
|
settings.sort(key=lambda itm: itm[1])
|
||||||
|
topgroup[key] = settings
|
||||||
context['view_settings'] = view_settings
|
context['view_settings'] = view_settings
|
||||||
|
|
||||||
return context
|
return context
|
||||||
|
|
Loading…
Reference in a new issue