解决冲突

This commit is contained in:
min.jiang 2024-06-23 01:21:10 +08:00
parent e3806926d2
commit 22732f2061
3 changed files with 57 additions and 24 deletions

View File

@ -75,12 +75,12 @@
Propose Propose
</button> </button>
<div class="request-description-content" v-html="request.content"></div> <div class="request-description-content" v-html="request.content"></div>
<div v-for="(file, index) in request.attached_files" :key="index"> <div class="preview-btn-container" v-for="(file, index) in request.attached_files" :key="index">
<button @click="previewAttachedFile(request.id, file.document_id)"> <button class="btn btn-link" data-bs-toggle="modal" data-bs-target="#previewModal" :data-bs-file="file.file_name" :data-bs-rid="request.id" :data-bs-did="file.document_id">
Preview{{ file.file_name }} Preview {{ file.file_name }}
</button> </button>
<button @click="downloadAttachedFile(request.id, file.document_id)"> <button class="btn btn-link" @click="downloadAttachedFile(request.id, file.document_id)">
Download{{ file.file_name }} Download {{ file.file_name }}
</button> </button>
</div> </div>
</div> </div>
@ -177,24 +177,56 @@
</div> </div>
</div> </div>
</div> </div>
<div class="modal fade" id="previewModal" ref="previewModal" aria-labelledby="previewModalLabel" aria-hidden="true">
<div class="modal-dialog modal-xl">
<div class="modal-content">
<div class="modal-header">
<h1 class="modal-title fs-5" id="previewModalLabel">{{previewModal.filename}}</h1>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
<PDFReader :doc="previewModal.doc" />
</div>
</div>
</div>
</div>
</template> </template>
<script> <script>
import { RequestHubApi, WorksapceApi, DateUtils, requestHubUtils } from '../../../utils/index' import { RequestHubApi, WorksapceApi, DateUtils, requestHubUtils } from '../../../utils/index'
import { proposingModelEnum } from '../../../types/index' import { proposingModelEnum } from '../../../types/index'
import PDFReader from '@/components/PDFReader.vue'
export default { export default {
name: 'RequestHub', name: 'RequestHub',
props: {}, props: {},
mounted() { mounted() {
this.fetchRequests() this.fetchRequests()
this.$refs.previewModal.addEventListener('shown.bs.modal', event => {
const relatedTarget = event.relatedTarget
const filename = relatedTarget.getAttribute('data-bs-file')
this.previewModal = { filename }
const requestId = relatedTarget.getAttribute('data-bs-rid')
const documentId = relatedTarget.getAttribute('data-bs-did')
WorksapceApi.fetchAttachedFileAsMediaData(requestId, documentId)
.then((response) => {
this.previewModal.doc = {url: response.data}
})
.catch((error) => {
this.mnx_backendErrorHandler(error)
})
})
this.$refs.previewModal.addEventListener('hidden.bs.modal', () => {
this.previewModal = {}
})
}, },
data() { data() {
return { return {
requestGroups: [], requestGroups: [],
message: null message: null,
previewModal: {}
} }
}, },
components: { PDFReader },
methods: { methods: {
fetchRequests() { fetchRequests() {
RequestHubApi.fetchRequestForHub() RequestHubApi.fetchRequestForHub()
@ -212,18 +244,6 @@ export default {
getDateFromFulltimeString(fulltime) { getDateFromFulltimeString(fulltime) {
return DateUtils.FromJsonToDateString(fulltime) return DateUtils.FromJsonToDateString(fulltime)
}, },
previewAttachedFile(request_id, document_id) {
// !!! SHOULD NOT use PdfContentViewer which is designed for unlogged in users.
// !!! Instead, should have a dedicated pdf viewer which should follow the figma design.
// WorksapceApi.fetchAttachedFileAsMediaData(request_id, document_id)
// .then((response) => {
// let media_data = response.data
// console.log(media_data)
// })
// .catch((error) => {
// this.mnx_backendErrorHandler(error)
// })
},
downloadAttachedFile(request_id, document_id) { downloadAttachedFile(request_id, document_id) {
WorksapceApi.fetchAttachedFileAsDownload(request_id, document_id) WorksapceApi.fetchAttachedFileAsDownload(request_id, document_id)
.then((response) => { .then((response) => {
@ -411,4 +431,15 @@ export default {
@extend .text-start; @extend .text-start;
font-weight: bold; font-weight: bold;
} }
.preview-btn-container {
display: flex;
text-align: left;
.btn-link {
font-weight: bold;
margin-right: 15px;
text-decoration: underline;
}
}
</style> </style>

View File

@ -33,7 +33,7 @@
aria-expanded="false" aria-expanded="false"
:aria-controls="'collapse' + index" :aria-controls="'collapse' + index"
> >
{{ existingProposal.request.title }} <span class="dashed-container">{{ existingProposal.request.title }}</span>
</button> </button>
</h2> </h2>
<div <div
@ -88,7 +88,7 @@
aria-expanded="false" aria-expanded="false"
:aria-controls="'collapse' + index" :aria-controls="'collapse' + index"
> >
{{ template.title }} <span class="dashed-container">{{ template.title }}</span>
</button> </button>
</h2> </h2>
<div <div
@ -742,13 +742,15 @@ export default {
} }
.load-template-button { .load-template-button {
@extend .proceed-button; @extend .btn;
@extend .btn-link;
@extend .float-end; @extend .float-end;
width: fit-content; width: fit-content;
} }
.copy-existing-button { .copy-existing-button {
@extend .proceed-button; @extend .btn;
@extend .btn-link;
@extend .float-end; @extend .float-end;
width: fit-content; width: fit-content;
} }

View File

@ -32,7 +32,7 @@
aria-expanded="false" aria-expanded="false"
:aria-controls="'collapse' + index" :aria-controls="'collapse' + index"
> >
{{ existingRequest.title }} <span class="dashed-container">{{ existingRequest.title }}</span>
</button> </button>
</h2> </h2>
<div <div