minor improvements

- add a 'lock' symbol to hidden files
- default disable (and rename) hidden filter status
- limit display of workflow states for restricted users
- remove supporter sorting
- mark other strings for translation
- fix new workflow id for statute amendments
- remove csv file type check (on Windows file type is always empty)
This commit is contained in:
Maximilian Krambach 2019-02-19 12:13:45 +01:00 committed by Emanuel Schütze
parent f09a39a3c3
commit 4c8da7b04d
7 changed files with 33 additions and 28 deletions

View File

@ -286,18 +286,10 @@ export abstract class BaseImportService<V extends BaseViewModel> {
* @param event type is Event, but has target.files, which typescript doesn't seem to recognize * @param event type is Event, but has target.files, which typescript doesn't seem to recognize
*/ */
public onSelectFile(event: any): void { public onSelectFile(event: any): void {
// TODO type // TODO: error message for wrong file type (test Firefox on Windows!)
if (event.target.files && event.target.files.length === 1) { if (event.target.files && event.target.files.length === 1) {
if (event.target.files[0].type.startsWith('text/csv')) {
this._rawFile = event.target.files[0]; this._rawFile = event.target.files[0];
this.readFile(event.target.files[0]); this.readFile(event.target.files[0]);
} else {
this.matSnackbar.open(this.translate.instant('Wrong file type detected. Import failed.'), '', {
duration: 3000
});
this.clearPreview();
this._rawFile = null;
}
} }
} }

View File

@ -53,7 +53,7 @@ export abstract class BaseSortListService<V extends BaseViewModel> {
/** /**
* Constructor. Does nothing. TranslateService is used for localeCompeare. * Constructor. Does nothing. TranslateService is used for localeCompeare.
*/ */
public constructor(private translate: TranslateService, private store: StorageService) {} public constructor(public translate: TranslateService, private store: StorageService) {}
/** /**
* Put an array of data that you want sorted. * Put an array of data that you want sorted.

View File

@ -78,7 +78,12 @@
<!-- Filename --> <!-- Filename -->
<ng-container matColumnDef="title"> <ng-container matColumnDef="title">
<mat-header-cell *matHeaderCellDef mat-sort-header>Name</mat-header-cell> <mat-header-cell *matHeaderCellDef mat-sort-header>Name</mat-header-cell>
<mat-cell *matCellDef="let file" (click)="selectItem(file, $event)">{{ file.title }}</mat-cell> <mat-cell *matCellDef="let file" (click)="selectItem(file, $event)">
<span *ngIf="file.is_hidden">
<mat-icon matTooltip="{{'is hidden' | translate }}">lock</mat-icon>
&nbsp;
</span>
{{ file.title }}</mat-cell>
</ng-container> </ng-container>
<!-- Info --> <!-- Info -->

View File

@ -37,10 +37,10 @@ export class MediafileFilterListService extends BaseFilterListService<Mediafile,
*/ */
public hiddenOptions: OsFilter = { public hiddenOptions: OsFilter = {
property: 'is_hidden', property: 'is_hidden',
label: this.translate.instant('Hidden'), label: this.translate.instant('Hidden status'),
options: [ options: [
{ condition: true, label: this.translate.instant('is hidden') }, { condition: true, label: this.translate.instant('is hidden') },
{ condition: false, label: this.translate.instant('is not hidden'), isActive: true } { condition: false, label: this.translate.instant('is not hidden') }
] ]
}; };

View File

@ -12,6 +12,7 @@ import { MotionCommentSectionRepositoryService } from 'app/core/repositories/mot
import { TranslateService } from '@ngx-translate/core'; import { TranslateService } from '@ngx-translate/core';
import { ConfigService } from 'app/core/ui-services/config.service'; import { ConfigService } from 'app/core/ui-services/config.service';
import { ViewWorkflow } from '../models/view-workflow'; import { ViewWorkflow } from '../models/view-workflow';
import { OperatorService } from 'app/core/core-services/operator.service';
@Injectable({ @Injectable({
providedIn: 'root' providedIn: 'root'
@ -134,7 +135,8 @@ export class MotionFilterListService extends BaseFilterListService<Motion, ViewM
private commentRepo: MotionCommentSectionRepositoryService, private commentRepo: MotionCommentSectionRepositoryService,
private translate: TranslateService, private translate: TranslateService,
private config: ConfigService, private config: ConfigService,
motionRepo: MotionRepositoryService motionRepo: MotionRepositoryService,
private operator: OperatorService
) { ) {
super(store, motionRepo); super(store, motionRepo);
this.subscribeWorkflows(); this.subscribeWorkflows();
@ -248,6 +250,11 @@ export class MotionFilterListService extends BaseFilterListService<Motion, ViewM
workflowOptions.push(workflow.name); workflowOptions.push(workflow.name);
recommendationOptions.push(workflow.name); recommendationOptions.push(workflow.name);
workflow.states.forEach(state => { workflow.states.forEach(state => {
// filter out restricted states for unpriviledged users
if (
this.operator.hasPerms('motions.can_manage', 'motions.can_manage_metadata') ||
state.access_level === 0
) {
if (state.isFinalState) { if (state.isFinalState) {
finalStates.push(state.id); finalStates.push(state.id);
} else { } else {
@ -258,6 +265,7 @@ export class MotionFilterListService extends BaseFilterListService<Motion, ViewM
label: state.name, label: state.name,
isActive: false isActive: false
}); });
}
if (state.recommendation_label) { if (state.recommendation_label) {
recommendationOptions.push({ recommendationOptions.push({
condition: state.id, condition: state.id,

View File

@ -15,15 +15,14 @@ export class MotionSortListService extends BaseSortListService<ViewMotion> {
sortAscending: true, sortAscending: true,
options: [ options: [
{ property: 'callListWeight', label: 'Call list' }, { property: 'callListWeight', label: 'Call list' },
{ property: 'supporters' },
{ property: 'identifier' }, { property: 'identifier' },
{ property: 'title' }, { property: 'title' },
{ property: 'submitters' }, { property: 'submitters' },
{ property: 'category' }, { property: 'category' },
{ property: 'motion_block_id', label: 'Motion block' }, { property: 'motion_block_id', label: 'Motion block' },
{ property: 'state' }, { property: 'state' },
{ property: 'creationDate', label: 'Creation date' }, { property: 'creationDate', label: this.translate.instant('Creation date') },
{ property: 'lastChangeDate', label: 'Last modified' } { property: 'lastChangeDate', label: this.translate.instant('Last modified') }
] ]
}; };
protected name = 'Motion'; protected name = 'Motion';

View File

@ -163,6 +163,7 @@ class MotionViewSet(ModelViewSet):
"reason", "reason",
"category_id", "category_id",
"statute_paragraph_id", "statute_paragraph_id",
"workflow_id",
] ]
if parent_motion is not None: if parent_motion is not None:
# For creating amendments. # For creating amendments.