mirror of
https://github.com/johannesjo/super-productivity.git
synced 2026-07-29 02:30:03 +00:00
fix: theme issue on config page
This commit is contained in:
parent
692fb5e2a3
commit
cd69e78410
3 changed files with 26 additions and 12 deletions
|
|
@ -114,7 +114,7 @@
|
|||
|
||||
// update data for current new project from current data
|
||||
for (let field in data) {
|
||||
newProject.data[field] = data[field];
|
||||
newProject.data[field] = data[field];
|
||||
}
|
||||
|
||||
// update $rootScope.r.projects
|
||||
|
|
@ -183,13 +183,14 @@
|
|||
|
||||
// update ls current project
|
||||
$rootScope.r.currentProject = newCurrentProject;
|
||||
$rootScope.$broadcast(EV_PROJECT_CHANGED);
|
||||
|
||||
// re-init all global models
|
||||
InitGlobalModels();
|
||||
|
||||
// Show success message
|
||||
SimpleToast('SUCCESS', `Switched to project "${newCurrentProject.title}"`);
|
||||
|
||||
$rootScope.$broadcast(EV_PROJECT_CHANGED);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ describe('Service: Projects', () => {
|
|||
.returns('TEST');
|
||||
|
||||
const result = Projects.getListWithLsData();
|
||||
expect(result).toBe('TEST')
|
||||
expect(result).toBe('TEST');
|
||||
}));
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -28,18 +28,24 @@
|
|||
}
|
||||
|
||||
/* @ngInject */
|
||||
function ThemeSettingsCtrl($scope, THEMES, DEFAULT_THEME, $rootScope) {
|
||||
function ThemeSettingsCtrl($scope, THEMES, DEFAULT_THEME, $rootScope, EV_PROJECT_CHANGED) {
|
||||
let vm = this;
|
||||
vm.themes = THEMES;
|
||||
|
||||
// wait for var to be there
|
||||
$scope.$evalAsync(() => {
|
||||
vm.currentTheme = vm.currentTheme || DEFAULT_THEME;
|
||||
vm.isDarkTheme = vm.currentTheme && vm.currentTheme.indexOf('dark') > -1;
|
||||
vm.selectedTheme = vm.currentTheme && vm.currentTheme
|
||||
.replace('-theme', '')
|
||||
.replace('-dark', '');
|
||||
});
|
||||
// workarounds required to make data model work with theming engine of ng-material
|
||||
function cleanupThemeVars() {
|
||||
// wait for var to be there
|
||||
$scope.$evalAsync(() => {
|
||||
|
||||
vm.currentTheme = vm.currentTheme || DEFAULT_THEME;
|
||||
vm.isDarkTheme = vm.currentTheme && vm.currentTheme.indexOf('dark') > -1;
|
||||
vm.selectedTheme = vm.currentTheme && vm.currentTheme
|
||||
.replace('-theme', '')
|
||||
.replace('-dark', '');
|
||||
});
|
||||
}
|
||||
|
||||
cleanupThemeVars();
|
||||
|
||||
// WATCHER & EVENTS
|
||||
// ----------------
|
||||
|
|
@ -80,6 +86,13 @@
|
|||
}
|
||||
}));
|
||||
|
||||
$scope.$on(EV_PROJECT_CHANGED, () => {
|
||||
// currentTheme is not updated right away, because it is a primitive,
|
||||
// that's why we set it here from the rootScope
|
||||
vm.currentTheme = $rootScope.r.theme;
|
||||
cleanupThemeVars();
|
||||
});
|
||||
|
||||
$scope.$on('$destroy', () => {
|
||||
// remove watchers manually
|
||||
_.each(watchers, (watcher) => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue