Skip to content

Commit

Permalink
Update package.json, package_win.json, and 12 more files...
Browse files Browse the repository at this point in the history
  • Loading branch information
FDT2k committed May 6, 2022
1 parent 4bcea7a commit ae1fb92
Show file tree
Hide file tree
Showing 14 changed files with 338 additions and 45,810 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "bia-manager-electron",
"main": "packages/electron/dist/index.cjs",
"version": "1.0.15",
"version": "1.0.16",
"author": "Karsegard Digital Agency",
"repository": "https://github.com/FDT2k/bia-manager",
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion package_win.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "bia-manager-electron",
"main": "packages/electron/dist/index.cjs",
"version": "1.0.15",
"version": "1.0.16",
"author": "Karsegard Digital Agency",
"repository": "https://github.com/FDT2k/bia-manager",
"scripts": {
Expand Down
28 changes: 14 additions & 14 deletions packages/electron/src/menu/menu.darwin.js
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,20 @@ export default (app, window, labelEnhancer=identity,actions) => {
window.webContents.send('location-change', '#/search');
}

}
]
},
{
label: labelEnhancer('Paramètres'),
submenu: [
{
label: labelEnhancer('Inserer l\'entête personnalisée'),
id:'customize-header',
enabled:true,
click() {
window.webContents.send('trigger-custom-header');
}

},
{
label: labelEnhancer('Retirer l\'entête personnalisée'),
Expand All @@ -194,20 +208,6 @@ export default (app, window, labelEnhancer=identity,actions) => {
}
]
},
{
label: labelEnhancer('Paramètres'),
submenu: [
{
label: labelEnhancer('Inserer l\'entête personnalisée'),
id:'customize-header',
enabled:true,
click() {
window.webContents.send('trigger-custom-header');
}

}
]
},
];


