Sort list of available themes
and add `computed` attr for WholePage; needed by some customizations
This commit is contained in:
		
							parent
							
								
									adaa39f572
								
							
						
					
					
						commit
						34878f9293
					
				
					 2 changed files with 21 additions and 5 deletions
				
			
		|  | @ -1010,6 +1010,7 @@ | ||||||
|     const WholePage = { |     const WholePage = { | ||||||
|         template: '#whole-page-template', |         template: '#whole-page-template', | ||||||
|         mixins: [SimpleRequestMixin], |         mixins: [SimpleRequestMixin], | ||||||
|  |         computed: {}, | ||||||
| 
 | 
 | ||||||
|         mounted() { |         mounted() { | ||||||
|             window.addEventListener('keydown', this.globalKey) |             window.addEventListener('keydown', this.globalKey) | ||||||
|  |  | ||||||
|  | @ -377,22 +377,37 @@ def get_theme_template_path(rattail_config, theme=None, session=None): | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| def get_available_themes(rattail_config, include=None): | def get_available_themes(rattail_config, include=None): | ||||||
|  |     """ | ||||||
|  |     Returns a list of theme names which are available.  If config does | ||||||
|  |     not specify, some defaults will be assumed. | ||||||
|  |     """ | ||||||
|  |     # get available list from config, if it has one | ||||||
|     available = rattail_config.getlist('tailbone', 'themes.keys') |     available = rattail_config.getlist('tailbone', 'themes.keys') | ||||||
|     if not available: |     if not available: | ||||||
|         available = rattail_config.getlist('tailbone', 'themes', |         available = rattail_config.getlist('tailbone', 'themes', | ||||||
|                                            ignore_ambiguous=True) |                                            ignore_ambiguous=True) | ||||||
|         if available: |         if available: | ||||||
|             warnings.warn(f"URGENT: instead of 'tailbone.themes', " |             warnings.warn("URGENT: instead of 'tailbone.themes', " | ||||||
|                           f"you should set 'tailbone.themes.keys'", |                           "you should set 'tailbone.themes.keys'", | ||||||
|                           DeprecationWarning, stacklevel=2) |                           DeprecationWarning, stacklevel=2) | ||||||
|         else: |         else: | ||||||
|             available = [] |             available = [] | ||||||
|     if 'default' not in available: | 
 | ||||||
|         available.insert(0, 'default') |     # include any themes specified by caller | ||||||
|     if include is not None: |     if include is not None: | ||||||
|         for theme in include: |         for theme in include: | ||||||
|             if theme not in available: |             if theme not in available: | ||||||
|                 available.append(theme) |                 available.append(theme) | ||||||
|  | 
 | ||||||
|  |     # sort the list by name | ||||||
|  |     available.sort() | ||||||
|  | 
 | ||||||
|  |     # make default theme the first option | ||||||
|  |     i = available.index('default') | ||||||
|  |     if i >= 0: | ||||||
|  |         available.pop(i) | ||||||
|  |     available.insert(0, 'default') | ||||||
|  | 
 | ||||||
|     return available |     return available | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
|  | @ -427,7 +442,7 @@ def should_use_oruga(request): | ||||||
|     the default of Buefy + Vue 2. |     the default of Buefy + Vue 2. | ||||||
|     """ |     """ | ||||||
|     theme = request.registry.settings['tailbone.theme'] |     theme = request.registry.settings['tailbone.theme'] | ||||||
|     if theme == 'butterball': |     if 'butterball' in theme: | ||||||
|         return True |         return True | ||||||
|     return False |     return False | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Lance Edgar
						Lance Edgar