Fixes directories as attachments

- Directories are not available anymore.
This commit is contained in:
GabrielMeyer 2019-08-21 09:03:07 +02:00
parent bbe294a1ad
commit 4dd79296e8
15 changed files with 59 additions and 46 deletions

View File

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

View File

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

View File

@ -2,7 +2,8 @@ import { Component, EventEmitter, Input, OnInit, Output, TemplateRef } from '@an
import { ControlValueAccessor, FormControl } from '@angular/forms'; import { ControlValueAccessor, FormControl } from '@angular/forms';
import { MatDialog } from '@angular/material'; 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 { MediafileRepositoryService } from 'app/core/repositories/mediafiles/mediafile-repository.service';
import { mediumDialogSettings } from 'app/shared/utils/dialog-settings'; 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` * The file list that is necessary for the `SearchValueSelector`
*/ */
public mediaFileList: BehaviorSubject<ViewMediafile[]> = new BehaviorSubject([]); public mediaFileList: Observable<ViewMediafile[]>;
/** /**
* Default constructor * Default constructor
@ -43,7 +44,9 @@ export class AttachmentControlComponent implements OnInit, ControlValueAccessor
* On init method * On init method
*/ */
public ngOnInit(): void { 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 * @param dialog the dialog to open
*/ */
public openUploadDialog(dialog: TemplateRef<string>): void { 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 ngDefaultControl
[formControl]="extensionFieldForm.get('list')" [formControl]="extensionFieldForm.get('list')"
[fullWidth]="true" [fullWidth]="true"
[InputListValues]="searchList" [inputListValues]="searchList"
[listname]="searchListLabel" [listname]="searchListLabel"
></os-search-value-selector> ></os-search-value-selector>

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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