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

[GWELLS-2011] FEATURE** Update visuals, change how date is selected #2036

Merged
merged 1 commit into from
Nov 7, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
4 changes: 2 additions & 2 deletions app/backend/gwells/documents.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,8 @@ def create_url_list(self, objects, host, bucket_name, private=False):
# split on last occurrence of '/' and return last item (supports any or no prefixes)
'name': unquote_plus(document.object_name).rsplit('/', 1)[-1],
"well_number": self.extract_well_number(document.object_name),
"date_of_action": self.extract_date_of_action(document.object_name),
"well_label": self.extract_well_label(document.object_name),
"date_of_upload": self.extract_date_of_action(document.object_name),
"document_type": self.extract_well_label(document.object_name),
"document_status": private
}, objects)
)
Expand Down
6 changes: 3 additions & 3 deletions app/frontend/src/common/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,15 @@ export const WELL_TAGS_PRIVATE = [

export const WELL_TAGS = [
{
text: "Select Label",
text: "Select Document Type",
value: null,
},
{
label: "Public Labels",
label: "Public Document",
options: WELL_TAGS_PUBLIC,
},
{
label: "Private Labels",
label: "Private Document",
options: WELL_TAGS_PRIVATE,
},
]
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,15 @@ Licensed under the Apache License, Version 2.0 (the "License");
<div v-if="uploadedFiles && uploadedFiles.private && uploadedFiles.public" class="table-responsive">
<b-table
hover
:fields="['well_number', 'well_label', 'date_of_action', 'document_status', 'uploaded_document', 'delete']"
:fields="['well_number', 'document_type', 'date_of_upload', 'document_status', 'uploaded_document', 'delete']"
striped
:items="[...uploadedFiles.public, ...uploadedFiles.private]"
>
<template v-slot:cell(well_label)="data">
{{ callLongFormLabel(data.item.well_label) }}
<template v-slot:cell(document_type)="data">
{{ callLongFormLabel(data.item.document_type) }}
</template>
<template v-slot:cell(date_of_action)="data">
{{ data.item.date_of_action !== -1 ? new Date(data.item.date_of_action).toLocaleDateString() : "Date Unknown" }}
<template v-slot:cell(date_of_upload)="data">
{{ data.item.date_of_upload !== -1 ? new Date(data.item.date_of_upload).toLocaleDateString() : "Date Unknown" }}
</template>
<template v-slot:cell(uploaded_document)="data">
<a :href="data.item.url" :download="data.item.name" target="_blank">{{ data.item.name }}</a>
Expand All @@ -55,16 +55,19 @@ Licensed under the Apache License, Version 2.0 (the "License");
</template>
</b-table>
</div>
<div v-else>
No documents available
</div>
<div class="table-responsive" id="attachmentsTable" v-if="attachmentsData">
<table class="table table-sm" aria-describedby="attachmentsDetails">
<thead>
<tr>
<th class="font-weight-normal">Well Number</th>
<th class="font-weight-normal">Well Label/Type</th>
<th class="font-weight-normal">Date of Action</th>
<th class="font-weight-normal">New File Name</th>
<th class="font-weight-normal">Document Type</th>
<th class="font-weight-normal">File</th>
<th class="font-weight-normal">Private Document?</th>
<th class="font-weight-normal">New File Name</th>
<th class="font-weight-normal">Date of Upload</th>
<th></th>
</tr>
</thead>
Expand All @@ -74,46 +77,26 @@ Licensed under the Apache License, Version 2.0 (the "License");
{{ attachment.well_tag_number = wellTagNumber }}
</td>
<td>
<!-- Label Selector -->
<!-- Document Selector -->
<b-form-group
:id="'attachmentLabel_' + index"
class="mt-1 mb-0"
:aria-describedby="`attachmentLabelInvalidFeedback${index}`">
<b-form-select
@change="setFileName(index)"
v-model="attachment.document_label_code"
v-model="attachment.document_code"
:options="WELL_TAGS"
:state="getAttachmentError(index).document_label_code ? false : null"
:state="getAttachmentError(index).document_code ? false : null"
size="med"
>
</b-form-select>
<b-form-invalid-feedback :id="`attachmentCodeInvalidFeedback${index}`">
<div v-for="(error, error_index) in getAttachmentError(index).document_label_code" :key="`Label input error ${error_index}`">
<div v-for="(error, error_index) in getAttachmentError(index).document_code" :key="`Document Type input error ${error_index}`">
{{ error }}
</div>
</b-form-invalid-feedback>
</b-form-group>
</td>
<!-- Date -->
<td class="p-2">
<b-form-datepicker
@input="setFileName(index)"
v-model="attachment.upload_date"
value-as-date
autoclose
/>
</td>
<td>
<!-- File Name -->
<b-form-input
class="mt-1 mb-0"
v-model="attachment.file_name"
placeholder="File_Name"
:errors="getAttachmentError(index).file_name"
:loaded="getFieldsLoaded(index).file_name"
disabled
/>
</td>
<td>
<!-- File Upload -->
<b-form-file
Expand All @@ -125,14 +108,29 @@ Licensed under the Apache License, Version 2.0 (the "License");
:loaded="getFieldsLoaded(index).file"
/>
</td>
<!-- Privacy Flag -->
<td>
<!-- Privacy Flag -->
<td>
<b-form-checkbox
class="mt-2 ml-3"
v-model="attachment.private"
:loaded="getFieldsLoaded(index).private"
/>
</td>
<td>
<!-- File Name -->
<b-form-input
class="mt-1 mb-0"
v-model="attachment.file_name"
placeholder="File_Name"
:errors="getAttachmentError(index).file_name"
:loaded="getFieldsLoaded(index).file_name"
disabled
/>
</td>
<!-- Date -->
<td class="p-2">
{{ new Date().toLocaleDateString() }}
</td>
<td class="pt-1 py-0">
<b-btn size="sm" variant="primary" :id="`removeAttachmentRowBtn${index}`" @click="removeRowIfOk(attachment)" class="mt-2 float-right"><i class="fa fa-minus-square-o"></i>&nbsp;Remove</b-btn>
</td>
Expand Down Expand Up @@ -304,10 +302,10 @@ export default {
let file_name = null
let WTN = this.wellTagNumber ? `WTN ${this.wellTagNumber}_` : ''
let entry = this.attachmentsData[index];
if (entry.document_label_code &&
if (entry.document_code &&
entry.upload_date &&
entry.file){
file_name = `${WTN}${entry.document_label_code}_${(entry.upload_date.getTime() + Math.floor(Math.random() * 999999))}.${entry.file.name.split('.')[1]}`;
file_name = `${WTN}${entry.document_code}_${entry.upload_date}.${entry.file.name.split('.')[1]}`;
}
this.attachmentsData[index].file_name = file_name;
if(this.attachmentsData[index].file_name !== null){ this.$emit('setFormValueChanged'); }
Expand All @@ -330,8 +328,8 @@ export default {
emptyObject () {
return {
well_tag_number: null,
document_label_code: null,
upload_date: null,
document_code: null,
upload_date: Date.now(),
file_name: null,
file: null,
private: false,
Expand Down
10 changes: 5 additions & 5 deletions app/frontend/src/wells/components/Documents.vue
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@
</div>
<b-table
hover
:fields="['well_number', 'well_label', 'date_of_action', 'document_status', 'uploaded_document']"
:fields="['well_number', 'document_type', 'date_of_upload', 'document_status', 'uploaded_document']"
striped
:items="files.private ? [...files.public, ...files.private] : [...files.public]"
>
<template v-slot:cell(well_label)="data">
{{ callLongFormLabel(data.item.well_label) }}
<template v-slot:cell(document_type)="data">
{{ callLongFormLabel(data.item.document_type) }}
</template>
<template v-slot:cell(date_of_action)="data">
{{ data.item.date_of_action !== -1 ? new Date(data.item.date_of_action).toLocaleDateString() : "Date Unknown" }}
<template v-slot:cell(date_of_upload)="data">
{{ data.item.date_of_action !== -1 ? new Date(data.item.date_of_upload).toLocaleDateString() : "Date Unknown" }}
</template>
<template v-slot:cell(uploaded_document)="data">
<a :href="data.item.url" :download="data.item.name" target="_blank" @click="handleDownloadEvent(data.item.name)">{{ data.item.name }}</a>
Expand Down