mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-04-02 13:45:10 -05:00
Fix: use default permissions for objects created via dropdown (#4778)
This commit is contained in:
parent
5b502b1e1a
commit
47a2ded30d
@ -131,6 +131,7 @@ describe('EditDialogComponent', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('should interpolate object permissions', () => {
|
it('should interpolate object permissions', () => {
|
||||||
|
component.getMatchingAlgorithms() // coverage
|
||||||
component.object = tag
|
component.object = tag
|
||||||
component.dialogMode = EditDialogMode.EDIT
|
component.dialogMode = EditDialogMode.EDIT
|
||||||
component.ngOnInit()
|
component.ngOnInit()
|
||||||
|
@ -58,8 +58,8 @@ export abstract class EditDialogComponent<
|
|||||||
objectForm: FormGroup = this.getForm()
|
objectForm: FormGroup = this.getForm()
|
||||||
|
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
if (this.object != null) {
|
if (this.object != null && this.dialogMode !== EditDialogMode.CREATE) {
|
||||||
if (this.object['permissions']) {
|
if ((this.object as ObjectWithPermissions).permissions) {
|
||||||
this.object['set_permissions'] = this.object['permissions']
|
this.object['set_permissions'] = this.object['permissions']
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -69,6 +69,8 @@ export abstract class EditDialogComponent<
|
|||||||
}
|
}
|
||||||
this.objectForm.patchValue(this.object)
|
this.objectForm.patchValue(this.object)
|
||||||
} else {
|
} else {
|
||||||
|
// e.g. if name was set
|
||||||
|
this.objectForm.patchValue(this.object)
|
||||||
// defaults from settings
|
// defaults from settings
|
||||||
this.objectForm.patchValue({
|
this.objectForm.patchValue({
|
||||||
permissions_form: {
|
permissions_form: {
|
||||||
|
@ -32,11 +32,9 @@ import { CheckComponent } from '../check/check.component'
|
|||||||
import { IfOwnerDirective } from 'src/app/directives/if-owner.directive'
|
import { IfOwnerDirective } from 'src/app/directives/if-owner.directive'
|
||||||
import { TextComponent } from '../text/text.component'
|
import { TextComponent } from '../text/text.component'
|
||||||
import { ColorComponent } from '../color/color.component'
|
import { ColorComponent } from '../color/color.component'
|
||||||
import { IfPermissionsDirective } from 'src/app/directives/if-permissions.directive'
|
|
||||||
import { PermissionsFormComponent } from '../permissions/permissions-form/permissions-form.component'
|
import { PermissionsFormComponent } from '../permissions/permissions-form/permissions-form.component'
|
||||||
import { SelectComponent } from '../select/select.component'
|
import { SelectComponent } from '../select/select.component'
|
||||||
import { ColorSliderModule } from 'ngx-color/slider'
|
import { SettingsService } from 'src/app/services/settings.service'
|
||||||
import { By } from '@angular/platform-browser'
|
|
||||||
|
|
||||||
const tags: PaperlessTag[] = [
|
const tags: PaperlessTag[] = [
|
||||||
{
|
{
|
||||||
@ -63,8 +61,8 @@ const tags: PaperlessTag[] = [
|
|||||||
describe('TagsComponent', () => {
|
describe('TagsComponent', () => {
|
||||||
let component: TagsComponent
|
let component: TagsComponent
|
||||||
let fixture: ComponentFixture<TagsComponent>
|
let fixture: ComponentFixture<TagsComponent>
|
||||||
let input: HTMLInputElement
|
|
||||||
let modalService: NgbModal
|
let modalService: NgbModal
|
||||||
|
let settingsService: SettingsService
|
||||||
|
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
TestBed.configureTestingModule({
|
TestBed.configureTestingModule({
|
||||||
@ -110,6 +108,7 @@ describe('TagsComponent', () => {
|
|||||||
}).compileComponents()
|
}).compileComponents()
|
||||||
|
|
||||||
modalService = TestBed.inject(NgbModal)
|
modalService = TestBed.inject(NgbModal)
|
||||||
|
settingsService = TestBed.inject(SettingsService)
|
||||||
fixture = TestBed.createComponent(TagsComponent)
|
fixture = TestBed.createComponent(TagsComponent)
|
||||||
fixture.debugElement.injector.get(NG_VALUE_ACCESSOR)
|
fixture.debugElement.injector.get(NG_VALUE_ACCESSOR)
|
||||||
component = fixture.componentInstance
|
component = fixture.componentInstance
|
||||||
@ -139,6 +138,7 @@ describe('TagsComponent', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('should support create new using last search term and open a modal', () => {
|
it('should support create new using last search term and open a modal', () => {
|
||||||
|
settingsService.currentUser = { id: 1 }
|
||||||
let activeInstances: NgbModalRef[]
|
let activeInstances: NgbModalRef[]
|
||||||
modalService.activeInstances.subscribe((v) => (activeInstances = v))
|
modalService.activeInstances.subscribe((v) => (activeInstances = v))
|
||||||
component.select.searchTerm = 'foobar'
|
component.select.searchTerm = 'foobar'
|
||||||
|
@ -263,6 +263,7 @@ describe('DocumentDetailComponent', () => {
|
|||||||
toastService = TestBed.inject(ToastService)
|
toastService = TestBed.inject(ToastService)
|
||||||
documentListViewService = TestBed.inject(DocumentListViewService)
|
documentListViewService = TestBed.inject(DocumentListViewService)
|
||||||
settingsService = TestBed.inject(SettingsService)
|
settingsService = TestBed.inject(SettingsService)
|
||||||
|
settingsService.currentUser = { id: 1 }
|
||||||
customFieldsService = TestBed.inject(CustomFieldsService)
|
customFieldsService = TestBed.inject(CustomFieldsService)
|
||||||
fixture = TestBed.createComponent(DocumentDetailComponent)
|
fixture = TestBed.createComponent(DocumentDetailComponent)
|
||||||
component = fixture.componentInstance
|
component = fixture.componentInstance
|
||||||
|
Loading…
x
Reference in New Issue
Block a user