fixed an issue with the settings not saving in case no saved views are present

This commit is contained in:
jonaswinkler 2020-12-16 16:04:20 +01:00
parent b13ec571f8
commit 0e78f32009
2 changed files with 17 additions and 7 deletions

View File

@ -50,16 +50,26 @@ export class SettingsComponent implements OnInit {
}) })
} }
private saveLocalSettings() {
localStorage.setItem(GENERAL_SETTINGS.DOCUMENT_LIST_SIZE, this.settingsForm.value.documentListItemPerPage)
this.documentListViewService.updatePageSize()
this.toastService.showToast(Toast.make("Information", "Settings saved successfully."))
}
saveSettings() { saveSettings() {
let x = [] let x = []
for (let id in this.savedViewGroup.value) { for (let id in this.savedViewGroup.value) {
x.push(this.savedViewGroup.value[id]) x.push(this.savedViewGroup.value[id])
} }
if (x.length > 0) {
this.savedViewService.patchMany(x).subscribe(s => { this.savedViewService.patchMany(x).subscribe(s => {
this.toastService.showToast(Toast.make("Information", "Settings saved successfully.")) this.saveLocalSettings()
localStorage.setItem(GENERAL_SETTINGS.DOCUMENT_LIST_SIZE, this.settingsForm.value.documentListItemPerPage) }, error => {
this.documentListViewService.updatePageSize() this.toastService.showToast(Toast.makeError(`Error while storing settings on server: ${JSON.stringify(error.error)}`))
}) })
} else {
this.saveLocalSettings()
}
} }
} }

View File

@ -116,13 +116,13 @@ export class DocumentListViewService {
set filterRules(filterRules: FilterRule[]) { set filterRules(filterRules: FilterRule[]) {
//we're going to clone the filterRules object, since we don't //we're going to clone the filterRules object, since we don't
//want changes in the filter editor to propagate into here right away. //want changes in the filter editor to propagate into here right away.
this.view.filter_rules = cloneFilterRules(filterRules) this.view.filter_rules = filterRules
this.reload() this.reload()
this.saveDocumentListView() this.saveDocumentListView()
} }
get filterRules(): FilterRule[] { get filterRules(): FilterRule[] {
return cloneFilterRules(this.view.filter_rules) return this.view.filter_rules
} }
set sortField(field: string) { set sortField(field: string) {