Expand Down
2 changes: 1 addition & 1 deletion packages/react-bia-manager/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@karsegard/react-bia-manager",
"version": "1.0.15",
"version": "1.0.16",
"description": "",
"author": "FDT2k",
"license": "MIT",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ import React from 'react';
const Component = props => {


const { gotoPage, previousPage, nextPage, setPageSize, canPreviousPage, canNextPage, pageCount, pageIndex, pageOptions, pageSize } = props;
const { gotoPage, previousPage, nextPage, setPageSize, canPreviousPage, canNextPage, pageCount, pageIndex, pageOptions, pageSize,handlePageChange } = props;

return (<LayoutFlexRow className="pagination" justBetween>
<div>
<Button onClick={() => gotoPage(0)} disabled={!canPreviousPage}>
<Button onClick={() => {gotoPage(0); handlePageChange(0)}} disabled={!canPreviousPage}>
{'<<'}
</Button>{' '}
<Button onClick={() => previousPage()} disabled={!canPreviousPage}>
<Button onClick={() => { previousPage(); handlePageChange(pageIndex-1)}} disabled={!canPreviousPage}>
{'<'}
</Button>{' '}
</div>
Expand All @@ -27,10 +27,10 @@ const Component = props => {
</strong>{' '}
</span>
<div>
<Button onClick={() => nextPage()} disabled={!canNextPage}>
<Button onClick={() =>{ nextPage(); handlePageChange(pageIndex+1)}} disabled={!canNextPage}>
{'>'}
</Button>{' '}
<Button onClick={() => gotoPage(pageCount - 1)} disabled={!canNextPage}>
<Button onClick={() =>{ gotoPage(pageCount - 1);; handlePageChange(pageCount-1)}} disabled={!canNextPage}>
{'>>'}
</Button>{' '}
</div>
Expand Down
56 changes: 51 additions & 5 deletions packages/react-bia-manager/src/Components/Table/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@ import Pagination from './Pagination';

import { LayoutFlexColumn } from '@karsegard/react-core-layout'
import { matchSorter } from 'match-sorter';
import React from 'react';
import React,{useEffect} from 'react';
import { useFilters, useGlobalFilter, usePagination, useSortBy, useTable } from 'react-table';
import DefaultFilter from './Filters/DefaultFilter';


const [__base_class, element, modifier] = bem('listing')

export default props => {
export const Table = props => {


const { data,className, style,columns,tabIndex, forwardedRef,selectedIndex, handleSelect, Tools, SortUp, SortDown, ...rest } = props;
const { data,className, style,columns,tabIndex, forwardedRef,selectedIndex, handleSelect,handlePageChange, Tools, SortUp, SortDown,initialPageIndex, ...rest } = props;

function fuzzyTextFilterFn(rows, id, filterValue) {
return matchSorter(rows, filterValue, { keys: [row => row.values[id]] })
Expand Down Expand Up @@ -42,15 +42,42 @@ export default props => {
[]
)

const sortTypes= React.useMemo(()=>({

alphanumeric: (row1, row2, columnName) => {

const rowOneColumn = row1.values[columnName];
const rowTwoColumn = row2.values[columnName];
if (isNaN(rowOneColumn)) {
return rowOneColumn.toUpperCase() >
rowTwoColumn.toUpperCase()
? 1
: -1;
}
return Number(rowOneColumn) > Number(rowTwoColumn) ? 1 : -1;
}

}));

const defaultColumn = React.useMemo(
() => ({
// Let's set up our default Filter UI
Filter: DefaultFilter,
}),
[]
)
const tableInstance = useTable({ columns, data, defaultColumn, filterTypes }, useFilters, useGlobalFilter, useSortBy, usePagination)
const tableInstance = useTable({ columns, data, defaultColumn, filterTypes,sortTypes, initialState: {
sortBy: [
{
id: 'lastname',
desc: false
}
],
pageIndex:initialPageIndex
} }, useFilters, useGlobalFilter, useSortBy, usePagination)




const {
getTableProps,
Expand All @@ -64,6 +91,12 @@ export default props => {
preGlobalFilteredRows,
setGlobalFilter,
} = tableInstance

useEffect(()=>{
console.log(state.pageIndex);
},[state.pageIndex]);


const pageProps = {};

({
Expand All @@ -79,6 +112,13 @@ export default props => {
state: { pageIndex: pageProps.pageIndex, pageSize: pageProps.pageSize }

} = tableInstance);

useEffect(()=>{
console.log('going to page',initialPageIndex);
pageProps.gotoPage(initialPageIndex);
},[initialPageIndex]);


return (<LayoutFlexColumn justBetween cover tabIndex={tabIndex} className={className} style={style}>
<table ref={forwardedRef} className={cEx([__base_class])} {...getTableProps()} {...rest}>
<thead >
Expand Down Expand Up @@ -129,7 +169,13 @@ export default props => {
</tbody>

</table>
{pageProps.pageCount > 1 && <Pagination {...pageProps} />}
{pageProps.pageCount > 1 && <Pagination handlePageChange={handlePageChange} {...pageProps} />}
</LayoutFlexColumn>
)
}

Table.defaultProps= {
initialPageIndex:0
}

export default Table;
17 changes: 12 additions & 5 deletions packages/react-bia-manager/src/Containers/Search/withRedux.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export const Container = ({selectors,actions}) => Component => props => {
const tags = useSelector(selectors.select_tags);
const custom_filters= useSelector(selectors.select_custom_filters);
const has_filters = useSelector(selectors.has_custom_filters)

const pageIndex = useSelector(selectors.current_page_index);
const handleSearch = (tags,results) => {
dispatch( actions.search(tags))
}
Expand All @@ -44,15 +44,21 @@ export const Container = ({selectors,actions}) => Component => props => {

useEffect(()=>{
return ()=>{
dispatch(actions.clear());
// dispatch(actions.clear());
}
},[])
},[]);

const handlePageChange= pageIndex=>{

dispatch(actions.pageChange(pageIndex));
}
const handlers = {
..._handlers,
handleSearch,
setFilter,
clearFilter,
handleFetch
handleFetch,
handlePageChange
}
return (

Expand All @@ -61,7 +67,8 @@ export const Container = ({selectors,actions}) => Component => props => {
results={results}
tags={tags}
custom_filters={custom_filters}
handlers={handlers} />
handlers={handlers}
pageIndex={pageIndex} />
)
}

Expand Down
16 changes: 13 additions & 3 deletions packages/react-bia-manager/src/Features/Search/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -207,9 +207,9 @@ export const Component = props => {

const { t, dateSysToHuman } = useTranslation();

const { handleSearch, handleCSVExport, handleCreate, handleSelectRow: _handleSelectRow, } = props.handlers;
const { handleSearch, handleCSVExport, handleCreate, handleSelectRow: _handleSelectRow,handlePageChange:_handlePageChange } = props.handlers;
const { clearFilter, setFilter } = props.handlers
const { results, tags, custom_filters } = props;
const { results, tags, custom_filters ,pageIndex} = props;


useEffect(() => {
Expand Down Expand Up @@ -283,6 +283,10 @@ export const Component = props => {
_handleSelectRow && _handleSelectRow(index, row.original)
}

const handlePageChange = (pageIndex)=>{
console.log('page changed',pageIndex);
_handlePageChange && _handlePageChange(pageIndex);
}

return (
<SearchLayout cover contained className="page-search">
Expand Down Expand Up @@ -317,6 +321,9 @@ export const Component = props => {
area="list"
data={data}
columns={columns}

handlePageChange={handlePageChange}
initialPageIndex={pageIndex}
/>
</SearchLayout>
)
Expand All @@ -328,6 +335,8 @@ Component.defaultProps = {
custom_filters: {

},
pageIndex: 0,

handlers: {
handleSearch: _ => console.warn('search handler not implemented'),
handleCreate: _ => console.warn('create handler not implemented'),
Expand Down Expand Up @@ -372,7 +381,8 @@ export const Page = props => {
Page.defaultProps = {
stats: { count: 0, count_mesures: 0 },
patients: [],
db_name: 'default'
db_name: 'default',

}


Expand Down
17 changes: 15 additions & 2 deletions packages/react-bia-manager/src/Redux/Search/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@ export default (getModule) => {

actions.clear = createAction(types.CLEAR);
actions.update_search_tags = createAction(types.UPDATE_SEARCH_TAGS);
actions.fetched = createAction(types.FETCHED);
actions.fetched = createAction(types.FETCHED,payload=>{
debugger;
return payload;
});


actions.filter_patients = createAction(types.FILTER_PATIENTS);
Expand All @@ -31,6 +34,13 @@ export default (getModule) => {
}
return x;
}
actions._pageChange = createAction(types.PAGE_CHANGE);
actions.pageChange = (pageIndex)=>(dispatch, getState) => {
const { current_page_index } = selectors;

let current_page = current_page_index(getState())
dispatch(actions._pageChange(pageIndex));
}

actions.search = (tags = []) => (dispatch, getState) => {
console.log('[TAGS]',tags)
Expand Down Expand Up @@ -62,8 +72,11 @@ export default (getModule) => {



actions.fetch = results => (dispatch)=> {
actions.fetch = results => (dispatch,getState)=> {
const { current_page_index } = selectors;
dispatch(actions.fetched(results))
/* let current_page = current_page_index(getState())
dispatch(actions.pageChange(current_page));*/
dispatch(actions.filter_results())
}

Expand Down
25 changes: 24 additions & 1 deletion packages/react-bia-manager/src/Redux/Search/reducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,12 +98,35 @@ export default (getModule) => {

}
)
const clearpage = (state, {payload}) => {
return {
...state,
pageIndex:0
}
};
module.list = createReducer({},
{
[types.PAGE_CHANGE]: (state, {payload}) => {
return {
...state,
pageIndex:payload
}
},
[types.ADD_CUSTOM_FILTER]: clearpage,
[types.CLEAR_CUSTOM_FILTER]: clearpage,
[types.CLEAR]: clearpage,
[types.ADD_SEARCH_TAG]: clearpage,
[types.UPDATE_SEARCH_TAGS]: clearpage,
[types.DEL_SEARCH_TAG]: clearpage,
}
)


module.reducer = combineReducers({
tags: module.tags,
patients: module.patients,
custom_filters: module.custom_filters
custom_filters: module.custom_filters,
list: module.list
});


Expand Down
3 changes: 3 additions & 0 deletions packages/react-bia-manager/src/Redux/Search/selectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ export default getModule => {
})
return result;
})
module.list = createSelector(baseSelector,state=> state.list);
module.current_page_index = createSelector(module.list,state=>state.pageIndex)

return module;

}
Expand Down
3 changes: 2 additions & 1 deletion packages/react-bia-manager/src/Redux/Search/types.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ export const ACTIONS_TYPES = createActionTypes(
'REMOVE_FILTER',

'ADD_CUSTOM_FILTER',
'CLEAR_CUSTOM_FILTER'
'CLEAR_CUSTOM_FILTER',
'PAGE_CHANGE'
)


Expand Down

0 comments on commit ae1fb92

Please sign in to comment.