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

TOLK-2142 : Som tolk ønsker jeg å kunne laste opp fil til tolkebruker #2031

Open
wants to merge 38 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
d6dbf48
.
olsenrasmus Jul 11, 2024
f28d197
Forbedringer
olsenrasmus Jul 12, 2024
1190fb4
Merge branch 'master' into TOLK-2142
olsenrasmus Jul 17, 2024
2417c9d
Merge branch 'master' into TOLK-2142
olsenrasmus Aug 22, 2024
61bda1e
.
olsenrasmus Aug 22, 2024
4e220ea
ps
olsenrasmus Aug 22, 2024
2643593
.
olsenrasmus Aug 23, 2024
89f9b33
Merge branch 'master' into TOLK-2142
olsenrasmus Aug 26, 2024
ec9db41
Merge branch 'master' into TOLK-2142
olsenrasmus Aug 26, 2024
3e17942
merge main into TOLK 2142
AndreMarthinsen Oct 18, 2024
101cd23
legge til endringer i ny modal
AndreMarthinsen Oct 21, 2024
5bc5614
delvis refactor av modal
MathiBK Oct 21, 2024
33d1888
fikse wage claim modal bug
MathiBK Oct 22, 2024
6565ec8
midlertidige endrigner
MathiBK Oct 29, 2024
fe9ee88
legge til lightning modal funksjonalitet
MathiBK Oct 31, 2024
5e8c39c
legge til modal for wanted seervice appointment
MathiBK Nov 4, 2024
713ab56
Update settings.json
MathiBK Nov 4, 2024
b8361ef
fikse logs og unødvendig kode
MathiBK Nov 4, 2024
5923416
fjerne mer unødvendig kode
MathiBK Nov 4, 2024
ce84cb4
fjerne mer unødvendig kode
MathiBK Nov 4, 2024
7c73331
Merge pull request #2122 from navikt/TOLK-2142-bytte-til-lightning-modal
MathiBK Nov 5, 2024
487a935
Legge til klasse og flow for filopplasting mellom tolk og bruker + fi…
MathiBK Nov 21, 2024
b34421a
slette test som ikke fungerer
MathiBK Nov 27, 2024
f0d8976
legge til deletion av filer
MathiBK Nov 27, 2024
41bac2b
fikse feil med visning av opplastede filer
MathiBK Nov 28, 2024
f106253
filse slette policy feil
MathiBK Nov 28, 2024
12d7725
fikse ledige oppdrag modal feil
MathiBK Nov 28, 2024
75b6a2d
Merge branch 'master' into TOLK-2142
MathiBK Nov 28, 2024
d5a789b
fjerne litt comments
MathiBK Nov 28, 2024
bfb4576
fikse modal css og fjerne case feed perm
MathiBK Nov 28, 2024
2a3ab0d
Fikse feil hvor tolk ikke kunne se hva bruker hadde lastet opp
MathiBK Dec 5, 2024
d9c216f
Fjerne unødvendig permset
MathiBK Dec 6, 2024
21b7b8a
Oppdatere css
MathiBK Dec 6, 2024
838b33e
Merge branch 'master' into TOLK-2142
MathiBK Dec 6, 2024
b3e1227
legge til test for HOT_RecordFilesControllerWithSharing
MathiBK Dec 11, 2024
18f50fd
Merge branch 'master' into TOLK-2142
MathiBK Dec 11, 2024
ad2aa5c
Merge branch 'master' into TOLK-2142
MathiBK Jan 6, 2025
25c7699
Merge branch 'master' into TOLK-2142
MathiBK Jan 10, 2025
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
@@ -0,0 +1,34 @@
public with sharing class HOT_RecordFilesControllerWithSharing {
@AuraEnabled(cacheable=true)
public static List<ContentDocument> getContentDocuments(String recordId, Boolean isGetAll) {
if (recordId == null) {
return new List<ContentDocument>{};
}
List<ServiceAppointment> serviceAppointments=[SELECT Id FROM ServiceAppointment WHERE HOT_WorkOrderLineItem__r.WorkOrderId=:recordId];
Set<Id>saIds=new Set<Id>();
for(ServiceAppointment sa : serviceAppointments){
saIds.add(sa.Id);
}
List<ContentDocumentLink> contentDocumentLinks = [
SELECT ContentDocumentId
FROM ContentDocumentLink
WHERE LinkedEntityId = :recordId OR LinkedEntityId IN :saIds
];

List<Id> contentDocumentIds = new List<Id>();
for (ContentDocumentLink contentDocumentLink : contentDocumentLinks) {
contentDocumentIds.add(contentDocumentLink.ContentDocumentId);
}

if (!isGetAll) {
contentDocumentIds = RecordFilesControllerWithSharing.getOnlyMyContentDocuments(contentDocumentIds);
}

List<ContentDocument> contentDocuments = [
SELECT Id, FileType, CreatedDate, Title
FROM ContentDocument
WHERE Id IN :contentDocumentIds AND ContentAssetId = NULL
];
return contentDocuments;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
<apiVersion>56.0</apiVersion>
<status>Active</status>
</ApexClass>
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
.header {
margin: 0;
font-family: 'Source Sans Pro', Arial, sans-serif;
font-size: 1.125rem;
line-height: 1.375rem;
font-weight: 600;
}

.listelement {
margin: 0;
font-family: 'Source Sans Pro', Arial, sans-serif;
font-size: 1rem;
line-height: 1.375rem;
}

.navds-button {
cursor: pointer;
color: #ba3a26;
text-align: center;
text-decoration: none;
align-items: center;
padding: 0;
font-weight: bold;
font-size: 1rem;
border-color: transparent;
background-color: transparent;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<template>
<section if:false={isContentDocumentsEmpty}>
<h3 class="header" if:true={filesToShowLength} style={headerAlign}>{defaultTitle}</h3>
<ul>
<template for:each={filesToShow} for:item="file" for:index="index">
<li key={file.Title}>
<a
if:false={noDownloadLink}
class="listelement"
style="margin: 0 0.5em 0 0"
href={file.downloadLink}
>{file.Title}
</a>
<p if:true={noDownloadLink} class="listelement" style="margin: 0 0.5em 0 0">{file.Title}</p>
<div if:true={isDelete} style="display: inline">
<button
if:true={file.isDeletable}
onfocus={onFileFocus}
aria-label={fileButtonLabel}
data-index={index}
key={file.Title}
type="button"
value={file.Title}
class="navds-button"
onclick={onFileDelete}
>
Slett
</button>
</div>
</li>
</template>
</ul>
</section>
</template>
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
import { LightningElement, api, wire, track } from 'lwc';
import getContentDocuments from '@salesforce/apex/HOT_RecordFilesControllerWithSharing.getContentDocuments';
import getBaseDownloadUrl from '@salesforce/apex/RecordFilesControllerWithSharing.getBaseDownloadUrl';
import deleteFilesOnRecord from '@salesforce/apex/RecordFilesControllerWithSharing.deleteFilesOnRecord';
import getOnlyMyContentDocuments from '@salesforce/apex/RecordFilesControllerWithSharing.getOnlyMyContentDocuments';
import { setDefaultValue, convertStringToBoolean } from 'c/componentHelperClass';
import { refreshApex } from '@salesforce/apex';
export default class hot_recordFilesWithSharing extends LightningElement {
@api recordId;
@api title;
@api files = [];
@api isGetAll = false;
@api isDeleteOption = false;
@api deleteFileOnButtonClick = false;
@api headerAlignment;
@api noDownloadLink = false;
contentDocuments = [];
myContentDocuments = [];
isContentDocumentsEmpty = false;
@track filesToShow = [];

get contentDocumentsArray() {
return this.recordId === undefined ? this.files : this.contentDocuments;
}

get defaultTitle() {
return setDefaultValue(this.title, 'Vedlegg');
}

get isDelete() {
return convertStringToBoolean(this.isDeleteOption);
}

get headerAlign() {
return 'align-items: ' + setDefaultValue(this.headerAlignment + ';', 'center;');
}

renderedCallback() {
this.hasFiles();
}

hasFiles() {
this.isContentDocumentsEmpty = this.contentDocuments.length === 0 && this.files.length === 0 ? true : false;
}

@api checkIfEmpty() {
return this.isContentDocumentsEmpty;
}

fileButtonLabel;
onFileFocus(event) {
this.fileButtonLabel = '';
const index = event.currentTarget.dataset.index;
this.fileButtonLabel = 'Slett vedlegg ' + this.filesToShow[index].Title;
}

markFilesAvailableForDeletion() {
this.filesToShow = [...this.contentDocumentsArray]; // Copy value to be able to set new attribute
this.filesToShowLength = this.filesToShow.length > 0;
this.filesToShow.forEach((item) => {
this.myContentDocuments.forEach((myItem) => {
if (item.Id === myItem) {
item.isDeletable = true;
}
});
});
}

// Call this when submit/save is run to delete selected files
@api deleteMarkedFiles() {
if (this.filesToDelete.length > 0) {
deleteFilesOnRecord({ files: this.filesToDelete }).then(() => {
refreshApex(this.wiredGetContentDocumentsResult);
});
}
}

filesToDelete = [];
filesToShowLength = false;
onFileDelete(event) {
const index = event.currentTarget.dataset.index;
if (this.filesToShow.length < index) {
return;
}
this.filesToDelete.push(this.filesToShow[index].Id);
this.filesToShow.splice(index, 1);
this.filesToShowLength = this.filesToShow.length > 0;
if (this.deleteFileOnButtonClick) {
this.deleteMarkedFiles();
}
}

wiredGetContentDocumentsResult;
@wire(getContentDocuments, { recordId: '$recordId', isGetAll: '$isGetAll' })
async wiredgetContentDocuments(result) {
this.wiredGetContentDocumentsResult = result;
if (result.data) {
const url = await getBaseDownloadUrl();

// Using a Set to ensure unique ContentDocumentIds
const uniqueContentDocumentIds = new Set();
this.contentDocuments = [];

result.data.forEach((item) => {
if (!uniqueContentDocumentIds.has(item.Id)) {
uniqueContentDocumentIds.add(item.Id);
this.contentDocuments.push({
...item,
downloadLink: url + item.Id
});
}
});

this.hasFiles();
const contentDocumentIds = Array.from(uniqueContentDocumentIds);

getOnlyMyContentDocuments({ contentDocumentIds: contentDocumentIds }).then((res) => {
this.myContentDocuments = res;
this.markFilesAvailableForDeletion();
});
}
}

@api refreshContentDocuments() {
refreshApex(this.wiredGetContentDocumentsResult);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata">
<apiVersion>52.0</apiVersion>
<isExposed>false</isExposed>
</LightningComponentBundle>
Original file line number Diff line number Diff line change
Expand Up @@ -70,3 +70,19 @@ span {
.hidden {
display: none;
}
.fileUploadContainer {
background-color: #f2f3f5;
justify-content: center;
align-items: center;
margin: auto;
border-radius: 4px;
padding: 1.5rem;
}
@media (max-width: 576px) {
.fileUploadContainer {
justify-content: center;
align-items: center;
margin: auto;
width: 100%;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ <h2 class="typo-undertittel">Informasjon om oppdraget:</h2>
<c-record-files-with-sharing
record-id={serviceAppointment.Id}
is-get-all="true"
is-delete-option="false"
is-delete-option="true"
title="Vedlegg"
delete-file-on-button-click="false"
></c-record-files-with-sharing>
Expand Down Expand Up @@ -196,6 +196,22 @@ <h2 class="typo-undertittel">Informasjon om oppdraget:</h2>
>
</c-button>
</div>
<div class="fileUploadContainer">
<h2>Legg ved filer til bruker</h2>
<lightning-file-upload
record-id={recordId}
name="fileUploader"
class="file-selector-large"
label="Ved å laste opp filer er jeg klar over at filene vil bli delt med tolkebruker. Opplastingen vil starte umiddelbart. Maks filstørelse: 2 GB."
title="Maks filstørrelse: 2 GB."
onuploadfinished={handleUploadFinished}
multiple
>
</lightning-file-upload>
<br if:true={fileUploadMessage} />
<p if:true={fileUploadMessage} class="typo-normal">{fileUploadMessage}</p>
<br />
</div>
</div>
</div>
</section>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -524,6 +524,16 @@ export default class Hot_myServiceAppointments extends NavigationMixin(Lightning
}
return this.filteredRecordsLength;
}
@track fileUploadMessage;
handleUploadFinished(event) {
const uploadedFiles = event.detail.files;
if (uploadedFiles.length > 0) {
this.fileUploadMessage = 'Filen(e) ble lastet opp. Se filen i listen over vedlegg ovenfor.';
this.template.querySelector('c-record-files-with-sharing').refreshContentDocuments();
} else {
this.fileUploadMessage = '';
}
}
changeStatus() {
this.isflow = true;
this.isEditButtonDisabled = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,4 +201,9 @@ public without sharing class HOT_WorkOrderListController {
}
return Id;
}
@AuraEnabled(cacheable=true)
public static List<ServiceAppointment> getServiceAppointmentsIds(String workOrderId) {
List<ServiceAppointment> saIds = [SELECT Id FROM ServiceAppointment WHERE HOT_WorkOrderLineItem__r.WorkOrderId=:workOrderId];
return saIds;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -89,14 +89,14 @@ <h2 class="header" tabindex="-1" autofocus>{headerToShow}</h2>
<strong>Tilleggsopplysninger: </strong><span>{request.Description__c}</span>
</p>
</div>
<c-record-files-with-sharing
<c-hot_record-files-with-sharing
if:true={isSeries}
record-id={request.Id}
is-get-all={isGetAllFiles}
is-delete-option="true"
title="Vedlegg"
delete-file-on-button-click="true"
></c-record-files-with-sharing>
></c-hot_record-files-with-sharing>
<br />
</div>
<div if:true={isWorkOrderDetails}>
Expand Down Expand Up @@ -154,14 +154,14 @@ <h2 class="header" tabindex="-1" autofocus>{headerToShow}</h2>
<strong>Tilleggsopplysninger: </strong><span>{request.Description__c}</span>
</p>
</div>
<c-record-files-with-sharing
if:false={isSeries}
record-id={request.Id}
<!-- Lag heller en sjekk om if WO så vises denne -->
<c-hot_record-files-with-sharing
record-id={workOrder.Id}
is-get-all={isGetAllFiles}
is-delete-option="true"
title="Vedlegg"
delete-file-on-button-click="true"
></c-record-files-with-sharing>
></c-hot_record-files-with-sharing>
<br />
</div>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export default class MineBestillingerWrapper extends NavigationMixin(LightningEl
const uploadedFiles = event.detail.files;
if (uploadedFiles.length > 0) {
this.fileUploadMessage = 'Filen(e) ble lastet opp';
this.template.querySelector('c-record-files-with-sharing').refreshContentDocuments();
this.template.querySelector('c-hot_record-files-with-sharing').refreshContentDocuments();
}
}

Expand Down Expand Up @@ -347,6 +347,7 @@ export default class MineBestillingerWrapper extends NavigationMixin(LightningEl
this.isWorkOrderDetails = this.urlStateParameters.level === 'WO';
this.isRequestOrWorkOrderDetails = this.isWorkOrderDetails || this.isRequestDetails;
this.isSeries = this.workOrder?.HOT_Request__r?.IsSerieoppdrag__c;
console.log('serie? ' + this.isSeries);
this.interpreter = this.workOrder?.HOT_Interpreters__c?.length > 1 ? 'Tolker' : 'Tolk';
this.isOrdererWantStatusUpdateOnSMS = this.request.IsOrdererWantStatusUpdateOnSMS__c ? 'Ja' : 'Nei';
this.IsNotNotifyAccount = this.request.IsNotNotifyAccount__c ? 'Nei' : 'Ja';
Expand Down Expand Up @@ -567,8 +568,8 @@ export default class MineBestillingerWrapper extends NavigationMixin(LightningEl
}

onUploadComplete() {
if (this.template.querySelector('c-record-files-with-sharing') !== null) {
this.template.querySelector('c-record-files-with-sharing').refreshContentDocuments();
if (this.template.querySelector('c-hot_record-files-with-sharing') !== null) {
this.template.querySelector('c-hot_record-files-with-sharing').refreshContentDocuments();
}
this.template.querySelector('.loader').classList.add('hidden');
this.modalHeader = 'Suksess!';
Expand Down Expand Up @@ -643,7 +644,7 @@ export default class MineBestillingerWrapper extends NavigationMixin(LightningEl
}

deleteMarkedFiles() {
this.template.querySelector('c-record-files-with-sharing').deleteMarkedFiles();
this.template.querySelector('c-hot_record-files-with-sharing').deleteMarkedFiles();
}

navigateToThread(recordId) {
Expand Down
Loading