Commit efa21700 authored by Oleksii Savran's avatar Oleksii Savran Committed by Matija Obreza

AuditDataDisplay applied for DetailsPages

parent c352fd0b
import Cooperator from '@gringlobal/client/model/gringlobal/Cooperator';
export default class AuditedModel {
public createdBy: number | Cooperator;
public createdDate: Date;
public modifiedBy: number | Cooperator;
public modifiedDate: Date;
}
import AuditedModel from '@gringlobal/client/model/common/AuditedModel';
import Cooperator from '@gringlobal/client/model/gringlobal/Cooperator';
export default class CooperatorOwnedModel extends AuditedModel {
public ownedBy: Cooperator;
public ownedDate: Date;
}
......@@ -22,7 +22,6 @@ import { FilteredPage } from '@gringlobal/client/model/page';
import Loading from '@gringlobal/client/ui/common/Loading';
import { Card, CardContent, CardHeader, CardActions, Button } from '@material-ui/core';
import { Properties, PropertiesItem } from '@gringlobal/client/ui/common/Properties';
import { Link } from 'react-router-dom';
import PrettyDate from '@gringlobal/client/ui/common/time/PrettyDate';
import Table, { TextAlign } from '@gringlobal/client/ui/common/table/Table';
import { PrintSpecies } from 'common/Taxonomy';
......@@ -33,6 +32,7 @@ import ButtonBar from '@gringlobal/client/ui/common/button/ButtonBar';
import PageTitle from '@gringlobal/client/ui/common/PageTitle';
import FileUploader from '@gringlobal/client/ui/common/file-uploader';
import AttachmentsDisplay from 'repository/ui/c/AttachmentsDisplay';
import AuditDataDisplay from 'common/AuditDataDisplay';
const InventoryTableConfig = new TableConfiguration(TableConfiguration.merge(
......@@ -243,39 +243,7 @@ class AccessionDetailsPage extends React.Component<IDetailsPageProps> {
{ accession.note }
</PropertiesItem>
}
{ accession.createdDate &&
<PropertiesItem title={ t('client:model._.createdDate') }>
<PrettyDate value={ accession.createdDate } />
</PropertiesItem>
}
{ /* accession.createdBy &&
<PropertiesItem title={ t('client:model._.createdBy') }>
{ accession.createdBy }
</PropertiesItem>
*/ }
{ accession.modifiedDate &&
<PropertiesItem title={ t('client:model._.modifiedDate') }>
<PrettyDate value={ accession.modifiedDate } />
</PropertiesItem>
}
{ /* accession.modifiedBy &&
<PropertiesItem title={ t('client:model._.modifiedBy') }>
{ accession.modifiedBy }
</PropertiesItem>
*/ }
{ accession.ownedDate &&
<PropertiesItem title={ t('client:model._.ownedDate') }>
<PrettyDate value={ accession.ownedDate } />
</PropertiesItem>
}
{ accession.ownedBy &&
<PropertiesItem title={ t('client:model._.ownedBy') }>
<Link to={ `/cooperator/${ accession.ownedBy.id }` }>
{ accession.ownedBy.firstName }
</Link>
</PropertiesItem>
}
<AuditDataDisplay item={ accession }/>
</Properties>
</CardContent>
</Card>
......
import * as React from 'react';
import { createStyles, withStyles, WithStyles } from '@material-ui/core';
import { useTranslation } from 'react-i18next';
import { PropertiesItem } from '@gringlobal/client/ui/common/Properties';
import PrettyDate from '@gringlobal/client/ui/common/time/PrettyDate';
import { CooperatorLink } from 'ui/common/Links';
import CooperatorOwnedModel from '@gringlobal/client/model/common/CooperatorOwnedModel';
const styles = (theme) => createStyles({});
interface IAuditDataDisplay extends React.ClassAttributes<any> {
item: CooperatorOwnedModel & Record<string, any>;
withoutOwnedFields?: boolean;
withoutAuditFields?: boolean;
}
function AuditDataDisplay(props: IAuditDataDisplay & Partial<WithStyles>) {
const { item, withoutOwnedFields = false, withoutAuditFields = false } = props;
const { t } = useTranslation();
return (
<>
{ !withoutAuditFields &&
<>
{ item.createdDate &&
<PropertiesItem title={ t('client:model._.createdDate') }>
<PrettyDate value={ item.createdDate } />
</PropertiesItem>
}
{ item.modifiedDate &&
<PropertiesItem title={ t('client:model._.modifiedDate') }>
<PrettyDate value={ item.modifiedDate } />
</PropertiesItem>
}
</>
}
{ !withoutOwnedFields &&
<>
{ item.ownedDate &&
<PropertiesItem title={ t('client:model._.ownedDate') }>
<PrettyDate value={ item.ownedDate } />
</PropertiesItem>
}
{ item.ownedBy &&
<PropertiesItem title={ t('client:model._.ownedBy') }>
<CooperatorLink cooperator={ item.ownedBy }/>
</PropertiesItem>
}
</>
}
</>
);
}
export default withStyles(styles)(AuditDataDisplay);
......@@ -17,8 +17,8 @@ import { Properties, PropertiesItem } from '@gringlobal/client/ui/common/Propert
import Loading from '@gringlobal/client/ui/common/Loading';
import PageTitle from '@gringlobal/client/ui/common/PageTitle';
import Email from '@gringlobal/client/ui/common/Email';
import PrettyDate from '@gringlobal/client/ui/common/time/PrettyDate';
import { CodeValueDisplay } from 'common/CodeValue';
import AuditDataDisplay from 'common/AuditDataDisplay';
interface ICooperatorDetailsPage extends React.ClassAttributes<any>, WithTranslation {
......@@ -178,11 +178,7 @@ class CooperatorDetailsPage extends React.Component<ICooperatorDetailsPage> {
<PropertiesItem title={ t(['client:model.Cooperator.site', 'client:model._.site']) }>
{ cooperator.site && <>{ cooperator.site.siteShortName }</> }
</PropertiesItem>
{ [ 'createdDate', 'modifiedDate' ].map((property) => (
<PropertiesItem key={ property } title={ t([`client:model.Cooperator.${property}`, `client:model._.${property}`]) }>
{ cooperator[property] && <PrettyDate value={ cooperator[property] } /> }
</PropertiesItem>
)) }
<AuditDataDisplay item={ cooperator } withoutOwnedFields/>
</Properties>
</CardContent>
</Card>
......
......@@ -23,7 +23,7 @@ import TabPanel from '@gringlobal/client/ui/common/tabs/TabPanel';
import { Properties, PropertiesItem } from '@gringlobal/client/ui/common/Properties';
import PrettyDate from '@gringlobal/client/ui/common/time/PrettyDate';
import { PrintSpecies } from 'common/Taxonomy';
import { AccessionLink, CooperatorLink, InventoryLink } from 'ui/common/Links';
import { AccessionLink, InventoryLink } from 'ui/common/Links';
import ButtonBar from '@gringlobal/client/ui/common/button/ButtonBar';
import { CodeValueDisplay } from 'common/CodeValue';
import PageTitle from '@gringlobal/client/ui/common/PageTitle';
......@@ -31,6 +31,7 @@ import { BasicInventoryActionsTable as InventoryActionsTable } from 'inventory/
import { InventoryAuditLogsTable } from 'inventory/ui/c/InventoryAuditLogsTable';
import AttachmentsDisplay from 'repository/ui/c/AttachmentsDisplay';
import FileUploader from '@gringlobal/client/ui/common/file-uploader';
import AuditDataDisplay from 'common/AuditDataDisplay';
interface IDetailsPageProps extends React.ClassAttributes<any>, WithTranslation {
......@@ -361,37 +362,7 @@ class InventoryDetailsPage extends React.Component<IDetailsPageProps> {
{ inventory.note }
</PropertiesItem>
}
{ inventory.createdDate &&
<PropertiesItem title={ t(['client:model.Inventory.createdDate', 'client:model._.createdDate']) }>
<PrettyDate value={ inventory.createdDate } />
</PropertiesItem>
}
{ /* inventory.createdBy &&
<PropertiesItem title={ t('client:model.Inventory.createdBy') }>
{ inventory.createdBy }
</PropertiesItem>
*/ }
{ inventory.modifiedDate &&
<PropertiesItem title={ t(['client:model.Inventory.modifiedDate', 'client:model._.modifiedDate']) }>
<PrettyDate value={ inventory.modifiedDate } />
</PropertiesItem>
}
{ /* inventory.modifiedBy &&
<PropertiesItem title={ t('client:model.Inventory.modifiedBy') }>
{ inventory.modifiedBy }
</PropertiesItem>
*/ }
{ inventory.ownedDate &&
<PropertiesItem title={ t(['client:model.Inventory.ownedDate', 'client:model._.ownedDate']) }>
<PrettyDate value={ inventory.ownedDate } />
</PropertiesItem>
}
{ inventory.ownedBy &&
<PropertiesItem title={ t(['client:model.Inventory.ownedBy', 'client:model._.ownedBy']) }>
<CooperatorLink cooperator={ inventory.ownedBy }/>
</PropertiesItem>
}
<AuditDataDisplay item={ inventory }/>
</Properties>
</CardContent>
</Card>
......
......@@ -13,7 +13,7 @@ import TabPanel from '@gringlobal/client/ui/common/tabs/TabPanel';
import { Properties, PropertiesItem } from '@gringlobal/client/ui/common/Properties';
import PrettyDate from '@gringlobal/client/ui/common/time/PrettyDate';
// import { PrintSpecies } from 'common/Taxonomy';
import { CooperatorLink, AccessionLink, InventoryLink } from 'ui/common/Links';
import { AccessionLink, InventoryLink } from 'ui/common/Links';
import AccessionInvGroup from '@gringlobal/client/model/gringlobal/AccessionInvGroup';
import Table, { TextAlign } from '@gringlobal/client/ui/common/table/Table';
import { CooperatorOwnedTableConfiguration as TableConfiguration } from '@gringlobal/client/ui/common/table/TableConfiguration';
......@@ -24,6 +24,7 @@ import { dereferenceReferences3 } from '@gringlobal/client/utilities';
import { Page, SortDirection, IPageRequest } from '@gringlobal/client/model/page';
import AccessionInvGroupMap from '@gringlobal/client/model/gringlobal/AccessionInvGroupMap';
import PageTitle from '@gringlobal/client/ui/common/PageTitle';
import AuditDataDisplay from 'common/AuditDataDisplay';
import EditGroupDialog from 'inventorygroup/ui/c/EditGroupDialog';
import confirm from '@gringlobal/client/utilities/confirmAlert';
......@@ -228,26 +229,7 @@ class InventoryDetailsPage extends React.Component<IDetailsPageProps> {
<PropertiesItem title={ t(['client:model.AccessionInvGroup.isWebVisible', 'client:model._.isWebVisible']) }>
{ inventoryGroup.isWebVisible }
</PropertiesItem>
{ inventoryGroup.createdDate &&
<PropertiesItem title={ t(['client:model.AccessionInvGroup.createdDate', 'client:model._.createdDate']) }>
<PrettyDate value={ inventoryGroup.createdDate } />
</PropertiesItem>
}
{ inventoryGroup.modifiedDate &&
<PropertiesItem title={ t(['client:model.AccessionInvGroup.modifiedDate', 'client:model._.modifiedDate']) }>
<PrettyDate value={ inventoryGroup.modifiedDate } />
</PropertiesItem>
}
{ inventoryGroup.ownedDate &&
<PropertiesItem title={ t(['client:model.AccessionInvGroup.ownedDate', 'client:model._.ownedDate']) }>
<PrettyDate value={ inventoryGroup.ownedDate } />
</PropertiesItem>
}
{ inventoryGroup.ownedBy &&
<PropertiesItem title={ t(['client:model.AccessionInvGroup.ownedBy', 'client:model._.ownedBy']) }>
<CooperatorLink cooperator={ inventoryGroup.ownedBy }/>
</PropertiesItem>
}
<AuditDataDisplay item={ inventoryGroup }/>
</Properties>
</CardContent>
<CardActions>
......
......@@ -14,12 +14,12 @@ import { Button, Card, CardActions, CardContent } from '@material-ui/core';
import { Properties, PropertiesItem } from '@gringlobal/client/ui/common/Properties';
import Loading from '@gringlobal/client/ui/common/Loading';
import { CooperatorLink } from 'ui/common/Links';
import PrettyDate from '@gringlobal/client/ui/common/time/PrettyDate';
import Permissions from '@gringlobal/client/ui/common/permission/Permissions';
import { CodeValueDisplay } from 'common/CodeValue';
import PageTitle from '@gringlobal/client/ui/common/PageTitle';
import { YesNoToBoolean } from '@gringlobal/client/utilities';
import Number from '@gringlobal/client/ui/common/Number';
import AuditDataDisplay from 'common/AuditDataDisplay';
interface IInventoryPolicyDetailsPage extends React.ClassAttributes<any>, WithTranslation {
......@@ -153,27 +153,7 @@ class InventoryPolicyDetailsPage extends React.Component<IInventoryPolicyDetails
/>
</PropertiesItem>
}
{ inventoryPolicy.createdDate &&
<PropertiesItem title={ t('client:model._.createdDate') }>
<PrettyDate value={ inventoryPolicy.createdDate } />
</PropertiesItem>
}
{ inventoryPolicy.modifiedDate &&
<PropertiesItem title={ t('client:model._.modifiedDate') }>
<PrettyDate value={ inventoryPolicy.modifiedDate } />
</PropertiesItem>
}
{ inventoryPolicy.ownedDate &&
<PropertiesItem title={ t('client:model._.ownedDate') }>
<PrettyDate value={ inventoryPolicy.ownedDate } />
</PropertiesItem>
}
{ inventoryPolicy.ownedBy &&
<PropertiesItem title={ t('client:model._.ownedBy') }>
<CooperatorLink cooperator={ inventoryPolicy.ownedBy }/>
</PropertiesItem>
}
<AuditDataDisplay item={ inventoryPolicy }/>
</Properties>
</CardContent>
<CardActions>
......
......@@ -13,7 +13,6 @@ import Loading from '@gringlobal/client/ui/common/Loading';
import { Card, CardContent, CardHeader, CardActions, Button } from '@material-ui/core';
import { Properties, PropertiesItem } from '@gringlobal/client/ui/common/Properties';
import { Link } from 'react-router-dom';
import PrettyDate from '@gringlobal/client/ui/common/time/PrettyDate';
import OrderRequestItem, { OrderRequestItemStatus } from '@gringlobal/client/model/gringlobal/OrderRequestItem';
import { FilteredPage } from '@gringlobal/client/model/page';
import Table, { TextAlign } from '@gringlobal/client/ui/common/table/Table';
......@@ -30,6 +29,7 @@ import Tab from '@material-ui/core/Tab';
import HeaderTabs from '@gringlobal/client/ui/common/tabs/HeaderTabs';
import TabPanel from '@gringlobal/client/ui/common/tabs/TabPanel';
import SlotLayout from '@gringlobal/client/ui/common/layout/SlotLayout';
import AuditDataDisplay from 'common/AuditDataDisplay';
const OrderRequestItemTableConfig = new TableConfiguration({
defaultColumns: [
......@@ -194,18 +194,7 @@ class OrderRequestDetailsPage extends React.Component<IDetailsPageProps> {
<PropertiesItem title={ t('client:model.OrderRequest.intendedUseCode') }>
<CodeValueDisplay codeGroup={ OrderRequest.CodeValues.intendedUseCode } value={ request.intendedUseCode } />
</PropertiesItem>
{ request.ownedDate &&
<PropertiesItem title={ t('client:model._.ownedDate') }>
<PrettyDate value={ request.ownedDate } />
</PropertiesItem>
}
{ request.ownedBy &&
<PropertiesItem title={ t('client:model._.ownedBy') }>
<Link to={ `/cooperator/${ request.ownedBy.id }` }>
{ request.ownedBy.firstName }
</Link>
</PropertiesItem>
}
<AuditDataDisplay item={ request } withoutAuditFields/>
</Properties>
</CardContent>
<CardActions>
......
......@@ -13,11 +13,10 @@ import ContentHeader from '@gringlobal/client/ui/common/heading/ContentHeader';
import { Button, Card, CardActions, CardContent } from '@material-ui/core';
import { Properties, PropertiesItem } from '@gringlobal/client/ui/common/Properties';
import Loading from '@gringlobal/client/ui/common/Loading';
import { CooperatorLink } from 'ui/common/Links';
import PrettyDate from '@gringlobal/client/ui/common/time/PrettyDate';
import Permissions from '@gringlobal/client/ui/common/permission/Permissions';
import { CodeValueDisplay } from 'common/CodeValue';
import PageTitle from '@gringlobal/client/ui/common/PageTitle';
import AuditDataDisplay from 'common/AuditDataDisplay';
interface ISiteDetailsPage extends React.ClassAttributes<any>, WithTranslation {
......@@ -83,26 +82,7 @@ class SiteDetailsPage extends React.Component<ISiteDetailsPage> {
<PropertiesItem title={ t('client:model.Site.typeCode') }>
<CodeValueDisplay codeGroup={ Site.CodeValues.typeCode } value={ site.typeCode } />
</PropertiesItem>
{ site.createdDate &&
<PropertiesItem title={ t('client:model._.createdDate') }>
<PrettyDate value={ site.createdDate } />
</PropertiesItem>
}
{ site.modifiedDate &&
<PropertiesItem title={ t('client:model._.modifiedDate') }>
<PrettyDate value={ site.modifiedDate } />
</PropertiesItem>
}
{ site.ownedDate &&
<PropertiesItem title={ t('client:model._.ownedDate') }>
<PrettyDate value={ site.ownedDate } />
</PropertiesItem>
}
{ site.ownedBy &&
<PropertiesItem title={ t('client:model._.ownedBy') }>
<CooperatorLink cooperator={ site.ownedBy }/>
</PropertiesItem>
}
<AuditDataDisplay item={ site }/>
</Properties>
</CardContent>
<CardActions>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment