Skip to content

Commit

Permalink
Fix for #156
Browse files Browse the repository at this point in the history
  • Loading branch information
eeintech committed Aug 3, 2023
1 parent 6969a60 commit a78b14f
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 14 deletions.
2 changes: 1 addition & 1 deletion kintree/config/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ def load_ipn_settings():
CONFIG_GENERAL = config_interface.load_file(CONFIG_GENERAL_PATH)
# Datasheets
DATASHEET_SAVE_ENABLED = CONFIG_GENERAL.get('DATASHEET_SAVE_ENABLED', False)
DATASHEET_SAVE_PATH = CONFIG_GENERAL.get('DATASHEET_SAVE_PATH', False)
DATASHEET_SAVE_PATH = CONFIG_GENERAL.get('DATASHEET_SAVE_PATH', '')
# Open Browser
AUTOMATIC_BROWSER_OPEN = CONFIG_GENERAL.get('AUTOMATIC_BROWSER_OPEN', False)
# Default Supplier
Expand Down
1 change: 1 addition & 0 deletions kintree/config/user/general.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
DATASHEET_SAVE_ENABLED: false
DATASHEET_SAVE_PATH: null
DATASHEET_INVENTREE_ENABLED: false
AUTOMATIC_BROWSER_OPEN: true
INVENTREE_ENV: null
DEFAULT_SUPPLIER: Digi-Key
Expand Down
22 changes: 9 additions & 13 deletions kintree/gui/views/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -499,11 +499,16 @@ class UserSettingsView(PathSettingsView):
'CACHE_VALID_DAYS': global_settings.CACHE_VALID_DAYS
},
}
settings_file = [
settings_file_list = [
global_settings.USER_CONFIG_FILE,
global_settings.CONFIG_GENERAL_PATH,
global_settings.CONFIG_SEARCH_API_PATH,
]

def save(self):
# Save all settings
for sf in self.settings_file_list:
super().save(settings_file=sf, show_dialog=True)

def increment_cache_value(self, inc):
field = SETTINGS[self.title]['CACHE_VALID_DAYS'][1]
Expand Down Expand Up @@ -542,22 +547,13 @@ def build_column(self):
self.column.controls.append(cache_row)
# Add cache row to switch refs
SETTINGS[self.title]['Enable Supplier Search Cache'][1].refs = [cache_row_ref]

setting_file1 = self.settings_file[1]
setting_file2 = self.settings_file[2]

for name, field in SETTINGS[self.title].items():
if field[0] in ['AUTOMATIC_BROWSER_OPEN', 'DATASHEET_SAVE_ENABLED', 'DATASHEET_SAVE_PATH', 'DATASHEET_INVENTREE_ENABLED']:
self.fields[name].on_change = lambda _: self.save(
settings_file=setting_file1,
show_dialog=False
)
self.fields[name].on_change = lambda _: self.save()
elif field[0] in ['CACHE_ENABLED', 'CACHE_VALID_DAYS']:
self.fields[name].on_change = lambda _: self.save(
settings_file=setting_file2,
show_dialog=False
)
self.settings_file = self.settings_file[0]
self.fields[name].on_change = lambda _: self.save()
self.settings_file = self.settings_file_list[0]

# Update datasheet ref
for idx, field in enumerate(self.column.controls):
Expand Down

0 comments on commit a78b14f

Please sign in to comment.