Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/add editmode checking on attachment and revision #611

Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,6 @@
bottom: 0;
width: 93%;
}
.pia-cardsBlock-item-form {
padding-bottom: 65px;
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,6 @@
bottom: 0;
width: 93%;
}
.pia-cardsBlock-item-form {
padding-bottom: 65px;
}
20 changes: 20 additions & 0 deletions src/app/modules/entries/cards/pia-card/pia-card.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,11 @@
>
{{ item.display }}
<delete-icon
*ngIf="
authService.currentUserValue.access_type.includes(
'functional'
)
"
(click)="input.removeItem(item, index)"
></delete-icon>
</div>
Expand Down Expand Up @@ -194,6 +199,11 @@
>
{{ item.display }}
<delete-icon
*ngIf="
authService.currentUserValue.access_type.includes(
'functional'
)
"
(click)="input.removeItem(item, index)"
></delete-icon>
</div>
Expand Down Expand Up @@ -255,6 +265,11 @@
>
{{ item.display }}
<delete-icon
*ngIf="
authService.currentUserValue.access_type.includes(
'functional'
)
"
(click)="input.removeItem(item, index)"
></delete-icon>
</div>
Expand Down Expand Up @@ -312,6 +327,11 @@
<div [ngClass]="{ 'custom-tag': true }">
{{ item.display }}
<delete-icon
*ngIf="
authService.currentUserValue.access_type.includes(
'functional'
)
"
(click)="input.removeItem(item, index)"
></delete-icon>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,6 @@
bottom: 0;
width: 93%;
}
.pia-cardsBlock-item-form {
padding-bottom: 65px;
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,6 @@
bottom: 0;
width: 93%;
}
.pia-cardsBlock-item-form {
padding-bottom: 65px;
}
Original file line number Diff line number Diff line change
@@ -1,41 +1,86 @@
<div class="pia-attachmentsBlock-item bounceIn" *ngIf="attachment.file && attachment.file.length > 0">
<a href="javascript:;" (click)="downloadAttachment()" title="{{ 'pia.attachments.download' | translate }}">
<div
class="pia-attachmentsBlock-item bounceIn"
*ngIf="attachment.file && attachment.file.length > 0"
>
<a
href="javascript:;"
(click)="downloadAttachment()"
title="{{ 'pia.attachments.download' | translate }}"
>
<i class="fa fa-download" aria-hidden="true"></i>
</a>
<a href="javascript:;" (click)="previewAttachment(true)" title="{{attachment.name}}" class="truncate">{{attachment.name}}</a>
<button *ngIf="!isPreview && showAddAttachmentButton()" type="button" class="btn" (click)="removeAttachment(attachment.id)" title="{{ 'pia.attachments.remove' | translate }}">
<a
href="javascript:;"
(click)="previewAttachment(true)"
title="{{ attachment.name }}"
class="truncate"
>{{ attachment.name }}</a
>
<button
*ngIf="
!isPreview &&
showAddAttachmentButton() &&
(['author', 'validator', 'evaluator'].indexOf(editMode[0]) >= 0 ||
editMode === 'local')
"
type="button"
class="btn"
(click)="removeAttachment(attachment.id)"
title="{{ 'pia.attachments.remove' | translate }}"
>
<span class="pia-icons pia-icon-close"></span>
</button>
</div>
<div class="pia-attachmentsBlock-item-preview hide">
<img src="" class="hide">
<button (click)="previewAttachment(false)" class="pia-icons pia-icon-close-big" title="{{ 'modals.close' | translate }}"></button>
<div style="width:80%; height:100%; margin:auto;"
*ngIf="fileUrl" >
<img src="" class="hide" />
<button
(click)="previewAttachment(false)"
class="pia-icons pia-icon-close-big"
title="{{ 'modals.close' | translate }}"
></button>
<div style="width:80%; height:100%; margin:auto;" *ngIf="fileUrl">
<ng2-pdfjs-viewer
[pdfSrc]="fileUrl"
[openFile]="false"
[viewBookmark]="false">
[viewBookmark]="false"
>
</ng2-pdfjs-viewer>
</div>
</div>

