Merge pull request #4933 from GabrielInTheWorld/fixAttachments

Fixes directories as attachments
This commit is contained in:
Sean 2019-08-21 11:34:09 +02:00 committed by GitHub
commit 180aad853b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
15 changed files with 59 additions and 46 deletions

View File

@ -28,7 +28,7 @@
[multiple]="false"
[includeNone]="true"
listname="{{ 'Parent agenda item' | translate }}"
[InputListValues]="itemObserver"
[inputListValues]="itemObserver"
></os-search-value-selector>
</div>
</ng-container>

View File

@ -5,14 +5,9 @@
[multiple]="true"
listname="{{ 'Attachments' | translate }}"
[formControl]="controlName"
[InputListValues]="mediaFileList"
[inputListValues]="mediaFileList"
></os-search-value-selector>
<button
type="button"
mat-icon-button
(click)="openUploadDialog(uploadDialog)"
*osPerms="'mediafiles.can_manage'"
>
<button type="button" mat-icon-button (click)="openUploadDialog(uploadDialog)" *osPerms="'mediafiles.can_manage'">
<mat-icon>cloud_upload</mat-icon>
</button>
</div>

View File

@ -2,7 +2,8 @@ import { Component, EventEmitter, Input, OnInit, Output, TemplateRef } from '@an
import { ControlValueAccessor, FormControl } from '@angular/forms';
import { MatDialog } from '@angular/material';
import { BehaviorSubject } from 'rxjs';
import { Observable } from 'rxjs';
import { map } from 'rxjs/operators';
import { MediafileRepositoryService } from 'app/core/repositories/mediafiles/mediafile-repository.service';
import { mediumDialogSettings } from 'app/shared/utils/dialog-settings';
@ -29,7 +30,7 @@ export class AttachmentControlComponent implements OnInit, ControlValueAccessor
/**
* The file list that is necessary for the `SearchValueSelector`
*/
public mediaFileList: BehaviorSubject<ViewMediafile[]> = new BehaviorSubject([]);
public mediaFileList: Observable<ViewMediafile[]>;
/**
* Default constructor
@ -43,7 +44,9 @@ export class AttachmentControlComponent implements OnInit, ControlValueAccessor
* On init method
*/
public ngOnInit(): void {
this.mediaFileList = this.mediaService.getViewModelListBehaviorSubject();
this.mediaFileList = this.mediaService
.getViewModelListObservable()
.pipe(map(files => files.filter(file => !file.is_directory)));
}
/**
@ -52,7 +55,7 @@ export class AttachmentControlComponent implements OnInit, ControlValueAccessor
* @param dialog the dialog to open
*/
public openUploadDialog(dialog: TemplateRef<string>): void {
this.dialogService.open(dialog, mediumDialogSettings);
this.dialogService.open(dialog, { ...mediumDialogSettings, disableClose: false });
}
/**

View File

@ -43,7 +43,7 @@
ngDefaultControl
[formControl]="extensionFieldForm.get('list')"
[fullWidth]="true"
[InputListValues]="searchList"
[inputListValues]="searchList"
[listname]="searchListLabel"
></os-search-value-selector>

View File

@ -21,7 +21,7 @@
[includeNone]="true"
[noneTitle]="'Base folder'"
listname="{{ 'Parent directory' | translate }}"
[InputListValues]="directoryBehaviorSubject"
[inputListValues]="directoryBehaviorSubject"
></os-search-value-selector>
</div>
@ -72,7 +72,7 @@
[formControl]="file.form.get('access_groups_id')"
[multiple]="true"
listname="{{ 'Access groups' | translate }}"
[InputListValues]="groupsBehaviorSubject"
[inputListValues]="groupsBehaviorSubject"
></os-search-value-selector>
</td>
</ng-container>

View File

@ -40,7 +40,7 @@ describe('SearchValueSelectorComponent', () => {
subjectList.push(new EmptySelectable());
}
const subject: BehaviorSubject<Selectable[]> = new BehaviorSubject(subjectList);
hostComponent.searchValueSelectorComponent.InputListValues = subject;
hostComponent.searchValueSelectorComponent.inputListValues = subject;
const formBuilder: FormBuilder = TestBed.get(FormBuilder);
const formGroup = formBuilder.group({

View File

@ -3,7 +3,7 @@ import { FormControl } from '@angular/forms';
import { MatSelect } from '@angular/material';
import { TranslateService } from '@ngx-translate/core';
import { BehaviorSubject, Subscription } from 'rxjs';
import { Observable, Subscription } from 'rxjs';
import { auditTime } from 'rxjs/operators';
import { Selectable } from '../selectable';
@ -79,7 +79,7 @@ export class SearchValueSelectorComponent implements OnDestroy {
* changes its values.
*/
@Input()
public set InputListValues(value: BehaviorSubject<Selectable[]>) {
public set inputListValues(value: Observable<Selectable[]>) {
if (!value) {
return;
}
@ -91,9 +91,9 @@ export class SearchValueSelectorComponent implements OnDestroy {
this._inputListSubscription = value.pipe(auditTime(10)).subscribe(items => {
this.selectableItems = items;
if (this.formControl) {
items.length === 0
? this.formControl.disable({ emitEvent: false })
: this.formControl.enable({ emitEvent: false });
!!items && items.length > 0
? this.formControl.enable({ emitEvent: false })
: this.formControl.disable({ emitEvent: false });
}
});
}

View File

@ -128,7 +128,7 @@
ngDefaultControl
[formControl]="addSpeakerForm.get('user_id')"
listname="{{ 'Select or search new speaker ...' | translate }}"
[InputListValues]="filteredUsers"
[inputListValues]="filteredUsers"
></os-search-value-selector>
</form>
</div>
@ -136,7 +136,12 @@
<!-- Add me and remove me if OP has correct permission -->
<div *osPerms="'agenda.can_be_speaker'" class="add-self-buttons">
<div *ngIf="speakers && !closedList">
<button mat-stroked-button [disabled]="viewListOfSpeakers.closed" (click)="addNewSpeaker()" *ngIf="!isOpInList() && canAddSelf">
<button
mat-stroked-button
[disabled]="viewListOfSpeakers.closed"
(click)="addNewSpeaker()"
*ngIf="!isOpInList() && canAddSelf"
>
<mat-icon>add</mat-icon>
<span translate>Add me</span>
</button>

View File

@ -199,7 +199,7 @@
[formControl]="candidatesForm.get('userId')"
[multiple]="false"
listname="{{ 'Select a new candidate' | translate }}"
[InputListValues]="filteredCandidates"
[inputListValues]="filteredCandidates"
></os-search-value-selector>
</form>
</div>
@ -263,16 +263,22 @@
[multiple]="true"
[includeNone]="true"
listname="{{ 'Tags' | translate }}"
[InputListValues]="tagsObserver"
[inputListValues]="tagsObserver"
></os-search-value-selector>
</div>
<!-- Attachments -->
<div class="content-field">
<os-attachment-control (errorHandler)="raiseError($event)" [controlName]="assignmentForm.get('attachments_id')"></os-attachment-control>
<os-attachment-control
(errorHandler)="raiseError($event)"
[controlName]="assignmentForm.get('attachments_id')"
></os-attachment-control>
</div>
<os-agenda-content-object-form *ngIf="newAssignment" [form]="assignmentForm"></os-agenda-content-object-form>
<os-agenda-content-object-form
*ngIf="newAssignment"
[form]="assignmentForm"
></os-agenda-content-object-form>
<!-- poll_description_default -->
<div>
@ -296,8 +302,12 @@
type="number"
required
/>
<mat-error *ngIf="assignmentForm.get('open_posts').hasError('required')">{{ 'This field is required.' | translate }}</mat-error>
<mat-error *ngIf="assignmentForm.get('open_posts').hasError('min')">{{ 'The number has to be greater than 0.' | translate }}</mat-error>
<mat-error *ngIf="assignmentForm.get('open_posts').hasError('required')">{{
'This field is required.' | translate
}}</mat-error>
<mat-error *ngIf="assignmentForm.get('open_posts').hasError('min')">{{
'The number has to be greater than 0.' | translate
}}</mat-error>
</mat-form-field>
</div>
<!-- TODO searchValueSelector: Parent -->

View File

@ -20,7 +20,7 @@
[multiple]="false"
[includeNone]="false"
listname="{{ 'Motion' | translate }}"
[InputListValues]="collectionObserver"
[inputListValues]="collectionObserver"
></os-search-value-selector>
</span>
<span class="spacer-left-20">

View File

@ -273,7 +273,7 @@
[formControl]="fileEditForm.get('access_groups_id')"
[multiple]="true"
listname="{{ 'Access groups' | translate }}"
[InputListValues]="groupsBehaviorSubject"
[inputListValues]="groupsBehaviorSubject"
></os-search-value-selector>
</form>
</div>
@ -308,7 +308,7 @@
[formControl]="newDirectoryForm.get('access_groups_id')"
[multiple]="true"
listname="{{ 'Access groups' | translate }}"
[InputListValues]="groupsBehaviorSubject"
[inputListValues]="groupsBehaviorSubject"
></os-search-value-selector>
</form>
</div>
@ -335,7 +335,7 @@
[includeNone]="true"
[noneTitle]="'Base folder'"
listname="{{ 'Parent directory' | translate }}"
[InputListValues]="filteredDirectoryBehaviorSubject"
[inputListValues]="filteredDirectoryBehaviorSubject"
></os-search-value-selector>
</div>
<div mat-dialog-actions>

View File

@ -14,10 +14,7 @@
<div class="head-spacer"></div>
<mat-accordion class="os-card">
<mat-expansion-panel
*ngFor="let section of this.commentSections"
multiple="false"
>
<mat-expansion-panel *ngFor="let section of this.commentSections" multiple="false">
<mat-expansion-panel-header>
<mat-panel-title>
<div class="header-container">
@ -95,7 +92,7 @@
[formControl]="commentFieldForm.get('read_groups_id')"
[multiple]="true"
listname="Groups with read permissions"
[InputListValues]="groups"
[inputListValues]="groups"
></os-search-value-selector>
</p>
<p>
@ -104,7 +101,7 @@
[formControl]="commentFieldForm.get('write_groups_id')"
[multiple]="true"
listname="Groups with write permissions"
[InputListValues]="groups"
[inputListValues]="groups"
></os-search-value-selector>
</p>
</form>

View File

@ -39,7 +39,7 @@
ngDefaultControl
[formControl]="addSubmitterForm.get('userId')"
listname="{{ 'Select or search new submitter ...' | translate }}"
[InputListValues]="users"
[inputListValues]="users"
></os-search-value-selector>
</form>

View File

@ -601,7 +601,7 @@
[formControl]="contentForm.get('submitters_id')"
[multiple]="true"
listname="{{ 'Submitters' | translate }}"
[InputListValues]="submitterObserver"
[inputListValues]="submitterObserver"
></os-search-value-selector>
</div>
</div>
@ -788,7 +788,7 @@
[formControl]="contentForm.get('category_id')"
[includeNone]="true"
listname="{{ 'Category' | translate }}"
[InputListValues]="categoryObserver"
[inputListValues]="categoryObserver"
></os-search-value-selector>
</div>
@ -823,7 +823,7 @@
[formControl]="contentForm.get('supporters_id')"
[multiple]="true"
listname="{{ 'Supporters' | translate }}"
[InputListValues]="supporterObserver"
[inputListValues]="supporterObserver"
></os-search-value-selector>
</div>
</div>
@ -835,7 +835,7 @@
ngDefaultControl
[formControl]="contentForm.get('workflow_id')"
listname="{{ 'Workflow' | translate }}"
[InputListValues]="workflowObserver"
[inputListValues]="workflowObserver"
></os-search-value-selector>
</div>
</div>

View File

@ -69,7 +69,10 @@
</div>
<!-- Attachments -->
<os-attachment-control [controlName]="topicForm.get('attachments_id')" (errorHandler)="raiseError($event)"></os-attachment-control>
<os-attachment-control
[controlName]="topicForm.get('attachments_id')"
(errorHandler)="raiseError($event)"
></os-attachment-control>
<div *ngIf="newTopic">
<!-- Visibility -->
@ -90,7 +93,7 @@
[formControl]="topicForm.get('agenda_parent_id')"
[includeNone]="true"
listname="{{ 'Parent agenda item' | translate }}"
[InputListValues]="itemObserver"
[inputListValues]="itemObserver"
></os-search-value-selector>
</div>
</div>