diff --git a/backend/apps/journals/migrations/0006_journal_file_upload.py b/backend/apps/journals/migrations/0006_journal_file_upload.py new file mode 100644 index 0000000..871ea3a --- /dev/null +++ b/backend/apps/journals/migrations/0006_journal_file_upload.py @@ -0,0 +1,18 @@ +# Generated by Django 3.1.6 on 2021-04-01 00:35 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('journals', '0005_auto_20210331_1613'), + ] + + operations = [ + migrations.AddField( + model_name='journal', + name='file_upload', + field=models.CharField(max_length=255, null=True, verbose_name='file_upload'), + ), + ] diff --git a/backend/apps/journals/models.py b/backend/apps/journals/models.py index a39eee0..ab7f815 100644 --- a/backend/apps/journals/models.py +++ b/backend/apps/journals/models.py @@ -11,6 +11,7 @@ class Journal(models.Model): date = models.DateField(verbose_name='date', auto_now_add=True, null=True) source = models.CharField(verbose_name='source', max_length=255, null=True) comment = models.CharField(verbose_name='comment', max_length=255, null=True) + file_upload = models.CharField(verbose_name='file_upload', max_length=255, null=True) def __str__(self): return self.name diff --git a/frontend/src/components/JournalModal.js b/frontend/src/components/JournalModal.js index f2a2bdc..ecba668 100644 --- a/frontend/src/components/JournalModal.js +++ b/frontend/src/components/JournalModal.js @@ -135,6 +135,17 @@ export default class JournalModal extends Component { placeholder="Enter Comment" /> + + + + diff --git a/frontend/src/components/JournalTable.js b/frontend/src/components/JournalTable.js index 605ad82..2d65098 100644 --- a/frontend/src/components/JournalTable.js +++ b/frontend/src/components/JournalTable.js @@ -1,8 +1,9 @@ import React, { useState, useEffect } from 'react' import API from '../api' -import { Header, Table, Button, Checkbox, Dropdown } from 'semantic-ui-react' +import { Header, Table, Button, Checkbox, Dropdown, Input } from 'semantic-ui-react' import JouralModal from '../components/JournalModal' import JournalModal from '../components/JournalModal'; +import '../css/components/JournalTable.css' export default function LogTable() { const [journalList, setJournalList] = useState(null); @@ -53,30 +54,24 @@ export default function LogTable() { setSelectedJournals(selectedJournals.filter((el) => el.id != item.id)) } - const verifyIsCheked = (journalList, item) => { - let arr = journalList.filter((el) => el.id == item.id); - if (arr.length == 0) - return false; - else - return true; - } - const handleSubmit = async (item) => { setModal(!modal) setIsAdd(true); - if (selectedJournals != null || selectedJournals[0] != undefined) { - handleEditAccount(item) - } + if (item.id) + API.put(`/api/journals/admin/${item.id}/`, item).then(res => res.data); + else + API.post(`/api/journals/admin/`, item).then(res => res.data); - API.post(`/api/journals/admin/`, item).then(res => res.data); refreshItems(); setSelectedJournals([]); } const handleEditAccount = (item) => { + console.log(selectedJournals[0]) + setActiveItem(selectedJournals[0]); setIsAdd(false); - setActiveItem(selectedJournals[0]) + setModal(!modal) } const deleteSelectedRows = async (journals) => { @@ -84,6 +79,7 @@ export default function LogTable() { API.delete(`/api/journals/admin/${journals[entry].id}/`).then(res => res.data); } refreshItems(); + window.location.replace('/apps/journals') } const handleChange = async (e, item) => { @@ -92,19 +88,6 @@ export default function LogTable() { refreshItems(); } - const mapValueToStatus = (value) => { - switch (value) { - case "Approved": - return 1 - case "Pending": - return 2 - case "Rejected": - return 3 - default: - return "Unknown" - } - } - const mapStatusToValue = (status) => { switch(Number.parseInt(status)) { case 1: @@ -198,6 +181,13 @@ export default function LogTable() {
{(log["comment"] != null ? log["comment"] : "N/A")}
+ +
{(log["file_upload"] != null ? log["file_upload"] : "N/A")}
+ +
) }); @@ -206,10 +196,19 @@ export default function LogTable() { return (
-
- - - +
+
+ + + +
+
+ +
@@ -223,6 +222,7 @@ export default function LogTable() { Amount Source Comment + File Uploads diff --git a/frontend/src/css/components/JournalTable.css b/frontend/src/css/components/JournalTable.css new file mode 100644 index 0000000..cc17ec1 --- /dev/null +++ b/frontend/src/css/components/JournalTable.css @@ -0,0 +1,4 @@ +.journal-title-bar { + display: flex; + justify-content: space-between; +} \ No newline at end of file