<app-modal *ngIf="showRemoveAttachmentForm" (clickOnClose)="showRemoveAttachmentForm = false">
<app-modal
*ngIf="showRemoveAttachmentForm"
(clickOnClose)="showRemoveAttachmentForm = false"
>
<p [innerHTML]="'modals.remove_attachment.content' | translate"></p>
<form [formGroup]="removeAttachmentForm" class="pia-remove-attachment-comment">
<label for="pia-remove-attachment-comment">{{ 'modals.remove_attachment.comment' | translate }}</label>
<br>
<textarea id="pia-remove-attachment-comment"
formControlName="comment">
</textarea>
</form>
<div class="pia-modalBlock-buttons-choice">
<button tabindex="1" class="btn btn-red" type="button" (click)="showRemoveAttachmentForm = false">
{{ 'modals.remove_attachment.keep' | translate }}
</button>
<button tabindex="2" class="btn btn-red get-focus" [disabled]="removeAttachmentForm.invalid"
(click)="submitRemoveAttachment()" type="button">
{{ 'modals.remove_attachment.remove' | translate }}
</button>
</div>
<form
[formGroup]="removeAttachmentForm"
class="pia-remove-attachment-comment"
>
<label for="pia-remove-attachment-comment">{{
"modals.remove_attachment.comment" | translate
}}</label>
<br />
<textarea id="pia-remove-attachment-comment" formControlName="comment">
</textarea>
</form>
<div class="pia-modalBlock-buttons-choice">
<button
tabindex="1"
class="btn btn-red"
type="button"
(click)="showRemoveAttachmentForm = false"
>
{{ "modals.remove_attachment.keep" | translate }}
</button>
<button
tabindex="2"
class="btn btn-red get-focus"
[disabled]="removeAttachmentForm.invalid"
(click)="submitRemoveAttachment()"
type="button"
>
{{ "modals.remove_attachment.remove" | translate }}
</button>
</div>
</app-modal>
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ import { AttachmentsService } from 'src/app/services/attachments.service';
})
export class AttachmentItemComponent implements OnInit {
@ViewChild('pdfViewerAutoLoad', { static: false }) pdfViewerAutoLoad;

@Input() editMode: 'local' | 'author' | 'evaluator' | 'validator' | 'guest' =
'local';
@Input() isPreview: boolean;
@Input() attachment: Attachment;
@Input() pia: any;
Expand Down
57 changes: 42 additions & 15 deletions src/app/modules/pia/attachments/attachments.component.html
Original file line number Diff line number Diff line change
@@ -1,25 +1,52 @@
<div class="pia-attachmentsBlock" *ngIf="attachments">
<p>{{ 'pia.attachments.title' | translate }}</p>
<div class="pia-attachmentsBlock" *ngIf="attachments">
<p>{{ "pia.attachments.title" | translate }}</p>

<app-attachment-item
*ngFor="let attachment of attachments;let i=index"
[attachment]="attachment"
(deleted)="onDeleted($event)"
[isPreview]="isPreview" [pia]="pia">
</app-attachment-item>
<ng-container *ngIf="attachments.length > 0; else noAttachments">
<app-attachment-item
[editMode]="editMode"
*ngFor="let attachment of attachments; let i = index"
[attachment]="attachment"
(deleted)="onDeleted($event)"
[isPreview]="isPreview"
[pia]="pia"
>
</app-attachment-item>
</ng-container>
<ng-template #noAttachments>
<p>
<small>{{ "pia.attachments.no_attachment" | translate }}</small>
</p>
</ng-template>

<form *ngIf="!isPreview && attachments" enctype="multipart/form-data" [formGroup]="attachmentForm">
<input type="file" formControlName="attachment_file" id="attachment_file" (change)="uploadAttachement($event)" class="hide">
<button class="pia-attachmentsBlock-addBtn btn"
<form
*ngIf="!isPreview && attachments"
enctype="multipart/form-data"
[formGroup]="attachmentForm"
>
<input
type="file"
formControlName="attachment_file"
id="attachment_file"
(change)="uploadAttachement($event)"
class="hide"
/>
<button
class="pia-attachmentsBlock-addBtn btn"
*ngIf="
['author', 'validator', 'evaluator'].indexOf(editMode[0]) >= 0 ||
editMode === 'local'
"
[disabled]="loading"
[ngClass]="{'hide': !dispplayAttachmentButton}" type="button"
(click)="addAttachment()">
[ngClass]="{ hide: !dispplayAttachmentButton }"
type="button"
(click)="addAttachment()"
>
<ng-container *ngIf="!loading; else loadingElse">
<span class="pia-icons pia-icon-add"></span>
{{ 'pia.attachments.add' | translate }}
{{ "pia.attachments.add" | translate }}
</ng-container>
<ng-template #loadingElse>
{{ 'pia.attachments.loading' | translate }}
{{ "pia.attachments.loading" | translate }}
</ng-template>
</button>
</form>
Expand Down
10 changes: 7 additions & 3 deletions src/app/modules/pia/attachments/attachments.component.scss
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
@import '~src/assets/stylesheets/variables';
@import "~src/assets/stylesheets/variables";
.pia {
&-attachmentsBlock {
box-shadow: 0px 1px 4px 0px rgba(0, 0, 0, 0.2);
background-color: #fff;
margin: 10px 0;
padding: 10px;
padding: 10px;
p {
margin-top:0;
margin-top: 0;
color: $pia-dark-black;
font-size: 1.1rem;
text-transform: uppercase;
Expand All @@ -20,6 +20,10 @@
span {
margin-right: 10px;
}
&:disabled {
border: 0px;
color: $pia-gray;
}
}
}
}
2 changes: 2 additions & 0 deletions src/app/modules/pia/attachments/attachments.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import { AttachmentsService } from 'src/app/services/attachments.service';
export class AttachmentsComponent implements OnInit {
@Input() isPreview: boolean;
@Input() pia: Pia;
@Input() editMode: 'local' | 'author' | 'evaluator' | 'validator' | 'guest' =
'local';
attachments: Array<Attachment> = [];
attachmentForm: FormGroup;
dispplayAttachmentButton = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,9 @@
></div>
<textarea
*ngIf="
question.answer_type == 'text' || question.answer_type == 'gauge'
"
[attr.disabled]="
!editMode.includes('author') && editMode !== 'local' ? 'true' : null
(question.answer_type == 'text' ||
question.answer_type == 'gauge') &&
(editMode.includes('author') || editMode === 'local')
"
[attr.data-id]="question.id"
id="pia-question-content-{{ question.id }}"
Expand Down
11 changes: 7 additions & 4 deletions src/app/modules/pia/content/questions/questions.component.scss
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
@import '~src/assets/stylesheets/variables';
@import "~src/assets/stylesheets/variables";
.pia {
&-questionBlock {
position: relative;
margin-bottom: 10px;
background-color: #fff;
padding: 12px 40px;
box-shadow: 1px 1px 15px 1px rgba(210,210,210,1);
box-shadow: 1px 1px 15px 1px rgba(210, 210, 210, 1);
.pia-accordeon {
position: absolute;
right: 15px;
top: 22px;
cursor: pointer;
&:before {
position: absolute;
content: '';
content: "";
top: -4px;
right: -4px;
left: -4px;
Expand Down Expand Up @@ -57,8 +57,11 @@
&::placeholder {
font-style: italic;
}
&:disabled {
&.hide {
padding: 0px;
background-color: transparent;
min-height: 0;
max-height: 0;
color: $pia-dark-black;
cursor: pointer;
}
Expand Down
3 changes: 2 additions & 1 deletion src/app/modules/pia/pia.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,13 @@
[section]="section"
[item]="item"
></app-sections>
<app-attachments [pia]="pia"></app-attachments>
<app-attachments [pia]="pia" [editMode]="editMode"></app-attachments>
<app-revisions
*ngIf="pia.is_example == 0 && pia.is_archive == 0"
[pia]="pia"
[title]="false"
[currentVersion]="pia.updated_at"
[editMode]="editMode"
>
</app-revisions>
</aside>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,12 @@
<div>{{ "homepage.cards.item.tools.export" | translate }}</div>
</button>
</div>
<div>
<div
*ngIf="
['author', 'validator', 'evaluator'].indexOf(editMode[0]) >= 0 ||
editMode === 'local'
"
>
<button type="button" (click)="restoreRevision()">
<i aria-hidden="true" class="fa fa-refresh"></i>
<div>{{ "summary.revision.restore_version" | translate }}</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ export class RevisionPreviewComponent implements OnInit {
@Input() revision: Revision;
@Input() date: Date;
@Output() restored = new EventEmitter();
@Input() editMode: 'local' | 'author' | 'evaluator' | 'validator' | 'guest' =
'local';
export: any;
pia: Pia;
allData: any;
Expand Down
Loading