Commit d6530930 authored by Matija Obreza's avatar Matija Obreza
Browse files

Actions: Improved action filtering and a new "Scheduled" actions tab

parent c285240f
import DateFilter from '@gringlobal-ce/client/model/common/DateFilter';
import { AccessionFilter } from '.';
/**
* AccessionActionFilter
......@@ -10,7 +11,7 @@ class AccessionActionFilter {
public NULL: string[];
public NOTNULL: string[];
public id: number[];
public accession: number[];
public accession: AccessionFilter;
public createdBy: string[];
public createdDate: DateFilter;
public modifiedBy: string[];
......
/**
* ActionState enum is used for filtering InventoryActions, AccessionActions, ...
*/
enum ActionState {
PENDING = 'PENDING', // Action is due to start!
INPROGRESS = 'INPROGRESS', // Action is started, but not finished
SCHEDULED = 'SCHEDULED', // Action is not yet due to start
COMPLETED = 'COMPLETED', // Action is completed
}
export default ActionState;
import DateFilter from '@gringlobal-ce/client/model/gringlobal/DateFilter';
import { InventoryFilter } from '.';
/**
* InventoryActionFilter
......@@ -21,7 +22,7 @@ class InventoryActionFilter {
public closed?: boolean;
public startedDate?: DateFilter;
public completedDate?: DateFilter;
public inventory?: number[];
public inventory?: InventoryFilter;
}
......
import DateFilter from '@gringlobal-ce/client/model/gringlobal/DateFilter';
import { OrderRequestFilter } from '.';
/**
* OrderRequestActionFilter
......@@ -10,7 +11,7 @@ class OrderRequestActionFilter {
public NULL: string[];
public NOTNULL: string[];
public id: number[];
public orderRequest: number[];
public orderRequest: OrderRequestFilter;
public createdBy: string[];
public createdDate: DateFilter;
public modifiedBy: string[];
......
import { FilteredPage } from '@gringlobal-ce/client/model/page';
import ActionState from './ActionState';
import Accession from './Accession';
import AccessionDetails from './AccessionDetails';
import AccessionAction from './AccessionAction';
......@@ -84,6 +85,7 @@ import SourceDescriptorCodeFilter from './SourceDescriptorCodeFilter';
import SourceDescriptorCodeLang from './SourceDescriptorCodeLang';
export {
ActionState,
AuditLog,
AuditLogFilter,
Accession, AccessionFilter,
......
......@@ -202,7 +202,8 @@
"tabs": {
"completed": "Completed",
"inProgress": "In progress",
"pending": "Pending"
"pending": "Pending",
"scheduled": "Scheduled"
}
},
"details": {
......@@ -492,7 +493,8 @@
"tabs": {
"completed": "Completed",
"inProgress": "In progress",
"pending": "Pending"
"pending": "Pending",
"scheduled": "Scheduled"
}
},
"details": {
......@@ -971,7 +973,8 @@
"tabs": {
"completed": "Completed",
"inProgress": "In progress",
"pending": "Pending"
"pending": "Pending",
"scheduled": "Scheduled"
}
}
},
......@@ -1237,7 +1240,8 @@
"tabs": {
"completed": "Completed",
"inProgress": "In progress",
"pending": "Pending"
"pending": "Pending",
"scheduled": "Scheduled"
}
},
"rule": {
......
......@@ -24,7 +24,8 @@
"tabs": {
"completed": "Completed",
"inProgress": "In progress",
"pending": "Pending"
"pending": "Pending",
"scheduled": "Scheduled"
}
},
"details": {
......
......@@ -10,7 +10,7 @@ import { listAccessionActionsAction, loadMoreAccessionActionsAction } from 'acce
// model
import { FilteredPage, IPageRequest } from '@gringlobal-ce/client/model/page';
import { AccessionAction, AccessionActionFilter } from '@gringlobal-ce/client/model/gringlobal';
import { AccessionAction, AccessionActionFilter, ActionState } from '@gringlobal-ce/client/model/gringlobal';
import { ApiCall } from '@gringlobal-ce/client/model/common';
// UI
......@@ -26,20 +26,25 @@ import useTabs from 'ui/common/useTabs';
const AccessionActionsTabs = {
IN_PROGRESS: {
index: 'IN_PROGRESS',
INPROGRESS: {
index: 'INPROGRESS',
label: 'accession.public.p.actions.tabs.inProgress',
config: [{ started: true, closed: false }, { page: 0, size: 100, direction: ['ASC'], properties: ['startedDate'] }],
config: [{ states: [ ActionState.INPROGRESS ] }, { page: 0, size: 100, direction: ['ASC'], properties: ['startedDate'] }],
},
PENDING: {
index: 'PENDING',
label: 'accession.public.p.actions.tabs.pending',
config: [{ started: false, closed: false }, { page: 0, size: 100, direction: ['ASC'], properties: ['createdDate'] }],
config: [{ states: [ ActionState.PENDING ] }, { page: 0, size: 100, direction: ['ASC'], properties: ['notBeforeDate', 'createdDate'] }],
},
COMPLETED: {
index: 'COMPLETED',
label: 'accession.public.p.actions.tabs.completed',
config: [{ closed: true }, { page: 0, size: 100, direction: ['DESC'], properties: ['completedDate'] }],
config: [{ states: [ ActionState.COMPLETED ] }, { page: 0, size: 100, direction: ['DESC'], properties: ['completedDate'] }],
},
SCHEDULED: {
index: 'SCHEDULED',
label: 'accession.public.p.actions.tabs.scheduled',
config: [{ states: [ ActionState.SCHEDULED ] }, { page: 0, size: 100, direction: ['ASC'], properties: ['notBeforeDate'] }],
},
};
......@@ -55,7 +60,7 @@ const AccessionActionsPage = ({ loadableData, listAction, loadMoreData, routingP
// util
const { t } = useTranslation();
const { selectedTab = 'IN_PROGRESS', selectTab } = useTabs({ routingProps, defaultTab: AccessionActionsTabs.IN_PROGRESS.index })
const { selectedTab = 'INPROGRESS', selectTab } = useTabs({ routingProps, defaultTab: AccessionActionsTabs.INPROGRESS.index })
const listAccessionAction = React.useCallback((filter?: AccessionActionFilter, pageR?: IPageRequest) => {
return listAction({...AccessionActionsTabs[selectedTab].config[0], ...filter}, AccessionActionsTabs[selectedTab].config[1]);
......
......@@ -4,6 +4,7 @@ import { useTranslation } from 'react-i18next';
// UI
import { withFilters, DateFilter, CVFilter } from 'ui/common/filter';
import { AccessionAction } from '@gringlobal-ce/client/model/gringlobal';
import { AccessionFiltersEmbedded } from './Filters';
function AccessionActionFilters() {
const { t } = useTranslation();
......@@ -23,6 +24,11 @@ function AccessionActionFilters() {
label={ t([ 'client:model.AccessionAction.completedDate', 'client:model._.completedDate' ]) }
name="completedDate"
/>
<DateFilter
label={ t([ 'client:model.AccessionAction.notBeforeDate', 'client:model._.notBeforeDate' ]) }
name="notBeforeDate"
/>
<AccessionFiltersEmbedded prefix="accession." withFullText={ false } />
</>
);
}
......
......@@ -5,93 +5,97 @@ import { useTranslation } from 'react-i18next';
// UI
import { withFilters, TextFilter, StringArrFilter, NumberFilter, DateFilter, BooleanFilter, CVFilter , SiteFilter } from 'ui/common/filter';
function AccessionFilters() {
export function AccessionFiltersEmbedded({ prefix = '', withFullText = true }: { prefix?: string, withFullText?: boolean }) {
const { t } = useTranslation();
return (
<>
<TextFilter
label={ t([ 'client:model.Accession.text', 'client:model._.text' ]) }
name="_text"
placeholder={ t([ 'client:model.Accession.text-placeholder', 'client:model._.text-placeholder' ]) }
helperText={ t([ 'client:model.Accession.text-helperText', 'client:model._.text-helperText' ]) }
/>
{ withFullText &&
<TextFilter
label={ t([ 'client:model.Accession.text', 'client:model._.text' ]) }
name={ `${prefix}_text` }
placeholder={ t([ 'client:model.Accession.text-placeholder', 'client:model._.text-placeholder' ]) }
helperText={ t([ 'client:model.Accession.text-helperText', 'client:model._.text-helperText' ]) }
/>
}
<StringArrFilter
label={ t([ 'client:model.Accession.accessionNumber', 'client:model._.accessionNumber' ]) }
name="accessionNumber"
name={ `${prefix}accessionNumber` }
/>
<StringArrFilter
label={ t([ 'client:model.Accession.accessionNumberPart1', 'client:model._.accessionNumberPart1' ]) }
name="accessionNumberPart1"
name={ `${prefix}accessionNumberPart1` }
withOperations
/>
<NumberFilter
label={ t([ 'client:model.Accession.accessionNumberPart2', 'client:model._.accessionNumberPart2' ]) }
name="accessionNumberPart2"
name={ `${prefix}accessionNumberPart2` }
/>
<StringArrFilter
label={ t([ 'client:model.Accession.accessionNumberPart3', 'client:model._.accessionNumberPart3' ]) }
name="accessionNumberPart3"
name={ `${prefix}accessionNumberPart3` }
withOperations
/>
<CVFilter
label={ t([ 'client:model.Accession.statusCode' ]) }
name="statusCode"
name={ `${prefix}statusCode` }
codeGroup={ Accession.CodeGroup.statusCode }
/>
<CVFilter
label={ t([ 'client:model.Accession.mlsStatus' ]) }
name="mlsStatus"
name={ `${prefix}mlsStatus` }
codeGroup={ Accession.CodeGroup.mlsStatus }
/>
<CVFilter
label={ t([ 'client:model.Accession.lifeFormCode' ]) }
name="lifeFormCode"
name={ `${prefix}lifeFormCode` }
codeGroup={ Accession.CodeGroup.lifeFormCode }
/>
<CVFilter
label={ t([ 'client:model.Accession.improvementStatusCode' ]) }
name="improvementStatusCode"
name={ `${prefix}improvementStatusCode` }
codeGroup={ Accession.CodeGroup.improvementStatusCode }
/>
<SiteFilter
label={ t([ 'client:model.Accession.site' ]) }
name="site.id"
name={ `${prefix}site.id` }
/>
<CVFilter
label={ t([ 'client:model.Accession.reproductiveUniformityCode' ]) }
name="reproductiveUniformityCode"
name={ `${prefix}reproductiveUniformityCode` }
codeGroup={ Accession.CodeGroup.reproductiveUniformityCode }
/>
<DateFilter
label={ t([ 'client:model.Accession.initialReceivedDate', 'client:model._.initialReceivedDate' ]) }
name="initialReceivedDate"
name={ `${prefix}initialReceivedDate` }
/>
<BooleanFilter
label={ t('client:model.AccessionSource.isOrigin') }
name="sources.origin"
name={ `${prefix}sources.origin` }
/>
<CVFilter
sortByAlphabet
codeGroup={ Geography.CodeGroup.countryCode }
label={ t('client:model.Geography.countryCode') }
name="sources.geography.countryCode"
name={ `${prefix}sources.geography.countryCode` }
placeholder="NGA"
/>
<StringArrFilter
label={ t([ 'client:model.TaxonomyGenus.genusName' ]) }
name="taxonomySpecies.taxonomyGenus.genusName.eq"
name={ `${prefix}taxonomySpecies.taxonomyGenus.genusName.eq` }
/>
<StringArrFilter
label={ t([ 'client:model.TaxonomySpecies.speciesName' ]) }
name="taxonomySpecies.speciesName.eq"
name={ `${prefix}taxonomySpecies.speciesName.eq` }
/>
<BooleanFilter
label={ t(['client:model.Accession.isWebVisible', 'client:model._.isWebVisible']) }
name="webVisible"
name={ `${prefix}webVisible` }
/>
</>
);
}
export default withFilters(AccessionFilters);
AccessionFiltersEmbedded.displayName = 'AccessionFilters';
export default withFilters(AccessionFiltersEmbedded);
......@@ -21,7 +21,8 @@
"tabs": {
"completed": "Completed",
"inProgress": "In progress",
"pending": "Pending"
"pending": "Pending",
"scheduled": "Scheduled"
}
},
"details": {
......
......@@ -8,7 +8,7 @@ import Tab from '@material-ui/core/Tab';
import { listInventoryActionsAction, loadMoreInventoryActionsAction } from 'inventory/action/public';
// model
import { InventoryAction, InventoryActionFilter } from '@gringlobal-ce/client/model/gringlobal';
import { ActionState, InventoryAction, InventoryActionFilter } from '@gringlobal-ce/client/model/gringlobal';
import { FilteredPage, IPageRequest } from '@gringlobal-ce/client/model/page';
import { ApiCall } from '@gringlobal-ce/client/model/common';
// ui
......@@ -23,20 +23,25 @@ import useTabs from 'ui/common/useTabs';
import useBrowsePageBase from 'ui/common/useBrowsePageBase';
const InventoryActionsTabs = {
IN_PROGRESS: {
index: 'IN_PROGRESS',
INPROGRESS: {
index: 'INPROGRESS',
label: 'inventory.public.p.actions.tabs.inProgress',
config: [{ started: true, closed: false }, { page: 0, size: 100, direction: ['ASC'], properties: ['startedDate'] }],
config: [{ states: [ ActionState.INPROGRESS ] }, { page: 0, size: 100, direction: ['ASC'], properties: ['startedDate'] }],
},
PENDING: {
index: 'PENDING',
label: 'inventory.public.p.actions.tabs.pending',
config: [{ started: false, closed: false }, { page: 0, size: 100, direction: ['ASC'], properties: ['createdDate'] }],
config: [{ states: [ ActionState.PENDING ] }, { page: 0, size: 100, direction: ['ASC'], properties: ['notBeforeDate', 'createdDate'] }],
},
COMPLETED: {
index: 'COMPLETED',
label: 'inventory.public.p.actions.tabs.completed',
config: [{ closed: true }, { page: 0, size: 100, direction: ['DESC'], properties: ['completedDate'] }],
config: [{ states: [ ActionState.COMPLETED ] }, { page: 0, size: 100, direction: ['DESC'], properties: ['completedDate'] }],
},
SCHEDULED: {
index: 'SCHEDULED',
label: 'inventory.public.p.actions.tabs.scheduled',
config: [{ states: [ ActionState.SCHEDULED ] }, { page: 0, size: 100, direction: ['ASC'], properties: ['notBeforeDate'] }],
},
};
......@@ -52,7 +57,7 @@ const InventoryActionsPage = ({ loadableData, listAction, loadMoreData, routingP
// util
const { t } = useTranslation();
const { selectedTab = 'IN_PROGRESS', selectTab } = useTabs({ routingProps, defaultTab: InventoryActionsTabs.IN_PROGRESS.index })
const { selectedTab = 'INPROGRESS', selectTab } = useTabs({ routingProps, defaultTab: InventoryActionsTabs.INPROGRESS.index })
const listInventoryAction = React.useCallback((filter?: InventoryActionFilter, pageR?: IPageRequest) => {
return listAction({ ...InventoryActionsTabs[selectedTab].config[0], ...filter }, InventoryActionsTabs[selectedTab].config[1]);
......
......@@ -4,6 +4,7 @@ import { useTranslation } from 'react-i18next';
// UI
import { withFilters, DateFilter, CVFilter } from 'ui/common/filter';
import { InventoryAction } from '@gringlobal-ce/client/model/gringlobal';
import { InventoryFiltersEmbedded } from './Filters';
function InventoryActionFilters() {
const { t } = useTranslation();
......@@ -24,6 +25,11 @@ function InventoryActionFilters() {
label={ t([ 'client:model.InventoryAction.completedDate', 'client:model._.completedDate' ]) }
name="completedDate"
/>
<DateFilter
label={ t([ 'client:model.InventoryAction.notBeforeDate', 'client:model._.notBeforeDate' ]) }
name="notBeforeDate"
/>
<InventoryFiltersEmbedded prefix="inventory." withFullText={ false } />
</>
);
}
......
......@@ -30,7 +30,7 @@ export function InventoryFiltersEmbedded({ prefix = '', allowSystem = true, with
/>
<StringArrFilter
label={ t([ 'client:model.Inventory.inventoryNumberPart1', 'client:model._.inventoryNumberPart1' ]) }
name={ `${prefix} inventoryNumberPart1`}
name={ `${prefix}inventoryNumberPart1`}
withOperations
/>
<NumberFilter
......
......@@ -61,7 +61,8 @@
"tabs": {
"completed": "Completed",
"inProgress": "In progress",
"pending": "Pending"
"pending": "Pending",
"scheduled": "Scheduled"
}
}
},
......
......@@ -8,7 +8,7 @@ import Tab from '@material-ui/core/Tab';
import { listOrderRequestActionsAction, loadMoreOrderRequestActionsAction } from 'request/action/public';
// model
import { OrderRequestAction, OrderRequestActionFilter } from '@gringlobal-ce/client/model/gringlobal';
import { ActionState, OrderRequestAction, OrderRequestActionFilter } from '@gringlobal-ce/client/model/gringlobal';
import { FilteredPage, IPageRequest } from '@gringlobal-ce/client/model/page';
import { ApiCall } from '@gringlobal-ce/client/model/common';
// ui
......@@ -23,20 +23,25 @@ import useTabs from 'ui/common/useTabs';
import useBrowsePageBase from 'ui/common/useBrowsePageBase';
const RequestActionsTabs = {
IN_PROGRESS: {
index: 'IN_PROGRESS',
INPROGRESS: {
index: 'INPROGRESS',
label: 'request.public.p.actions.tabs.inProgress',
config: [{ started: true, closed: false }, { page: 0, size: 100, direction: ['ASC'], properties: ['startedDate'] }],
config: [{ states: [ ActionState.INPROGRESS ] }, { page: 0, size: 100, direction: ['ASC'], properties: ['startedDate'] }],
},
PENDING: {
index: 'PENDING',
label: 'request.public.p.actions.tabs.pending',
config: [{ started: false, closed: false }, { page: 0, size: 100, direction: ['ASC'], properties: ['createdDate'] }],
config: [{ states: [ ActionState.INPROGRESS ] }, { page: 0, size: 100, direction: ['ASC'], properties: [ 'notBeforeDate', 'createdDate' ] }],
},
COMPLETED: {
index: 'COMPLETED',
label: 'request.public.p.actions.tabs.completed',
config: [{ closed: true }, { page: 0, size: 100, direction: ['DESC'], properties: ['completedDate'] }],
config: [{ states: [ ActionState.INPROGRESS ] }, { page: 0, size: 100, direction: ['DESC'], properties: ['completedDate'] }],
},
SCHEDULED: {
index: 'SCHEDULED',
label: 'request.public.p.actions.tabs.scheduled',
config: [{ states: [ ActionState.SCHEDULED ] }, { page: 0, size: 100, direction: ['ASC'], properties: ['notBeforeDate'] }],
},
};
......@@ -52,7 +57,7 @@ const RequestActionsPage = ({ loadableData, listAction, loadMoreData, routingPro
// util
const { t } = useTranslation();
const { selectedTab = 'IN_PROGRESS', selectTab } = useTabs({ routingProps, defaultTab: RequestActionsTabs.IN_PROGRESS.index })
const { selectedTab = 'INPROGRESS', selectTab } = useTabs({ routingProps, defaultTab: RequestActionsTabs.INPROGRESS.index })
const listRequestActions = React.useCallback((filter?: OrderRequestActionFilter, pageR?: IPageRequest) => {
return listAction({ ...RequestActionsTabs[selectedTab].config[0], ...filter }, RequestActionsTabs[selectedTab].config[1]);
......
......@@ -4,6 +4,7 @@ import { useTranslation } from 'react-i18next';
// UI
import { withFilters, DateFilter, CVFilter } from 'ui/common/filter';
import { OrderRequestAction } from '@gringlobal-ce/client/model/gringlobal';
import { OrderRequestFiltersEmbedded } from './Filters';
function RequestActionFilters() {
const { t } = useTranslation();
......@@ -24,6 +25,11 @@ function RequestActionFilters() {
label={ t([ 'client:model.OrderRequestAction.completedDate', 'client:model._.completedDate' ]) }
name="completedDate"
/>
<DateFilter
label={ t([ 'client:model.OrderRequestAction.notBeforeDate', 'client:model._.notBeforeDate' ]) }
name="notBeforeDate"
/>
<OrderRequestFiltersEmbedded prefix="orderRequest" withFullText={ false } />
</>
);
}
......
......@@ -6,17 +6,19 @@ import { withFilters, TextFilter, StringArrFilter, DateFilter, NumberFilter } fr
import { OrderRequest } from '@gringlobal-ce/client/model/gringlobal';
import { CVFilter } from 'ui/common/filter';
function OrderRequestFilters() {
export function OrderRequestFiltersEmbedded({ prefix = '', withFullText = true }: { prefix?: string, withFullText?: boolean }) {
const { t } = useTranslation();
return (
<>
<TextFilter
label={ t([ 'client:model._.text' ]) }
name="_text"
placeholder={ t([ 'client:model._.text-placeholder' ]) }
helperText={ t([ 'client:model._.text-helperText' ]) }
/>
{ withFullText &&
<TextFilter
label={ t([ 'client:model._.text' ]) }
name={ `${prefix}_text` }
placeholder={ t([ 'client:model._.text-placeholder' ]) }
helperText={ t([ 'client:model._.text-helperText' ]) }
/>
}
<CVFilter
label={ t([ 'client:model.OrderRequest.orderTypeCode' ]) }
name={ `orderTypeCode` }
......@@ -24,38 +26,40 @@ function OrderRequestFilters() {
/>
<DateFilter
label={ t([ 'client:model.OrderRequest.orderedDate' ]) }
name="orderedDate"
name={ `${prefix}orderedDate` }
/>
<DateFilter
label={ t([ 'client:model.OrderRequest.completedDate' ]) }
name="completedDate"
name={ `${prefix}completedDate` }
/>
<StringArrFilter
label={ `${t([ 'client:model.OrderRequest.requestorCooperator' ])} ${t([ 'client:model.Cooperator.email', 'client:model._.email' ])}` }
name="requestorCooperator.email.contains"
name={ `${prefix}requestorCooperator.email.contains` }
/>
<StringArrFilter
label={ `${t([ 'client:model.OrderRequest.requestorCooperator' ])} ${t([ 'client:model.Geography.countryCode' ])}` }
name="requestorCooperator.geography.countryCode"
name={ `${prefix}requestorCooperator.geography.countryCode` }
/>
<StringArrFilter
label={ `${t([ 'client:model.OrderRequest.shipToCooperator' ])} ${t([ 'client:model.Cooperator.email', 'client:model._.email' ])}` }
name="shipToCooperator.email.contains"
name={ `${prefix}shipToCooperator.email.contains` }
/>
<StringArrFilter
label={ `${t([ 'client:model.OrderRequest.shipToCooperator' ])} ${t([ 'client:model.Geography.countryCode' ])}` }
name="shipToCooperator.geography.countryCode"
name={ `${prefix}shipToCooperator.geography.countryCode` }
/>
<NumberFilter
label={ t([ 'client:model.OrderRequest.numberOfItems', 'client:model._.numberOfItems' ]) }
name="numberOfItems"
name={ `${prefix}numberOfItems` }
/>
<NumberFilter
label={ t([ 'client:model.OrderRequest.durationInDays', 'client:model._.durationInDays' ]) }
name="durationInDays"
name={ `${prefix}durationInDays` }
/>
</>
);
}
export default withFilters(OrderRequestFilters);
OrderRequestFiltersEmbedded.displayName = 'OrderRequest';
export default withFilters(OrderRequestFiltersEmbedded);
......@@ -44,7 +44,8 @@
"tabs": {
"completed": "Completed",
"inProgress": "In progress",
"pending": "Pending"
"pending": "Pending",